Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4047691ybd; Tue, 25 Jun 2019 13:06:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqysWlA7RIvQy9nrk2Zrqu9XZwV9+30G7VdVwiPqWRZXj3txZDtDm34zZd39fl+HIk8vpyjq X-Received: by 2002:a63:a48:: with SMTP id z8mr40602709pgk.91.1561493200652; Tue, 25 Jun 2019 13:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561493200; cv=none; d=google.com; s=arc-20160816; b=qQGidHmGOBFzAAHq6Vp3hIeLDybog5kbrq32cpBaGIaFpWMBoQiGAjabcgpQ8sdwCT uYnthoZtzQ9alrGOc/Z5dwslpGtU9Pw0hGj3ZJ9tybQbI3O41L+hIK02GOrm85vnsOga 4sLxjs6cYEOYPkn59JNSWMKXcQuDTL4MZS5OC3HiObnEoBhXBBvN2LQOLnVBg2oM468L GLP39L4WbRRY0xcVjp994JsKoX8hAj5Gtk4dJDgpG76j7XPC1t0c8QG9f2kGR1ALzXuZ HsdvoLAdybGhR/dEYZVK9Zne9Q/8ioNU2w2aLob90eRImTF9KQGeC6jJxDrtX8esFB/5 33ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date:dkim-signature; bh=DmS1jNL47BlCeH7f/PXu4ZPXGuwE81QoT6SSZgP5EfA=; b=VWZahl+z4VAUqblFBwf2A4jp5YZajjlKRojNZw/7PWhGoL+WHnby5w5NyNhYVKUUM8 OzCxaNnFmzd77YwTxyxvpWk14SskrQJqQiHNF9oO3ij2uki5QyfctV7BS7TnYM38/VPo oe/7PwCOPqsbr/SFeUy8sFQiDx9O85BjqnlBxmOBX+gxip3tQ44aJ6VsJDZuf4zyeYw/ Zgki2eqkMMHvprtI+Xrs1I9xObMXj0fO4n9XglH2UpobgxNggq2V3FbjP1yup+oXfYZv 3fhbUJa50ANk0FeVmmDyer7C3928qHkA5Tqv7GIR3WaM05jvLoUNvyYoKQwOqch7+lbu bIkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=Qeo0rZGK; 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 62si1068678plb.258.2019.06.25.13.06.23; Tue, 25 Jun 2019 13:06:40 -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=fail header.i=@ffwll.ch header.s=google header.b=Qeo0rZGK; 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 S1726907AbfFYUCv (ORCPT + 99 others); Tue, 25 Jun 2019 16:02:51 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:34657 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbfFYUCu (ORCPT ); Tue, 25 Jun 2019 16:02:50 -0400 Received: by mail-ed1-f67.google.com with SMTP id s49so29003111edb.1 for ; Tue, 25 Jun 2019 13:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DmS1jNL47BlCeH7f/PXu4ZPXGuwE81QoT6SSZgP5EfA=; b=Qeo0rZGKwLlLKqReBhoZJ8BiSZyBWcjLuJ5zL9fbsq8WUKITB5LgdxoLYpK3FW0cG7 KQ9WeabH4I4Dh2ci7fWd2d7xv00yr6/dGF1cXGMNXq5HKXKb1R8TQIHT7sfu+U4DF6IS o5+8S4KcN7IFrcz5xN5c8/OkDyMjxdIQiFfM8= 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:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=DmS1jNL47BlCeH7f/PXu4ZPXGuwE81QoT6SSZgP5EfA=; b=p8xXcAlewnRqeYndTUnG+qNlTd11ELO+bTzd3eACO/mBC30AxRVkUpkippi/MIOb3e lmn0OSKC5Q39u44yUHvaelPZB6Z2KzuZLfzRROgZkmVYmbgSBZteswrag7OdTxAwS9Zg CBuN7boxfVuBTPCLQ4CwjqKxrD3h/40le8eGHTlCU2zcboP1wat+kHaN6Oddkgph/6bw RMzV8AGZRGGFSaT+HnC0szLI3kk2+As9dW+J1Vf4iNjtLJMVSykWF3CSk6O2gbian75v I6zWVHbM1hWcOdowEeX+R7XA4XCJ2Ova9rI6V1kA3jUElhLbbgX3a8vhQfhvhmwUg7sn YkxA== X-Gm-Message-State: APjAAAVk2S3Rof4WhkIRWN8N1g1rVVegQE9r7QbfaE6GpfpEoKqytqAS +uRPU6tCHPiPuypTix1/7s0HzA== X-Received: by 2002:a50:d0d6:: with SMTP id g22mr352450edf.250.1561492968402; Tue, 25 Jun 2019 13:02:48 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id a9sm5165772edc.44.2019.06.25.13.02.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 13:02:47 -0700 (PDT) Date: Tue, 25 Jun 2019 22:02:45 +0200 From: Daniel Vetter 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 Subject: Re: [PATCH v3 1/4] drm/vblank: warn on sending stale event Message-ID: <20190625200245.GD12905@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: <20190625200042.GC12905@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190625200042.GC12905@phenom.ffwll.local> X-Operating-System: Linux phenom 4.19.0-5-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 25, 2019 at 10:00:42PM +0200, Daniel Vetter wrote: > On Tue, Jun 25, 2019 at 06:59:12PM +0100, Robert Beckett wrote: > > Warn when about to send stale vblank info and add advice to > > documentation on how to avoid. > > > > Signed-off-by: Robert Beckett > > --- > > drivers/gpu/drm/drm_vblank.c | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > > index 603ab105125d..7dabb2bdb733 100644 > > --- a/drivers/gpu/drm/drm_vblank.c > > +++ b/drivers/gpu/drm/drm_vblank.c > > @@ -918,6 +918,19 @@ EXPORT_SYMBOL(drm_crtc_arm_vblank_event); > > * > > * See drm_crtc_arm_vblank_event() for a helper which can be used in certain > > * situation, especially to send out events for atomic commit operations. > > + * > > + * Care should be taken to avoid stale timestamps. If: > > + * - your driver has vblank support (i.e. dev->num_crtcs > 0) > > + * - the vblank irq is off (i.e. no one called drm_crtc_vblank_get) > > drm_crtc_vblank_get() so it becomes a neat hyperlink. > > > + * - from the vblank code's pov the pipe is still running (i.e. not > > + * in-between a drm_crtc_vblank_off()/on() pair) > > Not sure the above will lead to great markup, maybe spell out the > drm_crtc_vblank_on() and maybe make it a bit clearer like "i.e. not after > the call to drm_crtc_vblank_off() but before the next call to > drm_crtc_vblank_on()" so it's clear which said of this pair we're talking > about. > > > + * If all of these conditions hold then drm_crtc_send_vblank_event is > > style nit: the enumeration is one sentence (and and oxford comman missing > but whatever), but you don't continue it here. Also, does the enumeration > look pretty in the htmldocs output? > > > + * going to give you a garbage timestamp and and sequence number (the last > > + * recorded before the irq was disabled). If you call drm_crtc_vblank_get/put > > + * around it, or after vblank_off, then either of those will have rolled things > > + * forward for you. > > Again pls fix the markup so all the function reference stick out and work. One more style nit: s/you/drivers/, so maybe: "Drivers must either hold a vblank reference acquired through drm_crtc_vblank_get() or the vblank must have been shut off by calling drm_crtc_vblank_off()." Those functions then have in turn links and hints what you also need to do, like not forget to call drm_crtc_vblank_put(). > > > + * So, drivers should call drm_crtc_vblank_off() before this function in their > > + * crtc atomic_disable handlers. > > Imo this sentence here is needed but a bit confusing, and we have it > documented already in the atomic_disable hook. > > Other option would be to list all the places where a driver might want to > call this and how they could get it wrong, which imo doesn't make sense. > > With the nits addressed: > > Reviewed-by: Daniel Vetter > > > */ > > void drm_crtc_send_vblank_event(struct drm_crtc *crtc, > > struct drm_pending_vblank_event *e) > > @@ -925,8 +938,12 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc, > > struct drm_device *dev = crtc->dev; > > u64 seq; > > unsigned int pipe = drm_crtc_index(crtc); > > + struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; > > ktime_t now; > > > > + WARN_ONCE(dev->num_crtcs > 0 && !vblank->enabled && !vblank->inmodeset, > > + "sending stale vblank info\n"); > > + > > if (dev->num_crtcs > 0) { > > seq = drm_vblank_count_and_time(dev, pipe, &now); > > } else { > > -- > > 2.18.0 > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch