Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp999001yba; Thu, 4 Apr 2019 02:05:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1fGglnNTGtT9J6qdhaVd5xPxo0pOKezmnwUYKCAZ4LLictLIIsAwNk55Vxj839qfGrHwe X-Received: by 2002:a17:902:6949:: with SMTP id k9mr5160693plt.59.1554368747166; Thu, 04 Apr 2019 02:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368747; cv=none; d=google.com; s=arc-20160816; b=KRXU97KT3Uj0unKLONLEkeMGCCkCZt4+nqymNUN4x6GXdRYVZK0i5H305oxZ8cznfj OVUXNptWRMDg77ssW8rEJu4nhx9WsxPnrF+h84t2gcLsiRTf45p8BebwVY3792YRXblr lblhPtcHUKqeN0SVZdxxQWLY48S1yr9tTRXe18/CiMqFXBl82R6QUPoJdv6O883qNH7M StNCQSVQyAv+w1O1MnBrjnnN8NAgi3xUbtWb/sIhB6PzFG6B7Rkr6JxAZc0+NLnsljdf K9LPkN0OTnOXSB7E38wWJmVf9eS1jlVMqZ7gAdUVPPKBHNpmS6XAWOIGOOsCuxeORESF GViQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=diPQYT5Cr1TvdT17Ayl/moMmtP6qHaqZO0bGUBzQFTo=; b=c37yfPogq8G6ZcP+f5o1rMmhDJgFqSO5VeoTF1K0OCaJ9RGbPHiAeO3aa1bsi6TSyv 0B0XpMMQtj/cg6QHYJB0WxB9xXYezB/QQLq1C56nuQGcU2vfHRf8xL7hLoD1OPznfycN DFyhYarW1u8ktbbVU6ecXdiydndSRsx+1JFM7WTDwpee/LfXt1nGmmfvWRLqaXuSo7OC D4QdwMA57ix+0KBdbmJVp5PPdheIonf4T1Yf01X2nkaduL/5tg4LRig+nUZiGY/ub8Zi NaYKvZZnEbHTegA7lRPvdXe1JHKJ6cDyCmAtTBcChtObNqXv7H8drTPZjpTuziabIleT 2PzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mnKEOqK0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si16232027plb.199.2019.04.04.02.05.31; Thu, 04 Apr 2019 02:05:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mnKEOqK0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732063AbfDDJE7 (ORCPT + 99 others); Thu, 4 Apr 2019 05:04:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:42880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730311AbfDDJE4 (ORCPT ); Thu, 4 Apr 2019 05:04:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C6842177E; Thu, 4 Apr 2019 09:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368696; bh=fbS6ods7WwJ5DFFvN7MEXqb8fSwWF2sFE6gswlY7pAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mnKEOqK0TO9JJ/1w0ykCwcTNeuVIcpdnqf80JYJAHDeRKEw4glMvwB6YKgomxmFEt pQ0Lfxu6RuvuKWmHTjB7HAQ0mAEGCj4FgS6rOMeArnWSIV1f0Bfhua+ll5WzfIqxIq MXqPMHRrMPaHS2iZxDf2ng+ktsELUQF33iMfZoc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shayenne Moura , Daniel Vetter , Rodrigo Siqueira , Sasha Levin Subject: [PATCH 4.19 135/187] drm/vkms: Bugfix extra vblank frame Date: Thu, 4 Apr 2019 10:47:52 +0200 Message-Id: <20190404084609.565715367@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit def35e7c592616bc09be328de8795e5e624a3cf8 ] kms_flip tests are breaking on vkms when simulate vblank because vblank event sequence count returns one extra frame after arm vblank event to make a page flip. When vblank interrupt happens, userspace processes the vblank event and issues the next page flip command. Kernel calls queue_work to call commit_planes and arm the new page flip. The next vblank picks up the newly armed vblank event and vblank interrupt happens again. The arm and vblank event are asynchronous, then, on the next vblank, we receive x+2 from `get_vblank_timestamp`, instead x+1, although timestamp and vblank seqno matches. Function `get_vblank_timestamp` is reached by 2 ways: - from `drm_mode_page_flip_ioctl`: driver is doing one atomic operation to synchronize planes in the same output. There is no vblank simulation, the `drm_crtc_arm_vblank_event` function adds 1 on vblank count, and the variable in_vblank_irq is false - from `vkms_vblank_simulate`: since the driver is doing a vblank simulation, the variable in_vblank_irq is true. Fix this problem subtracting one vblank period from vblank_time when `get_vblank_timestamp` is called from trace `drm_mode_page_flip_ioctl`, i.e., is not a real vblank interrupt, and getting the timestamp and vblank seqno when it is a real vblank interrupt. The reason for all this is that get_vblank_timestamp always supplies the timestamp for the next vblank event. The hrtimer is the vblank simulator, and it needs the correct previous value to present the next vblank. Since this is how hw timestamp registers work and what the vblank core expects. Signed-off-by: Shayenne Moura Signed-off-by: Daniel Vetter Reviewed-by: Rodrigo Siqueira Signed-off-by: Rodrigo Siqueira Link: https://patchwork.freedesktop.org/patch/msgid/171e6e1c239cbca0c3df7183ed8acdfeeace9cf4.1548856186.git.shayenneluzmoura@gmail.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/vkms/vkms_crtc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 1ea2dd35bca9..0a271f762a0a 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -55,6 +55,9 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, *vblank_time = output->vblank_hrtimer.node.expires; + if (!in_vblank_irq) + *vblank_time -= output->period_ns; + return true; } -- 2.19.1