Skip to content

Commit 0514f63

Browse files
fxkamdalexdeucher
authored andcommitted
Revert "drm/prime: Unexport helpers for fd/handle conversion"
This reverts commit 71a7974. These helper functions are needed for KFD to export and import DMABufs the right way without duplicating the tracking of DMABufs associated with GEM objects while ensuring that move notifier callbacks are working as intended. CC: Christian König <christian.koenig@amd.com> CC: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent ed6e4f0 commit 0514f63

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

drivers/gpu/drm/drm_prime.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf)
278278
}
279279
EXPORT_SYMBOL(drm_gem_dmabuf_release);
280280

281-
/*
281+
/**
282282
* drm_gem_prime_fd_to_handle - PRIME import function for GEM drivers
283283
* @dev: drm_device to import into
284284
* @file_priv: drm file-private structure
@@ -292,9 +292,9 @@ EXPORT_SYMBOL(drm_gem_dmabuf_release);
292292
*
293293
* Returns 0 on success or a negative error code on failure.
294294
*/
295-
static int drm_gem_prime_fd_to_handle(struct drm_device *dev,
296-
struct drm_file *file_priv, int prime_fd,
297-
uint32_t *handle)
295+
int drm_gem_prime_fd_to_handle(struct drm_device *dev,
296+
struct drm_file *file_priv, int prime_fd,
297+
uint32_t *handle)
298298
{
299299
struct dma_buf *dma_buf;
300300
struct drm_gem_object *obj;
@@ -360,6 +360,7 @@ static int drm_gem_prime_fd_to_handle(struct drm_device *dev,
360360
dma_buf_put(dma_buf);
361361
return ret;
362362
}
363+
EXPORT_SYMBOL(drm_gem_prime_fd_to_handle);
363364

364365
int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
365366
struct drm_file *file_priv)
@@ -408,7 +409,7 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,
408409
return dmabuf;
409410
}
410411

411-
/*
412+
/**
412413
* drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers
413414
* @dev: dev to export the buffer from
414415
* @file_priv: drm file-private structure
@@ -421,10 +422,10 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,
421422
* The actual exporting from GEM object to a dma-buf is done through the
422423
* &drm_gem_object_funcs.export callback.
423424
*/
424-
static int drm_gem_prime_handle_to_fd(struct drm_device *dev,
425-
struct drm_file *file_priv, uint32_t handle,
426-
uint32_t flags,
427-
int *prime_fd)
425+
int drm_gem_prime_handle_to_fd(struct drm_device *dev,
426+
struct drm_file *file_priv, uint32_t handle,
427+
uint32_t flags,
428+
int *prime_fd)
428429
{
429430
struct drm_gem_object *obj;
430431
int ret = 0;
@@ -506,6 +507,7 @@ static int drm_gem_prime_handle_to_fd(struct drm_device *dev,
506507

507508
return ret;
508509
}
510+
EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
509511

510512
int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
511513
struct drm_file *file_priv)
@@ -864,9 +866,9 @@ EXPORT_SYMBOL(drm_prime_get_contiguous_size);
864866
* @obj: GEM object to export
865867
* @flags: flags like DRM_CLOEXEC and DRM_RDWR
866868
*
867-
* This is the implementation of the &drm_gem_object_funcs.export functions
868-
* for GEM drivers using the PRIME helpers. It is used as the default for
869-
* drivers that do not set their own.
869+
* This is the implementation of the &drm_gem_object_funcs.export functions for GEM drivers
870+
* using the PRIME helpers. It is used as the default in
871+
* drm_gem_prime_handle_to_fd().
870872
*/
871873
struct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj,
872874
int flags)
@@ -962,9 +964,10 @@ EXPORT_SYMBOL(drm_gem_prime_import_dev);
962964
* @dev: drm_device to import into
963965
* @dma_buf: dma-buf object to import
964966
*
965-
* This is the implementation of the gem_prime_import functions for GEM
966-
* drivers using the PRIME helpers. It is the default for drivers that do
967-
* not set their own &drm_driver.gem_prime_import.
967+
* This is the implementation of the gem_prime_import functions for GEM drivers
968+
* using the PRIME helpers. Drivers can use this as their
969+
* &drm_driver.gem_prime_import implementation. It is used as the default
970+
* implementation in drm_gem_prime_fd_to_handle().
968971
*
969972
* Drivers must arrange to call drm_prime_gem_destroy() from their
970973
* &drm_gem_object_funcs.free hook when using this function.

include/drm/drm_prime.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,19 @@ enum dma_data_direction;
6060

6161
struct drm_device;
6262
struct drm_gem_object;
63+
struct drm_file;
6364

6465
/* core prime functions */
6566
struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,
6667
struct dma_buf_export_info *exp_info);
6768
void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
6869

70+
int drm_gem_prime_fd_to_handle(struct drm_device *dev,
71+
struct drm_file *file_priv, int prime_fd, uint32_t *handle);
72+
int drm_gem_prime_handle_to_fd(struct drm_device *dev,
73+
struct drm_file *file_priv, uint32_t handle, uint32_t flags,
74+
int *prime_fd);
75+
6976
/* helper functions for exporting */
7077
int drm_gem_map_attach(struct dma_buf *dma_buf,
7178
struct dma_buf_attachment *attach);

0 commit comments

Comments
 (0)