Re: [PATCH 2/5] drm: Compile out legacy chunks from struct drm_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Am 23.10.20 um 14:28 schrieb Daniel Vetter:
> This means some very few #ifdef in code, but it allows us to
> enlist the compiler to make sure this stuff isn't used anymore.
> 
> More important, only legacy drivers change drm_device (for the
> legacy_dev_list shadow attach management), therefore this is
> prep to allow modern drivers to have a const driver struct. Which
> is nice, because there's a ton of function pointers in there.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>
> Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
> Cc: Maxime Ripard <mripard@xxxxxxxxxx>
> Cc: Thomas Zimmermann <tzimmermann@xxxxxxx>
> Cc: David Airlie <airlied@xxxxxxxx>
> Cc: Daniel Vetter <daniel@xxxxxxxx>
> Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx>

Review-by: Thomas Zimmermann <tzimmermann@xxxxxxx>

Sort of related: the implementation for KMS and UMS devices is more and
more distinct from each other. Did you ever consider going for separate
legacy helpers instead of mixing-in all these ifdefs?

Best regards
Thomas

> ---
>  drivers/gpu/drm/drm_file.c   |  2 ++
>  drivers/gpu/drm/drm_vblank.c | 15 ++++++++++++---
>  include/drm/drm_drv.h        |  2 ++
>  3 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index 0ac4566ae3f4..b50380fa80ce 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -258,9 +258,11 @@ void drm_file_free(struct drm_file *file)
>  		  (long)old_encode_dev(file->minor->kdev->devt),
>  		  atomic_read(&dev->open_count));
>  
> +#ifdef CONFIG_DRM_LEGACY
>  	if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
>  	    dev->driver->preclose)
>  		dev->driver->preclose(dev, file);
> +#endif
>  
>  	if (drm_core_check_feature(dev, DRIVER_LEGACY))
>  		drm_legacy_lock_release(dev, file->filp);
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index ba7e741764aa..15e5ea436434 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -210,9 +210,12 @@ 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);
> -	} else if (dev->driver->get_vblank_counter) {
> +	}
> +#ifdef CONFIG_DRM_LEGACY
> +	else if (dev->driver->get_vblank_counter) {
>  		return dev->driver->get_vblank_counter(dev, pipe);
>  	}
> +#endif
>  
>  	return drm_vblank_no_hw_counter(dev, pipe);
>  }
> @@ -430,9 +433,12 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
>  
>  		if (crtc->funcs->disable_vblank)
>  			crtc->funcs->disable_vblank(crtc);
> -	} else {
> +	}
> +#ifdef CONFIG_DRM_LEGACY
> +	else {
>  		dev->driver->disable_vblank(dev, pipe);
>  	}
> +#endif
>  }
>  
>  /*
> @@ -1097,9 +1103,12 @@ 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) {
> +	}
> +#ifdef CONFIG_DRM_LEGACY
> +	else if (dev->driver->enable_vblank) {
>  		return dev->driver->enable_vblank(dev, pipe);
>  	}
> +#endif
>  
>  	return -EINVAL;
>  }
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index c6d17550efc9..7af220226a25 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -498,6 +498,7 @@ struct drm_driver {
>  	 */
>  	const struct file_operations *fops;
>  
> +#ifdef CONFIG_DRM_LEGACY
>  	/* Everything below here is for legacy driver, never use! */
>  	/* private: */
>  
> @@ -512,6 +513,7 @@ struct drm_driver {
>  	int (*enable_vblank)(struct drm_device *dev, unsigned int pipe);
>  	void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);
>  	int dev_priv_size;
> +#endif
>  };
>  
>  void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux