Re: [PATCH 06/35] drm: Hide master MAP cleanup in drm_bufs.c

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

 



On Tue, Apr 26, 2016 at 07:29:39PM +0200, Daniel Vetter wrote:
> And again make sure it's a no-op for modern drivers, again with the
> exception of nouveau. Another case of dev->struct_mutex gone for
> modern drivers!
> 
> v2: Also add a DRIVER_* check like for all other maps functions to
> really short-circuit the code. And give drm_legacy_rmmap used by the
> dev unregister code the same treatment.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>
> ---
>  drivers/gpu/drm/drm_bufs.c | 28 ++++++++++++++++++++++++----
>  drivers/gpu/drm/drm_drv.c  | 10 +---------
>  include/drm/drm_legacy.h   |  4 +++-
>  3 files changed, 28 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index e8a12a4fd400..5a51633da033 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -542,18 +542,38 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
>  }
>  EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>  
> -int drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
> +void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>  {
> -	int ret;
> +	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +	    drm_core_check_feature(dev, DRIVER_MODESET))
> +		return;
>  
>  	mutex_lock(&dev->struct_mutex);
> -	ret = drm_legacy_rmmap_locked(dev, map);
> +	drm_legacy_rmmap_locked(dev, map);
>  	mutex_unlock(&dev->struct_mutex);
>  
> -	return ret;
> +	return;

2 dead lines.

>  }
>  EXPORT_SYMBOL(drm_legacy_rmmap);
>  
> +void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
> +{
> +	struct drm_map_list *r_list, *list_temp;
> +
> +	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +	    drm_core_check_feature(dev, DRIVER_MODESET))
> +		return;
> +
> +	mutex_lock(&dev->struct_mutex);
> +	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
> +		if (r_list->master == master) {
> +			drm_legacy_rmmap_locked(dev, r_list->map);
> +			r_list = NULL;
> +		}
> +	}
> +	mutex_unlock(&dev->struct_mutex);
> +}

Hmm, the entirety of the addmap interface is not guarded by legacy.
Would be good to say the two users mga and savage are !MODESET.

> +
>  /* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
>   * the last close of the device, and this is necessary for cleanup when things
>   * exit uncleanly.  Therefore, having userland manually remove mappings seems
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 55273f8f3acb..e1fb52d4f72c 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -121,19 +121,11 @@ static void drm_master_destroy(struct kref *kref)
>  {
>  	struct drm_master *master = container_of(kref, struct drm_master, refcount);
>  	struct drm_device *dev = master->minor->dev;
> -	struct drm_map_list *r_list, *list_temp;
>  
>  	if (dev->driver->master_destroy)
>  		dev->driver->master_destroy(dev, master);
>  
> -	mutex_lock(&dev->struct_mutex);
> -	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
> -		if (r_list->master == master) {
> -			drm_legacy_rmmap_locked(dev, r_list->map);
> -			r_list = NULL;
> -		}
> -	}
> -	mutex_unlock(&dev->struct_mutex);
> +	drm_legacy_master_rmmaps(dev, master);

WARN_ON(!list_empty(&dev->maplist));

might be useful?

Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux