Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: airlied@linux.ie, daniel@ffwll.ch, alexander.deucher@amd.com,
	christian.koenig@amd.com, David1.Zhou@amd.com,
	maarten.lankhorst@linux.intel.com, patrik.r.jakobsson@gmail.com,
	robdclark@gmail.com, sean@poorly.run,
	benjamin.gaignard@linaro.org, vincent.abriou@st.com,
	yannick.fertre@st.com, philippe.cornu@st.com,
	mcoquelin.stm32@gmail.com, alexandre.torgue@st.com,
	eric@anholt.net, rodrigosiqueiramelo@gmail.com,
	hamohammed.sa@gmail.com, linux-graphics-maintainer@vmware.com,
	thellstrom@vmware.com, bskeggs@redhat.com,
	harry.wentland@amd.com, sunpeng.li@amd.com,
	jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
	rodrigo.vivi@intel.com, dri-devel@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	nouveau@lists.freedesktop.org
Subject: Re: [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver
Date: Sun, 12 Jan 2020 23:54:21 +0100	[thread overview]
Message-ID: <20200112225421.GD5340@dvetter-linux.ger.corp.intel.com> (raw)
In-Reply-To: <20200112225312.GC5340@dvetter-linux.ger.corp.intel.com>

On Sun, Jan 12, 2020 at 11:53:12PM +0100, Daniel Vetter wrote:
> On Fri, Jan 10, 2020 at 10:21:27AM +0100, Thomas Zimmermann wrote:
> > All non-legacy users of VBLANK functions in struct drm_driver have been
> > converted to use the respective interfaces in struct drm_crtc_funcs. The
> > remaining users of VBLANK callbacks in struct drm_driver are legacy drivers
> > with userspace modesetting.
> > 
> > There are no users left of get_vblank_timestamp(), so the callback is
> > being removed. The other VBLANK callbacks are being moved to the legacy
> > section at the end of struct drm_driver.
> > 
> > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> I think sprinkling some WARN_ON (in drm_dev_register or wherever) if new
> drivers try to use the legacy hooks would be really nice. Experience says
> someone is going to copypaste this stuff around forever otherwise.

I meant to add: As a follow-up patch.
-Daniel

> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> > ---
> >  drivers/gpu/drm/drm_vblank.c |  39 +++++---------
> >  include/drm/drm_drv.h        | 101 ++---------------------------------
> >  2 files changed, 17 insertions(+), 123 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> > index 7cf436a4b908..ceff68474d4d 100644
> > --- a/drivers/gpu/drm/drm_vblank.c
> > +++ b/drivers/gpu/drm/drm_vblank.c
> > @@ -138,10 +138,9 @@ static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
> >  
> >  		if (crtc->funcs->get_vblank_counter)
> >  			return crtc->funcs->get_vblank_counter(crtc);
> > -	}
> > -
> > -	if (dev->driver->get_vblank_counter)
> > +	} else if (dev->driver->get_vblank_counter) {
> >  		return dev->driver->get_vblank_counter(dev, pipe);
> > +	}
> >  
> >  	return drm_vblank_no_hw_counter(dev, pipe);
> >  }
> > @@ -334,8 +333,7 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
> >  	unsigned long flags;
> >  
> >  	WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) &&
> > -		  !crtc->funcs->get_vblank_timestamp &&
> > -		  !dev->driver->get_vblank_timestamp,
> > +		  !crtc->funcs->get_vblank_timestamp,
> >  		  "This function requires support for accurate vblank timestamps.");
> >  
> >  	spin_lock_irqsave(&dev->vblank_time_lock, flags);
> > @@ -357,13 +355,11 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
> >  		if (WARN_ON(!crtc))
> >  			return;
> >  
> > -		if (crtc->funcs->disable_vblank) {
> > +		if (crtc->funcs->disable_vblank)
> >  			crtc->funcs->disable_vblank(crtc);
> > -			return;
> > -		}
> > +	} else {
> > +		dev->driver->disable_vblank(dev, pipe);
> >  	}
> > -
> > -	dev->driver->disable_vblank(dev, pipe);
> >  }
> >  
> >  /*
> > @@ -791,9 +787,6 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
> >  
> >  		ret = crtc->funcs->get_vblank_timestamp(crtc, &max_error,
> >  							tvblank, in_vblank_irq);
> > -	} else if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
> > -		ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error,
> > -							tvblank, in_vblank_irq);
> >  	}
> >  
> >  	/* GPU high precision timestamp query unsupported or failed.
> > @@ -1016,9 +1009,11 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
> >  
> >  		if (crtc->funcs->enable_vblank)
> >  			return crtc->funcs->enable_vblank(crtc);
> > +	} else if (dev->driver->enable_vblank) {
> > +		return dev->driver->enable_vblank(dev, pipe);
> >  	}
> >  
> > -	return dev->driver->enable_vblank(dev, pipe);
> > +	return -EINVAL;
> >  }
> >  
> >  static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
> > @@ -1109,13 +1104,10 @@ static bool __vblank_disable_immediate(struct drm_device *dev, unsigned int pipe
> >  		return false;
> >  
> >  	crtc = drm_crtc_from_index(dev, pipe);
> > -	if (crtc && crtc->funcs->get_vblank_timestamp)
> > -		return true;
> > -
> > -	if (dev->driver->get_vblank_timestamp)
> > -		return true;
> > +	if (!crtc || !crtc->funcs->get_vblank_timestamp)
> > +		return false;
> >  
> > -	return false;
> > +	return true;
> >  }
> >  
> >  static void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
> > @@ -1798,7 +1790,6 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
> >  	struct drm_pending_vblank_event *e, *t;
> >  	ktime_t now;
> >  	u64 seq;
> > -	bool high_prec;
> >  
> >  	assert_spin_locked(&dev->event_lock);
> >  
> > @@ -1818,10 +1809,8 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
> >  		send_vblank_event(dev, e, seq, now);
> >  	}
> >  
> > -	high_prec = crtc->funcs->get_vblank_timestamp ||
> > -		    dev->driver->get_vblank_timestamp;
> > -
> > -	trace_drm_vblank_event(pipe, seq, now, high_prec);
> > +	trace_drm_vblank_event(pipe, seq, now,
> > +			       crtc->funcs->get_vblank_timestamp != NULL);
> >  }
> >  
> >  /**
> > diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> > index b704e252f3b2..e290b3aca6eb 100644
> > --- a/include/drm/drm_drv.h
> > +++ b/include/drm/drm_drv.h
> > @@ -268,104 +268,6 @@ struct drm_driver {
> >  	 */
> >  	void (*release) (struct drm_device *);
> >  
> > -	/**
> > -	 * @get_vblank_counter:
> > -	 *
> > -	 * Driver callback for fetching a raw hardware vblank counter for the
> > -	 * CRTC specified with the pipe argument.  If a device doesn't have a
> > -	 * hardware counter, the driver can simply leave the hook as NULL.
> > -	 * The DRM core will account for missed vblank events while interrupts
> > -	 * where disabled based on system timestamps.
> > -	 *
> > -	 * Wraparound handling and loss of events due to modesetting is dealt
> > -	 * with in the DRM core code, as long as drivers call
> > -	 * drm_crtc_vblank_off() and drm_crtc_vblank_on() when disabling or
> > -	 * enabling a CRTC.
> > -	 *
> > -	 * This is deprecated and should not be used by new drivers.
> > -	 * Use &drm_crtc_funcs.get_vblank_counter instead.
> > -	 *
> > -	 * Returns:
> > -	 *
> > -	 * Raw vblank counter value.
> > -	 */
> > -	u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
> > -
> > -	/**
> > -	 * @enable_vblank:
> > -	 *
> > -	 * Enable vblank interrupts for the CRTC specified with the pipe
> > -	 * argument.
> > -	 *
> > -	 * This is deprecated and should not be used by new drivers.
> > -	 * Use &drm_crtc_funcs.enable_vblank instead.
> > -	 *
> > -	 * Returns:
> > -	 *
> > -	 * Zero on success, appropriate errno if the given @crtc's vblank
> > -	 * interrupt cannot be enabled.
> > -	 */
> > -	int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
> > -
> > -	/**
> > -	 * @disable_vblank:
> > -	 *
> > -	 * Disable vblank interrupts for the CRTC specified with the pipe
> > -	 * argument.
> > -	 *
> > -	 * This is deprecated and should not be used by new drivers.
> > -	 * Use &drm_crtc_funcs.disable_vblank instead.
> > -	 */
> > -	void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
> > -
> > -	/**
> > -	 * @get_vblank_timestamp:
> > -	 *
> > -	 * Called by drm_get_last_vbltimestamp(). Should return a precise
> > -	 * timestamp when the most recent VBLANK interval ended or will end.
> > -	 *
> > -	 * Specifically, the timestamp in @vblank_time should correspond as
> > -	 * closely as possible to the time when the first video scanline of
> > -	 * the video frame after the end of VBLANK will start scanning out,
> > -	 * the time immediately after end of the VBLANK interval. If the
> > -	 * @crtc is currently inside VBLANK, this will be a time in the future.
> > -	 * If the @crtc is currently scanning out a frame, this will be the
> > -	 * past start time of the current scanout. This is meant to adhere
> > -	 * to the OpenML OML_sync_control extension specification.
> > -	 *
> > -	 * Paramters:
> > -	 *
> > -	 * dev:
> > -	 *     dev DRM device handle.
> > -	 * pipe:
> > -	 *     crtc for which timestamp should be returned.
> > -	 * max_error:
> > -	 *     Maximum allowable timestamp error in nanoseconds.
> > -	 *     Implementation should strive to provide timestamp
> > -	 *     with an error of at most max_error nanoseconds.
> > -	 *     Returns true upper bound on error for timestamp.
> > -	 * vblank_time:
> > -	 *     Target location for returned vblank timestamp.
> > -	 * in_vblank_irq:
> > -	 *     True when called from drm_crtc_handle_vblank().  Some drivers
> > -	 *     need to apply some workarounds for gpu-specific vblank irq quirks
> > -	 *     if flag is set.
> > -	 *
> > -	 * Returns:
> > -	 *
> > -	 * True on success, false on failure, which means the core should
> > -	 * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
> > -	 *
> > -	 * FIXME:
> > -	 *
> > -	 * We should move this hook to &struct drm_crtc_funcs like all the other
> > -	 * vblank hooks.
> > -	 */
> > -	bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
> > -				     int *max_error,
> > -				     ktime_t *vblank_time,
> > -				     bool in_vblank_irq);
> > -
> >  	/**
> >  	 * @irq_handler:
> >  	 *
> > @@ -720,6 +622,9 @@ struct drm_driver {
> >  	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
> >  	int (*dma_quiescent) (struct drm_device *);
> >  	int (*context_dtor) (struct drm_device *dev, int context);
> > +	u32 (*get_vblank_counter)(struct drm_device *dev, unsigned int pipe);
> > +	int (*enable_vblank)(struct drm_device *dev, unsigned int pipe);
> > +	void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);
> >  	int dev_priv_size;
> >  };
> >  
> > -- 
> > 2.24.1
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2020-01-12 22:54 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  9:21 [PATCH 00/23] drm: Clean up VBLANK callbacks in struct drm_driver Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 01/23] drm: Add get_scanout_position() to struct drm_crtc_helper_funcs Thomas Zimmermann
2020-01-10 10:24   ` Jani Nikula
     [not found]   ` <921ff745-0f2a-0bb6-c758-07174ac26e40@st.com>
2020-01-15  7:31     ` Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 02/23] drm/amdgpu: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-13 18:52   ` Alex Deucher
2020-01-14  7:46     ` Thomas Zimmermann
2020-01-15  9:41     ` Thomas Zimmermann
2020-01-15 16:35       ` Alex Deucher
2020-01-10  9:21 ` [PATCH 03/23] drm/i915: Don't use struct drm_driver.get_scanout_position() Thomas Zimmermann
2020-01-10 11:59   ` Jani Nikula
2020-01-10 12:04     ` Thomas Zimmermann
2020-01-10 13:56       ` Jani Nikula
2020-01-10 15:25         ` Ville Syrjälä
2020-01-10  9:21 ` [PATCH 04/23] drm/nouveau: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 05/23] drm/radeon: " Thomas Zimmermann
2020-01-13 18:53   ` Alex Deucher
2020-01-10  9:21 ` [PATCH 06/23] drm/msm: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 07/23] drm/vc4: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 08/23] drm/stm: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 09/23] drm: Remove struct drm_driver.get_scanout_position() Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 10/23] drm: Evaluate struct drm_device.vblank_disable_immediate on each use Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 11/23] drm: Add get_vblank_timestamp() to struct drm_crtc_funcs Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 12/23] drm/amdgpu: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-13 19:00   ` Alex Deucher
2020-01-10  9:21 ` [PATCH 13/23] drm/gma500: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 14/23] drm/i915: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 15/23] drm/msm: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 16/23] drm/nouveau: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 17/23] drm/radeon: " Thomas Zimmermann
2020-01-13 19:02   ` Alex Deucher
2020-01-10  9:21 ` [PATCH 18/23] drm/sti: " Thomas Zimmermann
2020-01-10 13:38   ` Benjamin Gaignard
2020-01-10  9:21 ` [PATCH 19/23] drm/stm: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 20/23] drm/vc4: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 21/23] drm/vkms: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 22/23] drm/vmwgfx: " Thomas Zimmermann
2020-01-10  9:21 ` [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver Thomas Zimmermann
2020-01-12 22:53   ` Daniel Vetter
2020-01-12 22:54     ` Daniel Vetter [this message]
2020-01-14 13:48     ` Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200112225421.GD5340@dvetter-linux.ger.corp.intel.com \
    --to=daniel@ffwll.ch \
    --cc=David1.Zhou@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=alexandre.torgue@st.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=benjamin.gaignard@linaro.org \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric@anholt.net \
    --cc=freedreno@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=harry.wentland@amd.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=patrik.r.jakobsson@gmail.com \
    --cc=philippe.cornu@st.com \
    --cc=robdclark@gmail.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=rodrigosiqueiramelo@gmail.com \
    --cc=sean@poorly.run \
    --cc=sunpeng.li@amd.com \
    --cc=thellstrom@vmware.com \
    --cc=tzimmermann@suse.de \
    --cc=vincent.abriou@st.com \
    --cc=yannick.fertre@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox