Commit 7a9ddd2f authored by Chris Wilson's avatar Chris Wilson Committed by Greg Kroah-Hartman

drm/prime: Pass the right module owner through to dma_buf_export()

commit 56a76c01 upstream.

dma_buf_export() adds a reference to the owning module to the dmabuf (to
prevent the driver from being unloaded whilst a third party still refers
to the dmabuf). However, drm_gem_prime_export() was passing its own
THIS_MODULE (i.e. drm.ko) rather than the driver. Extract the right
owner from the device->fops instead.

v2: Use C99 initializers to zero out unset elements of
dma_buf_export_info
v3: Extract the right module from dev->fops.

Testcase: igt/vgem_basic/unload
Reported-by: default avatarPetri Latvala <petri.latvala@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Christian König <christian.koenig@amd.com>
Tested-by: default avatarPetri Latvala <petri.latvala@intel.com>
Reviewed-by: default avatarPetri Latvala <petri.latvala@intel.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161005122145.1507-1-chris@chris-wilson.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c843445f
...@@ -339,14 +339,17 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = { ...@@ -339,14 +339,17 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = {
* using the PRIME helpers. * using the PRIME helpers.
*/ */
struct dma_buf *drm_gem_prime_export(struct drm_device *dev, struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
struct drm_gem_object *obj, int flags) struct drm_gem_object *obj,
int flags)
{ {
DEFINE_DMA_BUF_EXPORT_INFO(exp_info); struct dma_buf_export_info exp_info = {
.exp_name = KBUILD_MODNAME, /* white lie for debug */
exp_info.ops = &drm_gem_prime_dmabuf_ops; .owner = dev->driver->fops->owner,
exp_info.size = obj->size; .ops = &drm_gem_prime_dmabuf_ops,
exp_info.flags = flags; .size = obj->size,
exp_info.priv = obj; .flags = flags,
.priv = obj,
};
if (dev->driver->gem_prime_res_obj) if (dev->driver->gem_prime_res_obj)
exp_info.resv = dev->driver->gem_prime_res_obj(obj); exp_info.resv = dev->driver->gem_prime_res_obj(obj);
......
...@@ -1029,7 +1029,8 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files, ...@@ -1029,7 +1029,8 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
#endif #endif
extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
struct drm_gem_object *obj, int flags); struct drm_gem_object *obj,
int flags);
extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
struct drm_file *file_priv, uint32_t handle, uint32_t flags, struct drm_file *file_priv, uint32_t handle, uint32_t flags,
int *prime_fd); int *prime_fd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment