2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-25 05:34:00 +08:00

drm/vblank: Switch to bool in_vblank_irq in get_vblank_timestamp

It's overkill to have a flag parameter which is essentially used just
as a boolean. This takes care of core + adjusting drivers.

Adjusting the scanout position callback is a bit harder, since radeon
also supplies it's own driver-private flags in there.

v2: Fixup misplaced hunks (Neil).

v3: kbuild says v1 was better ...

Cc: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Cc: Eric Anholt <eric@anholt.net>
Cc: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170509140329.24114-2-daniel.vetter@ffwll.ch
This commit is contained in:
Daniel Vetter 2017-05-09 16:03:26 +02:00
parent d673c02c4b
commit 3fcdcb2709
13 changed files with 50 additions and 45 deletions

View File

@ -1913,7 +1913,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe, bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags); bool in_vblank_irq);
long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd, long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg); unsigned long arg);

View File

@ -941,7 +941,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
* @crtc: crtc to get the timestamp for * @crtc: crtc to get the timestamp for
* @max_error: max error * @max_error: max error
* @vblank_time: time value * @vblank_time: time value
* @flags: flags passed to the driver * @in_vblank_irq: called from drm_handle_vblank()
* *
* Gets the timestamp on the requested crtc based on the * Gets the timestamp on the requested crtc based on the
* scanout position. (all asics). * scanout position. (all asics).
@ -950,7 +950,7 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe, bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags) bool in_vblank_irq)
{ {
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
@ -971,7 +971,7 @@ bool amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
/* Helper routine in DRM core does all the work: */ /* Helper routine in DRM core does all the work: */
return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error, return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
vblank_time, flags, vblank_time, in_vblank_irq,
&crtc->hwmode); &crtc->hwmode);
} }

View File

@ -54,7 +54,7 @@
static bool static bool
drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
struct timeval *tvblank, unsigned flags); struct timeval *tvblank, bool in_vblank_irq);
static unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */ static unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */
@ -138,7 +138,7 @@ static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe
*/ */
do { do {
cur_vblank = __get_vblank_counter(dev, pipe); cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0); rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, false);
} while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0); } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
/* /*
@ -171,7 +171,7 @@ static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe
* device vblank fields. * device vblank fields.
*/ */
static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe, static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
unsigned long flags) bool in_vblank_irq)
{ {
struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
u32 cur_vblank, diff; u32 cur_vblank, diff;
@ -194,7 +194,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
*/ */
do { do {
cur_vblank = __get_vblank_counter(dev, pipe); cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags); rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, in_vblank_irq);
} while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0); } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
if (dev->max_vblank_count != 0) { if (dev->max_vblank_count != 0) {
@ -214,13 +214,13 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
*/ */
diff = DIV_ROUND_CLOSEST_ULL(diff_ns, framedur_ns); diff = DIV_ROUND_CLOSEST_ULL(diff_ns, framedur_ns);
if (diff == 0 && flags & DRM_CALLED_FROM_VBLIRQ) if (diff == 0 && in_vblank_irq)
DRM_DEBUG_VBL("crtc %u: Redundant vblirq ignored." DRM_DEBUG_VBL("crtc %u: Redundant vblirq ignored."
" diff_ns = %lld, framedur_ns = %d)\n", " diff_ns = %lld, framedur_ns = %d)\n",
pipe, (long long) diff_ns, framedur_ns); pipe, (long long) diff_ns, framedur_ns);
} else { } else {
/* some kind of default for drivers w/o accurate vbl timestamping */ /* some kind of default for drivers w/o accurate vbl timestamping */
diff = (flags & DRM_CALLED_FROM_VBLIRQ) != 0; diff = in_vblank_irq ? 1 : 0;
} }
/* /*
@ -253,7 +253,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
* Otherwise reinitialize delayed at next vblank interrupt and assign 0 * Otherwise reinitialize delayed at next vblank interrupt and assign 0
* for now, to mark the vblanktimestamp as invalid. * for now, to mark the vblanktimestamp as invalid.
*/ */
if (!rc && (flags & DRM_CALLED_FROM_VBLIRQ) == 0) if (!rc && in_vblank_irq)
t_vblank = (struct timeval) {0, 0}; t_vblank = (struct timeval) {0, 0};
store_vblank(dev, pipe, diff, &t_vblank, cur_vblank); store_vblank(dev, pipe, diff, &t_vblank, cur_vblank);
@ -291,7 +291,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
spin_lock_irqsave(&dev->vblank_time_lock, flags); spin_lock_irqsave(&dev->vblank_time_lock, flags);
drm_update_vblank_count(dev, pipe, 0); drm_update_vblank_count(dev, pipe, false);
vblank = drm_vblank_count(dev, pipe); vblank = drm_vblank_count(dev, pipe);
spin_unlock_irqrestore(&dev->vblank_time_lock, flags); spin_unlock_irqrestore(&dev->vblank_time_lock, flags);
@ -349,7 +349,7 @@ static void vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
* this time. This makes the count account for the entire time * this time. This makes the count account for the entire time
* between drm_crtc_vblank_on() and drm_crtc_vblank_off(). * between drm_crtc_vblank_on() and drm_crtc_vblank_off().
*/ */
drm_update_vblank_count(dev, pipe, 0); drm_update_vblank_count(dev, pipe, false);
spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags); spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
} }
@ -700,9 +700,10 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
* @max_error: Desired maximum allowable error in timestamps (nanosecs) * @max_error: Desired maximum allowable error in timestamps (nanosecs)
* On return contains true maximum error of timestamp * On return contains true maximum error of timestamp
* @vblank_time: Pointer to struct timeval which should receive the timestamp * @vblank_time: Pointer to struct timeval which should receive the timestamp
* @flags: Flags to pass to driver: * @in_vblank_irq:
* 0 = Default, * True when called from drm_crtc_handle_vblank(). Some drivers
* DRM_CALLED_FROM_VBLIRQ = If function is called from vbl IRQ handler * need to apply some workarounds for gpu-specific vblank irq quirks
* if flag is set.
* @mode: mode which defines the scanout timings * @mode: mode which defines the scanout timings
* *
* Implements calculation of exact vblank timestamps from given drm_display_mode * Implements calculation of exact vblank timestamps from given drm_display_mode
@ -732,7 +733,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
unsigned int pipe, unsigned int pipe,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags, bool in_vblank_irq,
const struct drm_display_mode *mode) const struct drm_display_mode *mode)
{ {
struct timeval tv_etime; struct timeval tv_etime;
@ -740,6 +741,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
unsigned int vbl_status; unsigned int vbl_status;
int vpos, hpos, i; int vpos, hpos, i;
int delta_ns, duration_ns; int delta_ns, duration_ns;
unsigned flags = in_vblank_irq ? DRM_CALLED_FROM_VBLIRQ : 0;
if (pipe >= dev->num_crtcs) { if (pipe >= dev->num_crtcs) {
DRM_ERROR("Invalid crtc %u\n", pipe); DRM_ERROR("Invalid crtc %u\n", pipe);
@ -843,9 +845,10 @@ static struct timeval get_drm_timestamp(void)
* @dev: DRM device * @dev: DRM device
* @pipe: index of CRTC whose vblank timestamp to retrieve * @pipe: index of CRTC whose vblank timestamp to retrieve
* @tvblank: Pointer to target struct timeval which should receive the timestamp * @tvblank: Pointer to target struct timeval which should receive the timestamp
* @flags: Flags to pass to driver: * @in_vblank_irq:
* 0 = Default, * True when called from drm_crtc_handle_vblank(). Some drivers
* DRM_CALLED_FROM_VBLIRQ = If function is called from vbl IRQ handler * need to apply some workarounds for gpu-specific vblank irq quirks
* if flag is set.
* *
* Fetches the system timestamp corresponding to the time of the most recent * Fetches the system timestamp corresponding to the time of the most recent
* vblank interval on specified CRTC. May call into kms-driver to * vblank interval on specified CRTC. May call into kms-driver to
@ -859,7 +862,7 @@ static struct timeval get_drm_timestamp(void)
*/ */
static bool static bool
drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
struct timeval *tvblank, unsigned flags) struct timeval *tvblank, bool in_vblank_irq)
{ {
bool ret = false; bool ret = false;
@ -869,7 +872,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
/* Query driver if possible and precision timestamping enabled. */ /* Query driver if possible and precision timestamping enabled. */
if (dev->driver->get_vblank_timestamp && (max_error > 0)) if (dev->driver->get_vblank_timestamp && (max_error > 0))
ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error, ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error,
tvblank, flags); tvblank, in_vblank_irq);
/* GPU high precision timestamp query unsupported or failed. /* GPU high precision timestamp query unsupported or failed.
* Return current monotonic/gettimeofday timestamp as best estimate. * Return current monotonic/gettimeofday timestamp as best estimate.
@ -1747,7 +1750,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe)
return false; return false;
} }
drm_update_vblank_count(dev, pipe, DRM_CALLED_FROM_VBLIRQ); drm_update_vblank_count(dev, pipe, true);
spin_unlock(&dev->vblank_time_lock); spin_unlock(&dev->vblank_time_lock);

View File

@ -967,7 +967,7 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags) bool in_vblank_irq)
{ {
struct drm_i915_private *dev_priv = to_i915(dev); struct drm_i915_private *dev_priv = to_i915(dev);
struct intel_crtc *crtc; struct intel_crtc *crtc;
@ -991,7 +991,7 @@ static bool i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
/* Helper routine in DRM core does all the work: */ /* Helper routine in DRM core does all the work: */
return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error, return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
vblank_time, flags, vblank_time, in_vblank_irq,
&crtc->base.hwmode); &crtc->base.hwmode);
} }

View File

@ -595,7 +595,7 @@ static int mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags) bool in_vblank_irq)
{ {
struct msm_drm_private *priv = dev->dev_private; struct msm_drm_private *priv = dev->dev_private;
struct drm_crtc *crtc; struct drm_crtc *crtc;
@ -612,7 +612,7 @@ static bool mdp5_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
} }
return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error, return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
vblank_time, flags, vblank_time, in_vblank_irq,
&crtc->mode); &crtc->mode);
} }

