[PATCH 1/3] drm/debugfs: separate debugfs creation into init and register

Stanislaw Gruszka stanislaw.gruszka at linux.intel.com
Tue Feb 14 11:56:44 UTC 2023


On Thu, Feb 09, 2023 at 09:18:36AM +0100, Christian König wrote:
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index c6eb8972451a..88ce22c04672 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -156,6 +156,10 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
>  	if (IS_ERR(minor->kdev))
>  		return PTR_ERR(minor->kdev);
>  
> +	r = drm_debugfs_init(minor, minor->index, drm_debugfs_root);
> +	if (r)
> +		return r;
> +
>  	*drm_minor_get_slot(dev, type) = minor;
>  	return 0;
>  }
> @@ -172,15 +176,10 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
>  	if (!minor)
>  		return 0;
>  
> -	if (minor->type == DRM_MINOR_ACCEL) {
> +	if (minor->type == DRM_MINOR_ACCEL)
>  		accel_debugfs_init(minor, minor->index);

Please move this to drm_minor_alloc() as well. Or perhaps make
conditional code for DRM_MINOR_ACCEL inside drm_debugfs_init().

Regards
Stanislaw

> -	} else {
> -		ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root);
> -		if (ret) {
> -			DRM_ERROR("DRM: Failed to initialize /sys/kernel/debug/dri.\n");
> -			goto err_debugfs;
> -		}
> -	}
> +	else
> +		drm_debugfs_register(minor);

>  
>  	ret = device_add(minor->kdev);
>  	if (ret)
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index ed2103ee272c..332fb65a935a 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -185,6 +185,7 @@ int drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
>  #if defined(CONFIG_DEBUG_FS)
>  int drm_debugfs_init(struct drm_minor *minor, int minor_id,
>  		     struct dentry *root);
> +void drm_debugfs_register(struct drm_minor *minor);
>  void drm_debugfs_cleanup(struct drm_minor *minor);
>  void drm_debugfs_late_register(struct drm_device *dev);
>  void drm_debugfs_connector_add(struct drm_connector *connector);
> -- 
> 2.34.1
> 


More information about the dri-devel mailing list