Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5645503img; Wed, 27 Mar 2019 12:20:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhmJboRx+DtSz265L5Aw6b2DEibOBYgrOP9cGW7c52qdT0U6zbsk8jHzFWl7TLpmsB/baK X-Received: by 2002:a17:902:988e:: with SMTP id s14mr26248759plp.167.1553714446133; Wed, 27 Mar 2019 12:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714446; cv=none; d=google.com; s=arc-20160816; b=fmwvF2nkCu6+xbOmqCYqi20kaBbWJ/s1BhEIrI6DQJmTwas/L0qdjuBkn5zqF+V3k/ vaOUcvXT8e59Mi4pkmYOMBbvI6vY6H6lW0pux3HcZmk1qHyHu31lbILz1Is6gRo4mtim 7AyR2d/8O5i+ST+Ex/krpdAQy+vhW777tJazh25qRP8aT5Rb/2pVgZwifvbEncS3/jln DN6mir2LcSTlcajLbGGFqVqZTpXodo4tlmIudZgmpzAnCiA7nzVyzSIa9pylAeRwNLoM WD8g38DRxRXTuPsjnfDPTuCEsSY2ogi709E8Vipye3EVbk5z6zDIbttKLHZPievlgZFU 0Sow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ExXY56bmwj4fgpTHk3Qo+x2MNHa/9MyOXRUkuhGE2hc=; b=eiigaF68ZA9b734gQXOBkwb+WejVxzx94u9/ZTSHUMCCaETSYJ0OEaRF+vAayU2+RV OLeOusTu0EnGvoCibdrwpW8rPK8WEF7jVRxRgWQyPIqFiPoKSpGI4G3VrsW1cGN6xmo9 6Nbc3xQ7Vzd4zhUuM0q7XLPy9j5VPZcr1omJUgG/grbbdDtDXbVGkaV6FdyUWR4VdljM /tWADUIpT7ZAKxjeUEHNrCV1t6DLlf6lGNh0VQd9ZVc4LTc92H7vNpSVwKJ7CQ1FXxFc BXceBHAO76DuAbdllahoHgJaTKB4gVmYoRBBayWjrjxFY7I9ZY7ADSA2j0rBay6zSwJ8 r5WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MydxmlNC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o35si16630220pgb.551.2019.03.27.12.20.30; Wed, 27 Mar 2019 12:20:46 -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=MydxmlNC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388416AbfC0TSq (ORCPT + 99 others); Wed, 27 Mar 2019 15:18:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:49970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388278AbfC0SIA (ORCPT ); Wed, 27 Mar 2019 14:08:00 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED3FF2183F; Wed, 27 Mar 2019 18:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710079; bh=U99Mo/Q91e3RNz7SrxPPvitkAUQH/eUfMXyKA0WCGrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MydxmlNCWcVyFeVwC7BeUuH7PjD+TtDK9oG6eYs9nwmkijM3qwOaOpTjLG9tvZios gEZ9aACF8o/+49CIC5MBib2VDPSs8eM3d/pppodjMpWnb6IFRhYB+O/FuTRR9R15yp 6a2tyIgyfA0vlzYLukeqP2UNd3DdDzCojP/EI6/M= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shayenne Moura , Daniel Vetter , Rodrigo Siqueira , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.0 189/262] drm/vkms: Bugfix extra vblank frame Date: Wed, 27 Mar 2019 14:00:44 -0400 Message-Id: <20190327180158.10245-189-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shayenne Moura [ 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 53ab49408a98..a0bef7de9df7 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -75,6 +75,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