diff mbox

[1/2] drm: Wrap the check for atomic_commit implementation

Message ID 1482282183-4452-1-git-send-email-dhinakaran.pandiyan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dhinakaran Pandiyan Dec. 21, 2016, 1:03 a.m. UTC
This check is useful for drivers that do not have DRIVER_ATOMIC set but
have atomic modesetting internally implemented. Wrap the check into a
function since this is used in many places and as a bonus, the function
name helps to document what the check is for.

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
 drivers/gpu/drm/drm_fb_helper.c             | 6 +++---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++--
 drivers/gpu/drm/nouveau/nouveau_display.c   | 6 +++---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c     | 2 +-
 include/drm/drmP.h                          | 5 +++++
 5 files changed, 14 insertions(+), 9 deletions(-)

Comments

Daniel Vetter Dec. 21, 2016, 8:51 a.m. UTC | #1
On Tue, Dec 20, 2016 at 05:03:02PM -0800, Dhinakaran Pandiyan wrote:
> This check is useful for drivers that do not have DRIVER_ATOMIC set but
> have atomic modesetting internally implemented. Wrap the check into a
> function since this is used in many places and as a bonus, the function
> name helps to document what the check is for.
> 
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> ---
>  drivers/gpu/drm/drm_fb_helper.c             | 6 +++---
>  drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++--
>  drivers/gpu/drm/nouveau/nouveau_display.c   | 6 +++---
>  drivers/gpu/drm/nouveau/nouveau_fbcon.c     | 2 +-
>  include/drm/drmP.h                          | 5 +++++
>  5 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 145d55f..730342c 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -405,7 +405,7 @@ static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
>  
>  	drm_warn_on_modeset_not_all_locked(dev);
>  
> -	if (dev->mode_config.funcs->atomic_commit)
> +	if (drm_drv_uses_atomic_modeset(dev))
>  		return restore_fbdev_mode_atomic(fb_helper);
>  
>  	drm_for_each_plane(plane, dev) {
> @@ -1444,7 +1444,7 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
>  		return -EBUSY;
>  	}
>  
> -	if (dev->mode_config.funcs->atomic_commit) {
> +	if (drm_drv_uses_atomic_modeset(dev)) {
>  		ret = pan_display_atomic(var, info);
>  		goto unlock;
>  	}
> @@ -2060,7 +2060,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
>  	 * NULL we fallback to the default drm_atomic_helper_best_encoder()
>  	 * helper.
>  	 */
> -	if (fb_helper->dev->mode_config.funcs->atomic_commit &&
> +	if (drm_drv_uses_atomic_modeset(fb_helper->dev) &&
>  	    !connector_funcs->best_encoder)
>  		encoder = drm_atomic_helper_best_encoder(connector);
>  	else
> diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
> index 947c200..c4cc21a 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
> @@ -769,7 +769,7 @@ nouveau_connector_set_property(struct drm_connector *connector,
>  	struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
>  	int ret;
>  
> -	if (connector->dev->mode_config.funcs->atomic_commit)
> +	if (drm_drv_uses_atomic_modeset(connector->dev))
>  		return drm_atomic_helper_connector_set_property(connector, property, value);
>  
>  	ret = connector->funcs->atomic_set_property(&nv_connector->base,
> @@ -1074,7 +1074,7 @@ nouveau_connector_helper_funcs = {
>  static int
>  nouveau_connector_dpms(struct drm_connector *connector, int mode)
>  {
> -	if (connector->dev->mode_config.funcs->atomic_commit)
> +	if (drm_drv_uses_atomic_modeset(connector->dev))
>  		return drm_atomic_helper_connector_dpms(connector, mode);
>  	return drm_helper_connector_dpms(connector, mode);
>  }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
> index c5cf888..add353e 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -162,7 +162,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
>  	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
>  		if (nouveau_crtc(crtc)->index == pipe) {
>  			struct drm_display_mode *mode;
> -			if (dev->mode_config.funcs->atomic_commit)
> +			if (drm_drv_uses_atomic_modeset(dev))
>  				mode = &crtc->state->adjusted_mode;
>  			else
>  				mode = &crtc->hwmode;
> @@ -738,7 +738,7 @@ nouveau_display_suspend(struct drm_device *dev, bool runtime)
>  	struct nouveau_display *disp = nouveau_display(dev);
>  	struct drm_crtc *crtc;
>  
> -	if (dev->mode_config.funcs->atomic_commit) {
> +	if (drm_drv_uses_atomic_modeset(dev)) {
>  		if (!runtime) {
>  			disp->suspend = nouveau_atomic_suspend(dev);
>  			if (IS_ERR(disp->suspend)) {
> @@ -784,7 +784,7 @@ nouveau_display_resume(struct drm_device *dev, bool runtime)
>  	struct drm_crtc *crtc;
>  	int ret;
>  
> -	if (dev->mode_config.funcs->atomic_commit) {
> +	if (drm_drv_uses_atomic_modeset(dev)) {
>  		nouveau_display_init(dev);
>  		if (disp->suspend) {
>  			drm_atomic_helper_resume(dev, disp->suspend);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> index 5600f6c..ad722f14 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> @@ -524,7 +524,7 @@ nouveau_fbcon_init(struct drm_device *dev)
>  		preferred_bpp = 32;
>  
>  	/* disable all the possible outputs/crtcs before entering KMS mode */
> -	if (!dev->mode_config.funcs->atomic_commit)
> +	if (!drm_drv_uses_atomic_modeset(dev))
>  		drm_helper_disable_unused_functions(dev);
>  
>  	ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp);
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index a9cfd33..247acba 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -647,6 +647,11 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
>  	return ((dev->driver->driver_features & feature) ? 1 : 0);
>  }
>  
> +static inline int drm_drv_uses_atomic_modeset(struct drm_device *dev)

Please put this into the drm_atomic.h header and wrap some kernel-doc
around it to explain when to use this. Otherwise looks good to me.
-Daniel

> +{
> +	return dev->mode_config.funcs->atomic_commit ? 1 : 0;
> +}
> +
>  static inline void drm_device_set_unplugged(struct drm_device *dev)
>  {
>  	smp_wmb();
> -- 
> 2.7.4
>
Ville Syrjälä Dec. 21, 2016, 9:23 a.m. UTC | #2
On Tue, Dec 20, 2016 at 05:03:02PM -0800, Dhinakaran Pandiyan wrote:
> This check is useful for drivers that do not have DRIVER_ATOMIC set but
> have atomic modesetting internally implemented. Wrap the check into a
> function since this is used in many places and as a bonus, the function
> name helps to document what the check is for.
> 
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> ---
>  drivers/gpu/drm/drm_fb_helper.c             | 6 +++---
>  drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++--
>  drivers/gpu/drm/nouveau/nouveau_display.c   | 6 +++---
>  drivers/gpu/drm/nouveau/nouveau_fbcon.c     | 2 +-
>  include/drm/drmP.h                          | 5 +++++
>  5 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 145d55f..730342c 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -405,7 +405,7 @@ static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
>  
>  	drm_warn_on_modeset_not_all_locked(dev);
>  
> -	if (dev->mode_config.funcs->atomic_commit)
> +	if (drm_drv_uses_atomic_modeset(dev))
>  		return restore_fbdev_mode_atomic(fb_helper);
>  
>  	drm_for_each_plane(plane, dev) {
> @@ -1444,7 +1444,7 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
>  		return -EBUSY;
>  	}
>  
> -	if (dev->mode_config.funcs->atomic_commit) {
> +	if (drm_drv_uses_atomic_modeset(dev)) {
>  		ret = pan_display_atomic(var, info);
>  		goto unlock;
>  	}
> @@ -2060,7 +2060,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
>  	 * NULL we fallback to the default drm_atomic_helper_best_encoder()
>  	 * helper.
>  	 */
> -	if (fb_helper->dev->mode_config.funcs->atomic_commit &&
> +	if (drm_drv_uses_atomic_modeset(fb_helper->dev) &&
>  	    !connector_funcs->best_encoder)
>  		encoder = drm_atomic_helper_best_encoder(connector);
>  	else
> diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
> index 947c200..c4cc21a 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
> @@ -769,7 +769,7 @@ nouveau_connector_set_property(struct drm_connector *connector,
>  	struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
>  	int ret;
>  
> -	if (connector->dev->mode_config.funcs->atomic_commit)
> +	if (drm_drv_uses_atomic_modeset(connector->dev))
>  		return drm_atomic_helper_connector_set_property(connector, property, value);
>  
>  	ret = connector->funcs->atomic_set_property(&nv_connector->base,
> @@ -1074,7 +1074,7 @@ nouveau_connector_helper_funcs = {
>  static int
>  nouveau_connector_dpms(struct drm_connector *connector, int mode)
>  {
> -	if (connector->dev->mode_config.funcs->atomic_commit)
> +	if (drm_drv_uses_atomic_modeset(connector->dev))
>  		return drm_atomic_helper_connector_dpms(connector, mode);
>  	return drm_helper_connector_dpms(connector, mode);
>  }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
> index c5cf888..add353e 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -162,7 +162,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
>  	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
>  		if (nouveau_crtc(crtc)->index == pipe) {
>  			struct drm_display_mode *mode;
> -			if (dev->mode_config.funcs->atomic_commit)
> +			if (drm_drv_uses_atomic_modeset(dev))
>  				mode = &crtc->state->adjusted_mode;
>  			else
>  				mode = &crtc->hwmode;
> @@ -738,7 +738,7 @@ nouveau_display_suspend(struct drm_device *dev, bool runtime)
>  	struct nouveau_display *disp = nouveau_display(dev);
>  	struct drm_crtc *crtc;
>  
> -	if (dev->mode_config.funcs->atomic_commit) {
> +	if (drm_drv_uses_atomic_modeset(dev)) {
>  		if (!runtime) {
>  			disp->suspend = nouveau_atomic_suspend(dev);
>  			if (IS_ERR(disp->suspend)) {
> @@ -784,7 +784,7 @@ nouveau_display_resume(struct drm_device *dev, bool runtime)
>  	struct drm_crtc *crtc;
>  	int ret;
>  
> -	if (dev->mode_config.funcs->atomic_commit) {
> +	if (drm_drv_uses_atomic_modeset(dev)) {
>  		nouveau_display_init(dev);
>  		if (disp->suspend) {
>  			drm_atomic_helper_resume(dev, disp->suspend);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> index 5600f6c..ad722f14 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
> @@ -524,7 +524,7 @@ nouveau_fbcon_init(struct drm_device *dev)
>  		preferred_bpp = 32;
>  
>  	/* disable all the possible outputs/crtcs before entering KMS mode */
> -	if (!dev->mode_config.funcs->atomic_commit)
> +	if (!drm_drv_uses_atomic_modeset(dev))
>  		drm_helper_disable_unused_functions(dev);
>  
>  	ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp);
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index a9cfd33..247acba 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -647,6 +647,11 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
>  	return ((dev->driver->driver_features & feature) ? 1 : 0);
>  }
>  
> +static inline int drm_drv_uses_atomic_modeset(struct drm_device *dev)
> +{
> +	return dev->mode_config.funcs->atomic_commit ? 1 : 0;
> +}

bool ...
{
	return atomic_commit != NULL;
}

> +
>  static inline void drm_device_set_unplugged(struct drm_device *dev)
>  {
>  	smp_wmb();
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dhinakaran Pandiyan Dec. 21, 2016, 10:14 p.m. UTC | #3
Don't know what went wrong here, builds fine on my local machine.

-DK

On Wed, 2016-12-21 at 20:31 +0000, Patchwork wrote:
> == Series Details ==

> 

> Series: series starting with [v2,2/2] drm: Get atomic property value even if DRIVER_ATOMIC is not set (rev3)

> URL   : https://patchwork.freedesktop.org/series/17075/

> State : failure

> 

> == Summary ==

> 

>   CC [M]  drivers/gpu/drm/i915/intel_dsi_panel_vbt.o

>   CC [M]  drivers/gpu/drm/i915/intel_dsi_pll.o

>   CC [M]  drivers/gpu/drm/i915/intel_i2c.o

>   CC [M]  drivers/gpu/drm/i915/intel_hdmi.o

>   CC [M]  drivers/gpu/drm/i915/intel_dvo.o

>   CC [M]  drivers/gpu/drm/i915/intel_lvds.o

>   CC [M]  drivers/gpu/drm/i915/intel_lspcon.o

>   CC [M]  drivers/gpu/drm/i915/intel_panel.o

>   CC [M]  drivers/gpu/drm/i915/intel_sdvo.o

>   CC [M]  drivers/gpu/drm/i915/intel_tv.o

>   CC [M]  drivers/gpu/drm/i915/i915_perf.o

>   CC [M]  drivers/gpu/drm/i915/i915_vgpu.o

>   CC [M]  drivers/gpu/drm/i915/i915_gpu_error.o

>   CC [M]  drivers/gpu/drm/i915/intel_gvt.o

>   CC [M]  drivers/gpu/drm/i915/i915_oa_hsw.o

>   CC [M]  drivers/gpu/drm/i915/gvt/gvt.o

>   CC [M]  drivers/gpu/drm/i915/gvt/aperture_gm.o

>   CC [M]  drivers/gpu/drm/i915/gvt/handlers.o

>   CC [M]  drivers/gpu/drm/i915/gvt/trace_points.o

>   CC [M]  drivers/gpu/drm/i915/gvt/vgpu.o

>   CC [M]  drivers/gpu/drm/i915/gvt/firmware.o

>   CC [M]  drivers/gpu/drm/i915/gvt/interrupt.o

>   CC [M]  drivers/gpu/drm/i915/gvt/gtt.o

>   CC [M]  drivers/gpu/drm/i915/gvt/cfg_space.o

>   CC [M]  drivers/gpu/drm/i915/gvt/mmio.o

>   CC [M]  drivers/gpu/drm/i915/gvt/opregion.o

>   CC [M]  drivers/gpu/drm/i915/gvt/display.o

>   CC [M]  drivers/gpu/drm/i915/gvt/edid.o

>   CC [M]  drivers/gpu/drm/i915/gvt/execlist.o

>   CC [M]  drivers/gpu/drm/i915/gvt/sched_policy.o

>   CC [M]  drivers/gpu/drm/i915/gvt/render.o

>   CC [M]  drivers/gpu/drm/i915/gvt/scheduler.o

>   CC [M]  drivers/gpu/drm/i915/gvt/cmd_parser.o

>   LD [M]  sound/pci/hda/snd-hda-codec-generic.o

>   LD      sound/pci/built-in.o

>   LD      drivers/thermal/thermal_sys.o

>   LD      drivers/thermal/built-in.o

>   LD      drivers/spi/built-in.o

>   LD      drivers/acpi/acpica/acpi.o

>   LD      drivers/video/fbdev/built-in.o

>   LD      drivers/tty/serial/8250/8250.o

>   LD [M]  drivers/net/ethernet/intel/igbvf/igbvf.o

>   LD      sound/built-in.o

>   LD      drivers/iommu/built-in.o

>   LD      net/packet/built-in.o

>   LD      drivers/acpi/acpica/built-in.o

>   LD      drivers/usb/gadget/udc/udc-core.o

>   LD      drivers/scsi/scsi_mod.o

>   LD      drivers/usb/gadget/udc/built-in.o

>   LD      drivers/usb/gadget/built-in.o

>   LD      drivers/acpi/built-in.o

>   LD [M]  drivers/net/ethernet/intel/e1000/e1000.o

>   LD      net/xfrm/built-in.o

>   LD      lib/raid6/raid6_pq.o

>   LD [M]  drivers/net/ethernet/broadcom/genet/genet.o

>   LD      drivers/video/console/built-in.o

>   LD      lib/raid6/built-in.o

>   LD      drivers/video/built-in.o

>   LD      drivers/tty/serial/8250/8250_base.o

>   LD      drivers/scsi/sd_mod.o

>   LD      drivers/tty/serial/8250/built-in.o

>   LD      drivers/scsi/built-in.o

>   LD      drivers/tty/serial/built-in.o

>   LD      net/ipv6/ipv6.o

>   LD      drivers/usb/core/usbcore.o

>   LD [M]  drivers/net/ethernet/intel/igb/igb.o

>   LD      net/ipv6/built-in.o

>   LD      drivers/usb/core/built-in.o

>   AR      lib/lib.a

>   EXPORTS lib/lib-ksyms.o

>   LD      lib/built-in.o

>   LD      fs/btrfs/btrfs.o

>   LD      drivers/md/md-mod.o

>   LD      drivers/md/built-in.o

>   CC      arch/x86/kernel/cpu/capflags.o

>   LD      arch/x86/kernel/cpu/built-in.o

>   LD      arch/x86/kernel/built-in.o

>   LD      fs/btrfs/built-in.o

>   LD      drivers/tty/vt/built-in.o

>   LD      drivers/tty/built-in.o

>   LD      arch/x86/built-in.o

>   LD      net/ipv4/built-in.o

>   LD      drivers/usb/host/xhci-hcd.o

>   LD      drivers/usb/host/built-in.o

>   LD      drivers/usb/built-in.o

>   LD [M]  drivers/net/ethernet/intel/e1000e/e1000e.o

>   LD      net/core/built-in.o

>   LD      net/built-in.o

>   LD      fs/ext4/ext4.o

>   LD      fs/ext4/built-in.o

>   LD      fs/built-in.o

>   LD      drivers/net/ethernet/built-in.o

>   LD      drivers/net/built-in.o

>   LD [M]  drivers/gpu/drm/i915/i915.o

> scripts/Makefile.build:544: recipe for target 'drivers/gpu/drm' failed

> make[2]: *** [drivers/gpu/drm] Error 2

> scripts/Makefile.build:544: recipe for target 'drivers/gpu' failed

> make[1]: *** [drivers/gpu] Error 2

> Makefile:988: recipe for target 'drivers' failed

> make: *** [drivers] Error 2

> 

> _______________________________________________

> Intel-gfx mailing list

> Intel-gfx@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 145d55f..730342c 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -405,7 +405,7 @@  static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
 
 	drm_warn_on_modeset_not_all_locked(dev);
 
-	if (dev->mode_config.funcs->atomic_commit)
+	if (drm_drv_uses_atomic_modeset(dev))
 		return restore_fbdev_mode_atomic(fb_helper);
 
 	drm_for_each_plane(plane, dev) {
@@ -1444,7 +1444,7 @@  int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
 		return -EBUSY;
 	}
 
-	if (dev->mode_config.funcs->atomic_commit) {
+	if (drm_drv_uses_atomic_modeset(dev)) {
 		ret = pan_display_atomic(var, info);
 		goto unlock;
 	}
@@ -2060,7 +2060,7 @@  static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
 	 * NULL we fallback to the default drm_atomic_helper_best_encoder()
 	 * helper.
 	 */
-	if (fb_helper->dev->mode_config.funcs->atomic_commit &&
+	if (drm_drv_uses_atomic_modeset(fb_helper->dev) &&
 	    !connector_funcs->best_encoder)
 		encoder = drm_atomic_helper_best_encoder(connector);
 	else
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 947c200..c4cc21a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -769,7 +769,7 @@  nouveau_connector_set_property(struct drm_connector *connector,
 	struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
 	int ret;
 
-	if (connector->dev->mode_config.funcs->atomic_commit)
+	if (drm_drv_uses_atomic_modeset(connector->dev))
 		return drm_atomic_helper_connector_set_property(connector, property, value);
 
 	ret = connector->funcs->atomic_set_property(&nv_connector->base,
@@ -1074,7 +1074,7 @@  nouveau_connector_helper_funcs = {
 static int
 nouveau_connector_dpms(struct drm_connector *connector, int mode)
 {
-	if (connector->dev->mode_config.funcs->atomic_commit)
+	if (drm_drv_uses_atomic_modeset(connector->dev))
 		return drm_atomic_helper_connector_dpms(connector, mode);
 	return drm_helper_connector_dpms(connector, mode);
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index c5cf888..add353e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -162,7 +162,7 @@  nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		if (nouveau_crtc(crtc)->index == pipe) {
 			struct drm_display_mode *mode;
-			if (dev->mode_config.funcs->atomic_commit)
+			if (drm_drv_uses_atomic_modeset(dev))
 				mode = &crtc->state->adjusted_mode;
 			else
 				mode = &crtc->hwmode;
@@ -738,7 +738,7 @@  nouveau_display_suspend(struct drm_device *dev, bool runtime)
 	struct nouveau_display *disp = nouveau_display(dev);
 	struct drm_crtc *crtc;
 
-	if (dev->mode_config.funcs->atomic_commit) {
+	if (drm_drv_uses_atomic_modeset(dev)) {
 		if (!runtime) {
 			disp->suspend = nouveau_atomic_suspend(dev);
 			if (IS_ERR(disp->suspend)) {
@@ -784,7 +784,7 @@  nouveau_display_resume(struct drm_device *dev, bool runtime)
 	struct drm_crtc *crtc;
 	int ret;
 
-	if (dev->mode_config.funcs->atomic_commit) {
+	if (drm_drv_uses_atomic_modeset(dev)) {
 		nouveau_display_init(dev);
 		if (disp->suspend) {
 			drm_atomic_helper_resume(dev, disp->suspend);
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 5600f6c..ad722f14 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -524,7 +524,7 @@  nouveau_fbcon_init(struct drm_device *dev)
 		preferred_bpp = 32;
 
 	/* disable all the possible outputs/crtcs before entering KMS mode */
-	if (!dev->mode_config.funcs->atomic_commit)
+	if (!drm_drv_uses_atomic_modeset(dev))
 		drm_helper_disable_unused_functions(dev);
 
 	ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a9cfd33..247acba 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -647,6 +647,11 @@  static __inline__ int drm_core_check_feature(struct drm_device *dev,
 	return ((dev->driver->driver_features & feature) ? 1 : 0);
 }
 
+static inline int drm_drv_uses_atomic_modeset(struct drm_device *dev)
+{
+	return dev->mode_config.funcs->atomic_commit ? 1 : 0;
+}
+
 static inline void drm_device_set_unplugged(struct drm_device *dev)
 {
 	smp_wmb();