Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1011967yba; Thu, 4 Apr 2019 02:23:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvsh+UKQR63B1LlihY9R+FoUtv9bRmhE5YzJfKyCkoRZO8jjgbKc8ul3+5kwIupFrzMsJd X-Received: by 2002:a63:1203:: with SMTP id h3mr4853036pgl.164.1554369824516; Thu, 04 Apr 2019 02:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554369824; cv=none; d=google.com; s=arc-20160816; b=szTl4p4GL/wEr+qWKP22gBx96mvX4uV+KlN36LR46haVSLKV0WBAYQ/RmqGGgoUo9f Ev3rpQUHceZn9Y/F4ZsRJKeZvqW/+vmgi7hv6uUUYy6NNHO+XT0VbyG5KjFB0zYFF/3U T0uzoVCgIqSxRqHsXR71Sej08OaFRHbEhWZaBMJy99EBmB12Ytr7e3mPQ5g0mFK5YXx/ 3Zhhkd+44Sf7fxMAxEtWyMFRH43XrInVdUker52kNW6g2CVMoB38fidvYjSIUfZmPJfw kg3YKxRbTArohsKUw/0T4MILXX4wh+eifYgqMV2NDdooeUZJctGpWrRwMpPdD856QVuI KE8w== 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=9rT3PuFkF/3k11JuwMmYUdm2F5TPa4wN2KBtjJz8UOk=; b=a1W+M01frHy+gijrmkA4D7F8ZjK9ccC7M4btsRQqUajumiooG6/ULqJ5XnAv2SZMFD R+eslSGetY9di05UgfDq2olMYY4xpHR23aTYr9KDnTD8nUVg498ENDDBYat5kexatif8 O4UL06tcqdJBhCf+GqSU2HwfSaMiyDF7c23Cdl4SXEKYuA52KonPXJuYwMSWSQoZlzKO 4H9Zmj9I4IxHTOCanGDKLxWzwEOa8JFln0mlLOD7Zr24wkz/hqjKAm+CaH0Zrq+5hbje NrNVMwxDHcKDFq4vcOZMufc4wtM+/SzQTxaxl5q6itEeJJ0EuDNmgpzwucp75hB4UZim PcxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WWV7ejDS; 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 n14si15382240pgv.520.2019.04.04.02.23.29; Thu, 04 Apr 2019 02:23:44 -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=WWV7ejDS; 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 S2387740AbfDDJP4 (ORCPT + 99 others); Thu, 4 Apr 2019 05:15:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:56972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387728AbfDDJPv (ORCPT ); Thu, 4 Apr 2019 05:15:51 -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 996D2214AF; Thu, 4 Apr 2019 09:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369350; bh=7oG/zkV8JLr5pnAutFtVseolLo+zN8u4D3ZJJcnVSOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWV7ejDSjh7YJfp2i5espNGACAyRjngRoyu5jpaG/Q4LiYDpFkOyK/osADKKry27g l5BKKsr7M+fLwT5R9q+FGoOd2oj/M3pyDbfkFxFbGWFwNeSvSMZ0C2uV5QtqxVWnMW d4WGYOx8S2gV57s8ppPIjVI0cSnKKjsWO6kC4dpE= 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 5.0 178/246] drm/vkms: Bugfix extra vblank frame Date: Thu, 4 Apr 2019 10:47:58 +0200 Message-Id: <20190404084625.411787184@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@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 5.0-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 00d961862d77..1054f535178a 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