Re: [Nouveau] [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver

2020-01-17 Thread Thomas Zimmermann
Hi

Am 12.01.20 um 23:53 schrieb Daniel Vetter:
> 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 
> 
> 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've been thinking about moving these fields to separate structures, say
struct drm_legacy_device and struct drm_legacy_driver. Those would be
allocated for legacy drivers and KMS drivers would never see them
(except for their forward declaration).

Best regards
Thomas

> 
> Reviewed-by: Daniel Vetter 
> 
>> ---
>>  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(>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, _error,
>>  tvblank, in_vblank_irq);
>> -} else if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
>> -ret = dev->driver->get_vblank_timestamp(dev, pipe, _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(>event_lock);
>>  
>> @@ -1818,10 +1809,8 @@ static void 

Re: [Nouveau] [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver

2020-01-17 Thread Yannick FERTRE
Thanks for the patch.

Tested-by: Yannick Fertré 

BR
Yannick Fertré


On 1/10/20 10:21 AM, 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 

---
 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(>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, _error,
tvblank, in_vblank_irq);
-   } else if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
-   ret = dev->driver->get_vblank_timestamp(dev, pipe, _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(>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 

Re: [Nouveau] [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver

2020-01-13 Thread Daniel Vetter
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 
> 
> 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 
> 
> > ---
> >  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(>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, _error,
> > tvblank, in_vblank_irq);
> > -   } else if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
> > -   ret = dev->driver->get_vblank_timestamp(dev, pipe, _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(>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);
> > }
> >  
> 

Re: [Nouveau] [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver

2020-01-13 Thread Daniel Vetter
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 

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.

Reviewed-by: Daniel Vetter 

> ---
>  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(>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, _error,
>   tvblank, in_vblank_irq);
> - } else if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
> - ret = dev->driver->get_vblank_timestamp(dev, pipe, _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(>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,
> +

[Nouveau] [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver

2020-01-11 Thread Thomas Zimmermann
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 
---
 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(>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, _error,
tvblank, in_vblank_irq);
-   } else if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
-   ret = dev->driver->get_vblank_timestamp(dev, pipe, _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(>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