View File

@ -158,7 +158,7 @@ nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
bool bool
nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe, nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
int *max_error, struct timeval *time, unsigned flags) int *max_error, struct timeval *time, bool in_vblank_irq)
{ {
struct drm_crtc *crtc; struct drm_crtc *crtc;
@ -170,7 +170,8 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
else else
mode = &crtc->hwmode; mode = &crtc->hwmode;
return drm_calc_vbltimestamp_from_scanoutpos(dev, return drm_calc_vbltimestamp_from_scanoutpos(dev,
pipe, max_error, time, flags, mode); pipe, max_error, time, in_vblank_irq,
mode);
} }
} }

View File

@ -72,7 +72,7 @@ int nouveau_display_scanoutpos(struct drm_device *, unsigned int,
unsigned int, int *, int *, ktime_t *, unsigned int, int *, int *, ktime_t *,
ktime_t *, const struct drm_display_mode *); ktime_t *, const struct drm_display_mode *);
bool nouveau_display_vblstamp(struct drm_device *, unsigned int, int *, bool nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
struct timeval *, unsigned); struct timeval *, bool);
int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event, struct drm_pending_vblank_event *event,

View File

@ -118,7 +118,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe, bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags); bool in_vblank_irq);
void radeon_driver_irq_preinstall_kms(struct drm_device *dev); void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
int radeon_driver_irq_postinstall_kms(struct drm_device *dev); int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
void radeon_driver_irq_uninstall_kms(struct drm_device *dev); void radeon_driver_irq_uninstall_kms(struct drm_device *dev);

View File

@ -874,7 +874,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc, bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags) bool in_vblank_irq)
{ {
struct drm_crtc *drmcrtc; struct drm_crtc *drmcrtc;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
@ -891,7 +891,7 @@ bool radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
/* Helper routine in DRM core does all the work: */ /* Helper routine in DRM core does all the work: */
return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error, return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
vblank_time, flags, vblank_time, in_vblank_irq,
&drmcrtc->hwmode); &drmcrtc->hwmode);
} }

View File

@ -272,14 +272,14 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id, bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
int *max_error, struct timeval *vblank_time, int *max_error, struct timeval *vblank_time,
unsigned flags) bool in_vblank_irq)
{ {
struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id); struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
struct drm_crtc_state *state = crtc->state; struct drm_crtc_state *state = crtc->state;
/* Helper routine in DRM core does all the work: */ /* Helper routine in DRM core does all the work: */
return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error, return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error,
vblank_time, flags, vblank_time, in_vblank_irq,
&state->adjusted_mode); &state->adjusted_mode);
} }

View File

@ -495,7 +495,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
const struct drm_display_mode *mode); const struct drm_display_mode *mode);
bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id, bool vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
int *max_error, struct timeval *vblank_time, int *max_error, struct timeval *vblank_time,
unsigned flags); bool in_vblank_irq);
/* vc4_debugfs.c */ /* vc4_debugfs.c */
int vc4_debugfs_init(struct drm_minor *minor); int vc4_debugfs_init(struct drm_minor *minor);

View File

@ -241,8 +241,10 @@ struct drm_driver {
* DRM device. * DRM device.
* pipe: * pipe:
* Id of the crtc to query. * Id of the crtc to query.
* flags: * in_vblank_irq:
* Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0). * 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.
* vpos: * vpos:
* Target location for current vertical scanout position. * Target location for current vertical scanout position.
* hpos: * hpos:
@ -308,11 +310,10 @@ struct drm_driver {
* Returns true upper bound on error for timestamp. * Returns true upper bound on error for timestamp.
* vblank_time: * vblank_time:
* Target location for returned vblank timestamp. * Target location for returned vblank timestamp.
* flags: * in_vblank_irq:
* 0 = Defaults, no special treatment needed. * True when called from drm_crtc_handle_vblank(). Some drivers
* DRM_CALLED_FROM_VBLIRQ = Function is called from vblank * need to apply some workarounds for gpu-specific vblank irq quirks
* irq handler. Some drivers need to apply some workarounds * if flag is set.
* for gpu-specific vblank irq quirks if flag is set.
* *
* Returns: * Returns:
* *
@ -322,7 +323,7 @@ struct drm_driver {
bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe, bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
int *max_error, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags); bool in_vblank_irq);
/* these have to be filled in */ /* these have to be filled in */

View File

@ -156,7 +156,7 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
unsigned int pipe, int *max_error, unsigned int pipe, int *max_error,
struct timeval *vblank_time, struct timeval *vblank_time,
unsigned flags, bool in_vblank_irq,
const struct drm_display_mode *mode); const struct drm_display_mode *mode);
void drm_calc_timestamping_constants(struct drm_crtc *crtc, void drm_calc_timestamping_constants(struct drm_crtc *crtc,
const struct drm_display_mode *mode); const struct drm_display_mode *mode);