Hi all,
First few patches are resends (reviews, pretty please), but most of this is all new. After all this all the legacy code is guarded by DRIVER_* feature tests, and struct_mutex is never even acquired for modern drivers (except nouveau, because). And there's just 2 things left where struct_mutex actually matters for modern drivers:
- master locking. I've handled the low-hanging fruit, the leftover paths touch the dreaded legacy-horros hw.lock. No idea how to get rid of that, but master_list and master status probably need to grow a separate lock.
- 4 drivers who use struct_mutex as their BKL: i915, omapdrm, msm & udl. Most of those will require serious amounts of work to fix, but for new drivers I'm postive we don't have to deal with struct_mutex ever again: Either pick ttm (if you're ok with midlayers), or implement the locking scheme from etnaviv (which is just plain gem with ww mutexes and fences).
23 drivers (most of those kms-only, using cma for gem) are now entirely struct_mutex free!
Reviews, acks and comments highly welcome.
Cheers, Daniel
Benjamin Gaignard (1): drm: sti: remove useless call to dev->struct_mutex
Daniel Vetter (34): drm: Give drm_agp_clear drm_legacy_ prefix drm: Put legacy lastclose work into drm_legacy_dev_reinit drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix drm: Forbid legacy MAP functions for DRIVER_MODESET drm: Push struct_mutex into ->master_destroy drm: Hide master MAP cleanup in drm_bufs.c drm: Make drm_vm_open/close_locked private to drm_vm.c drm: Protect dev->filelist with its own mutex drm/gem: support BO freeing without dev->struct_mutex drm/amdgpu: Use lockless gem BO free callback drm/armada: Use lockless gem BO free callback drm/ast: Use lockless gem BO free callback drm/atmel: Use lockless gem BO free callback drm/bochs: Use lockless gem BO free callback drm/cirrus: Use lockless gem BO free callback drm/etnaviv: Use lockless gem BO free callback drm/exynos: Use lockless gem BO free callback drm/fls-dcu: Use lockless gem BO free callback drm/imx: Use lockless gem BO free callback drm/mga200g: Use lockless gem BO free callback drm/nouveau: Use lockless gem BO free callback drm/qxl: Use lockless gem BO free callback drm/radeon: Use lockless gem BO free callback drm/rcar-du: Use lockless gem BO free callback drm/rockchip: Use lockless gem BO free callback drm/shmob: Use lockless gem BO free callback drm/tegra: Use lockless gem BO free callback drm/tilcdc: Use lockless gem BO free callback drm/vc4: Use drm_gem_object_unreference_unlocked drm/vc4: Use lockless gem BO free callback drm/vgem: Use lockless gem BO free callback drm/virtio: Use lockless gem BO free callback drm/virtio: Use lockless gem BO free callback drm/rockchip: Use cma gem vm ops
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-- drivers/gpu/drm/armada/armada_drv.c | 2 +- drivers/gpu/drm/ast/ast_drv.c | 2 +- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +- drivers/gpu/drm/bochs/bochs_drv.c | 2 +- drivers/gpu/drm/cirrus/cirrus_drv.c | 2 +- drivers/gpu/drm/drm_agpsupport.c | 4 +- drivers/gpu/drm/drm_bufs.c | 92 ++++++++++++++++++++++++++-- drivers/gpu/drm/drm_drv.c | 11 +--- drivers/gpu/drm/drm_fops.c | 51 ++++++++------- drivers/gpu/drm/drm_gem.c | 64 +++++++++++++++---- drivers/gpu/drm/drm_info.c | 4 +- drivers/gpu/drm/drm_internal.h | 4 +- drivers/gpu/drm/drm_ioctl.c | 54 +--------------- drivers/gpu/drm/drm_legacy.h | 2 + drivers/gpu/drm/drm_pci.c | 2 +- drivers/gpu/drm/drm_vm.c | 16 ++--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 +- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 2 +- drivers/gpu/drm/i915/i915_debugfs.c | 12 +++- drivers/gpu/drm/imx/imx-drm-core.c | 2 +- drivers/gpu/drm/mgag200/mgag200_drv.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/qxl/qxl_drv.c | 2 +- drivers/gpu/drm/radeon/radeon_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 9 +-- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +- drivers/gpu/drm/sti/sti_cursor.c | 7 --- drivers/gpu/drm/sti/sti_drv.c | 8 +-- drivers/gpu/drm/sti/sti_dvo.c | 7 --- drivers/gpu/drm/sti/sti_gdp.c | 14 ----- drivers/gpu/drm/sti/sti_hda.c | 7 --- drivers/gpu/drm/sti/sti_hdmi.c | 7 --- drivers/gpu/drm/sti/sti_hqvdp.c | 7 --- drivers/gpu/drm/sti/sti_mixer.c | 7 --- drivers/gpu/drm/sti/sti_tvout.c | 7 --- drivers/gpu/drm/sti/sti_vid.c | 7 --- drivers/gpu/drm/tegra/drm.c | 2 +- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- drivers/gpu/drm/vc4/vc4_drv.c | 2 +- drivers/gpu/drm/vc4/vc4_gem.c | 11 +--- drivers/gpu/drm/vgem/vgem_drv.c | 2 +- drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +- include/drm/drmP.h | 13 +++- include/drm/drm_agpsupport.h | 4 +- include/drm/drm_gem.h | 45 +------------- include/drm/drm_legacy.h | 4 +- 50 files changed, 241 insertions(+), 291 deletions(-)
It has a DRIVER_MODESET check to sure make it's not creating havoc for drm drivers. Make that clear in the name too.
v2: Move misplaced hunk, spotted by 0day and Thierry.
Cc: Thierry Reding thierry.reding@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_agpsupport.c | 4 ++-- drivers/gpu/drm/drm_fops.c | 2 +- drivers/gpu/drm/drm_pci.c | 2 +- include/drm/drm_agpsupport.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c index a10ea6aec629..605bd243fb36 100644 --- a/drivers/gpu/drm/drm_agpsupport.c +++ b/drivers/gpu/drm/drm_agpsupport.c @@ -423,7 +423,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev) }
/** - * drm_agp_clear - Clear AGP resource list + * drm_legacy_agp_clear - Clear AGP resource list * @dev: DRM device * * Iterate over all AGP resources and remove them. But keep the AGP head @@ -434,7 +434,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev) * resources from getting destroyed. Drivers are responsible of cleaning them up * during device shutdown. */ -void drm_agp_clear(struct drm_device *dev) +void drm_legacy_agp_clear(struct drm_device *dev) { struct drm_agp_mem *entry, *tempe;
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index aeef58ed359b..7b5a13cda7a6 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -413,7 +413,7 @@ int drm_lastclose(struct drm_device * dev)
mutex_lock(&dev->struct_mutex);
- drm_agp_clear(dev); + drm_legacy_agp_clear(dev);
drm_legacy_sg_cleanup(dev); drm_legacy_vma_flush(dev); diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index a1fff1179a97..29d5a548d07a 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c @@ -250,7 +250,7 @@ void drm_pci_agp_destroy(struct drm_device *dev) { if (dev->agp) { arch_phys_wc_del(dev->agp->agp_mtrr); - drm_agp_clear(dev); + drm_legacy_agp_clear(dev); kfree(dev->agp); dev->agp = NULL; } diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h index 193ef19dfc5c..b2d912670a7f 100644 --- a/include/drm/drm_agpsupport.h +++ b/include/drm/drm_agpsupport.h @@ -37,7 +37,7 @@ struct agp_memory *drm_agp_bind_pages(struct drm_device *dev, uint32_t type);
struct drm_agp_head *drm_agp_init(struct drm_device *dev); -void drm_agp_clear(struct drm_device *dev); +void drm_legacy_agp_clear(struct drm_device *dev); int drm_agp_acquire(struct drm_device *dev); int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -93,7 +93,7 @@ static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev) return NULL; }
-static inline void drm_agp_clear(struct drm_device *dev) +static inline void drm_legacy_agp_clear(struct drm_device *dev) { }
On Tue, Apr 26, 2016 at 07:29:34PM +0200, Daniel Vetter wrote:
It has a DRIVER_MODESET check to sure make it's not creating havoc for drm drivers. Make that clear in the name too.
The pattern is that any extern that starts
if (drm_core_check_feature(MODESET)) return
becomes drm_legacy_ ? With the apparent caveat of KMS_LEGACY_CONTEXT.
v2: Move misplaced hunk, spotted by 0day and Thierry.
Cc: Thierry Reding thierry.reding@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Chris Wilson chris@chris-wilson.co.uk -Chris
On Tue, Apr 26, 2016 at 10:09:16PM +0100, Chris Wilson wrote:
On Tue, Apr 26, 2016 at 07:29:34PM +0200, Daniel Vetter wrote:
It has a DRIVER_MODESET check to sure make it's not creating havoc for drm drivers. Make that clear in the name too.
The pattern is that any extern that starts
if (drm_core_check_feature(MODESET)) return
becomes drm_legacy_ ? With the apparent caveat of KMS_LEGACY_CONTEXT.
Yeah that's what I'm aiming for. Gives you a clear signal that as soon as you spot drm_legacy_* you don't have to bother jumping into the function at all. We've done the same with headers, splitting things into legacy internal headers.
v2: Move misplaced hunk, spotted by 0day and Thierry.
Cc: Thierry Reding thierry.reding@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Chris Wilson chris@chris-wilson.co.uk
Thanks for the review, will apply. -Daniel
Except for the ->lasclose driver callback evrything in drm_lastclose() is all legacy cruft and can be hidden. Which means another dev->struct_mutex site disappears entirely for modern drivers!
Also while at it change the return value of drm_lastclose to void since it will always succeed. No one checks the return value of close() anyway, ever.
v2: Move misplaced hunk, spotted by 0day.
Cc: Thierry Reding thierry.reding@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_fops.c | 42 +++++++++++++++++++----------------------- drivers/gpu/drm/drm_internal.h | 2 +- 2 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 7b5a13cda7a6..c3d0aaac0669 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -381,14 +381,26 @@ static void drm_events_release(struct drm_file *file_priv) */ static void drm_legacy_dev_reinit(struct drm_device *dev) { - if (drm_core_check_feature(dev, DRIVER_MODESET)) - return; + if (dev->irq_enabled) + drm_irq_uninstall(dev); + + mutex_lock(&dev->struct_mutex); + + drm_legacy_agp_clear(dev); + + drm_legacy_sg_cleanup(dev); + drm_legacy_vma_flush(dev); + drm_legacy_dma_takedown(dev); + + mutex_unlock(&dev->struct_mutex);
dev->sigdata.lock = NULL;
dev->context_flag = 0; dev->last_context = 0; dev->if_version = 0; + + DRM_DEBUG("lastclose completed\n"); }
/* @@ -400,7 +412,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev) * * \sa drm_device */ -int drm_lastclose(struct drm_device * dev) +void drm_lastclose(struct drm_device * dev) { DRM_DEBUG("\n");
@@ -408,23 +420,8 @@ int drm_lastclose(struct drm_device * dev) dev->driver->lastclose(dev); DRM_DEBUG("driver lastclose completed\n");
- if (dev->irq_enabled && !drm_core_check_feature(dev, DRIVER_MODESET)) - drm_irq_uninstall(dev); - - mutex_lock(&dev->struct_mutex); - - drm_legacy_agp_clear(dev); - - drm_legacy_sg_cleanup(dev); - drm_legacy_vma_flush(dev); - drm_legacy_dma_takedown(dev); - - mutex_unlock(&dev->struct_mutex); - - drm_legacy_dev_reinit(dev); - - DRM_DEBUG("lastclose completed\n"); - return 0; + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + drm_legacy_dev_reinit(dev); }
/** @@ -445,7 +442,6 @@ int drm_release(struct inode *inode, struct file *filp) struct drm_file *file_priv = filp->private_data; struct drm_minor *minor = file_priv->minor; struct drm_device *dev = minor->dev; - int retcode = 0;
mutex_lock(&drm_global_mutex);
@@ -538,7 +534,7 @@ int drm_release(struct inode *inode, struct file *filp) */
if (!--dev->open_count) { - retcode = drm_lastclose(dev); + drm_lastclose(dev); if (drm_device_is_unplugged(dev)) drm_put_dev(dev); } @@ -546,7 +542,7 @@ int drm_release(struct inode *inode, struct file *filp)
drm_minor_release(minor);
- return retcode; + return 0; } EXPORT_SYMBOL(drm_release);
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 43cbda3306ac..c81ff4769e7b 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -26,7 +26,7 @@ extern unsigned int drm_timestamp_monotonic;
/* drm_fops.c */ extern struct mutex drm_global_mutex; -int drm_lastclose(struct drm_device *dev); +void drm_lastclose(struct drm_device *dev);
/* drm_pci.c */ int drm_pci_set_unique(struct drm_device *dev,
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Except for the ->lasclose driver callback evrything in drm_lastclose() is all legacy cruft and can be hidden. Which means another dev->struct_mutex site disappears entirely for modern drivers!
Also while at it change the return value of drm_lastclose to void since it will always succeed. No one checks the return value of close() anyway, ever.
v2: Move misplaced hunk, spotted by 0day.
Cc: Thierry Reding thierry.reding@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_fops.c | 42 +++++++++++++++++++----------------------- drivers/gpu/drm/drm_internal.h | 2 +- 2 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 7b5a13cda7a6..c3d0aaac0669 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -381,14 +381,26 @@ static void drm_events_release(struct drm_file *file_priv) */ static void drm_legacy_dev_reinit(struct drm_device *dev) {
if (drm_core_check_feature(dev, DRIVER_MODESET))
return;
if (dev->irq_enabled)
drm_irq_uninstall(dev);
mutex_lock(&dev->struct_mutex);
drm_legacy_agp_clear(dev);
drm_legacy_sg_cleanup(dev);
drm_legacy_vma_flush(dev);
drm_legacy_dma_takedown(dev);
mutex_unlock(&dev->struct_mutex); dev->sigdata.lock = NULL; dev->context_flag = 0; dev->last_context = 0; dev->if_version = 0;
DRM_DEBUG("lastclose completed\n");
}
/* @@ -400,7 +412,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
- \sa drm_device
*/ -int drm_lastclose(struct drm_device * dev) +void drm_lastclose(struct drm_device * dev) { DRM_DEBUG("\n");
@@ -408,23 +420,8 @@ int drm_lastclose(struct drm_device * dev) dev->driver->lastclose(dev); DRM_DEBUG("driver lastclose completed\n");
if (dev->irq_enabled && !drm_core_check_feature(dev, DRIVER_MODESET))
drm_irq_uninstall(dev);
mutex_lock(&dev->struct_mutex);
drm_legacy_agp_clear(dev);
drm_legacy_sg_cleanup(dev);
drm_legacy_vma_flush(dev);
drm_legacy_dma_takedown(dev);
mutex_unlock(&dev->struct_mutex);
drm_legacy_dev_reinit(dev);
DRM_DEBUG("lastclose completed\n");
return 0;
if (!drm_core_check_feature(dev, DRIVER_MODESET))
drm_legacy_dev_reinit(dev);
}
/** @@ -445,7 +442,6 @@ int drm_release(struct inode *inode, struct file *filp) struct drm_file *file_priv = filp->private_data; struct drm_minor *minor = file_priv->minor; struct drm_device *dev = minor->dev;
int retcode = 0; mutex_lock(&drm_global_mutex);
@@ -538,7 +534,7 @@ int drm_release(struct inode *inode, struct file *filp) */
if (!--dev->open_count) {
retcode = drm_lastclose(dev);
drm_lastclose(dev); if (drm_device_is_unplugged(dev)) drm_put_dev(dev); }
@@ -546,7 +542,7 @@ int drm_release(struct inode *inode, struct file *filp)
drm_minor_release(minor);
return retcode;
return 0;
} EXPORT_SYMBOL(drm_release);
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 43cbda3306ac..c81ff4769e7b 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -26,7 +26,7 @@ extern unsigned int drm_timestamp_monotonic;
/* drm_fops.c */ extern struct mutex drm_global_mutex; -int drm_lastclose(struct drm_device *dev); +void drm_lastclose(struct drm_device *dev);
/* drm_pci.c */ int drm_pci_set_unique(struct drm_device *dev, -- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
It belongs right next to the addmap and rmmap functions really. And for OCD consistency name it drm_legacy_getmap_ioctl.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_bufs.c | 52 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 54 +------------------------------------------- drivers/gpu/drm/drm_legacy.h | 2 ++ 3 files changed, 55 insertions(+), 53 deletions(-)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index f1a204d253cc..d92db7007f62 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -416,6 +416,58 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data, return 0; }
+/* + * Get a mapping information. + * + * \param inode device inode. + * \param file_priv DRM file private. + * \param cmd command. + * \param arg user argument, pointing to a drm_map structure. + * + * \return zero on success or a negative number on failure. + * + * Searches for the mapping with the specified offset and copies its information + * into userspace + */ +int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_map *map = data; + struct drm_map_list *r_list = NULL; + struct list_head *list; + int idx; + int i; + + idx = map->offset; + if (idx < 0) + return -EINVAL; + + i = 0; + mutex_lock(&dev->struct_mutex); + list_for_each(list, &dev->maplist) { + if (i == idx) { + r_list = list_entry(list, struct drm_map_list, head); + break; + } + i++; + } + if (!r_list || !r_list->map) { + mutex_unlock(&dev->struct_mutex); + return -EINVAL; + } + + map->offset = r_list->map->offset; + map->size = r_list->map->size; + map->type = r_list->map->type; + map->flags = r_list->map->flags; + map->handle = (void *)(unsigned long) r_list->user_token; + map->mtrr = arch_phys_wc_index(r_list->map->mtrr); + + mutex_unlock(&dev->struct_mutex); + + return 0; +} + /** * Remove a map private from list and deallocate resources if the mapping * isn't in use. diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 3ecd1368c23a..24b941c3b561 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -148,58 +148,6 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) }
/* - * Get a mapping information. - * - * \param inode device inode. - * \param file_priv DRM file private. - * \param cmd command. - * \param arg user argument, pointing to a drm_map structure. - * - * \return zero on success or a negative number on failure. - * - * Searches for the mapping with the specified offset and copies its information - * into userspace - */ -static int drm_getmap(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - struct drm_map *map = data; - struct drm_map_list *r_list = NULL; - struct list_head *list; - int idx; - int i; - - idx = map->offset; - if (idx < 0) - return -EINVAL; - - i = 0; - mutex_lock(&dev->struct_mutex); - list_for_each(list, &dev->maplist) { - if (i == idx) { - r_list = list_entry(list, struct drm_map_list, head); - break; - } - i++; - } - if (!r_list || !r_list->map) { - mutex_unlock(&dev->struct_mutex); - return -EINVAL; - } - - map->offset = r_list->map->offset; - map->size = r_list->map->size; - map->type = r_list->map->type; - map->flags = r_list->map->flags; - map->handle = (void *)(unsigned long) r_list->user_token; - map->mtrr = arch_phys_wc_index(r_list->map->mtrr); - - mutex_unlock(&dev->struct_mutex); - - return 0; -} - -/* * Get client information. * * \param inode device inode. @@ -556,7 +504,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED), + DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED|DRM_RENDER_ALLOW), diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h index 9b731786e4db..d3b6ee357a2b 100644 --- a/drivers/gpu/drm/drm_legacy.h +++ b/drivers/gpu/drm/drm_legacy.h @@ -63,6 +63,8 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
#define DRM_MAP_HASH_OFFSET 0x10000000
+int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
On Tue, Apr 26, 2016 at 07:29:36PM +0200, Daniel Vetter wrote:
It belongs right next to the addmap and rmmap functions really. And for OCD consistency name it drm_legacy_getmap_ioctl.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Chris Wilson chris@chris-wilson.co.uk -Chris
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
It belongs right next to the addmap and rmmap functions really. And for OCD consistency name it drm_legacy_getmap_ioctl.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_bufs.c | 52 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 54 +------------------------------------------- drivers/gpu/drm/drm_legacy.h | 2 ++ 3 files changed, 55 insertions(+), 53 deletions(-)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index f1a204d253cc..d92db7007f62 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -416,6 +416,58 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data, return 0; }
+/*
- Get a mapping information.
- \param inode device inode.
- \param file_priv DRM file private.
- \param cmd command.
- \param arg user argument, pointing to a drm_map structure.
- \return zero on success or a negative number on failure.
- Searches for the mapping with the specified offset and copies its information
- into userspace
- */
+int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
+{
struct drm_map *map = data;
struct drm_map_list *r_list = NULL;
struct list_head *list;
int idx;
int i;
idx = map->offset;
if (idx < 0)
return -EINVAL;
i = 0;
mutex_lock(&dev->struct_mutex);
list_for_each(list, &dev->maplist) {
if (i == idx) {
r_list = list_entry(list, struct drm_map_list, head);
break;
}
i++;
}
if (!r_list || !r_list->map) {
mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
map->offset = r_list->map->offset;
map->size = r_list->map->size;
map->type = r_list->map->type;
map->flags = r_list->map->flags;
map->handle = (void *)(unsigned long) r_list->user_token;
map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
mutex_unlock(&dev->struct_mutex);
return 0;
+}
/**
- Remove a map private from list and deallocate resources if the mapping
- isn't in use.
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 3ecd1368c23a..24b941c3b561 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -148,58 +148,6 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) }
/*
- Get a mapping information.
- \param inode device inode.
- \param file_priv DRM file private.
- \param cmd command.
- \param arg user argument, pointing to a drm_map structure.
- \return zero on success or a negative number on failure.
- Searches for the mapping with the specified offset and copies its information
- into userspace
- */
-static int drm_getmap(struct drm_device *dev, void *data,
struct drm_file *file_priv)
-{
struct drm_map *map = data;
struct drm_map_list *r_list = NULL;
struct list_head *list;
int idx;
int i;
idx = map->offset;
if (idx < 0)
return -EINVAL;
i = 0;
mutex_lock(&dev->struct_mutex);
list_for_each(list, &dev->maplist) {
if (i == idx) {
r_list = list_entry(list, struct drm_map_list, head);
break;
}
i++;
}
if (!r_list || !r_list->map) {
mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
map->offset = r_list->map->offset;
map->size = r_list->map->size;
map->type = r_list->map->type;
map->flags = r_list->map->flags;
map->handle = (void *)(unsigned long) r_list->user_token;
map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
mutex_unlock(&dev->struct_mutex);
return 0;
-}
-/*
- Get client information.
- \param inode device inode.
@@ -556,7 +504,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED|DRM_RENDER_ALLOW),
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h index 9b731786e4db..d3b6ee357a2b 100644 --- a/drivers/gpu/drm/drm_legacy.h +++ b/drivers/gpu/drm/drm_legacy.h @@ -63,6 +63,8 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
#define DRM_MAP_HASH_OFFSET 0x10000000
+int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f); -- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Like in
commit 0e975980d435d58df2d430d688b8c18778b42218 Author: Peter Antoine peter.antoine@intel.com Date: Tue Jun 23 08:18:49 2015 +0100
drm: Turn off Legacy Context Functions
we need to again make an exception for nouveau, but everyone else really doesn't need this.
Cc: Peter Antoine peter.antoine@intel.com Cc: Ben Skeggs bskeggs@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_bufs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index d92db7007f62..e8a12a4fd400 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data, if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM)) return -EPERM;
+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && + drm_core_check_feature(dev, DRIVER_MODESET)) + return -EINVAL; + err = drm_addmap_core(dev, map->offset, map->size, map->type, map->flags, &maplist);
@@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, int idx; int i;
+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && + drm_core_check_feature(dev, DRIVER_MODESET)) + return -EINVAL; + idx = map->offset; if (idx < 0) return -EINVAL; @@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data, struct drm_map_list *r_list; int ret;
+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && + drm_core_check_feature(dev, DRIVER_MODESET)) + return -EINVAL; + mutex_lock(&dev->struct_mutex); list_for_each_entry(r_list, &dev->maplist, head) { if (r_list->map &&
On Tue, Apr 26, 2016 at 07:29:37PM +0200, Daniel Vetter wrote:
Like in
commit 0e975980d435d58df2d430d688b8c18778b42218 Author: Peter Antoine peter.antoine@intel.com Date: Tue Jun 23 08:18:49 2015 +0100
drm: Turn off Legacy Context Functions
we need to again make an exception for nouveau, but everyone else really doesn't need this.
Cc: Peter Antoine peter.antoine@intel.com Cc: Ben Skeggs bskeggs@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
* mutters something about MODESET && !MODESET_LEGACY reading better.
Looks consistent, not going to comment on LEGACY though. There are no direct users of the the addmap interface, so just whatever comes in through an ioctl. -Chris
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Like in
commit 0e975980d435d58df2d430d688b8c18778b42218 Author: Peter Antoine peter.antoine@intel.com Date: Tue Jun 23 08:18:49 2015 +0100
drm: Turn off Legacy Context Functions
we need to again make an exception for nouveau, but everyone else really doesn't need this.
Cc: Peter Antoine peter.antoine@intel.com Cc: Ben Skeggs bskeggs@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Not really familiar with why nouveau needs this, but the logic seems correct. Acked-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_bufs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index d92db7007f62..e8a12a4fd400 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data, if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM)) return -EPERM;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
err = drm_addmap_core(dev, map->offset, map->size, map->type, map->flags, &maplist);
@@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, int idx; int i;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
idx = map->offset; if (idx < 0) return -EINVAL;
@@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data, struct drm_map_list *r_list; int ret;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
mutex_lock(&dev->struct_mutex); list_for_each_entry(r_list, &dev->maplist, head) { if (r_list->map &&
-- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Tue, Apr 26, 2016 at 05:35:42PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Like in
commit 0e975980d435d58df2d430d688b8c18778b42218 Author: Peter Antoine peter.antoine@intel.com Date: Tue Jun 23 08:18:49 2015 +0100
drm: Turn off Legacy Context Functions
we need to again make an exception for nouveau, but everyone else really doesn't need this.
Cc: Peter Antoine peter.antoine@intel.com Cc: Ben Skeggs bskeggs@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Not really familiar with why nouveau needs this, but the logic seems correct.
Hm, I thought the referenced commit explained this, but now that I recheck it doesn't. I'm not too sure again myself why I thought nouveau needs this. The legacy ctx stuff is required because of some old kms nouveau ddx that still used that stuff. I thought it also used legacy maps ... I'll double check once more. -Daniel
Acked-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_bufs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index d92db7007f62..e8a12a4fd400 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data, if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == _DRM_SHM)) return -EPERM;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
err = drm_addmap_core(dev, map->offset, map->size, map->type, map->flags, &maplist);
@@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, int idx; int i;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
idx = map->offset; if (idx < 0) return -EINVAL;
@@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data, struct drm_map_list *r_list; int ret;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
mutex_lock(&dev->struct_mutex); list_for_each_entry(r_list, &dev->maplist, head) { if (r_list->map &&
-- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Wed, Apr 27, 2016 at 08:46:31AM +0200, Daniel Vetter wrote:
On Tue, Apr 26, 2016 at 05:35:42PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Like in
commit 0e975980d435d58df2d430d688b8c18778b42218 Author: Peter Antoine peter.antoine@intel.com Date: Tue Jun 23 08:18:49 2015 +0100
drm: Turn off Legacy Context Functions
we need to again make an exception for nouveau, but everyone else really doesn't need this.
Cc: Peter Antoine peter.antoine@intel.com Cc: Ben Skeggs bskeggs@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Not really familiar with why nouveau needs this, but the logic seems correct.
Hm, I thought the referenced commit explained this, but now that I recheck it doesn't. I'm not too sure again myself why I thought nouveau needs this. The legacy ctx stuff is required because of some old kms nouveau ddx that still used that stuff. I thought it also used legacy maps ... I'll double check once more.
Ok, nouveau ddx indeed used legacy addmap and friends, but that code is nuked since 2006. That's 10 years, which is the rule of thumb for when we can drop support. I'll respin this patch. -Daniel
Hm, I thought the referenced commit explained this, but now that I recheck it doesn't. I'm not too sure again myself why I thought nouveau needs this. The legacy ctx stuff is required because of some old kms nouveau ddx that still used that stuff. I thought it also used legacy maps ... I'll double check once more.
Ok, nouveau ddx indeed used legacy addmap and friends, but that code is nuked since 2006. That's 10 years, which is the rule of thumb for when we can drop support. I'll respin this patch. -Daniel
Nope,
commit b1a630b48210d6a3c44994fce1b73273000ace5c Author: Dave Airlie airlied@redhat.com Date: Wed Nov 7 14:45:14 2012 +1000
nouveau: drop DRI1 device open interface.
Was when it was fixed.
Dave.
On Wed, Apr 27, 2016 at 05:12:22PM +1000, Dave Airlie wrote:
Hm, I thought the referenced commit explained this, but now that I recheck it doesn't. I'm not too sure again myself why I thought nouveau needs this. The legacy ctx stuff is required because of some old kms nouveau ddx that still used that stuff. I thought it also used legacy maps ... I'll double check once more.
Ok, nouveau ddx indeed used legacy addmap and friends, but that code is nuked since 2006. That's 10 years, which is the rule of thumb for when we can drop support. I'll respin this patch. -Daniel
Nope,
commit b1a630b48210d6a3c44994fce1b73273000ace5c Author: Dave Airlie airlied@redhat.com Date: Wed Nov 7 14:45:14 2012 +1000
nouveau: drop DRI1 device open interface.
Was when it was fixed.
Oh right now I remember, the fun was in the X server, not in the DDX. I'll amend the original commit message and merge. -Daniel
From: Benjamin Gaignard benjamin.gaignard@linaro.org
No need to protect debugfs functions with dev->struct_mutex
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org Signed-off-by: Daniel Vetter daniel.vetter@ffwll.ch --- drivers/gpu/drm/sti/sti_cursor.c | 7 ------- drivers/gpu/drm/sti/sti_drv.c | 6 ------ drivers/gpu/drm/sti/sti_dvo.c | 7 ------- drivers/gpu/drm/sti/sti_gdp.c | 14 -------------- drivers/gpu/drm/sti/sti_hda.c | 7 ------- drivers/gpu/drm/sti/sti_hdmi.c | 7 ------- drivers/gpu/drm/sti/sti_hqvdp.c | 7 ------- drivers/gpu/drm/sti/sti_mixer.c | 7 ------- drivers/gpu/drm/sti/sti_tvout.c | 7 ------- drivers/gpu/drm/sti/sti_vid.c | 7 ------- 10 files changed, 76 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c index 3abb400151ac..e6ee4c526665 100644 --- a/drivers/gpu/drm/sti/sti_cursor.c +++ b/drivers/gpu/drm/sti/sti_cursor.c @@ -103,12 +103,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_cursor *cursor = (struct sti_cursor *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&cursor->plane), cursor->regs); @@ -127,7 +121,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP(CUR_AWE); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 6bd6abaa5a70..a8eece20b6b4 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -72,11 +72,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void *data) struct drm_info_node *node = s->private; struct drm_device *dev = node->minor->dev; struct drm_plane *p; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
list_for_each_entry(p, &dev->mode_config.plane_list, head) { struct sti_plane *plane = to_sti_plane(p); @@ -86,7 +81,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void *data) plane->fps_info.fips_str); }
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c index 25f76632002c..d439128e6309 100644 --- a/drivers/gpu/drm/sti/sti_dvo.c +++ b/drivers/gpu/drm/sti/sti_dvo.c @@ -177,12 +177,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_dvo *dvo = (struct sti_dvo *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "DVO: (vaddr = 0x%p)", dvo->regs); DBGFS_DUMP(DVO_AWG_DIGSYNC_CTRL); @@ -193,7 +187,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data) dvo_dbg_awg_microcode(s, dvo->regs + DVO_DIGSYNC_INSTR_I); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c index ff3d3e7e7704..3d098f1ab919 100644 --- a/drivers/gpu/drm/sti/sti_gdp.c +++ b/drivers/gpu/drm/sti/sti_gdp.c @@ -207,14 +207,8 @@ static int gdp_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; struct drm_plane *drm_plane = &gdp->plane.drm_plane; struct drm_crtc *crtc = drm_plane->crtc; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&gdp->plane), gdp->regs); @@ -247,7 +241,6 @@ static int gdp_dbg_show(struct seq_file *s, void *data) seq_printf(s, " Connected to DRM CRTC #%d (%s)\n", crtc->base.id, sti_mixer_to_str(to_sti_mixer(crtc)));
- mutex_unlock(&dev->struct_mutex); return 0; }
@@ -278,13 +271,7 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; unsigned int b; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
for (b = 0; b < GDP_NODE_NB_BANK; b++) { seq_printf(s, "\n%s[%d].top", sti_plane_to_str(&gdp->plane), b); @@ -293,7 +280,6 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg) gdp_node_dump_node(s, gdp->node_list[b].btm_field); }
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c index ec0d017eaf1a..d0e1647ce41a 100644 --- a/drivers/gpu/drm/sti/sti_hda.c +++ b/drivers/gpu/drm/sti/sti_hda.c @@ -375,12 +375,6 @@ static int hda_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hda *hda = (struct sti_hda *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "HD Analog: (vaddr = 0x%p)", hda->regs); DBGFS_DUMP(HDA_ANA_CFG); @@ -396,7 +390,6 @@ static int hda_dbg_show(struct seq_file *s, void *data) hda_dbg_video_dacs_ctrl(s, hda->video_dacs_ctrl); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c index 6ef0715bd5b9..85545ebf88d3 100644 --- a/drivers/gpu/drm/sti/sti_hdmi.c +++ b/drivers/gpu/drm/sti/sti_hdmi.c @@ -628,12 +628,6 @@ static int hdmi_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); DBGFS_DUMP("\n", HDMI_CFG); @@ -690,7 +684,6 @@ static int hdmi_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP_DI(HDMI_SW_DI_N_PKT_WORD6, HDMI_IFRAME_SLOT_VENDOR); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c index e05b0dc523ff..6230565048c3 100644 --- a/drivers/gpu/drm/sti/sti_hqvdp.c +++ b/drivers/gpu/drm/sti/sti_hqvdp.c @@ -554,14 +554,8 @@ static int hqvdp_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hqvdp *hqvdp = (struct sti_hqvdp *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; int cmd, cmd_offset, infoxp70; void *virt; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&hqvdp->plane), hqvdp->regs); @@ -629,7 +623,6 @@ static int hqvdp_dbg_show(struct seq_file *s, void *data)
seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_mixer.c b/drivers/gpu/drm/sti/sti_mixer.c index e7425c38fc93..cc89d75273df 100644 --- a/drivers/gpu/drm/sti/sti_mixer.c +++ b/drivers/gpu/drm/sti/sti_mixer.c @@ -150,12 +150,6 @@ static int mixer_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_mixer *mixer = (struct sti_mixer *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_mixer_to_str(mixer), mixer->regs); @@ -175,7 +169,6 @@ static int mixer_dbg_show(struct seq_file *s, void *arg) mixer_dbg_mxn(s, mixer->regs + GAM_MIXER_MX0); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c index 2c99016443e5..d641a5fe512b 100644 --- a/drivers/gpu/drm/sti/sti_tvout.c +++ b/drivers/gpu/drm/sti/sti_tvout.c @@ -514,13 +514,7 @@ static int tvout_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_tvout *tvout = (struct sti_tvout *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; struct drm_crtc *crtc; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "TVOUT: (vaddr = 0x%p)", tvout->regs);
@@ -586,7 +580,6 @@ static int tvout_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP(TVO_AUX_IN_VID_FORMAT); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_vid.c b/drivers/gpu/drm/sti/sti_vid.c index 5a2c5dc3687b..cba32140a763 100644 --- a/drivers/gpu/drm/sti/sti_vid.c +++ b/drivers/gpu/drm/sti/sti_vid.c @@ -91,12 +91,6 @@ static int vid_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_vid *vid = (struct sti_vid *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "VID: (vaddr= 0x%p)", vid->regs);
@@ -121,7 +115,6 @@ static int vid_dbg_show(struct seq_file *s, void *arg) DBGFS_DUMP(VID_CSAT); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
On Wed, Apr 27, 2016 at 09:21:29AM +0200, Daniel Vetter wrote:
From: Benjamin Gaignard benjamin.gaignard@linaro.org
No need to protect debugfs functions with dev->struct_mutex
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org Signed-off-by: Daniel Vetter daniel.vetter@ffwll.ch
Oops, resent wrong patch, but the iteration that dropped the nouveau special case was busted anyway. -Daniel
drivers/gpu/drm/sti/sti_cursor.c | 7 ------- drivers/gpu/drm/sti/sti_drv.c | 6 ------ drivers/gpu/drm/sti/sti_dvo.c | 7 ------- drivers/gpu/drm/sti/sti_gdp.c | 14 -------------- drivers/gpu/drm/sti/sti_hda.c | 7 ------- drivers/gpu/drm/sti/sti_hdmi.c | 7 ------- drivers/gpu/drm/sti/sti_hqvdp.c | 7 ------- drivers/gpu/drm/sti/sti_mixer.c | 7 ------- drivers/gpu/drm/sti/sti_tvout.c | 7 ------- drivers/gpu/drm/sti/sti_vid.c | 7 ------- 10 files changed, 76 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c index 3abb400151ac..e6ee4c526665 100644 --- a/drivers/gpu/drm/sti/sti_cursor.c +++ b/drivers/gpu/drm/sti/sti_cursor.c @@ -103,12 +103,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_cursor *cursor = (struct sti_cursor *)node->info_ent->data;
struct drm_device *dev = node->minor->dev;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&cursor->plane), cursor->regs);
@@ -127,7 +121,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP(CUR_AWE); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 6bd6abaa5a70..a8eece20b6b4 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -72,11 +72,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void *data) struct drm_info_node *node = s->private; struct drm_device *dev = node->minor->dev; struct drm_plane *p;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
list_for_each_entry(p, &dev->mode_config.plane_list, head) { struct sti_plane *plane = to_sti_plane(p);
@@ -86,7 +81,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void *data) plane->fps_info.fips_str); }
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c index 25f76632002c..d439128e6309 100644 --- a/drivers/gpu/drm/sti/sti_dvo.c +++ b/drivers/gpu/drm/sti/sti_dvo.c @@ -177,12 +177,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_dvo *dvo = (struct sti_dvo *)node->info_ent->data;
struct drm_device *dev = node->minor->dev;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "DVO: (vaddr = 0x%p)", dvo->regs); DBGFS_DUMP(DVO_AWG_DIGSYNC_CTRL);
@@ -193,7 +187,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data) dvo_dbg_awg_microcode(s, dvo->regs + DVO_DIGSYNC_INSTR_I); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c index ff3d3e7e7704..3d098f1ab919 100644 --- a/drivers/gpu/drm/sti/sti_gdp.c +++ b/drivers/gpu/drm/sti/sti_gdp.c @@ -207,14 +207,8 @@ static int gdp_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data;
struct drm_device *dev = node->minor->dev; struct drm_plane *drm_plane = &gdp->plane.drm_plane; struct drm_crtc *crtc = drm_plane->crtc;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&gdp->plane), gdp->regs);
@@ -247,7 +241,6 @@ static int gdp_dbg_show(struct seq_file *s, void *data) seq_printf(s, " Connected to DRM CRTC #%d (%s)\n", crtc->base.id, sti_mixer_to_str(to_sti_mixer(crtc)));
- mutex_unlock(&dev->struct_mutex); return 0;
}
@@ -278,13 +271,7 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data;
struct drm_device *dev = node->minor->dev; unsigned int b;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
for (b = 0; b < GDP_NODE_NB_BANK; b++) { seq_printf(s, "\n%s[%d].top", sti_plane_to_str(&gdp->plane), b);
@@ -293,7 +280,6 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg) gdp_node_dump_node(s, gdp->node_list[b].btm_field); }
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c index ec0d017eaf1a..d0e1647ce41a 100644 --- a/drivers/gpu/drm/sti/sti_hda.c +++ b/drivers/gpu/drm/sti/sti_hda.c @@ -375,12 +375,6 @@ static int hda_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hda *hda = (struct sti_hda *)node->info_ent->data;
struct drm_device *dev = node->minor->dev;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "HD Analog: (vaddr = 0x%p)", hda->regs); DBGFS_DUMP(HDA_ANA_CFG);
@@ -396,7 +390,6 @@ static int hda_dbg_show(struct seq_file *s, void *data) hda_dbg_video_dacs_ctrl(s, hda->video_dacs_ctrl); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c index 6ef0715bd5b9..85545ebf88d3 100644 --- a/drivers/gpu/drm/sti/sti_hdmi.c +++ b/drivers/gpu/drm/sti/sti_hdmi.c @@ -628,12 +628,6 @@ static int hdmi_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data;
struct drm_device *dev = node->minor->dev;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); DBGFS_DUMP("\n", HDMI_CFG);
@@ -690,7 +684,6 @@ static int hdmi_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP_DI(HDMI_SW_DI_N_PKT_WORD6, HDMI_IFRAME_SLOT_VENDOR); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c index e05b0dc523ff..6230565048c3 100644 --- a/drivers/gpu/drm/sti/sti_hqvdp.c +++ b/drivers/gpu/drm/sti/sti_hqvdp.c @@ -554,14 +554,8 @@ static int hqvdp_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hqvdp *hqvdp = (struct sti_hqvdp *)node->info_ent->data;
struct drm_device *dev = node->minor->dev; int cmd, cmd_offset, infoxp70; void *virt;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&hqvdp->plane), hqvdp->regs);
@@ -629,7 +623,6 @@ static int hqvdp_dbg_show(struct seq_file *s, void *data)
seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_mixer.c b/drivers/gpu/drm/sti/sti_mixer.c index e7425c38fc93..cc89d75273df 100644 --- a/drivers/gpu/drm/sti/sti_mixer.c +++ b/drivers/gpu/drm/sti/sti_mixer.c @@ -150,12 +150,6 @@ static int mixer_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_mixer *mixer = (struct sti_mixer *)node->info_ent->data;
struct drm_device *dev = node->minor->dev;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_mixer_to_str(mixer), mixer->regs);
@@ -175,7 +169,6 @@ static int mixer_dbg_show(struct seq_file *s, void *arg) mixer_dbg_mxn(s, mixer->regs + GAM_MIXER_MX0); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c index 2c99016443e5..d641a5fe512b 100644 --- a/drivers/gpu/drm/sti/sti_tvout.c +++ b/drivers/gpu/drm/sti/sti_tvout.c @@ -514,13 +514,7 @@ static int tvout_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_tvout *tvout = (struct sti_tvout *)node->info_ent->data;
struct drm_device *dev = node->minor->dev; struct drm_crtc *crtc;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "TVOUT: (vaddr = 0x%p)", tvout->regs);
@@ -586,7 +580,6 @@ static int tvout_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP(TVO_AUX_IN_VID_FORMAT); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
diff --git a/drivers/gpu/drm/sti/sti_vid.c b/drivers/gpu/drm/sti/sti_vid.c index 5a2c5dc3687b..cba32140a763 100644 --- a/drivers/gpu/drm/sti/sti_vid.c +++ b/drivers/gpu/drm/sti/sti_vid.c @@ -91,12 +91,6 @@ static int vid_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_vid *vid = (struct sti_vid *)node->info_ent->data;
struct drm_device *dev = node->minor->dev;
int ret;
ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret)
return ret;
seq_printf(s, "VID: (vaddr= 0x%p)", vid->regs);
@@ -121,7 +115,6 @@ static int vid_dbg_show(struct seq_file *s, void *arg) DBGFS_DUMP(VID_CSAT); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0;
}
-- 2.8.1
Only two drivers implement this hook. vmwgfx (which doesn't need it really) and legacy radeon (which since v1 has been nuked, yay).
v1: Rebase over radeon ums removal.
Cc: Thomas Hellstrom thellstrom@vmware.com Cc: Alex Deucher alexdeucher@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index f8a7a6e66b7e..55273f8f3acb 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -123,10 +123,10 @@ static void drm_master_destroy(struct kref *kref) struct drm_device *dev = master->minor->dev; struct drm_map_list *r_list, *list_temp;
- mutex_lock(&dev->struct_mutex); 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);
On Tue, Apr 26, 2016 at 07:29:38PM +0200, Daniel Vetter wrote:
Only two drivers implement this hook. vmwgfx (which doesn't need it really) and legacy radeon (which since v1 has been nuked, yay).
v1: Rebase over radeon ums removal.
Cc: Thomas Hellstrom thellstrom@vmware.com Cc: Alex Deucher alexdeucher@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Chris Wilson chris@chris-wilson.co.uk -Chris
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Only two drivers implement this hook. vmwgfx (which doesn't need it really) and legacy radeon (which since v1 has been nuked, yay).
v1: Rebase over radeon ums removal.
Cc: Thomas Hellstrom thellstrom@vmware.com Cc: Alex Deucher alexdeucher@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index f8a7a6e66b7e..55273f8f3acb 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -123,10 +123,10 @@ static void drm_master_destroy(struct kref *kref) struct drm_device *dev = master->minor->dev; struct drm_map_list *r_list, *list_temp;
mutex_lock(&dev->struct_mutex); 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);
-- 2.8.1
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@intel.com --- 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; } 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); +} + /* 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);
idr_destroy(&master->magic_map); kfree(master->unique); diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h index 3e698038dc7b..a5ef2c7e40f8 100644 --- a/include/drm/drm_legacy.h +++ b/include/drm/drm_legacy.h @@ -154,8 +154,10 @@ struct drm_map_list { int drm_legacy_addmap(struct drm_device *d, resource_size_t offset, unsigned int size, enum drm_map_type type, enum drm_map_flags flags, struct drm_local_map **map_p); -int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_master_rmmaps(struct drm_device *dev, + struct drm_master *master); struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev); int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
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@intel.com
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@chris-wilson.co.uk -Chris
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch 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@intel.com
Just one comment below.
Acked-by: Alex Deucher alexander.deucher@amd.com
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;
Can drop this.
} 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);
+}
/* 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); idr_destroy(&master->magic_map); kfree(master->unique);
diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h index 3e698038dc7b..a5ef2c7e40f8 100644 --- a/include/drm/drm_legacy.h +++ b/include/drm/drm_legacy.h @@ -154,8 +154,10 @@ struct drm_map_list { int drm_legacy_addmap(struct drm_device *d, resource_size_t offset, unsigned int size, enum drm_map_type type, enum drm_map_flags flags, struct drm_local_map **map_p); -int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_master_rmmaps(struct drm_device *dev,
struct drm_master *master);
struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev); int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
-- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
And again make sure it's a no-op for modern drivers. Another case of dev->struct_mutex gone for modern drivers!
Note that the entirety of the legacy addmap interface is now protected by DRIVER_MODESET. Note that just auditing kernel code is not enough, since userspace loves to set up legacy maps on it's own for various things - with ums userspace and kernel space share control over resources.
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.
v3: - remove redundant return; (Alex, Chris) - don't special case nouveau with DRIVER_KMS_LEGACY_CONTEXT.
Acked-by: Alex Deucher alexander.deucher@amd.com Reviewed-by: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexander.deucher@amd.com Cc: Chris Wilson chris@chris-wilson.co.uk Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_bufs.c | 26 +++++++++++++++++++++----- drivers/gpu/drm/drm_drv.c | 10 +--------- include/drm/drm_legacy.h | 4 +++- 3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index 2255c61b8dcb..2217da7e9986 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -540,18 +540,34 @@ 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_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; } 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_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); +} + /* 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);
idr_destroy(&master->magic_map); kfree(master->unique); diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h index 3e698038dc7b..a5ef2c7e40f8 100644 --- a/include/drm/drm_legacy.h +++ b/include/drm/drm_legacy.h @@ -154,8 +154,10 @@ struct drm_map_list { int drm_legacy_addmap(struct drm_device *d, resource_size_t offset, unsigned int size, enum drm_map_type type, enum drm_map_flags flags, struct drm_local_map **map_p); -int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_master_rmmaps(struct drm_device *dev, + struct drm_master *master); struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev); int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
And again make sure it's a no-op for modern drivers. Another case of dev->struct_mutex gone for modern drivers!
Note that the entirety of the legacy addmap interface is now protected by DRIVER_MODESET. Note that just auditing kernel code is not enough, since userspace loves to set up legacy maps on it's own for various things - with ums userspace and kernel space share control over resources.
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.
v3: - remove redundant return; (Alex, Chris) - don't special case nouveau with DRIVER_KMS_LEGACY_CONTEXT.
v4: Again special case nouveau. The problem is not directly in the ddx, but that it calls dri1 functions from the X server. And those do call drmAddMap. Fixed only in
commit b1a630b48210d6a3c44994fce1b73273000ace5c Author: Dave Airlie airlied@redhat.com Date: Wed Nov 7 14:45:14 2012 +1000
nouveau: drop DRI1 device open interface.
Acked-by: Alex Deucher alexander.deucher@amd.com Reviewed-by: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexander.deucher@amd.com Cc: Chris Wilson chris@chris-wilson.co.uk Signed-off-by: Daniel Vetter daniel.vetter@intel.com Link: http://patchwork.freedesktop.org/patch/msgid/1461741618-12679-1-git-send-ema... --- drivers/gpu/drm/drm_bufs.c | 27 ++++++++++++++++++++++----- drivers/gpu/drm/drm_drv.c | 10 +--------- include/drm/drm_legacy.h | 4 +++- 3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index e8a12a4fd400..9b34158c0f77 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -542,18 +542,35 @@ 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; } 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_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); +} + /* 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);
idr_destroy(&master->magic_map); kfree(master->unique); diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h index 3e698038dc7b..a5ef2c7e40f8 100644 --- a/include/drm/drm_legacy.h +++ b/include/drm/drm_legacy.h @@ -154,8 +154,10 @@ struct drm_map_list { int drm_legacy_addmap(struct drm_device *d, resource_size_t offset, unsigned int size, enum drm_map_type type, enum drm_map_flags flags, struct drm_local_map **map_p); -int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map); int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map); +void drm_legacy_master_rmmaps(struct drm_device *dev, + struct drm_master *master); struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev); int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
It's only used for legacy mmaping support now.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_internal.h | 2 -- drivers/gpu/drm/drm_vm.c | 16 ++++------------ 2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index c81ff4769e7b..902cf6a15212 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -37,8 +37,6 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
/* drm_vm.c */ int drm_vma_info(struct seq_file *m, void *data); -void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); -void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
/* drm_prime.c */ int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index f90bd5fe35ba..ac9f4b3ec615 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -395,16 +395,8 @@ static const struct vm_operations_struct drm_vm_sg_ops = { .close = drm_vm_close, };
-/** - * \c open method for shared virtual memory. - * - * \param vma virtual memory area. - * - * Create a new drm_vma_entry structure as the \p vma private data entry and - * add it to drm_device::vmalist. - */ -void drm_vm_open_locked(struct drm_device *dev, - struct vm_area_struct *vma) +static void drm_vm_open_locked(struct drm_device *dev, + struct vm_area_struct *vma) { struct drm_vma_entry *vma_entry;
@@ -429,8 +421,8 @@ static void drm_vm_open(struct vm_area_struct *vma) mutex_unlock(&dev->struct_mutex); }
-void drm_vm_close_locked(struct drm_device *dev, - struct vm_area_struct *vma) +static void drm_vm_close_locked(struct drm_device *dev, + struct vm_area_struct *vma) { struct drm_vma_entry *pt, *temp;
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
It's only used for legacy mmaping support now.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_internal.h | 2 -- drivers/gpu/drm/drm_vm.c | 16 ++++------------ 2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index c81ff4769e7b..902cf6a15212 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -37,8 +37,6 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
/* drm_vm.c */ int drm_vma_info(struct seq_file *m, void *data); -void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); -void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
/* drm_prime.c */ int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index f90bd5fe35ba..ac9f4b3ec615 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -395,16 +395,8 @@ static const struct vm_operations_struct drm_vm_sg_ops = { .close = drm_vm_close, };
-/**
- \c open method for shared virtual memory.
- \param vma virtual memory area.
- Create a new drm_vma_entry structure as the \p vma private data entry and
- add it to drm_device::vmalist.
- */
-void drm_vm_open_locked(struct drm_device *dev,
struct vm_area_struct *vma)
+static void drm_vm_open_locked(struct drm_device *dev,
struct vm_area_struct *vma)
{ struct drm_vma_entry *vma_entry;
@@ -429,8 +421,8 @@ static void drm_vm_open(struct vm_area_struct *vma) mutex_unlock(&dev->struct_mutex); }
-void drm_vm_close_locked(struct drm_device *dev,
struct vm_area_struct *vma)
+static void drm_vm_close_locked(struct drm_device *dev,
struct vm_area_struct *vma)
{ struct drm_vma_entry *pt, *temp;
-- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +++++----- drivers/gpu/drm/drm_drv.c | 1 + drivers/gpu/drm/drm_fops.c | 9 ++++++--- drivers/gpu/drm/drm_info.c | 4 ++-- drivers/gpu/drm/i915/i915_debugfs.c | 12 ++++++++++-- include/drm/drmP.h | 1 + 6 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index fa6a27bff298..a087b9638cde 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -93,7 +93,7 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev) struct drm_device *ddev = adev->ddev; struct drm_file *file;
- mutex_lock(&ddev->struct_mutex); + mutex_lock(&ddev->filelist_mutex);
list_for_each_entry(file, &ddev->filelist, lhead) { struct drm_gem_object *gobj; @@ -103,13 +103,13 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev) spin_lock(&file->table_lock); idr_for_each_entry(&file->object_idr, gobj, handle) { WARN_ONCE(1, "And also active allocations!\n"); - drm_gem_object_unreference(gobj); + drm_gem_object_unreference_unlocked(gobj); } idr_destroy(&file->object_idr); spin_unlock(&file->table_lock); }
- mutex_unlock(&ddev->struct_mutex); + mutex_unlock(&ddev->filelist_mutex); }
/* @@ -769,7 +769,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) struct drm_file *file; int r;
- r = mutex_lock_interruptible(&dev->struct_mutex); + r = mutex_lock_interruptible(&dev->filelist_mutex); if (r) return r;
@@ -793,7 +793,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) spin_unlock(&file->table_lock); }
- mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->filelist_mutex); return 0; }
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index e1fb52d4f72c..bff89226a344 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -590,6 +590,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, spin_lock_init(&dev->buf_lock); spin_lock_init(&dev->event_lock); mutex_init(&dev->struct_mutex); + mutex_init(&dev->filelist_mutex); mutex_init(&dev->ctxlist_mutex); mutex_init(&dev->master_mutex);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index c3d0aaac0669..7af7f8bcb355 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -297,9 +297,9 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) } mutex_unlock(&dev->master_mutex);
- mutex_lock(&dev->struct_mutex); + mutex_lock(&dev->filelist_mutex); list_add(&priv->lhead, &dev->filelist); - mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->filelist_mutex);
#ifdef __alpha__ /* @@ -447,8 +447,11 @@ int drm_release(struct inode *inode, struct file *filp)
DRM_DEBUG("open_count = %d\n", dev->open_count);
- mutex_lock(&dev->struct_mutex); + mutex_lock(&dev->filelist_mutex); list_del(&file_priv->lhead); + mutex_unlock(&dev->filelist_mutex); + + mutex_lock(&dev->struct_mutex); if (file_priv->magic) idr_remove(&file_priv->master->magic_map, file_priv->magic); mutex_unlock(&dev->struct_mutex); diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c index cbb4fc0fc969..5d469b2f26f4 100644 --- a/drivers/gpu/drm/drm_info.c +++ b/drivers/gpu/drm/drm_info.c @@ -174,7 +174,7 @@ int drm_clients_info(struct seq_file *m, void *data) /* dev->filelist is sorted youngest first, but we want to present * oldest first (i.e. kernel, servers, clients), so walk backwardss. */ - mutex_lock(&dev->struct_mutex); + mutex_lock(&dev->filelist_mutex); list_for_each_entry_reverse(priv, &dev->filelist, lhead) { struct task_struct *task;
@@ -190,7 +190,7 @@ int drm_clients_info(struct seq_file *m, void *data) priv->magic); rcu_read_unlock(); } - mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->filelist_mutex); return 0; }
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 4950d05d2948..8b8d6f07d7aa 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -528,6 +528,10 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
seq_putc(m, '\n'); print_batch_pool_stats(m, dev_priv); + + mutex_unlock(&dev->struct_mutex); + + mutex_lock(&dev->filelist_mutex); list_for_each_entry_reverse(file, &dev->filelist, lhead) { struct file_stats stats; struct task_struct *task; @@ -548,8 +552,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data) print_file_stats(m, task ? task->comm : "<unknown>", stats); rcu_read_unlock(); } - - mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->filelist_mutex);
return 0; } @@ -2354,6 +2357,7 @@ static int i915_ppgtt_info(struct seq_file *m, void *data) else if (INTEL_INFO(dev)->gen >= 6) gen6_ppgtt_info(m, dev);
+ mutex_lock(&dev->filelist_mutex); list_for_each_entry_reverse(file, &dev->filelist, lhead) { struct drm_i915_file_private *file_priv = file->driver_priv; struct task_struct *task; @@ -2368,6 +2372,7 @@ static int i915_ppgtt_info(struct seq_file *m, void *data) idr_for_each(&file_priv->context_idr, per_file_ctx, (void *)(unsigned long)m); } + mutex_unlock(&dev->filelist_mutex);
out_put: intel_runtime_pm_put(dev_priv); @@ -2403,6 +2408,8 @@ static int i915_rps_boost_info(struct seq_file *m, void *data) intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); + + mutex_lock(&dev->filelist_mutex); spin_lock(&dev_priv->rps.client_lock); list_for_each_entry_reverse(file, &dev->filelist, lhead) { struct drm_i915_file_private *file_priv = file->driver_priv; @@ -2425,6 +2432,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data) list_empty(&dev_priv->rps.mmioflips.link) ? "" : ", active"); seq_printf(m, "Kernel boosts: %d\n", dev_priv->rps.boosts); spin_unlock(&dev_priv->rps.client_lock); + mutex_unlock(&dev->filelist_mutex);
return 0; } diff --git a/include/drm/drmP.h b/include/drm/drmP.h index f82979dee647..c81dd2250fc6 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -769,6 +769,7 @@ struct drm_device { atomic_t buf_alloc; /**< Buffer allocation in progress */ /*@} */
+ struct mutex filelist_mutex; struct list_head filelist;
/** \name Memory management */
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Just wondering if this worth converting over. Opening/closing isn't going to be high contention, I hope, though we can certainly write stress cases for it! The goal for drivers to stop using the struct_mutex as their BKL, which doesn't preclude keeping the struct_mutex around for where it makes sense to have a single mutex rather than a multitude.
I have some misgivings over this, but only because I think its overkill. Reviewed-by: Chris Wilson chris@chris-wilson.co.uk -Chris
On Tue, Apr 26, 2016 at 4:52 PM, Chris Wilson chris@chris-wilson.co.uk wrote:
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Just wondering if this worth converting over. Opening/closing isn't going to be high contention, I hope, though we can certainly write stress cases for it! The goal for drivers to stop using the struct_mutex as their BKL, which doesn't preclude keeping the struct_mutex around for where it makes sense to have a single mutex rather than a multitude.
I have some misgivings over this, but only because I think its overkill. Reviewed-by: Chris Wilson chris@chris-wilson.co.uk
I agree with Chris' sentiments.
Reviewed-by: Alex Deucher alexander.deucher@amd.com
-Chris
-- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Tue, Apr 26, 2016 at 05:45:44PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 4:52 PM, Chris Wilson chris@chris-wilson.co.uk wrote:
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Just wondering if this worth converting over. Opening/closing isn't going to be high contention, I hope, though we can certainly write stress cases for it! The goal for drivers to stop using the struct_mutex as their BKL, which doesn't preclude keeping the struct_mutex around for where it makes sense to have a single mutex rather than a multitude.
I have some misgivings over this, but only because I think its overkill. Reviewed-by: Chris Wilson chris@chris-wilson.co.uk
I agree with Chris' sentiments.
It's not to have more speed or less contention, but just to have fewer things to worry about when reviewing locking. Hence orthogonal locks for independent parts.
My goal is that in the end dev->struct_mutex is only used by some existing drivers for their internals, plus all the legacy core stuff. And never even used by modern drivers. New locks are pretty cheap, and not dragging in the entire legacy horror show has benefits.
When/once I tackle the one thing left (master locking) I might move the master handling under this lock too (since it's closely related to open files). Not sure yet. -Daniel
Reviewed-by: Alex Deucher alexander.deucher@amd.com
On Wed, Apr 27, 2016 at 09:06:09AM +0200, Daniel Vetter wrote:
On Tue, Apr 26, 2016 at 05:45:44PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 4:52 PM, Chris Wilson chris@chris-wilson.co.uk wrote:
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Just wondering if this worth converting over. Opening/closing isn't going to be high contention, I hope, though we can certainly write stress cases for it! The goal for drivers to stop using the struct_mutex as their BKL, which doesn't preclude keeping the struct_mutex around for where it makes sense to have a single mutex rather than a multitude.
I have some misgivings over this, but only because I think its overkill. Reviewed-by: Chris Wilson chris@chris-wilson.co.uk
I agree with Chris' sentiments.
It's not to have more speed or less contention, but just to have fewer things to worry about when reviewing locking. Hence orthogonal locks for independent parts.
My goal is that in the end dev->struct_mutex is only used by some existing drivers for their internals, plus all the legacy core stuff. And never even used by modern drivers. New locks are pretty cheap, and not dragging in the entire legacy horror show has benefits.
When/once I tackle the one thing left (master locking) I might move the master handling under this lock too (since it's closely related to open files). Not sure yet.
Oh and the main reason I did it here: Much easier to review using git grep struct_mutex than auditing codepaths. With this drivers have no reason to ever grab struct_mutex (not even for debugfs or similar), since the last remaining bit (master control) really shouldn't be a concern for drivers ever.
That also makes reviewing new drivers simpler: Contains struct_mutex? Reject it!
Cheers, Daniel
-----Original Message----- From: Daniel Vetter [mailto:daniel.vetter@ffwll.ch] On Behalf Of Daniel Vetter Sent: Wednesday, April 27, 2016 3:09 AM To: Alex Deucher Cc: Chris Wilson; Daniel Vetter; DRI Development; Deucher, Alexander; Intel Graphics Development; Daniel Vetter Subject: Re: [Intel-gfx] [PATCH 08/35] drm: Protect dev->filelist with its own mutex
On Wed, Apr 27, 2016 at 09:06:09AM +0200, Daniel Vetter wrote:
On Tue, Apr 26, 2016 at 05:45:44PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 4:52 PM, Chris Wilson chris@chris-wilson.co.uk
wrote:
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's
walking
the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to
drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Just wondering if this worth converting over. Opening/closing isn't going to be high contention, I hope, though we can certainly write stress cases for it! The goal for drivers to stop using the struct_mutex as their BKL, which doesn't preclude keeping the struct_mutex around
for
where it makes sense to have a single mutex rather than a multitude.
I have some misgivings over this, but only because I think its overkill. Reviewed-by: Chris Wilson chris@chris-wilson.co.uk
I agree with Chris' sentiments.
It's not to have more speed or less contention, but just to have fewer things to worry about when reviewing locking. Hence orthogonal locks for independent parts.
My goal is that in the end dev->struct_mutex is only used by some existing drivers for their internals, plus all the legacy core stuff. And never even used by modern drivers. New locks are pretty cheap, and not
dragging
in the entire legacy horror show has benefits.
When/once I tackle the one thing left (master locking) I might move the master handling under this lock too (since it's closely related to open files). Not sure yet.
Oh and the main reason I did it here: Much easier to review using git grep struct_mutex than auditing codepaths. With this drivers have no reason to ever grab struct_mutex (not even for debugfs or similar), since the last remaining bit (master control) really shouldn't be a concern for drivers ever.
That also makes reviewing new drivers simpler: Contains struct_mutex? Reject it!
I'm convinced! Thanks for cleaning this up.
Alex
Cheers, Daniel
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
On Wed, Apr 27, 2016 at 09:06:09AM +0200, Daniel Vetter wrote:
On Tue, Apr 26, 2016 at 05:45:44PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 4:52 PM, Chris Wilson chris@chris-wilson.co.uk wrote:
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Just wondering if this worth converting over. Opening/closing isn't going to be high contention, I hope, though we can certainly write stress cases for it! The goal for drivers to stop using the struct_mutex as their BKL, which doesn't preclude keeping the struct_mutex around for where it makes sense to have a single mutex rather than a multitude.
I have some misgivings over this, but only because I think its overkill. Reviewed-by: Chris Wilson chris@chris-wilson.co.uk
I agree with Chris' sentiments.
It's not to have more speed or less contention, but just to have fewer things to worry about when reviewing locking. Hence orthogonal locks for independent parts.
My goal is that in the end dev->struct_mutex is only used by some existing drivers for their internals, plus all the legacy core stuff. And never even used by modern drivers. New locks are pretty cheap, and not dragging in the entire legacy horror show has benefits.
When/once I tackle the one thing left (master locking) I might move the master handling under this lock too (since it's closely related to open files). Not sure yet.
drm: s/struct_mutex/legacy_mutex/ drm/i915: s/struct_mutex/bfg9000/ -Chris
On Wed, Apr 27, 2016 at 08:17:08AM +0100, Chris Wilson wrote:
On Wed, Apr 27, 2016 at 09:06:09AM +0200, Daniel Vetter wrote:
On Tue, Apr 26, 2016 at 05:45:44PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 4:52 PM, Chris Wilson chris@chris-wilson.co.uk wrote:
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Just wondering if this worth converting over. Opening/closing isn't going to be high contention, I hope, though we can certainly write stress cases for it! The goal for drivers to stop using the struct_mutex as their BKL, which doesn't preclude keeping the struct_mutex around for where it makes sense to have a single mutex rather than a multitude.
I have some misgivings over this, but only because I think its overkill. Reviewed-by: Chris Wilson chris@chris-wilson.co.uk
I agree with Chris' sentiments.
It's not to have more speed or less contention, but just to have fewer things to worry about when reviewing locking. Hence orthogonal locks for independent parts.
My goal is that in the end dev->struct_mutex is only used by some existing drivers for their internals, plus all the legacy core stuff. And never even used by modern drivers. New locks are pretty cheap, and not dragging in the entire legacy horror show has benefits.
When/once I tackle the one thing left (master locking) I might move the master handling under this lock too (since it's closely related to open files). Not sure yet.
drm: s/struct_mutex/legacy_mutex/
Yeah that's the eventual plan. Probably need to convert over some of the current gem drivers first to make it less of a flag day.
drm/i915: s/struct_mutex/bfg9000/
Can't do that yet because holding struct_mutex prevents objects from disappearing, speficially all our mm and lru lists only hold a weak reference. We need to rework our shrinkers first and switch over to gem_object_free_unlocked before we can disengage from struct_mutex in i915.
But yeah, again that's the plan. -Daniel
On Wed, Apr 27, 2016 at 10:01:16AM +0200, Daniel Vetter wrote:
On Wed, Apr 27, 2016 at 08:17:08AM +0100, Chris Wilson wrote:
drm/i915: s/struct_mutex/bfg9000/
Can't do that yet because holding struct_mutex prevents objects from disappearing, speficially all our mm and lru lists only hold a weak reference. We need to rework our shrinkers first and switch over to gem_object_free_unlocked before we can disengage from struct_mutex in i915.
Done. Just a few years of backlog still to go... -Chris
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all.
While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too.
v2: don't forget to switch to drm_gem_object_unreference_unlocked.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Ok, merged up to this patch to drm-misc, thanks a lot for feedback and review. -Daniel
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +++++----- drivers/gpu/drm/drm_drv.c | 1 + drivers/gpu/drm/drm_fops.c | 9 ++++++--- drivers/gpu/drm/drm_info.c | 4 ++-- drivers/gpu/drm/i915/i915_debugfs.c | 12 ++++++++++-- include/drm/drmP.h | 1 + 6 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index fa6a27bff298..a087b9638cde 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -93,7 +93,7 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev) struct drm_device *ddev = adev->ddev; struct drm_file *file;
- mutex_lock(&ddev->struct_mutex);
mutex_lock(&ddev->filelist_mutex);
list_for_each_entry(file, &ddev->filelist, lhead) { struct drm_gem_object *gobj;
@@ -103,13 +103,13 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev) spin_lock(&file->table_lock); idr_for_each_entry(&file->object_idr, gobj, handle) { WARN_ONCE(1, "And also active allocations!\n");
drm_gem_object_unreference(gobj);
} idr_destroy(&file->object_idr); spin_unlock(&file->table_lock); }drm_gem_object_unreference_unlocked(gobj);
- mutex_unlock(&ddev->struct_mutex);
- mutex_unlock(&ddev->filelist_mutex);
}
/* @@ -769,7 +769,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) struct drm_file *file; int r;
- r = mutex_lock_interruptible(&dev->struct_mutex);
- r = mutex_lock_interruptible(&dev->filelist_mutex); if (r) return r;
@@ -793,7 +793,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) spin_unlock(&file->table_lock); }
- mutex_unlock(&dev->struct_mutex);
- mutex_unlock(&dev->filelist_mutex); return 0;
}
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index e1fb52d4f72c..bff89226a344 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -590,6 +590,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, spin_lock_init(&dev->buf_lock); spin_lock_init(&dev->event_lock); mutex_init(&dev->struct_mutex);
- mutex_init(&dev->filelist_mutex); mutex_init(&dev->ctxlist_mutex); mutex_init(&dev->master_mutex);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index c3d0aaac0669..7af7f8bcb355 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -297,9 +297,9 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) } mutex_unlock(&dev->master_mutex);
- mutex_lock(&dev->struct_mutex);
- mutex_lock(&dev->filelist_mutex); list_add(&priv->lhead, &dev->filelist);
- mutex_unlock(&dev->struct_mutex);
- mutex_unlock(&dev->filelist_mutex);
#ifdef __alpha__ /* @@ -447,8 +447,11 @@ int drm_release(struct inode *inode, struct file *filp)
DRM_DEBUG("open_count = %d\n", dev->open_count);
- mutex_lock(&dev->struct_mutex);
- mutex_lock(&dev->filelist_mutex); list_del(&file_priv->lhead);
- mutex_unlock(&dev->filelist_mutex);
- mutex_lock(&dev->struct_mutex); if (file_priv->magic) idr_remove(&file_priv->master->magic_map, file_priv->magic); mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c index cbb4fc0fc969..5d469b2f26f4 100644 --- a/drivers/gpu/drm/drm_info.c +++ b/drivers/gpu/drm/drm_info.c @@ -174,7 +174,7 @@ int drm_clients_info(struct seq_file *m, void *data) /* dev->filelist is sorted youngest first, but we want to present * oldest first (i.e. kernel, servers, clients), so walk backwardss. */
- mutex_lock(&dev->struct_mutex);
- mutex_lock(&dev->filelist_mutex); list_for_each_entry_reverse(priv, &dev->filelist, lhead) { struct task_struct *task;
@@ -190,7 +190,7 @@ int drm_clients_info(struct seq_file *m, void *data) priv->magic); rcu_read_unlock(); }
- mutex_unlock(&dev->struct_mutex);
- mutex_unlock(&dev->filelist_mutex); return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 4950d05d2948..8b8d6f07d7aa 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -528,6 +528,10 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
seq_putc(m, '\n'); print_batch_pool_stats(m, dev_priv);
- mutex_unlock(&dev->struct_mutex);
- mutex_lock(&dev->filelist_mutex); list_for_each_entry_reverse(file, &dev->filelist, lhead) { struct file_stats stats; struct task_struct *task;
@@ -548,8 +552,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data) print_file_stats(m, task ? task->comm : "<unknown>", stats); rcu_read_unlock(); }
- mutex_unlock(&dev->struct_mutex);
mutex_unlock(&dev->filelist_mutex);
return 0;
} @@ -2354,6 +2357,7 @@ static int i915_ppgtt_info(struct seq_file *m, void *data) else if (INTEL_INFO(dev)->gen >= 6) gen6_ppgtt_info(m, dev);
- mutex_lock(&dev->filelist_mutex); list_for_each_entry_reverse(file, &dev->filelist, lhead) { struct drm_i915_file_private *file_priv = file->driver_priv; struct task_struct *task;
@@ -2368,6 +2372,7 @@ static int i915_ppgtt_info(struct seq_file *m, void *data) idr_for_each(&file_priv->context_idr, per_file_ctx, (void *)(unsigned long)m); }
- mutex_unlock(&dev->filelist_mutex);
out_put: intel_runtime_pm_put(dev_priv); @@ -2403,6 +2408,8 @@ static int i915_rps_boost_info(struct seq_file *m, void *data) intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit), intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit), intel_gpu_freq(dev_priv, dev_priv->rps.max_freq));
- mutex_lock(&dev->filelist_mutex); spin_lock(&dev_priv->rps.client_lock); list_for_each_entry_reverse(file, &dev->filelist, lhead) { struct drm_i915_file_private *file_priv = file->driver_priv;
@@ -2425,6 +2432,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data) list_empty(&dev_priv->rps.mmioflips.link) ? "" : ", active"); seq_printf(m, "Kernel boosts: %d\n", dev_priv->rps.boosts); spin_unlock(&dev_priv->rps.client_lock);
mutex_unlock(&dev->filelist_mutex);
return 0;
} diff --git a/include/drm/drmP.h b/include/drm/drmP.h index f82979dee647..c81dd2250fc6 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -769,6 +769,7 @@ struct drm_device { atomic_t buf_alloc; /**< Buffer allocation in progress */ /*@} */
struct mutex filelist_mutex; struct list_head filelist;
/** \name Memory management */
-- 2.8.1
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/** - * drm_gem_object_free - free a GEM object - * @kref: kref of the object to free - * - * Called after the last reference to the object has been lost. - * Must be called holding struct_ mutex - * - * Frees the object - */ -void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL) + if (dev->driver->gem_free_object_unlocked != NULL) + dev->driver->gem_free_object_unlocked(obj); + else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj); } -EXPORT_SYMBOL(drm_gem_object_free); + +/** + * drm_gem_object_unreference_unlocked - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must not hold the + * dev->struct_mutex lock when calling this function. + */ +void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{ + struct drm_device *dev; + + if (!obj) + return; + + dev = obj->dev; + might_lock(&dev->struct_mutex); + + if (dev->driver->gem_free_object != NULL) + kref_put(&obj->refcount, drm_gem_object_free); + else if (kref_put_mutex(&obj->refcount, drm_gem_object_free, + &dev->struct_mutex)) + mutex_unlock(&dev->struct_mutex); +} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked); + +/** + * drm_gem_object_unreference - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must hold the dev->struct_mutex + * lock when calling this function, even when the driver doesn't use + * dev->struct_mutex for anything. + * + * For drivers not encumbered with legacy locking use + * drm_gem_object_unreference_unlocked() instead. + */ +void +drm_gem_object_unreference(struct drm_gem_object *obj) +{ + if (obj != NULL) { + WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); + + kref_put(&obj->refcount, drm_gem_object_free); + } +} +EXPORT_SYMBOL(drm_gem_object_unreference);
/** * drm_gem_vm_open - vma->ops->open implementation for GEM diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..7e30b3d2b25c 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -583,9 +583,19 @@ struct drm_driver { * Driver-specific constructor for drm_gem_objects, to set up * obj->driver_private. * - * Returns 0 on success. + * This is deprecated and should not be used by new drivers. Use + * @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj); + + /** + * Driver-specific constructor for drm_gem_objects, to set up + * obj->driver_private. This is for drivers which are not encumbered + * with dev->struct_mutex legacy locking schemes. Use this hook instead + * of @gem_free_object. + */ + void (*gem_free_object_unlocked) (struct drm_gem_object *obj); + int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..ae1c7f18eec0 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -175,7 +175,6 @@ struct drm_gem_object { };
void drm_gem_object_release(struct drm_gem_object *obj); -void drm_gem_object_free(struct kref *kref); int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj, size_t size); void drm_gem_private_object_init(struct drm_device *dev, @@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj) kref_get(&obj->refcount); }
-/** - * drm_gem_object_unreference - release a GEM BO reference - * @obj: GEM buffer object - * - * This releases a reference to @obj. Callers must hold the dev->struct_mutex - * lock when calling this function, even when the driver doesn't use - * dev->struct_mutex for anything. - * - * For drivers not encumbered with legacy locking use - * drm_gem_object_unreference_unlocked() instead. - */ -static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) -{ - if (obj != NULL) { - WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); - - kref_put(&obj->refcount, drm_gem_object_free); - } -} - -/** - * drm_gem_object_unreference_unlocked - release a GEM BO reference - * @obj: GEM buffer object - * - * This releases a reference to @obj. Callers must not hold the - * dev->struct_mutex lock when calling this function. - */ -static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{ - struct drm_device *dev; - - if (!obj) - return; - - dev = obj->dev; - if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex)) - mutex_unlock(&dev->struct_mutex); - else - might_lock(&dev->struct_mutex); -} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,
On Tue, Apr 26, 2016 at 07:29:42PM +0200, Daniel Vetter wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked != NULL)
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
+/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
I have i915.ko in a state where we could use this as well. I would like to have our inlines back though. I would add
static inline void i915_gem_object_put(struct drm_i915_gem_object *obj) { kref_put(&obj->base.refcount, drm_gem_object_free); }
Hmm, considering how simple that is, maybe I won't ask for
static inline void __drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) { BUG_ON(obj->dev->driver->gem_free_object == NULL); kref_put(&obj->refcount, drm_gem_object_free); }
after all! -Chris
On Tue, Apr 26, 2016 at 08:47:32PM +0100, Chris Wilson wrote:
On Tue, Apr 26, 2016 at 07:29:42PM +0200, Daniel Vetter wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked != NULL)
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
+/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
I have i915.ko in a state where we could use this as well. I would like to have our inlines back though. I would add
static inline void i915_gem_object_put(struct drm_i915_gem_object *obj) { kref_put(&obj->base.refcount, drm_gem_object_free); }
Hmm, considering how simple that is, maybe I won't ask for
static inline void __drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) { BUG_ON(obj->dev->driver->gem_free_object == NULL); kref_put(&obj->refcount, drm_gem_object_free); }
Yeah, something like that makes sense. Imo the core versions really need all the silly locking checks and all that to make sure no one abuses them by accident, or breaks a driver still using struct_mutex. Adding a fastpath for drivers using gem_free_object_unlocked just wrapping the kref_put certainly looks like a good idea.
And if we document the exact use case I think we could even nuke the BUG_ON too. This can be audited with a simple
$ git grep __drm_gem_object_unreference_unlocked -- drivers/gpu/drm/$driver
so imo nothing too dangerous.
Ack/r-b on the patch itself? -Daniel
On Tue, Apr 26, 2016 at 10:10:14PM +0200, Daniel Vetter wrote:
On Tue, Apr 26, 2016 at 08:47:32PM +0100, Chris Wilson wrote:
On Tue, Apr 26, 2016 at 07:29:42PM +0200, Daniel Vetter wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked != NULL)
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
+/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
I have i915.ko in a state where we could use this as well. I would like to have our inlines back though. I would add
static inline void i915_gem_object_put(struct drm_i915_gem_object *obj) { kref_put(&obj->base.refcount, drm_gem_object_free); }
Hmm, considering how simple that is, maybe I won't ask for
static inline void __drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) { BUG_ON(obj->dev->driver->gem_free_object == NULL); kref_put(&obj->refcount, drm_gem_object_free); }
Yeah, something like that makes sense. Imo the core versions really need all the silly locking checks and all that to make sure no one abuses them by accident, or breaks a driver still using struct_mutex. Adding a fastpath for drivers using gem_free_object_unlocked just wrapping the kref_put certainly looks like a good idea.
And if we document the exact use case I think we could even nuke the BUG_ON too. This can be audited with a simple
$ git grep __drm_gem_object_unreference_unlocked -- drivers/gpu/drm/$driver
so imo nothing too dangerous.
Ack/r-b on the patch itself?
Only an ack, I'm afraid. I haven't considered the ramifictions to know if the intermediate steps are going to be painful (in some cases we'll have an all a new hot function in our profiles, but overall there'll be little change I hope). The end goal is definitely an improvement.
I've talked myself into having a better read of the core patches... -Chris
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
This and the rest of the series are: Acked-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
if (dev->driver->gem_free_object != NULL)
if (dev->driver->gem_free_object_unlocked != NULL)
dev->driver->gem_free_object_unlocked(obj);
else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
+/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
might_lock(&dev->struct_mutex);
if (dev->driver->gem_free_object != NULL)
kref_put(&obj->refcount, drm_gem_object_free);
else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
&dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
+} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
+void +drm_gem_object_unreference(struct drm_gem_object *obj) +{
if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
+} +EXPORT_SYMBOL(drm_gem_object_unreference);
/**
- drm_gem_vm_open - vma->ops->open implementation for GEM
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..7e30b3d2b25c 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -583,9 +583,19 @@ struct drm_driver { * Driver-specific constructor for drm_gem_objects, to set up * obj->driver_private. *
* Returns 0 on success.
* This is deprecated and should not be used by new drivers. Use
* @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj);
/**
* Driver-specific constructor for drm_gem_objects, to set up
* obj->driver_private. This is for drivers which are not encumbered
* with dev->struct_mutex legacy locking schemes. Use this hook instead
* of @gem_free_object.
*/
void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..ae1c7f18eec0 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -175,7 +175,6 @@ struct drm_gem_object { };
void drm_gem_object_release(struct drm_gem_object *obj); -void drm_gem_object_free(struct kref *kref); int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj, size_t size); void drm_gem_private_object_init(struct drm_device *dev, @@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj) kref_get(&obj->refcount); }
-/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
-static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) -{
if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
-}
-/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
-static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
else
might_lock(&dev->struct_mutex);
-} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj, -- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Tue, Apr 26, 2016 at 05:52:31PM -0400, Alex Deucher wrote:
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
This and the rest of the series are: Acked-by: Alex Deucher alexander.deucher@amd.com
Before I pull this in, I'd like at least an r-b on this and one of the driver patches. t-b even better. -Daniel
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
if (dev->driver->gem_free_object != NULL)
if (dev->driver->gem_free_object_unlocked != NULL)
dev->driver->gem_free_object_unlocked(obj);
else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
+/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
might_lock(&dev->struct_mutex);
if (dev->driver->gem_free_object != NULL)
kref_put(&obj->refcount, drm_gem_object_free);
else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
&dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
+} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
+void +drm_gem_object_unreference(struct drm_gem_object *obj) +{
if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
+} +EXPORT_SYMBOL(drm_gem_object_unreference);
/**
- drm_gem_vm_open - vma->ops->open implementation for GEM
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..7e30b3d2b25c 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -583,9 +583,19 @@ struct drm_driver { * Driver-specific constructor for drm_gem_objects, to set up * obj->driver_private. *
* Returns 0 on success.
* This is deprecated and should not be used by new drivers. Use
* @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj);
/**
* Driver-specific constructor for drm_gem_objects, to set up
* obj->driver_private. This is for drivers which are not encumbered
* with dev->struct_mutex legacy locking schemes. Use this hook instead
* of @gem_free_object.
*/
void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..ae1c7f18eec0 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -175,7 +175,6 @@ struct drm_gem_object { };
void drm_gem_object_release(struct drm_gem_object *obj); -void drm_gem_object_free(struct kref *kref); int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj, size_t size); void drm_gem_private_object_init(struct drm_device *dev, @@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj) kref_get(&obj->refcount); }
-/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
-static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) -{
if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
-}
-/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
-static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
else
might_lock(&dev->struct_mutex);
-} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj, -- 2.8.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Two mostly cosmetic comments below, otherwise looks good:
Reviewed-by: Lucas Stach l.stach@pengutronix.de
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked != NULL)
Why those explicit != NULL checks? The style mostly used in this file is to omit those, like "if (dev->driver->gem_free_object_unlocked)". Same comment applies to several hunks of this patch.
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
+/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
- struct drm_device *dev;
- if (!obj)
return;
- dev = obj->dev;
- might_lock(&dev->struct_mutex);
- if (dev->driver->gem_free_object != NULL)
kref_put(&obj->refcount, drm_gem_object_free);
- else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
&dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
+} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
+void +drm_gem_object_unreference(struct drm_gem_object *obj) +{
- if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
- }
+} +EXPORT_SYMBOL(drm_gem_object_unreference);
/**
- drm_gem_vm_open - vma->ops->open implementation for GEM
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..7e30b3d2b25c 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -583,9 +583,19 @@ struct drm_driver { * Driver-specific constructor for drm_gem_objects, to set up * obj->driver_private. *
* Returns 0 on success.
* This is deprecated and should not be used by new drivers. Use
*/ void (*gem_free_object) (struct drm_gem_object *obj);* @gem_free_object_unlocked instead.
- /**
* Driver-specific constructor for drm_gem_objects, to set up
* obj->driver_private.
This part of the comment is really off. I see it's just copy&paste from the comment above gem_free_object, but I think it should have been placed above gem_open_object and has nothing to do with the free* callbacks.
This is for drivers which are not encumbered
* with dev->struct_mutex legacy locking schemes. Use this hook instead
* of @gem_free_object.
*/
- void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
- int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..ae1c7f18eec0 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -175,7 +175,6 @@ struct drm_gem_object { };
void drm_gem_object_release(struct drm_gem_object *obj); -void drm_gem_object_free(struct kref *kref); int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj, size_t size); void drm_gem_private_object_init(struct drm_device *dev, @@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj) kref_get(&obj->refcount); }
-/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
-static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) -{
- if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
- }
-}
-/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
-static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{
- struct drm_device *dev;
- if (!obj)
return;
- dev = obj->dev;
- if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
- else
might_lock(&dev->struct_mutex);
-} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,
On Wed, Apr 27, 2016 at 11:31:00AM +0200, Lucas Stach wrote:
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Two mostly cosmetic comments below, otherwise looks good:
Reviewed-by: Lucas Stach l.stach@pengutronix.de
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 12 ++++++++- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..8f2eff448bb5 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked != NULL)
Why those explicit != NULL checks? The style mostly used in this file is to omit those, like "if (dev->driver->gem_free_object_unlocked)". Same comment applies to several hunks of this patch.
I move some of these functions around, the != NULL checks where there already. I can easily change all the ones I touch.
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object != NULL) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
+/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
- struct drm_device *dev;
- if (!obj)
return;
- dev = obj->dev;
- might_lock(&dev->struct_mutex);
- if (dev->driver->gem_free_object != NULL)
kref_put(&obj->refcount, drm_gem_object_free);
- else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
&dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
+} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
+void +drm_gem_object_unreference(struct drm_gem_object *obj) +{
- if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
- }
+} +EXPORT_SYMBOL(drm_gem_object_unreference);
/**
- drm_gem_vm_open - vma->ops->open implementation for GEM
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..7e30b3d2b25c 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -583,9 +583,19 @@ struct drm_driver { * Driver-specific constructor for drm_gem_objects, to set up * obj->driver_private. *
* Returns 0 on success.
* This is deprecated and should not be used by new drivers. Use
*/ void (*gem_free_object) (struct drm_gem_object *obj);* @gem_free_object_unlocked instead.
- /**
* Driver-specific constructor for drm_gem_objects, to set up
* obj->driver_private.
This part of the comment is really off. I see it's just copy&paste from the comment above gem_free_object, but I think it should have been placed above gem_open_object and has nothing to do with the free* callbacks.
Oops, wanted to add proper kerneldoc for this new hook and the old one to explain the differences, and totally failed at that. Will fix up. -Daniel
This is for drivers which are not encumbered
* with dev->struct_mutex legacy locking schemes. Use this hook instead
* of @gem_free_object.
*/
- void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
- int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..ae1c7f18eec0 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -175,7 +175,6 @@ struct drm_gem_object { };
void drm_gem_object_release(struct drm_gem_object *obj); -void drm_gem_object_free(struct kref *kref); int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj, size_t size); void drm_gem_private_object_init(struct drm_device *dev, @@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj) kref_get(&obj->refcount); }
-/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
-static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) -{
- if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
- }
-}
-/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
-static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{
- struct drm_device *dev;
- if (!obj)
return;
- dev = obj->dev;
- if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
- else
might_lock(&dev->struct_mutex);
-} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas: - drop != NULL in pointer checks. - fixup copypasted kerneldoc to actually match the functions.
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 15 ++++++++--- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 66 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..a4684a306c48 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/** - * drm_gem_object_free - free a GEM object - * @kref: kref of the object to free - * - * Called after the last reference to the object has been lost. - * Must be called holding struct_ mutex - * - * Frees the object - */ -void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL) + if (dev->driver->gem_free_object_unlocked) + dev->driver->gem_free_object_unlocked(obj); + else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj); } -EXPORT_SYMBOL(drm_gem_object_free); + +/** + * drm_gem_object_unreference_unlocked - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must not hold the + * dev->struct_mutex lock when calling this function. + */ +void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{ + struct drm_device *dev; + + if (!obj) + return; + + dev = obj->dev; + might_lock(&dev->struct_mutex); + + if (dev->driver->gem_free_object) + kref_put(&obj->refcount, drm_gem_object_free); + else if (kref_put_mutex(&obj->refcount, drm_gem_object_free, + &dev->struct_mutex)) + mutex_unlock(&dev->struct_mutex); +} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked); + +/** + * drm_gem_object_unreference - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must hold the dev->struct_mutex + * lock when calling this function, even when the driver doesn't use + * dev->struct_mutex for anything. + * + * For drivers not encumbered with legacy locking use + * drm_gem_object_unreference_unlocked() instead. + */ +void +drm_gem_object_unreference(struct drm_gem_object *obj) +{ + if (obj) { + WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); + + kref_put(&obj->refcount, drm_gem_object_free); + } +} +EXPORT_SYMBOL(drm_gem_object_unreference);
/** * drm_gem_vm_open - vma->ops->open implementation for GEM diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..bd7b262d7af0 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -580,12 +580,21 @@ struct drm_driver { void (*debugfs_cleanup)(struct drm_minor *minor);
/** - * Driver-specific constructor for drm_gem_objects, to set up - * obj->driver_private. + * @gem_free_object: deconstructor for drm_gem_objects * - * Returns 0 on success. + * This is deprecated and should not be used by new drivers. Use + * @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj); + + /** + * @gem_free_object_unlocked: deconstructor for drm_gem_objects + * + * This is for drivers which are not encumbered with dev->struct_mutex + * legacy locking schemes. Use this hook instead of @gem_free_object. + */ + void (*gem_free_object_unlocked) (struct drm_gem_object *obj); + int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..ae1c7f18eec0 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -175,7 +175,6 @@ struct drm_gem_object { };
void drm_gem_object_release(struct drm_gem_object *obj); -void drm_gem_object_free(struct kref *kref); int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj, size_t size); void drm_gem_private_object_init(struct drm_device *dev, @@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj) kref_get(&obj->refcount); }
-/** - * drm_gem_object_unreference - release a GEM BO reference - * @obj: GEM buffer object - * - * This releases a reference to @obj. Callers must hold the dev->struct_mutex - * lock when calling this function, even when the driver doesn't use - * dev->struct_mutex for anything. - * - * For drivers not encumbered with legacy locking use - * drm_gem_object_unreference_unlocked() instead. - */ -static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) -{ - if (obj != NULL) { - WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); - - kref_put(&obj->refcount, drm_gem_object_free); - } -} - -/** - * drm_gem_object_unreference_unlocked - release a GEM BO reference - * @obj: GEM buffer object - * - * This releases a reference to @obj. Callers must not hold the - * dev->struct_mutex lock when calling this function. - */ -static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{ - struct drm_device *dev; - - if (!obj) - return; - - dev = obj->dev; - if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex)) - mutex_unlock(&dev->struct_mutex); - else - might_lock(&dev->struct_mutex); -} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,
On Wed, Apr 27, 2016 at 01:50:00PM +0200, Daniel Vetter wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas:
- drop != NULL in pointer checks.
- fixup copypasted kerneldoc to actually match the functions.
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 15 ++++++++--- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 66 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..a4684a306c48 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked)
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
With my plan, I want to keep drm_gem_object_free exported. The plan being a __drm_gem_object_free_lockless fastpath. -Chris
On Wed, Apr 27, 2016 at 12:58:51PM +0100, Chris Wilson wrote:
On Wed, Apr 27, 2016 at 01:50:00PM +0200, Daniel Vetter wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas:
- drop != NULL in pointer checks.
- fixup copypasted kerneldoc to actually match the functions.
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 15 ++++++++--- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 66 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..a4684a306c48 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked)
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
With my plan, I want to keep drm_gem_object_free exported. The plan being a __drm_gem_object_free_lockless fastpath.
Yeah, but I think we can reexport again in the patch that adds __drm_gem_object_free_lockless. Just not much personally a friend of sprawling EXPORT_SYMBOL when not needed. But I can drop that part too if you feel strongly. -Daniel
On Wed, Apr 27, 2016 at 02:12:46PM +0200, Daniel Vetter wrote:
On Wed, Apr 27, 2016 at 12:58:51PM +0100, Chris Wilson wrote:
On Wed, Apr 27, 2016 at 01:50:00PM +0200, Daniel Vetter wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas:
- drop != NULL in pointer checks.
- fixup copypasted kerneldoc to actually match the functions.
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/drm_gem.c | 64 ++++++++++++++++++++++++++++++++++++++--------- include/drm/drmP.h | 15 ++++++++--- include/drm/drm_gem.h | 45 ++------------------------------- 3 files changed, 66 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..a4684a306c48 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_object_release);
-/**
- drm_gem_object_free - free a GEM object
- @kref: kref of the object to free
- Called after the last reference to the object has been lost.
- Must be called holding struct_ mutex
- Frees the object
- */
-void +static void drm_gem_object_free(struct kref *kref) { struct drm_gem_object *obj = @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL)
- if (dev->driver->gem_free_object_unlocked)
dev->driver->gem_free_object_unlocked(obj);
- else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj);
} -EXPORT_SYMBOL(drm_gem_object_free);
With my plan, I want to keep drm_gem_object_free exported. The plan being a __drm_gem_object_free_lockless fastpath.
Yeah, but I think we can reexport again in the patch that adds __drm_gem_object_free_lockless. Just not much personally a friend of sprawling EXPORT_SYMBOL when not needed. But I can drop that part too if you feel strongly.
The alternative is to add the function now and then I can just drop the support into my tree and start testing :) -Chris
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas: - drop != NULL in pointer checks. - fixup copypasted kerneldoc to actually match the functions.
v4: Add __drm_gem_object_unreference as a fastpath helper for drivers who abolished dev->struct_mutex, requested by Chris.
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de Reviewed-by: Chris Wilson chris@chris-wilson.co.uk Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_gem.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++- include/drm/drmP.h | 15 ++++++++++--- include/drm/drm_gem.h | 48 +++++++++++++---------------------------- 3 files changed, 80 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..750d8975c318 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -806,12 +806,64 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL) + if (dev->driver->gem_free_object_unlocked) + dev->driver->gem_free_object_unlocked(obj); + else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj); } EXPORT_SYMBOL(drm_gem_object_free);
/** + * drm_gem_object_unreference_unlocked - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must not hold the + * dev->struct_mutex lock when calling this function. + * + * See also __drm_gem_object_unreference(). + */ +void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{ + struct drm_device *dev; + + if (!obj) + return; + + dev = obj->dev; + might_lock(&dev->struct_mutex); + + if (dev->driver->gem_free_object) + kref_put(&obj->refcount, drm_gem_object_free); + else if (kref_put_mutex(&obj->refcount, drm_gem_object_free, + &dev->struct_mutex)) + mutex_unlock(&dev->struct_mutex); +} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked); + +/** + * drm_gem_object_unreference - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must hold the dev->struct_mutex + * lock when calling this function, even when the driver doesn't use + * dev->struct_mutex for anything. + * + * For drivers not encumbered with legacy locking use + * drm_gem_object_unreference_unlocked() instead. + */ +void +drm_gem_object_unreference(struct drm_gem_object *obj) +{ + if (obj) { + WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); + + kref_put(&obj->refcount, drm_gem_object_free); + } +} +EXPORT_SYMBOL(drm_gem_object_unreference); + +/** * drm_gem_vm_open - vma->ops->open implementation for GEM * @vma: VM area structure * diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..bd7b262d7af0 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -580,12 +580,21 @@ struct drm_driver { void (*debugfs_cleanup)(struct drm_minor *minor);
/** - * Driver-specific constructor for drm_gem_objects, to set up - * obj->driver_private. + * @gem_free_object: deconstructor for drm_gem_objects * - * Returns 0 on success. + * This is deprecated and should not be used by new drivers. Use + * @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj); + + /** + * @gem_free_object_unlocked: deconstructor for drm_gem_objects + * + * This is for drivers which are not encumbered with dev->struct_mutex + * legacy locking schemes. Use this hook instead of @gem_free_object. + */ + void (*gem_free_object_unlocked) (struct drm_gem_object *obj); + int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..408d6c47d98b 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -200,47 +200,29 @@ drm_gem_object_reference(struct drm_gem_object *obj) }
/** - * drm_gem_object_unreference - release a GEM BO reference + * __drm_gem_object_unreference - raw function to release a GEM BO reference * @obj: GEM buffer object * - * This releases a reference to @obj. Callers must hold the dev->struct_mutex - * lock when calling this function, even when the driver doesn't use - * dev->struct_mutex for anything. + * This function is meant to be used by drivers which are not encumbered with + * dev->struct_mutex legacy locking and which are using the + * gem_free_object_unlocked callback. It avoids all the locking checks and + * locking overhead of drm_gem_object_unreference() and + * drm_gem_object_unreference_unlocked(). * - * For drivers not encumbered with legacy locking use - * drm_gem_object_unreference_unlocked() instead. + * Drivers should never call this directly in their code. Instead they should + * wrap it up into a driver_gem_object_unreference(struct driver_gem_object + * *obj) wrapper function, and use that. Shared code should never call this, to + * avoid breaking drivers by accident which still depend upon dev->struct_mutex + * locking. */ static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) +__drm_gem_object_unreference(struct drm_gem_object *obj) { - if (obj != NULL) { - WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); - - kref_put(&obj->refcount, drm_gem_object_free); - } + kref_put(&obj->refcount, drm_gem_object_free); }
-/** - * drm_gem_object_unreference_unlocked - release a GEM BO reference - * @obj: GEM buffer object - * - * This releases a reference to @obj. Callers must not hold the - * dev->struct_mutex lock when calling this function. - */ -static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{ - struct drm_device *dev; - - if (!obj) - return; - - dev = obj->dev; - if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex)) - mutex_unlock(&dev->struct_mutex); - else - might_lock(&dev->struct_mutex); -} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas: - drop != NULL in pointer checks. - fixup copypasted kerneldoc to actually match the functions.
v4: Add __drm_gem_object_unreference as a fastpath helper for drivers who abolished dev->struct_mutex, requested by Chris.
v5: Fix silly mistake in drm_gem_object_unreference_unlocked caught by intel-gfx CI - I checked for gem_free_object instead of gem_free_object_unlocked ...
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de (v3) Reviewed-by: Chris Wilson chris@chris-wilson.co.uk (v4) Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/drm_gem.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++- include/drm/drmP.h | 15 ++++++++++--- include/drm/drm_gem.h | 48 +++++++++++++---------------------------- 3 files changed, 80 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..973eb8805ce0 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -806,12 +806,64 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
- if (dev->driver->gem_free_object != NULL) + if (dev->driver->gem_free_object_unlocked) + dev->driver->gem_free_object_unlocked(obj); + else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj); } EXPORT_SYMBOL(drm_gem_object_free);
/** + * drm_gem_object_unreference_unlocked - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must not hold the + * dev->struct_mutex lock when calling this function. + * + * See also __drm_gem_object_unreference(). + */ +void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{ + struct drm_device *dev; + + if (!obj) + return; + + dev = obj->dev; + might_lock(&dev->struct_mutex); + + if (dev->driver->gem_free_object_unlocked) + kref_put(&obj->refcount, drm_gem_object_free); + else if (kref_put_mutex(&obj->refcount, drm_gem_object_free, + &dev->struct_mutex)) + mutex_unlock(&dev->struct_mutex); +} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked); + +/** + * drm_gem_object_unreference - release a GEM BO reference + * @obj: GEM buffer object + * + * This releases a reference to @obj. Callers must hold the dev->struct_mutex + * lock when calling this function, even when the driver doesn't use + * dev->struct_mutex for anything. + * + * For drivers not encumbered with legacy locking use + * drm_gem_object_unreference_unlocked() instead. + */ +void +drm_gem_object_unreference(struct drm_gem_object *obj) +{ + if (obj) { + WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); + + kref_put(&obj->refcount, drm_gem_object_free); + } +} +EXPORT_SYMBOL(drm_gem_object_unreference); + +/** * drm_gem_vm_open - vma->ops->open implementation for GEM * @vma: VM area structure * diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..bd7b262d7af0 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -580,12 +580,21 @@ struct drm_driver { void (*debugfs_cleanup)(struct drm_minor *minor);
/** - * Driver-specific constructor for drm_gem_objects, to set up - * obj->driver_private. + * @gem_free_object: deconstructor for drm_gem_objects * - * Returns 0 on success. + * This is deprecated and should not be used by new drivers. Use + * @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj); + + /** + * @gem_free_object_unlocked: deconstructor for drm_gem_objects + * + * This is for drivers which are not encumbered with dev->struct_mutex + * legacy locking schemes. Use this hook instead of @gem_free_object. + */ + void (*gem_free_object_unlocked) (struct drm_gem_object *obj); + int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..408d6c47d98b 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -200,47 +200,29 @@ drm_gem_object_reference(struct drm_gem_object *obj) }
/** - * drm_gem_object_unreference - release a GEM BO reference + * __drm_gem_object_unreference - raw function to release a GEM BO reference * @obj: GEM buffer object * - * This releases a reference to @obj. Callers must hold the dev->struct_mutex - * lock when calling this function, even when the driver doesn't use - * dev->struct_mutex for anything. + * This function is meant to be used by drivers which are not encumbered with + * dev->struct_mutex legacy locking and which are using the + * gem_free_object_unlocked callback. It avoids all the locking checks and + * locking overhead of drm_gem_object_unreference() and + * drm_gem_object_unreference_unlocked(). * - * For drivers not encumbered with legacy locking use - * drm_gem_object_unreference_unlocked() instead. + * Drivers should never call this directly in their code. Instead they should + * wrap it up into a driver_gem_object_unreference(struct driver_gem_object + * *obj) wrapper function, and use that. Shared code should never call this, to + * avoid breaking drivers by accident which still depend upon dev->struct_mutex + * locking. */ static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) +__drm_gem_object_unreference(struct drm_gem_object *obj) { - if (obj != NULL) { - WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); - - kref_put(&obj->refcount, drm_gem_object_free); - } + kref_put(&obj->refcount, drm_gem_object_free); }
-/** - * drm_gem_object_unreference_unlocked - release a GEM BO reference - * @obj: GEM buffer object - * - * This releases a reference to @obj. Callers must not hold the - * dev->struct_mutex lock when calling this function. - */ -static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{ - struct drm_device *dev; - - if (!obj) - return; - - dev = obj->dev; - if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex)) - mutex_unlock(&dev->struct_mutex); - else - might_lock(&dev->struct_mutex); -} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,
On Mon, May 2, 2016 at 4:40 AM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas:
- drop != NULL in pointer checks.
- fixup copypasted kerneldoc to actually match the functions.
v4: Add __drm_gem_object_unreference as a fastpath helper for drivers who abolished dev->struct_mutex, requested by Chris.
v5: Fix silly mistake in drm_gem_object_unreference_unlocked caught by intel-gfx CI - I checked for gem_free_object instead of gem_free_object_unlocked ...
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de (v3) Reviewed-by: Chris Wilson chris@chris-wilson.co.uk (v4) Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/drm_gem.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++- include/drm/drmP.h | 15 ++++++++++--- include/drm/drm_gem.h | 48 +++++++++++++---------------------------- 3 files changed, 80 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..973eb8805ce0 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -806,12 +806,64 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
if (dev->driver->gem_free_object != NULL)
if (dev->driver->gem_free_object_unlocked)
dev->driver->gem_free_object_unlocked(obj);
else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj);
} EXPORT_SYMBOL(drm_gem_object_free);
/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- See also __drm_gem_object_unreference().
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
might_lock(&dev->struct_mutex);
if (dev->driver->gem_free_object_unlocked)
kref_put(&obj->refcount, drm_gem_object_free);
else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
&dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
+} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
+void +drm_gem_object_unreference(struct drm_gem_object *obj) +{
if (obj) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
+} +EXPORT_SYMBOL(drm_gem_object_unreference);
+/**
- drm_gem_vm_open - vma->ops->open implementation for GEM
- @vma: VM area structure
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..bd7b262d7af0 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -580,12 +580,21 @@ struct drm_driver { void (*debugfs_cleanup)(struct drm_minor *minor);
/**
* Driver-specific constructor for drm_gem_objects, to set up
* obj->driver_private.
* @gem_free_object: deconstructor for drm_gem_objects *
* Returns 0 on success.
* This is deprecated and should not be used by new drivers. Use
* @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj);
/**
* @gem_free_object_unlocked: deconstructor for drm_gem_objects
*
* This is for drivers which are not encumbered with dev->struct_mutex
* legacy locking schemes. Use this hook instead of @gem_free_object.
*/
void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..408d6c47d98b 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -200,47 +200,29 @@ drm_gem_object_reference(struct drm_gem_object *obj) }
/**
- drm_gem_object_unreference - release a GEM BO reference
- __drm_gem_object_unreference - raw function to release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- This function is meant to be used by drivers which are not encumbered with
- dev->struct_mutex legacy locking and which are using the
- gem_free_object_unlocked callback. It avoids all the locking checks and
- locking overhead of drm_gem_object_unreference() and
- drm_gem_object_unreference_unlocked().
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- Drivers should never call this directly in their code. Instead they should
- wrap it up into a driver_gem_object_unreference(struct driver_gem_object
- *obj) wrapper function, and use that. Shared code should never call this, to
- avoid breaking drivers by accident which still depend upon dev->struct_mutex
*/
- locking.
static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) +__drm_gem_object_unreference(struct drm_gem_object *obj) {
if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
kref_put(&obj->refcount, drm_gem_object_free);
}
-/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
-static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
else
might_lock(&dev->struct_mutex);
-} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj, -- 2.8.1
On Tue, May 03, 2016 at 11:59:19AM -0400, Alex Deucher wrote:
On Mon, May 2, 2016 at 4:40 AM, Daniel Vetter daniel.vetter@ffwll.ch wrote:
Finally all the core gem and a lot of drivers are entirely free of dev->struct_mutex depencies, and we can start to have an entirely lockless unref path.
To make sure that no one who touches the core code accidentally breaks existing drivers which still require dev->struct_mutex I've made the might_lock check unconditional.
While at it de-inline the ref/unref functions, they've become a bit too big.
v2: Make it not leak like a sieve.
v3: Review from Lucas:
- drop != NULL in pointer checks.
- fixup copypasted kerneldoc to actually match the functions.
v4: Add __drm_gem_object_unreference as a fastpath helper for drivers who abolished dev->struct_mutex, requested by Chris.
v5: Fix silly mistake in drm_gem_object_unreference_unlocked caught by intel-gfx CI - I checked for gem_free_object instead of gem_free_object_unlocked ...
Cc: Chris Wilson chris@chris-wilson.co.uk Cc: Alex Deucher alexdeucher@gmail.com Cc: Lucas Stach l.stach@pengutronix.de Reviewed-by: Lucas Stach l.stach@pengutronix.de (v3) Reviewed-by: Chris Wilson chris@chris-wilson.co.uk (v4) Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Reviewed-by: Alex Deucher alexander.deucher@amd.com
Thanks for the review. I merged this one plus the driver patches acked by maintainers to drm-misc. -Daniel
drivers/gpu/drm/drm_gem.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++- include/drm/drmP.h | 15 ++++++++++--- include/drm/drm_gem.h | 48 +++++++++++++---------------------------- 3 files changed, 80 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 25dac31eef37..973eb8805ce0 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -806,12 +806,64 @@ drm_gem_object_free(struct kref *kref)
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
if (dev->driver->gem_free_object != NULL)
if (dev->driver->gem_free_object_unlocked)
dev->driver->gem_free_object_unlocked(obj);
else if (dev->driver->gem_free_object) dev->driver->gem_free_object(obj);
} EXPORT_SYMBOL(drm_gem_object_free);
/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- See also __drm_gem_object_unreference().
- */
+void +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) +{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
might_lock(&dev->struct_mutex);
if (dev->driver->gem_free_object_unlocked)
kref_put(&obj->refcount, drm_gem_object_free);
else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
&dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
+} +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+/**
- drm_gem_object_unreference - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- */
+void +drm_gem_object_unreference(struct drm_gem_object *obj) +{
if (obj) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
+} +EXPORT_SYMBOL(drm_gem_object_unreference);
+/**
- drm_gem_vm_open - vma->ops->open implementation for GEM
- @vma: VM area structure
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c81dd2250fc6..bd7b262d7af0 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -580,12 +580,21 @@ struct drm_driver { void (*debugfs_cleanup)(struct drm_minor *minor);
/**
* Driver-specific constructor for drm_gem_objects, to set up
* obj->driver_private.
* @gem_free_object: deconstructor for drm_gem_objects *
* Returns 0 on success.
* This is deprecated and should not be used by new drivers. Use
* @gem_free_object_unlocked instead. */ void (*gem_free_object) (struct drm_gem_object *obj);
/**
* @gem_free_object_unlocked: deconstructor for drm_gem_objects
*
* This is for drivers which are not encumbered with dev->struct_mutex
* legacy locking schemes. Use this hook instead of @gem_free_object.
*/
void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 0b3e11ab8757..408d6c47d98b 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -200,47 +200,29 @@ drm_gem_object_reference(struct drm_gem_object *obj) }
/**
- drm_gem_object_unreference - release a GEM BO reference
- __drm_gem_object_unreference - raw function to release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must hold the dev->struct_mutex
- lock when calling this function, even when the driver doesn't use
- dev->struct_mutex for anything.
- This function is meant to be used by drivers which are not encumbered with
- dev->struct_mutex legacy locking and which are using the
- gem_free_object_unlocked callback. It avoids all the locking checks and
- locking overhead of drm_gem_object_unreference() and
- drm_gem_object_unreference_unlocked().
- For drivers not encumbered with legacy locking use
- drm_gem_object_unreference_unlocked() instead.
- Drivers should never call this directly in their code. Instead they should
- wrap it up into a driver_gem_object_unreference(struct driver_gem_object
- *obj) wrapper function, and use that. Shared code should never call this, to
- avoid breaking drivers by accident which still depend upon dev->struct_mutex
*/
- locking.
static inline void -drm_gem_object_unreference(struct drm_gem_object *obj) +__drm_gem_object_unreference(struct drm_gem_object *obj) {
if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
kref_put(&obj->refcount, drm_gem_object_free);
}
kref_put(&obj->refcount, drm_gem_object_free);
}
-/**
- drm_gem_object_unreference_unlocked - release a GEM BO reference
- @obj: GEM buffer object
- This releases a reference to @obj. Callers must not hold the
- dev->struct_mutex lock when calling this function.
- */
-static inline void -drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) -{
struct drm_device *dev;
if (!obj)
return;
dev = obj->dev;
if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex))
mutex_unlock(&dev->struct_mutex);
else
might_lock(&dev->struct_mutex);
-} +void drm_gem_object_unreference_unlocked(struct drm_gem_object *obj); +void drm_gem_object_unreference(struct drm_gem_object *obj);
int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj, -- 2.8.1
No dev->struct_mutex anywhere to be seen.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 93462aea9faa..44955f0f32d0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -514,7 +514,7 @@ static struct drm_driver kms_driver = { .irq_uninstall = amdgpu_irq_uninstall, .irq_handler = amdgpu_irq_handler, .ioctls = amdgpu_ioctls_kms, - .gem_free_object = amdgpu_gem_object_free, + .gem_free_object_unlocked = amdgpu_gem_object_free, .gem_open_object = amdgpu_gem_object_open, .gem_close_object = amdgpu_gem_object_close, .dumb_create = amdgpu_mode_dumb_create,
No dev->struct_mutex anywhere to be seen.
Cc: Russell King rmk+kernel@arm.linux.org.uk Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/armada/armada_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 82043c204b76..531fcb946346 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -198,7 +198,7 @@ static struct drm_driver armada_drm_driver = { .debugfs_init = armada_drm_debugfs_init, .debugfs_cleanup = armada_drm_debugfs_cleanup, #endif - .gem_free_object = armada_gem_free_object, + .gem_free_object_unlocked = armada_gem_free_object, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = armada_gem_prime_export,
On Tue, Apr 26, 2016 at 07:29:44PM +0200, Daniel Vetter wrote:
No dev->struct_mutex anywhere to be seen.
Cc: Russell King rmk+kernel@arm.linux.org.uk
Acked-by: Russell King rmk+kernel@arm.linux.org.uk
Thanks Daniel.
No dev->struct_mutex anywhere to be seen.
Cc: Dave Airlie airlied@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/ast/ast_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index fcd9c0714836..f54afd2113a9 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -209,7 +209,7 @@ static struct drm_driver driver = { .minor = DRIVER_MINOR, .patchlevel = DRIVER_PATCHLEVEL,
- .gem_free_object = ast_gem_free_object, + .gem_free_object_unlocked = ast_gem_free_object, .dumb_create = ast_dumb_create, .dumb_map_offset = ast_dumb_mmap_offset, .dumb_destroy = drm_gem_dumb_destroy,
No dev->struct_mutex anywhere to be seen.
Cc: Boris Brezillon boris.brezillon@free-electrons.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c index 8ded7645747e..6485fa5bee8b 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c @@ -776,7 +776,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = atmel_hlcdc_dc_enable_vblank, .disable_vblank = atmel_hlcdc_dc_disable_vblank, - .gem_free_object = drm_gem_cma_free_object, + .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
No dev->struct_mutex anywhere to be seen.
Cc: Gerd Hoffmann kraxel@redhat.com Cc: Dave Airlie airlied@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/bochs/bochs_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c index b332b4d3b0e2..abace82de6ea 100644 --- a/drivers/gpu/drm/bochs/bochs_drv.c +++ b/drivers/gpu/drm/bochs/bochs_drv.c @@ -89,7 +89,7 @@ static struct drm_driver bochs_driver = { .date = "20130925", .major = 1, .minor = 0, - .gem_free_object = bochs_gem_free_object, + .gem_free_object_unlocked = bochs_gem_free_object, .dumb_create = bochs_dumb_create, .dumb_map_offset = bochs_dumb_mmap_offset, .dumb_destroy = drm_gem_dumb_destroy,
No dev->struct_mutex anywhere to be seen.
Cc: Dave Airlie airlied@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/cirrus/cirrus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c index dc83f69da6f1..b05f7eae32ce 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.c +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c @@ -142,7 +142,7 @@ static struct drm_driver driver = { .major = DRIVER_MAJOR, .minor = DRIVER_MINOR, .patchlevel = DRIVER_PATCHLEVEL, - .gem_free_object = cirrus_gem_free_object, + .gem_free_object_unlocked = cirrus_gem_free_object, .dumb_create = cirrus_dumb_create, .dumb_map_offset = cirrus_dumb_mmap_offset, .dumb_destroy = drm_gem_dumb_destroy,
No dev->struct_mutex anywhere to be seen.
Cc: Christian Gmeiner christian.gmeiner@gmail.com Cc: Russell King rmk+kernel@arm.linux.org.uk Cc: Lucas Stach l.stach@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index e8858985f01e..c2f92e362812 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -497,7 +497,7 @@ static struct drm_driver etnaviv_drm_driver = { .open = etnaviv_open, .preclose = etnaviv_preclose, .set_busid = drm_platform_set_busid, - .gem_free_object = etnaviv_gem_free_object, + .gem_free_object_unlocked = etnaviv_gem_free_object, .gem_vm_ops = &vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
No dev->struct_mutex anywhere to be seen.
Cc: Christian Gmeiner christian.gmeiner@gmail.com Cc: Russell King rmk+kernel@arm.linux.org.uk Cc: Lucas Stach l.stach@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Acked-by: Lucas Stach l.stach@pengutronix.de
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index e8858985f01e..c2f92e362812 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -497,7 +497,7 @@ static struct drm_driver etnaviv_drm_driver = { .open = etnaviv_open, .preclose = etnaviv_preclose, .set_busid = drm_platform_set_busid,
- .gem_free_object = etnaviv_gem_free_object,
- .gem_free_object_unlocked = etnaviv_gem_free_object, .gem_vm_ops = &vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
On Tue, Apr 26, 2016 at 07:29:49PM +0200, Daniel Vetter wrote:
No dev->struct_mutex anywhere to be seen.
Cc: Christian Gmeiner christian.gmeiner@gmail.com Cc: Russell King rmk+kernel@arm.linux.org.uk
Acked-by: Russell King rmk+kernel@arm.linux.org.uk
Thanks Daniel.
No dev->struct_mutex anywhere to be seen.
Cc: Inki Dae inki.dae@samsung.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 5344940c8a07..f534ed62065e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -418,7 +418,7 @@ static struct drm_driver exynos_drm_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = exynos_drm_crtc_enable_vblank, .disable_vblank = exynos_drm_crtc_disable_vblank, - .gem_free_object = exynos_drm_gem_free_object, + .gem_free_object_unlocked = exynos_drm_gem_free_object, .gem_vm_ops = &exynos_drm_gem_vm_ops, .dumb_create = exynos_drm_gem_dumb_create, .dumb_map_offset = exynos_drm_gem_dumb_map_offset,
2016년 04월 27일 02:29에 Daniel Vetter 이(가) 쓴 글:
No dev->struct_mutex anywhere to be seen.
Acked-by: Inki Dae inki.dae@samsung.com
Thanks, Inki Dae
Cc: Inki Dae inki.dae@samsung.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 5344940c8a07..f534ed62065e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -418,7 +418,7 @@ static struct drm_driver exynos_drm_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = exynos_drm_crtc_enable_vblank, .disable_vblank = exynos_drm_crtc_disable_vblank,
- .gem_free_object = exynos_drm_gem_free_object,
- .gem_free_object_unlocked = exynos_drm_gem_free_object, .gem_vm_ops = &exynos_drm_gem_vm_ops, .dumb_create = exynos_drm_gem_dumb_create, .dumb_map_offset = exynos_drm_gem_dumb_map_offset,
No dev->struct_mutex anywhere to be seen.
Cc: Jianwei Wang jianwei.wang.chn@gmail.com Cc: Stefan Agner stefan@agner.ch Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index e8d9337a66d8..f96e8ea595e6 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -180,7 +180,7 @@ static struct drm_driver fsl_dcu_drm_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = fsl_dcu_drm_enable_vblank, .disable_vblank = fsl_dcu_drm_disable_vblank, - .gem_free_object = drm_gem_cma_free_object, + .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
No dev->struct_mutex anywhere to be seen.
Cc: Sascha Hauer s.hauer@pengutronix.de Cc: Philipp Zabel p.zabel@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/imx/imx-drm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index e26dcdec2aba..2453fb1c68a7 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = { .unload = imx_drm_driver_unload, .lastclose = imx_drm_driver_lastclose, .set_busid = drm_platform_set_busid, - .gem_free_object = drm_gem_cma_free_object, + .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
No dev->struct_mutex anywhere to be seen.
Cc: Sascha Hauer s.hauer@pengutronix.de Cc: Philipp Zabel p.zabel@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/imx/imx-drm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index e26dcdec2aba..2453fb1c68a7 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = { .unload = imx_drm_driver_unload, .lastclose = imx_drm_driver_lastclose, .set_busid = drm_platform_set_busid,
- .gem_free_object = drm_gem_cma_free_object,
- .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
Applied to imx-drm/fixes, thank you.
regards Philipp
On Wed, Apr 27, 2016 at 12:29:34PM +0200, Philipp Zabel wrote:
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
No dev->struct_mutex anywhere to be seen.
Cc: Sascha Hauer s.hauer@pengutronix.de Cc: Philipp Zabel p.zabel@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/imx/imx-drm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index e26dcdec2aba..2453fb1c68a7 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = { .unload = imx_drm_driver_unload, .lastclose = imx_drm_driver_lastclose, .set_busid = drm_platform_set_busid,
- .gem_free_object = drm_gem_cma_free_object,
- .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
Applied to imx-drm/fixes, thank you.
And that compiles for you? Might want to drop the patch again before someone notices ;-) -Daniel
Am Mittwoch, den 27.04.2016, 13:21 +0200 schrieb Daniel Vetter:
On Wed, Apr 27, 2016 at 12:29:34PM +0200, Philipp Zabel wrote:
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
No dev->struct_mutex anywhere to be seen.
Cc: Sascha Hauer s.hauer@pengutronix.de Cc: Philipp Zabel p.zabel@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/imx/imx-drm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index e26dcdec2aba..2453fb1c68a7 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = { .unload = imx_drm_driver_unload, .lastclose = imx_drm_driver_lastclose, .set_busid = drm_platform_set_busid,
- .gem_free_object = drm_gem_cma_free_object,
- .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
Applied to imx-drm/fixes, thank you.
And that compiles for you? Might want to drop the patch again before someone notices ;-)
Nope, dropped. Nobody will have to.
On Wed, Apr 27, 2016 at 02:01:35PM +0200, Philipp Zabel wrote:
Am Mittwoch, den 27.04.2016, 13:21 +0200 schrieb Daniel Vetter:
On Wed, Apr 27, 2016 at 12:29:34PM +0200, Philipp Zabel wrote:
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
No dev->struct_mutex anywhere to be seen.
Cc: Sascha Hauer s.hauer@pengutronix.de Cc: Philipp Zabel p.zabel@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/imx/imx-drm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index e26dcdec2aba..2453fb1c68a7 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = { .unload = imx_drm_driver_unload, .lastclose = imx_drm_driver_lastclose, .set_busid = drm_platform_set_busid,
- .gem_free_object = drm_gem_cma_free_object,
- .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
Applied to imx-drm/fixes, thank you.
And that compiles for you? Might want to drop the patch again before someone notices ;-)
Nope, dropped. Nobody will have to.
I presume you having tried to apply it is as good as an ack, so added to drm-misc. -Daniel
Am Mittwoch, den 04.05.2016, 12:28 +0200 schrieb Daniel Vetter:
On Wed, Apr 27, 2016 at 02:01:35PM +0200, Philipp Zabel wrote:
Am Mittwoch, den 27.04.2016, 13:21 +0200 schrieb Daniel Vetter:
On Wed, Apr 27, 2016 at 12:29:34PM +0200, Philipp Zabel wrote:
Am Dienstag, den 26.04.2016, 19:29 +0200 schrieb Daniel Vetter:
No dev->struct_mutex anywhere to be seen.
Cc: Sascha Hauer s.hauer@pengutronix.de Cc: Philipp Zabel p.zabel@pengutronix.de Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/imx/imx-drm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index e26dcdec2aba..2453fb1c68a7 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = { .unload = imx_drm_driver_unload, .lastclose = imx_drm_driver_lastclose, .set_busid = drm_platform_set_busid,
- .gem_free_object = drm_gem_cma_free_object,
- .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
Applied to imx-drm/fixes, thank you.
And that compiles for you? Might want to drop the patch again before someone notices ;-)
Nope, dropped. Nobody will have to.
I presume you having tried to apply it is as good as an ack, so added to drm-misc.
Yes, thank you.
regards Philipp
No dev->struct_mutex anywhere to be seen.
Cc: Dave Airlie airlied@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/mgag200/mgag200_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index ebb470ff7200..2b4b125eebc3 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -101,7 +101,7 @@ static struct drm_driver driver = { .minor = DRIVER_MINOR, .patchlevel = DRIVER_PATCHLEVEL,
- .gem_free_object = mgag200_gem_free_object, + .gem_free_object_unlocked = mgag200_gem_free_object, .dumb_create = mgag200_dumb_create, .dumb_map_offset = mgag200_dumb_mmap_offset, .dumb_destroy = drm_gem_dumb_destroy,
No dev->struct_mutex anywhere to be seen.
Cc: Ben Skeggs bskeggs@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index db5c7d0cc25c..3a4af87fba0f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -970,7 +970,7 @@ driver_stub = { .gem_prime_vmap = nouveau_gem_prime_vmap, .gem_prime_vunmap = nouveau_gem_prime_vunmap,
- .gem_free_object = nouveau_gem_object_del, + .gem_free_object_unlocked = nouveau_gem_object_del, .gem_open_object = nouveau_gem_object_open, .gem_close_object = nouveau_gem_object_close,
No dev->struct_mutex anywhere to be seen.
Cc: Dave Airlie airlied@redhat.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/qxl/qxl_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index dc9df5fe50ba..460bbceae297 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.c +++ b/drivers/gpu/drm/qxl/qxl_drv.c @@ -256,7 +256,7 @@ static struct drm_driver qxl_driver = { .gem_prime_vmap = qxl_gem_prime_vmap, .gem_prime_vunmap = qxl_gem_prime_vunmap, .gem_prime_mmap = qxl_gem_prime_mmap, - .gem_free_object = qxl_gem_object_free, + .gem_free_object_unlocked = qxl_gem_object_free, .gem_open_object = qxl_gem_object_open, .gem_close_object = qxl_gem_object_close, .fops = &qxl_fops,
No dev->struct_mutex anywhere to be seen.
Cc: Alex Deucher alexander.deucher@amd.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/radeon/radeon_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 5d44ed0d104a..b9f74e68527e 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -525,7 +525,7 @@ static struct drm_driver kms_driver = { .irq_uninstall = radeon_driver_irq_uninstall_kms, .irq_handler = radeon_driver_irq_handler_kms, .ioctls = radeon_ioctls_kms, - .gem_free_object = radeon_gem_object_free, + .gem_free_object_unlocked = radeon_gem_object_free, .gem_open_object = radeon_gem_object_open, .gem_close_object = radeon_gem_object_close, .dumb_create = radeon_mode_dumb_create,
No dev->struct_mutex anywhere to be seen.
Cc: Laurent Pinchart laurent.pinchart@ideasonboard.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index fb9242d27883..48ec4b6e8b26 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -217,7 +217,7 @@ static struct drm_driver rcar_du_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = rcar_du_enable_vblank, .disable_vblank = rcar_du_disable_vblank, - .gem_free_object = drm_gem_cma_free_object, + .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
No dev->struct_mutex anywhere to be seen.
Cc: Mark Yao mark.yao@rock-chips.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index f556a8f4fde6..903202224057 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -308,7 +308,7 @@ static struct drm_driver rockchip_drm_driver = { .enable_vblank = rockchip_drm_crtc_enable_vblank, .disable_vblank = rockchip_drm_crtc_disable_vblank, .gem_vm_ops = &rockchip_drm_vm_ops, - .gem_free_object = rockchip_gem_free_object, + .gem_free_object_unlocked = rockchip_gem_free_object, .dumb_create = rockchip_gem_dumb_create, .dumb_map_offset = rockchip_gem_dumb_map_offset, .dumb_destroy = drm_gem_dumb_destroy,
No dev->struct_mutex anywhere to be seen.
Cc: Laurent Pinchart laurent.pinchart@ideasonboard.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index 7700ff172079..ee79264b5b6a 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c @@ -264,7 +264,7 @@ static struct drm_driver shmob_drm_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = shmob_drm_enable_vblank, .disable_vblank = shmob_drm_disable_vblank, - .gem_free_object = drm_gem_cma_free_object, + .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
No dev->struct_mutex anywhere to be seen.
Cc: Thierry Reding thierry.reding@gmail.com Cc: Terje Bergström tbergstrom@nvidia.com Cc: linux-tegra@vger.kernel.org Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/tegra/drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 2be88eb0cb83..3d9241482f81 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -932,7 +932,7 @@ static struct drm_driver tegra_drm_driver = { .debugfs_cleanup = tegra_debugfs_cleanup, #endif
- .gem_free_object = tegra_bo_free_object, + .gem_free_object_unlocked = tegra_bo_free_object, .gem_vm_ops = &tegra_bo_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
On Tue, Apr 26, 2016 at 07:30:00PM +0200, Daniel Vetter wrote:
No dev->struct_mutex anywhere to be seen.
Cc: Thierry Reding thierry.reding@gmail.com Cc: Terje Bergström tbergstrom@nvidia.com Cc: linux-tegra@vger.kernel.org Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/tegra/drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Thierry Reding treding@nvidia.com
On Tue, May 10, 2016 at 03:33:00PM +0200, Thierry Reding wrote:
On Tue, Apr 26, 2016 at 07:30:00PM +0200, Daniel Vetter wrote:
No dev->struct_mutex anywhere to be seen.
Cc: Thierry Reding thierry.reding@gmail.com Cc: Terje Bergström tbergstrom@nvidia.com Cc: linux-tegra@vger.kernel.org Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/tegra/drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Thierry Reding treding@nvidia.com
Applied to drm-misc. -Daniel
No dev->struct_mutex anywhere to be seen.
Cc: Tomi Valkeinen tomi.valkeinen@ti.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 709bc903524d..308e197908fc 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c @@ -549,7 +549,7 @@ static struct drm_driver tilcdc_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = tilcdc_enable_vblank, .disable_vblank = tilcdc_disable_vblank, - .gem_free_object = drm_gem_cma_free_object, + .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
Since my last struct_mutex crusade someone escaped!
This already has the advantage that for the common case when someone else holds a ref the unref won't even acquire dev->struct_mutex. And I'm working on code to allow drivers to completely opt-out of any and all dev->struct_mutex usage, but that only works if they use the _unlocked variants everywhere.
v2: drop comment too.
Cc: Eric Anholt eric@anholt.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/vc4/vc4_gem.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 8d4384f8b78d..1f6711a98f5d 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c @@ -53,10 +53,8 @@ vc4_free_hang_state(struct drm_device *dev, struct vc4_hang_state *state) { unsigned int i;
- mutex_lock(&dev->struct_mutex); for (i = 0; i < state->user_state.bo_count; i++) - drm_gem_object_unreference(state->bo[i]); - mutex_unlock(&dev->struct_mutex); + drm_gem_object_unreference_unlocked(state->bo[i]);
kfree(state); } @@ -687,11 +685,9 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) struct vc4_dev *vc4 = to_vc4_dev(dev); unsigned i;
- /* Need the struct lock for drm_gem_object_unreference(). */ - mutex_lock(&dev->struct_mutex); if (exec->bo) { for (i = 0; i < exec->bo_count; i++) - drm_gem_object_unreference(&exec->bo[i]->base); + drm_gem_object_unreference_unlocked(&exec->bo[i]->base); kfree(exec->bo); }
@@ -699,9 +695,8 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec) struct vc4_bo *bo = list_first_entry(&exec->unref_list, struct vc4_bo, unref_head); list_del(&bo->unref_head); - drm_gem_object_unreference(&bo->base.base); + drm_gem_object_unreference_unlocked(&bo->base.base); } - mutex_unlock(&dev->struct_mutex);
mutex_lock(&vc4->power_lock); if (--vc4->power_refcount == 0)
No dev->struct_mutex anywhere to be seen.
Cc: Eric Anholt eric@anholt.net Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/vc4/vc4_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index b7d2ff0e6e1f..13f704de39e1 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -98,7 +98,7 @@ static struct drm_driver vc4_drm_driver = { #endif
.gem_create_object = vc4_create_object, - .gem_free_object = vc4_free_object, + .gem_free_object_unlocked = vc4_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
No dev->struct_mutex anywhere to be seen.
Cc: seanpaul@chromium.org Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/vgem/vgem_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index d61a547fa3c9..1228b40691fe 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -235,7 +235,7 @@ static const struct file_operations vgem_driver_fops = {
static struct drm_driver vgem_driver = { .driver_features = DRIVER_GEM, - .gem_free_object = vgem_gem_free_object, + .gem_free_object_unlocked = vgem_gem_free_object, .gem_vm_ops = &vgem_gem_vm_ops, .ioctls = vgem_ioctls, .fops = &vgem_driver_fops,
No dev->struct_mutex anywhere to be seen.
Cc: Gerd Hoffmann kraxel@redhat.com Cc: David Airlie airlied@linux.ie Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index 3cc7afa77a35..5820b7020ae5 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -143,7 +143,7 @@ static struct drm_driver driver = { .gem_prime_vunmap = virtgpu_gem_prime_vunmap, .gem_prime_mmap = virtgpu_gem_prime_mmap,
- .gem_free_object = virtio_gpu_gem_free_object, + .gem_free_object_unlocked = virtio_gpu_gem_free_object, .gem_open_object = virtio_gpu_gem_object_open, .gem_close_object = virtio_gpu_gem_object_close, .fops = &virtio_gpu_driver_fops,
From: Benjamin Gaignard benjamin.gaignard@linaro.org
No need to protect debugfs functions with dev->struct_mutex
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org Signed-off-by: Daniel Vetter daniel.vetter@ffwll.ch --- drivers/gpu/drm/sti/sti_cursor.c | 7 ------- drivers/gpu/drm/sti/sti_drv.c | 6 ------ drivers/gpu/drm/sti/sti_dvo.c | 7 ------- drivers/gpu/drm/sti/sti_gdp.c | 14 -------------- drivers/gpu/drm/sti/sti_hda.c | 7 ------- drivers/gpu/drm/sti/sti_hdmi.c | 7 ------- drivers/gpu/drm/sti/sti_hqvdp.c | 7 ------- drivers/gpu/drm/sti/sti_mixer.c | 7 ------- drivers/gpu/drm/sti/sti_tvout.c | 7 ------- drivers/gpu/drm/sti/sti_vid.c | 7 ------- 10 files changed, 76 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c index 3abb400151ac..e6ee4c526665 100644 --- a/drivers/gpu/drm/sti/sti_cursor.c +++ b/drivers/gpu/drm/sti/sti_cursor.c @@ -103,12 +103,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_cursor *cursor = (struct sti_cursor *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&cursor->plane), cursor->regs); @@ -127,7 +121,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP(CUR_AWE); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 6bd6abaa5a70..a8eece20b6b4 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -72,11 +72,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void *data) struct drm_info_node *node = s->private; struct drm_device *dev = node->minor->dev; struct drm_plane *p; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
list_for_each_entry(p, &dev->mode_config.plane_list, head) { struct sti_plane *plane = to_sti_plane(p); @@ -86,7 +81,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void *data) plane->fps_info.fips_str); }
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c index 25f76632002c..d439128e6309 100644 --- a/drivers/gpu/drm/sti/sti_dvo.c +++ b/drivers/gpu/drm/sti/sti_dvo.c @@ -177,12 +177,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_dvo *dvo = (struct sti_dvo *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "DVO: (vaddr = 0x%p)", dvo->regs); DBGFS_DUMP(DVO_AWG_DIGSYNC_CTRL); @@ -193,7 +187,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data) dvo_dbg_awg_microcode(s, dvo->regs + DVO_DIGSYNC_INSTR_I); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c index ff3d3e7e7704..3d098f1ab919 100644 --- a/drivers/gpu/drm/sti/sti_gdp.c +++ b/drivers/gpu/drm/sti/sti_gdp.c @@ -207,14 +207,8 @@ static int gdp_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; struct drm_plane *drm_plane = &gdp->plane.drm_plane; struct drm_crtc *crtc = drm_plane->crtc; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&gdp->plane), gdp->regs); @@ -247,7 +241,6 @@ static int gdp_dbg_show(struct seq_file *s, void *data) seq_printf(s, " Connected to DRM CRTC #%d (%s)\n", crtc->base.id, sti_mixer_to_str(to_sti_mixer(crtc)));
- mutex_unlock(&dev->struct_mutex); return 0; }
@@ -278,13 +271,7 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; unsigned int b; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
for (b = 0; b < GDP_NODE_NB_BANK; b++) { seq_printf(s, "\n%s[%d].top", sti_plane_to_str(&gdp->plane), b); @@ -293,7 +280,6 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg) gdp_node_dump_node(s, gdp->node_list[b].btm_field); }
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c index ec0d017eaf1a..d0e1647ce41a 100644 --- a/drivers/gpu/drm/sti/sti_hda.c +++ b/drivers/gpu/drm/sti/sti_hda.c @@ -375,12 +375,6 @@ static int hda_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hda *hda = (struct sti_hda *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "HD Analog: (vaddr = 0x%p)", hda->regs); DBGFS_DUMP(HDA_ANA_CFG); @@ -396,7 +390,6 @@ static int hda_dbg_show(struct seq_file *s, void *data) hda_dbg_video_dacs_ctrl(s, hda->video_dacs_ctrl); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c index 6ef0715bd5b9..85545ebf88d3 100644 --- a/drivers/gpu/drm/sti/sti_hdmi.c +++ b/drivers/gpu/drm/sti/sti_hdmi.c @@ -628,12 +628,6 @@ static int hdmi_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); DBGFS_DUMP("\n", HDMI_CFG); @@ -690,7 +684,6 @@ static int hdmi_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP_DI(HDMI_SW_DI_N_PKT_WORD6, HDMI_IFRAME_SLOT_VENDOR); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c index e05b0dc523ff..6230565048c3 100644 --- a/drivers/gpu/drm/sti/sti_hqvdp.c +++ b/drivers/gpu/drm/sti/sti_hqvdp.c @@ -554,14 +554,8 @@ static int hqvdp_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_hqvdp *hqvdp = (struct sti_hqvdp *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; int cmd, cmd_offset, infoxp70; void *virt; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_plane_to_str(&hqvdp->plane), hqvdp->regs); @@ -629,7 +623,6 @@ static int hqvdp_dbg_show(struct seq_file *s, void *data)
seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_mixer.c b/drivers/gpu/drm/sti/sti_mixer.c index e7425c38fc93..cc89d75273df 100644 --- a/drivers/gpu/drm/sti/sti_mixer.c +++ b/drivers/gpu/drm/sti/sti_mixer.c @@ -150,12 +150,6 @@ static int mixer_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_mixer *mixer = (struct sti_mixer *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "%s: (vaddr = 0x%p)", sti_mixer_to_str(mixer), mixer->regs); @@ -175,7 +169,6 @@ static int mixer_dbg_show(struct seq_file *s, void *arg) mixer_dbg_mxn(s, mixer->regs + GAM_MIXER_MX0); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c index 2c99016443e5..d641a5fe512b 100644 --- a/drivers/gpu/drm/sti/sti_tvout.c +++ b/drivers/gpu/drm/sti/sti_tvout.c @@ -514,13 +514,7 @@ static int tvout_dbg_show(struct seq_file *s, void *data) { struct drm_info_node *node = s->private; struct sti_tvout *tvout = (struct sti_tvout *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; struct drm_crtc *crtc; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "TVOUT: (vaddr = 0x%p)", tvout->regs);
@@ -586,7 +580,6 @@ static int tvout_dbg_show(struct seq_file *s, void *data) DBGFS_DUMP(TVO_AUX_IN_VID_FORMAT); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
diff --git a/drivers/gpu/drm/sti/sti_vid.c b/drivers/gpu/drm/sti/sti_vid.c index 5a2c5dc3687b..cba32140a763 100644 --- a/drivers/gpu/drm/sti/sti_vid.c +++ b/drivers/gpu/drm/sti/sti_vid.c @@ -91,12 +91,6 @@ static int vid_dbg_show(struct seq_file *s, void *arg) { struct drm_info_node *node = s->private; struct sti_vid *vid = (struct sti_vid *)node->info_ent->data; - struct drm_device *dev = node->minor->dev; - int ret; - - ret = mutex_lock_interruptible(&dev->struct_mutex); - if (ret) - return ret;
seq_printf(s, "VID: (vaddr= 0x%p)", vid->regs);
@@ -121,7 +115,6 @@ static int vid_dbg_show(struct seq_file *s, void *arg) DBGFS_DUMP(VID_CSAT); seq_puts(s, "\n");
- mutex_unlock(&dev->struct_mutex); return 0; }
With Benjanim's patch to remove the dev->struct_mutex cargo cult the sti driver is now also entirely legacy locking free. Let's convert it too.
Cc: Benjamin Gaignard benjamin.gaignard@linaro.org Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/sti/sti_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index a8eece20b6b4..a436264eab6b 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -304,7 +304,7 @@ static struct drm_driver sti_driver = { .driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC, .load = sti_load, - .gem_free_object = drm_gem_cma_free_object, + .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset,
No need to reinvent this little wheel.
Cc: Mark Yao mark.yao@rock-chips.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 903202224057..4484d5a53d89 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -292,11 +292,6 @@ static const struct file_operations rockchip_drm_driver_fops = { .release = drm_release, };
-const struct vm_operations_struct rockchip_drm_vm_ops = { - .open = drm_gem_vm_open, - .close = drm_gem_vm_close, -}; - static struct drm_driver rockchip_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC, @@ -307,7 +302,7 @@ static struct drm_driver rockchip_drm_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = rockchip_drm_crtc_enable_vblank, .disable_vblank = rockchip_drm_crtc_disable_vblank, - .gem_vm_ops = &rockchip_drm_vm_ops, + .gem_vm_ops = &drm_gem_cma_vm_ops, .gem_free_object_unlocked = rockchip_gem_free_object, .dumb_create = rockchip_gem_dumb_create, .dumb_map_offset = rockchip_gem_dumb_map_offset,
No need to reinvent this little wheel.
v2: Like, try to make it compile even.
Cc: Mark Yao mark.yao@rock-chips.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 903202224057..02fe3748bcc3 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -19,6 +19,7 @@ #include <drm/drmP.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> #include <linux/dma-mapping.h> #include <linux/pm_runtime.h> #include <linux/module.h> @@ -292,11 +293,6 @@ static const struct file_operations rockchip_drm_driver_fops = { .release = drm_release, };
-const struct vm_operations_struct rockchip_drm_vm_ops = { - .open = drm_gem_vm_open, - .close = drm_gem_vm_close, -}; - static struct drm_driver rockchip_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC, @@ -307,7 +303,7 @@ static struct drm_driver rockchip_drm_driver = { .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = rockchip_drm_crtc_enable_vblank, .disable_vblank = rockchip_drm_crtc_disable_vblank, - .gem_vm_ops = &rockchip_drm_vm_ops, + .gem_vm_ops = &drm_gem_cma_vm_ops, .gem_free_object_unlocked = rockchip_gem_free_object, .dumb_create = rockchip_gem_dumb_create, .dumb_map_offset = rockchip_gem_dumb_map_offset,
It's an optional hook. Might be needed for frontbuffer rendering on manual upload displays, but a simple TODO doesn't explain at all what needs to be done or why.
Cc: Inki Dae inki.dae@samsung.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/exynos/exynos_drm_fb.c | 11 ----------- 1 file changed, 11 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index 81cc5537cf25..f851a40ac6cb 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -97,20 +97,9 @@ static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb, &exynos_fb->exynos_gem[0]->base, handle); }
-static int exynos_drm_fb_dirty(struct drm_framebuffer *fb, - struct drm_file *file_priv, unsigned flags, - unsigned color, struct drm_clip_rect *clips, - unsigned num_clips) -{ - /* TODO */ - - return 0; -} - static const struct drm_framebuffer_funcs exynos_drm_fb_funcs = { .destroy = exynos_drm_fb_destroy, .create_handle = exynos_drm_fb_create_handle, - .dirty = exynos_drm_fb_dirty, };
struct drm_framebuffer *
Hi Daniel,
2016년 04월 27일 20:38에 Daniel Vetter 이(가) 쓴 글:
It's an optional hook. Might be needed for frontbuffer rendering on manual upload displays, but a simple TODO doesn't explain at all what needs to be done or why.
We have a plan for partial update support but not now yet. Picked it up.
Thanks, Inki Dae
Cc: Inki Dae inki.dae@samsung.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com
drivers/gpu/drm/exynos/exynos_drm_fb.c | 11 ----------- 1 file changed, 11 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index 81cc5537cf25..f851a40ac6cb 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -97,20 +97,9 @@ static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb, &exynos_fb->exynos_gem[0]->base, handle); }
-static int exynos_drm_fb_dirty(struct drm_framebuffer *fb,
struct drm_file *file_priv, unsigned flags,
unsigned color, struct drm_clip_rect *clips,
unsigned num_clips)
-{
- /* TODO */
- return 0;
-}
static const struct drm_framebuffer_funcs exynos_drm_fb_funcs = { .destroy = exynos_drm_fb_destroy, .create_handle = exynos_drm_fb_create_handle,
- .dirty = exynos_drm_fb_dirty,
};
struct drm_framebuffer *
It's an optional hook.
Cc: Rob Clark robdclark@gmail.com Signed-off-by: Daniel Vetter daniel.vetter@intel.com --- drivers/gpu/drm/msm/msm_fb.c | 8 -------- 1 file changed, 8 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c index 17e0c9eb1900..672d8b1c2d09 100644 --- a/drivers/gpu/drm/msm/msm_fb.c +++ b/drivers/gpu/drm/msm/msm_fb.c @@ -56,17 +56,9 @@ static void msm_framebuffer_destroy(struct drm_framebuffer *fb) kfree(msm_fb); }
-static int msm_framebuffer_dirty(struct drm_framebuffer *fb, - struct drm_file *file_priv, unsigned flags, unsigned color, - struct drm_clip_rect *clips, unsigned num_clips) -{ - return 0; -} - static const struct drm_framebuffer_funcs msm_framebuffer_funcs = { .create_handle = msm_framebuffer_create_handle, .destroy = msm_framebuffer_destroy, - .dirty = msm_framebuffer_dirty, };
#ifdef CONFIG_DEBUG_FS
dri-devel@lists.freedesktop.org