From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01903C48BD6 for ; Tue, 25 Jun 2019 20:11:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9FC92086D for ; Tue, 25 Jun 2019 20:11:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="neVAX/tI"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="EqENzc8Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9FC92086D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X6FMxkcQAuoZV5Pe3uyaZInIDor36lEx6vXaAT9vZew=; b=neVAX/tIoz6FIw anAJ4ttsktmfRI4kGMP5YEFAzIe82OmgnIx/69R9mVn55YHKqstfg1VgaOmx1RyQZ+5ANYx/0oCkh 26EhRGQNNaJI4Pr3YGKEJX8iH+Mdvqdrfh4h7SKwvNkyTbfNV2w61P5YBnz7my68ZUMNfoFXtmUEP 9OJF8M4HasG10BpVx1aAWX1Q4KTurR87G5SacVumO1JVGcLqdSXMtqHvLtt7eC7uG5wRDry9LqbZv iFT4WqnOT6oPYugYlQEaCmWJ9BfPQYtbtfoLFeKQ4IgEBRiIN7ubmOKv6SqptWnWbDnsIXGjY3Jte O3Xst48I38EnBPGxj+cw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hfrn4-0004ie-F7; Tue, 25 Jun 2019 20:11:42 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hfrn1-0004hv-9z for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2019 20:11:40 +0000 Received: by mail-ed1-x541.google.com with SMTP id r12so29033759edo.5 for ; Tue, 25 Jun 2019 13:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=zkV6FjfcQsvo6WYlA8ceAW7NTugFBRZuAe5/8PprGgI=; b=EqENzc8ZFmkojdUW4bYooe/jHYrBPUxIfH5lufyaa/ljp7fZjFaQVWzP2rlePy2DAk tfSJFccP/J6XNDXKPMrYnu/DCrc9n9AXAa/9a0pfe5ig1PwrFxmcHQChxJ1LNWbAM/az ssuZV1iUpkscfXe/eYKaPcbpNlh7TWiA16EY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=zkV6FjfcQsvo6WYlA8ceAW7NTugFBRZuAe5/8PprGgI=; b=pDGQ2ZnDGBL8o3z+os9QO+93f+ZR9oSJRO1C3jjC9p0sxYj5rodfCwMtrGB/t/ywB0 0XS48CdFbQbj6QM5az2G7LcV1Qa/vFBn21CgIO3nhGlBgJsPGs3nvFVHiAShMwKCQRrn gv2x8FsONelO2JSrIDTCrWdTgnuOHyRY+PHg5WqzsypA1A8xYwsbDPmeWhjvVeYMrmhR d72bIUzNVlf3qup/1Qe/bdVO/my1rri3NAJv8id45dW1ckrSanH9H9RmwBuw2Nrj5Tbh tfRQysz4SKjnVCbup6i8DnSEoX9d1Ea4OJFsNfFR8jy+HJXZKH1WtfBlqxpQkpX8/hK0 YKcQ== X-Gm-Message-State: APjAAAXtDpKNf6iOy5rG0RGelpSlwuu+gbCM7Uzo/msVqzcr84AK3FOV HE5hEHtuFVmLkVmi6udR4vMovc7Fqgc= X-Google-Smtp-Source: APXvYqwoVMnAgUuE3liJcixkOYd1NT201/L7ZxinP68zsYUut//RkA+BJy/SK3l/jTY4VRTqV7InDw== X-Received: by 2002:a50:b635:: with SMTP id b50mr327666ede.293.1561493497807; Tue, 25 Jun 2019 13:11:37 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id k3sm1048485edi.14.2019.06.25.13.11.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 13:11:36 -0700 (PDT) Date: Tue, 25 Jun 2019 22:11:34 +0200 From: Daniel Vetter To: Robert Beckett Subject: Re: [PATCH v3 3/4] drm/vblank: estimate vblank while disabling vblank if interrupt disabled Message-ID: <20190625201134.GF12905@phenom.ffwll.local> Mail-Followup-To: Robert Beckett , dri-devel@lists.freedesktop.org, Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Philipp Zabel , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 4.19.0-5-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190625_131139_349923_4C47D8AC X-CRM114-Status: GOOD ( 21.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabio Estevam , Philipp Zabel , Maxime Ripard , Shawn Guo , Sascha Hauer , Maarten Lankhorst , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, David Airlie , NXP Linux Team , Daniel Vetter , Sean Paul , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 25, 2019 at 06:59:14PM +0100, Robert Beckett wrote: > If interrupts are disabled (e.g. via vblank_disable_fn) and we come to > disable vblank, update the vblank count to best guess as to what it > would be had the interrupts remained enabled, and update the timesamp to > now. > > This avoids a stale vblank event being sent while disabling crtcs during > atomic modeset. > > Fixes: 68036b08b91bc ("drm/vblank: Do not update vblank count if interrupts > are already disabled.") > > Signed-off-by: Robert Beckett > --- > drivers/gpu/drm/drm_vblank.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > index 7dabb2bdb733..db68b8cbf797 100644 > --- a/drivers/gpu/drm/drm_vblank.c > +++ b/drivers/gpu/drm/drm_vblank.c > @@ -375,9 +375,23 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe) > * interrupts were enabled. This avoids calling the ->disable_vblank() > * operation in atomic context with the hardware potentially runtime > * suspended. > + * If interrupts are disabled (e.g. via blank_disable_fn) then make > + * best guess as to what it would be now and make sure we have an up > + * to date timestamp. > */ > - if (!vblank->enabled) > + if (!vblank->enabled) { > + ktime_t now = ktime_get(); Would be nice to fake this a bit more accurately and round the timestamp here to a multiple of the frame duration, i.e. ... > + u32 diff = 0; > + if (vblank->framedur_ns) { > + u64 diff_ns = ktime_to_ns(ktime_sub(now, vblank->time)); > + diff = DIV_ROUND_CLOSEST_ULL(diff_ns, > + vblank->framedur_ns); > + } now = vblank->time + diff * vblank_framedur_ns; Picking the right macro for doing 64bit multiplies left to you :-) > + > + store_vblank(dev, pipe, diff, now, vblank->count); > + > goto out; > + } > > /* > * Update the count and timestamp to maintain the Somewhat unhappy that we're duplicating this logic with drm_update_vblank_count, but it's just 2 lines of math. -Daniel > -- > 2.18.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel