Revert "drm/prime: Unexport helpers for fd/handle conversion"
Subsystems (4)
Felix Kuehling
maintainerPATCH 1/6 Revert "drm/prime: Unexport helpers for fd/handle conversion"
This reverts commit 71a7974ac7019afeec105a54447ae1dc7216cbb3.
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.
--- drivers/gpu/drm/drm_prime.c | 33 ++++++++++++++++++--------------- include/drm/drm_prime.h | 7 +++++++ 2 files changed, 25 insertions(+), 15 deletions(-)
drivers/gpu/drm/drm_prime.c +18 -15
@@ -278,7 +278,7 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf) }EXPORT_SYMBOL (drm_gem_dmabuf_release); -/* +/** * drm_gem_prime_fd_to_handle - PRIME import function for GEM drivers * @dev: drm_device to import into * @file_priv: drm file-private structure
@@ -292,9 +292,9 @@ EXPORT_SYMBOL(drm_gem_dmabuf_release);* * Returns 0 on success or a negative error code on failure. */ -static int drm_gem_prime_fd_to_handle (struct drm_device *dev, -struct drm_file *file_priv,int prime_fd, -uint32_t *handle) +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd, +uint32_t *handle) {struct dma_buf *dma_buf;struct drm_gem_object *obj;
@@ -360,6 +360,7 @@ static int drm_gem_prime_fd_to_handle(struct drm_device *dev,dma_buf_put (dma_buf);return ret; } +EXPORT_SYMBOL (drm_gem_prime_fd_to_handle);int drm_prime_fd_to_handle_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv)
@@ -408,7 +409,7 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,return dmabuf; } -/* +/** * drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers * @dev: dev to export the buffer from * @file_priv: drm file-private structure
@@ -421,10 +422,10 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,* The actual exporting from GEM object to a dma-buf is done through the * &drm_gem_object_funcs.export callback. */ -static int drm_gem_prime_handle_to_fd (struct drm_device *dev, -struct drm_file *file_priv,uint32_t handle, -uint32_t flags, -int *prime_fd) +int drm_gem_prime_handle_to_fd (struct drm_device *dev, +struct drm_file *file_priv,uint32_t handle, +uint32_t flags, +int *prime_fd) {struct drm_gem_object *obj;int ret =0 ;
@@ -506,6 +507,7 @@ static int drm_gem_prime_handle_to_fd(struct drm_device *dev,return ret; } +EXPORT_SYMBOL (drm_gem_prime_handle_to_fd);int drm_prime_handle_to_fd_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv)
@@ -864,9 +866,9 @@ EXPORT_SYMBOL(drm_prime_get_contiguous_size);* @obj: GEM object to export * @flags: flags like DRM_CLOEXEC and DRM_RDWR * -* This is the implementation of the &drm_gem_object_funcs.export functions -* for GEM drivers using the PRIME helpers. It is used as the default for -* drivers that do not set their own. +* This is the implementation of the &drm_gem_object_funcs.export functions for GEM drivers +* using the PRIME helpers. It is used as the default in +* drm_gem_prime_handle_to_fd(). */ struct dma_buf *drm_gem_prime_export (struct drm_gem_object *obj,int flags)
@@ -962,9 +964,10 @@ EXPORT_SYMBOL(drm_gem_prime_import_dev);* @dev: drm_device to import into * @dma_buf: dma-buf object to import * -* This is the implementation of the gem_prime_import functions for GEM -* drivers using the PRIME helpers. It is the default for drivers that do -* not set their own &drm_driver.gem_prime_import. +* This is the implementation of the gem_prime_import functions for GEM drivers +* using the PRIME helpers. Drivers can use this as their +* &drm_driver.gem_prime_import implementation. It is used as the default +* implementation in drm_gem_prime_fd_to_handle(). * * Drivers must arrange to call drm_prime_gem_destroy() from their * &drm_gem_object_funcs.free hook when using this function.
include/drm/drm_prime.h +7 -0
@@ -60,12 +60,19 @@ enum dma_data_direction;struct drm_device ;struct drm_gem_object ; +struct drm_file ;/* core prime functions */ struct dma_buf *drm_gem_dmabuf_export (struct drm_device *dev,struct dma_buf_export_info *exp_info);void drm_gem_dmabuf_release (struct dma_buf *dma_buf); +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd,uint32_t *handle); +int drm_gem_prime_handle_to_fd (struct drm_device *dev, +struct drm_file *file_priv,uint32_t handle,uint32_t flags, +int *prime_fd); +/* helper functions for exporting */ int drm_gem_map_attach (struct dma_buf *dma_buf,struct dma_buf_attachment *attach);
Signature · 1 line
2.34.1
Felix Kuehling
maintainerPATCH 2/6 drm/amdkfd: Export DMABufs from KFD using GEM handles
Create GEM handles for exporting DMABufs using GEM-Prime APIs. The GEM handles are created in a drm_client_dev context to avoid exposing them in user mode contexts through a DMABuf import.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 11 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 5 +++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 33 +++++++++++++++---- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 +-- 4 files changed, 44 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +11 -0
@@ -142,6 +142,7 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) {int i;int last_valid_bit; +int ret;amdgpu_amdkfd_gpuvm_init_mem_limits ();
@@ -160,6 +161,12 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) .enable_mes = adev->enable_mes, }; + ret =drm_client_init (&adev->ddev, &adev->kfd.client,"kfd" ,NULL ); +if (ret) { +dev_err (adev->dev,"Failed to init DRM client: %d\n" , ret); +return ; + } +/* this is going to have a few of the MSBs set that we need to * clear */
@@ -198,6 +205,10 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) adev->kfd.init_complete =kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); +if (adev->kfd.init_complete) +drm_client_register (&adev->kfd.client); +else +drm_client_release (&adev->kfd.client); amdgpu_amdkfd_total_mem_size += adev->gmc.real_vram_size;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +5 -0
@@ -33,6 +33,7 @@#include <linux/mmu_notifier.h> #include <linux/memremap.h> #include <kgd_kfd_interface.h> +#include <drm/drm_client.h> #include "amdgpu_sync.h" #include "amdgpu_vm.h" #include "amdgpu_xcp.h"
@@ -83,6 +84,7 @@ struct kgd_mem {struct amdgpu_sync sync; +uint32_t gem_handle;bool aql_queue;bool is_imported; };
@@ -105,6 +107,9 @@ struct amdgpu_kfd_dev {/* HMM page migration MEMORY_DEVICE_PRIVATE mapping */ struct dev_pagemap pgmap; + +/* Client for KFD BO GEM handle allocations */ +struct drm_client_dev client; };enum kgd_engine_type {
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +26 -7
@@ -25,6 +25,7 @@#include <linux/pagemap.h> #include <linux/sched/mm.h> #include <linux/sched/task.h> +#include <linux/fdtable.h> #include <drm/ttm/ttm_tt.h> #include <drm/drm_exec.h>
@@ -806,13 +807,22 @@ kfd_mem_dmaunmap_attachment(struct kgd_mem *mem,static int kfd_mem_export_dmabuf (struct kgd_mem *mem) {if (!mem->dmabuf) { -struct dma_buf *ret =amdgpu_gem_prime_export ( - &mem->bo->tbo.base, +struct amdgpu_device *bo_adev; +struct dma_buf *dmabuf; +int r, fd; + + bo_adev =amdgpu_ttm_adev (mem->bo->tbo.bdev); + r =drm_gem_prime_handle_to_fd (&bo_adev->ddev, bo_adev->kfd.client.file, + mem->gem_handle, mem->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ? -DRM_RDWR :0 ); -if (IS_ERR (ret)) -return PTR_ERR (ret); - mem->dmabuf = ret; +DRM_RDWR :0 , &fd); +if (r) +return r; + dmabuf =dma_buf_get (fd); +close_fd (fd); +if (WARN_ON_ONCE (IS_ERR (dmabuf))) +return PTR_ERR (dmabuf); + mem->dmabuf = dmabuf; }return 0 ;
@@ -1778,6 +1788,9 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(pr_debug ("Failed to allow vma node access. ret %d\n" , ret); goto err_node_allow; } + ret =drm_gem_handle_create (adev->kfd.client.file, gobj, &(*mem)->gem_handle); +if (ret) + goto err_gem_handle_create; bo =gem_to_amdgpu_bo (gobj);if (bo_type == ttm_bo_type_sg) { bo->tbo.sg = sg;
@@ -1829,6 +1842,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( err_pin_bo: err_validate_bo:remove_kgd_mem_from_kfd_bo_list (*mem, avm->process_info); +drm_gem_handle_delete (adev->kfd.client.file, (*mem)->gem_handle); +err_gem_handle_create:drm_vma_node_revoke (&gobj->vma_node, drm_priv); err_node_allow:/* Don't unreserve system mem limit twice */
@@ -1941,8 +1956,12 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(/* Free the BO*/ drm_vma_node_revoke (&mem->bo->tbo.base.vma_node, drm_priv); -if (mem->dmabuf) +if (!mem->is_imported) +drm_gem_handle_delete (adev->kfd.client.file, mem->gem_handle); +if (mem->dmabuf) {dma_buf_put (mem->dmabuf); + mem->dmabuf =NULL ; + }mutex_destroy (&mem->lock);/* If this releases the last reference, it will end up calling
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -2
@@ -1855,8 +1855,8 @@ static uint32_t get_process_num_bos(struct kfd_process *p)return num_of_bos; } -static int criu_get_prime_handle (struct kgd_mem *mem,int flags, -u32 *shared_fd) +static int criu_get_prime_handle (struct kgd_mem *mem, +int flags,u32 *shared_fd) {struct dma_buf *dmabuf;int ret;
Signature · 1 line
2.34.1
Felix Kuehling
maintainerPATCH 3/6 drm/amdkfd: Import DMABufs for interop through DRM
In reply to Felix KuehlingUse drm_gem_prime_fd_to_handle to import DMABufs for interop. This ensures that a GEM handle is created on import and that obj->dma_buf will be set and remain set as long as the object is imported into KFD.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 9 ++- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 64 +++++++++++++------ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 15 ++--- 3 files changed, 52 insertions(+), 36 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +4 -5
@@ -314,11 +314,10 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *process_info, struct dma_fence **ef);int amdgpu_amdkfd_gpuvm_get_vm_fault_info (struct amdgpu_device *adev,struct kfd_vm_fault_info *info); -int amdgpu_amdkfd_gpuvm_import_dmabuf (struct amdgpu_device *adev, -struct dma_buf *dmabuf, -uint64_t va,void *drm_priv, -struct kgd_mem **mem,uint64_t *size, -uint64_t *mmap_offset); +int amdgpu_amdkfd_gpuvm_import_dmabuf_fd (struct amdgpu_device *adev,int fd, +uint64_t va,void *drm_priv, +struct kgd_mem **mem,uint64_t *size, +uint64_t *mmap_offset);int amdgpu_amdkfd_gpuvm_export_dmabuf (struct kgd_mem *mem,struct dma_buf **dmabuf);void amdgpu_amdkfd_debug_mem_fence (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +44 -20
94 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +4 -11
@@ -1564,16 +1564,11 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, {struct kfd_ioctl_import_dmabuf_args *args = data;struct kfd_process_device *pdd; -struct dma_buf *dmabuf;int idr_handle;uint64_t size;void *mem;int r; - dmabuf =dma_buf_get (args->dmabuf_fd); -if (IS_ERR (dmabuf)) -return PTR_ERR (dmabuf); -mutex_lock (&p->mutex); pdd =kfd_process_device_data_by_id (p, args->gpu_id);if (!pdd) {
@@ -1587,10 +1582,10 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, goto err_unlock; } - r =amdgpu_amdkfd_gpuvm_import_dmabuf (pdd->dev->adev, dmabuf, - args->va_addr, pdd->drm_priv, - (struct kgd_mem **)&mem, &size, -NULL ); + r =amdgpu_amdkfd_gpuvm_import_dmabuf_fd (pdd->dev->adev, args->dmabuf_fd, + args->va_addr, pdd->drm_priv, + (struct kgd_mem **)&mem, &size, +NULL );if (r) goto err_unlock;
@@ -1601,7 +1596,6 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, }mutex_unlock (&p->mutex); -dma_buf_put (dmabuf); args->handle =MAKE_HANDLE (args->gpu_id, idr_handle);
@@ -1612,7 +1606,6 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, pdd->drm_priv, NULL); err_unlock:mutex_unlock (&p->mutex); -dma_buf_put (dmabuf);return r; }
Signature · 1 line
2.34.1
Felix Kuehling
maintainerPATCH 4/6 drm/amdgpu: New VM state for evicted user BOs
In reply to Felix KuehlingCreate a new VM state to track user BOs that are in the system domain. In the next patch this will be used do conditionally re-validate them in amdgpu_vm_handle_moved.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 17 +++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +17 -0
@@ -233,6 +233,22 @@ static void amdgpu_vm_bo_invalidated(struct amdgpu_vm_bo_base *vm_bo)spin_unlock (&vm_bo->vm->status_lock); } +/** +* amdgpu_vm_bo_evicted_user - vm_bo is evicted +* +* @vm_bo: vm_bo which is evicted +* +* State for BOs used by user mode queues which are not at the location they +* should be. +*/ +static void amdgpu_vm_bo_evicted_user (struct amdgpu_vm_bo_base *vm_bo) +{ + vm_bo->moved = true; +spin_lock (&vm_bo->vm->status_lock); +list_move (&vm_bo->vm_status, &vm_bo->vm->evicted_user); +spin_unlock (&vm_bo->vm->status_lock); +} +/** * amdgpu_vm_bo_relocated - vm_bo is reloacted *
@@ -2195,6 +2211,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,for (i =0 ; i <AMDGPU_MAX_VMHUBS ; i++) vm->reserved_vmid[i] =NULL ;INIT_LIST_HEAD (&vm->evicted); +INIT_LIST_HEAD (&vm->evicted_user);INIT_LIST_HEAD (&vm->relocated);INIT_LIST_HEAD (&vm->moved);INIT_LIST_HEAD (&vm->idle);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4 -1
@@ -288,9 +288,12 @@ struct amdgpu_vm {/* Lock to protect vm_bo add/del/move on all lists of vm */ spinlock_t status_lock; -/* BOs who needs a validation */ +/* Per VM and PT BOs who needs a validation */ struct list_head evicted; +/* BOs for user mode queues that need a validation */ +struct list_head evicted_user; +/* PT BOs which relocated and their parent need an update */ struct list_head relocated;
Signature · 1 line
2.34.1
Felix Kuehling
maintainerPATCH 5/6 drm/amdgpu: Auto-validate DMABuf imports in compute VMs
In reply to Felix KuehlingDMABuf imports in compute VMs are not wrapped in a kgd_mem object on the process_info->kfd_bo_list. There is no explicit KFD API call to validate them or add eviction fences to them.
This patch automatically validates and fences dymanic DMABuf imports when they are added to a compute VM. Revalidation after evictions is handled in the VM code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 + .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 45 ++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 26 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 122 +++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 12 +- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 +- 8 files changed, 196 insertions(+), 34 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +3 -0
@@ -182,6 +182,9 @@ int amdgpu_queue_mask_bit_to_set_resource_bit(struct amdgpu_device *adev,struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create (u64 context,struct mm_struct *mm,struct svm_range_bo *svm_bo); +int amdgpu_amdkfd_bo_validate_and_fence (struct amdgpu_bo *bo, +uint32_t domain, +struct dma_fence *fence);#if defined(CONFIG_DEBUG_FS )int kfd_debugfs_kfd_mem_limits (struct seq_file *m,void *data);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +28 -17
122 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -3
@@ -952,10 +952,10 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, p->bytes_moved =0 ; p->bytes_moved_vis =0 ; - r =amdgpu_vm_validate_pt_bos (p->adev, &fpriv->vm, - amdgpu_cs_bo_validate, p); + r =amdgpu_vm_validate_evicted_bos (p->adev, &fpriv->vm,NULL , + amdgpu_cs_bo_validate, p);if (r) { -DRM_ERROR ("amdgpu_vm_validate_pt_bos() failed.\n" ); +DRM_ERROR ("amdgpu_vm_validate_evicted_bos() failed.\n" ); goto out_free_user_pages; }
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +4 -0
@@ -377,6 +377,10 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach)struct amdgpu_vm_bo_base *bo_base;int r; +/* FIXME: This should be after the "if", but needs a fix to make sure +* DMABuf imports are initialized in the right VM list. +*/ +amdgpu_vm_bo_invalidate (adev, bo, false);if (!bo->tbo.resource || bo->tbo.resource->mem_type ==TTM_PL_SYSTEM )return ;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +26 -0
@@ -187,6 +187,32 @@ static int amdgpu_gem_object_open(struct drm_gem_object *obj,else ++bo_va->ref_count;amdgpu_bo_unreserve (abo); + +/* Validate and add eviction fence to DMABuf imports with dynamic +* attachment in compute VMs. Re-validation will be done by +* amdgpu_vm_validate_evicted_bos and the fence will be updated by +* amdgpu_vm_fence_imports in amdgpu_amdkfd_gpuvm_restore_process_bos. +* +* Nested locking below for the case that a GEM object is opened in +* kfd_mem_export_dmabuf. Since the lock below is only taken for imports, +* but not for export, this is a different lock class that cannot lead to +* circular lock dependencies. +*/ +if (!vm->is_compute_context || !vm->process_info) +return 0 ; +if (!obj->import_attach || + !dma_buf_is_dynamic (obj->import_attach->dmabuf)) +return 0 ; +mutex_lock_nested (&vm->process_info->lock,1 ); +if (!WARN_ON (!vm->process_info->eviction_fence)) { + r =amdgpu_amdkfd_bo_validate_and_fence (abo,AMDGPU_GEM_DOMAIN_GTT , + &vm->process_info->eviction_fence->base); +if (r) +dev_warn (adev->dev,"%d: validate_and_fence failed: %d\n" , + vm->task_info.pid, r); + } +mutex_unlock (&vm->process_info->lock); +return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +115 -7
162 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +9 -3
@@ -437,9 +437,12 @@ int amdgpu_vm_lock_pd(struct amdgpu_vm *vm, struct drm_exec *exec, unsigned int num_fences);bool amdgpu_vm_ready (struct amdgpu_vm *vm);uint64_t amdgpu_vm_generation (struct amdgpu_device *adev,struct amdgpu_vm *vm); -int amdgpu_vm_validate_pt_bos (struct amdgpu_device *adev,struct amdgpu_vm *vm, -int (*callback)(void *p,struct amdgpu_bo *bo), -void *param); +int amdgpu_vm_validate_evicted_bos (struct amdgpu_device *adev, +struct amdgpu_vm *vm, +struct ww_acquire_ctx *ticket, +int (*callback)(void *p, +struct amdgpu_bo *bo), +void *param);int amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job,bool need_pipe_sync);int amdgpu_vm_update_pdes (struct amdgpu_device *adev,struct amdgpu_vm *vm,bool immediate);
@@ -449,6 +452,9 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,int amdgpu_vm_handle_moved (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct ww_acquire_ctx *ticket); +int amdgpu_vm_fence_imports (struct amdgpu_vm *vm, +struct ww_acquire_ctx *ticket, +struct dma_fence *fence); int amdgpu_vm_flush_compute_tlb(struct amdgpu_device *adev, struct amdgpu_vm *vm, uint32_t flush_type,
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +8 -4
@@ -1557,9 +1557,11 @@ static int svm_range_reserve_bos(struct svm_validate_context *ctx, bool intr) goto unreserve_out; } - r =amdgpu_vm_validate_pt_bos (pdd->dev->adev, -drm_priv_to_vm (pdd->drm_priv), - svm_range_bo_validate,NULL ); + r =amdgpu_vm_validate_evicted_bos (pdd->dev->adev, +drm_priv_to_vm (pdd->drm_priv), +NULL , + svm_range_bo_validate, +NULL );if (r) {pr_debug ("failed %d validate pt bos\n" , r); goto unreserve_out;
@@ -1676,7 +1678,9 @@ static int svm_range_validate_and_map(struct mm_struct *mm, goto free_ctx; } -svm_range_reserve_bos (ctx, intr); + r =svm_range_reserve_bos (ctx, intr); +if (r) + goto free_ctx; p = container_of(prange->svms, struct kfd_process, svms); owner = kfd_svm_page_owner(p, find_first_bit(ctx->bitmap,
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH 5/6] drm/amdgpu: Auto-validate DMABuf imports in compute VMs
kernel test robot noticed the following build errors:
Hi Felix,
kernel test robot noticed the following build errors:
[auto build test ERROR on next-20231201]
[cannot apply to drm-misc/drm-misc-next drm/drm-next drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.7-rc3 v6.7-rc2 v6.7-rc1 v6.7-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Felix-Kuehling/drm-amdkfd-Export-DMABufs-from-KFD-using-GEM-handles/20231202-073833 base: next-20231201 patch link: https://lore.kernel.org/r/20231201233438.1709981-5-Felix.Kuehling%40amd.com patch subject: [PATCH 5/6] drm/amdgpu: Auto-validate DMABuf imports in compute VMs config: powerpc-randconfig-001-20231203 (https://download.01.org/0day-ci/archive/20231205/[email protected]/config) compiler: powerpc-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
powerpc-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_gem.o: in function `amdgpu_gem_object_open':
>> amdgpu_gem.c:(.text.amdgpu_gem_object_open+0x150): undefined reference to `amdgpu_amdkfd_bo_validate_and_fence'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 5/6] drm/amdgpu: Auto-validate DMABuf imports in compute VMs
In reply to Felix Kuehlingkernel test robot noticed the following build errors:
Hi Felix,
kernel test robot noticed the following build errors:
[auto build test ERROR on next-20231201]
[cannot apply to drm-misc/drm-misc-next drm/drm-next drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.7-rc3 v6.7-rc2 v6.7-rc1 v6.7-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Felix-Kuehling/drm-amdkfd-Export-DMABufs-from-KFD-using-GEM-handles/20231202-073833 base: next-20231201 patch link: https://lore.kernel.org/r/20231201233438.1709981-5-Felix.Kuehling%40amd.com patch subject: [PATCH 5/6] drm/amdgpu: Auto-validate DMABuf imports in compute VMs config: x86_64-randconfig-161-20231203 (https://download.01.org/0day-ci/archive/20231205/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
ld: drivers/gpu/drm/amd/amdgpu/amdgpu_gem.o: in function `amdgpu_gem_object_open':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:208: undefined reference to `amdgpu_amdkfd_bo_validate_and_fence'
vim +208 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
156
157 /*
158 * Call from drm_gem_handle_create which appear in both new and open ioctl
159 * case.
160 */
161 static int amdgpu_gem_object_open(struct drm_gem_object *obj,
162 struct drm_file *file_priv)
163 {
164 struct amdgpu_bo *abo = gem_to_amdgpu_bo(obj);
165 struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
166 struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
167 struct amdgpu_vm *vm = &fpriv->vm;
168 struct amdgpu_bo_va *bo_va;
169 struct mm_struct *mm;
170 int r;
171
172 mm = amdgpu_ttm_tt_get_usermm(abo->tbo.ttm);
173 if (mm && mm != current->mm)
174 return -EPERM;
175
176 if (abo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID &&
177 abo->tbo.base.resv != vm->root.bo->tbo.base.resv)
178 return -EPERM;
179
180 r = amdgpu_bo_reserve(abo, false);
181 if (r)
182 return r;
183
184 bo_va = amdgpu_vm_bo_find(vm, abo);
185 if (!bo_va)
186 bo_va = amdgpu_vm_bo_add(adev, vm, abo);
187 else
188 ++bo_va->ref_count;
189 amdgpu_bo_unreserve(abo);
190
191 /* Validate and add eviction fence to DMABuf imports with dynamic
192 * attachment in compute VMs. Re-validation will be done by
193 * amdgpu_vm_validate_evicted_bos and the fence will be updated by
194 * amdgpu_vm_fence_imports in amdgpu_amdkfd_gpuvm_restore_process_bos.
195 *
196 * Nested locking below for the case that a GEM object is opened in
197 * kfd_mem_export_dmabuf. Since the lock below is only taken for imports,
198 * but not for export, this is a different lock class that cannot lead to
199 * circular lock dependencies.
200 */
201 if (!vm->is_compute_context || !vm->process_info)
202 return 0;
203 if (!obj->import_attach ||
204 !dma_buf_is_dynamic(obj->import_attach->dmabuf))
205 return 0;
206 mutex_lock_nested(&vm->process_info->lock, 1);
207 if (!WARN_ON(!vm->process_info->eviction_fence)) {
> 208 r = amdgpu_amdkfd_bo_validate_and_fence(abo, AMDGPU_GEM_DOMAIN_GTT,
209 &vm->process_info->eviction_fence->base);
210 if (r)
211 dev_warn(adev->dev, "%d: validate_and_fence failed: %d\n",
212 vm->task_info.pid, r);
213 }
214 mutex_unlock(&vm->process_info->lock);
215
216 return 0;
217 }
218
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Felix Kuehling
maintainerPATCH 6/6 drm/amdkfd: Bump KFD ioctl version
In reply to Felix KuehlingThis is not strictly a change in the IOCTL API. This version bump is meant to indicate to user mode the presence of a number of changes and fixes that enable the management of VA mappings in compute VMs using the GEM_VA ioctl for DMABufs exported from KFD.
--- include/uapi/linux/kfd_ioctl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/linux/kfd_ioctl.h +2 -1
@@ -40,9 +40,10 @@* - 1.12 - Add DMA buf export ioctl * - 1.13 - Add debugger API * - 1.14 - Update kfd_event_data +* - 1.15 - Enable managing mappings in compute VMs with GEM_VA ioctl */ #define KFD_IOCTL_MAJOR_VERSION 1 -#define KFD_IOCTL_MINOR_VERSION 14 +#define KFD_IOCTL_MINOR_VERSION 15struct kfd_ioctl_get_version_args {__u32 major_version;/* from KFD */
Signature · 1 line
2.34.1
Felix Kuehling
maintainerHi Alex,
I'm about to push patches 1-3 to the rebased amd-staging-drm-next. It would be good to get patch 1 into drm-fixes so that Linux 6.6 will be the only kernel without these prime helpers. That would minimize the hassle for DKMS driver installations on future distros.
Thanks,
Felix
Quoted 133 lines · Felix Kuehling
This reverts commit
71a7974ac7019afeec105a54447ae1dc7216cbb3.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.
Acked-by Christian König <[email protected]>Acked-by Daniel Vetter <[email protected]>Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/drm_prime.c | 33 ++++++++++++++++++--------------- include/drm/drm_prime.h | 7 +++++++ 2 files changed, 25 insertions(+), 15 deletions(-)drivers/gpu/drm/drm_prime.c +18
-15@@ -278,7 +278,7 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf) }EXPORT_SYMBOL (drm_gem_dmabuf_release); -/* +/** * drm_gem_prime_fd_to_handle - PRIME import function for GEM drivers * @dev: drm_device to import into * @file_priv: drm file-private structure @@ -292,9 +292,9 @@ EXPORT_SYMBOL(drm_gem_dmabuf_release);* * Returns 0 on success or a negative error code on failure. */ -static int drm_gem_prime_fd_to_handle (struct drm_device *dev, -struct drm_file *file_priv,int prime_fd, -uint32_t *handle) +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd, +uint32_t *handle) {struct dma_buf *dma_buf;struct drm_gem_object *obj;@@ -360,6 +360,7 @@ static int drm_gem_prime_fd_to_handle(struct drm_device *dev,dma_buf_put (dma_buf);return ret; } +EXPORT_SYMBOL (drm_gem_prime_fd_to_handle);int drm_prime_fd_to_handle_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv)@@ -408,7 +409,7 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,return dmabuf; } -/* +/** * drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers * @dev: dev to export the buffer from * @file_priv: drm file-private structure @@ -421,10 +422,10 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,* The actual exporting from GEM object to a dma-buf is done through the * &drm_gem_object_funcs.export callback. */ -static int drm_gem_prime_handle_to_fd (struct drm_device *dev, -struct drm_file *file_priv,uint32_t handle, -uint32_t flags, -int *prime_fd) +int drm_gem_prime_handle_to_fd (struct drm_device *dev, +struct drm_file *file_priv,uint32_t handle, +uint32_t flags, +int *prime_fd) {struct drm_gem_object *obj;int ret =0 ;@@ -506,6 +507,7 @@ static int drm_gem_prime_handle_to_fd(struct drm_device *dev,return ret; } +EXPORT_SYMBOL (drm_gem_prime_handle_to_fd);int drm_prime_handle_to_fd_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv)@@ -864,9 +866,9 @@ EXPORT_SYMBOL(drm_prime_get_contiguous_size);* @obj: GEM object to export * @flags: flags like DRM_CLOEXEC and DRM_RDWR * -* This is the implementation of the &drm_gem_object_funcs.export functions -* for GEM drivers using the PRIME helpers. It is used as the default for -* drivers that do not set their own. +* This is the implementation of the &drm_gem_object_funcs.export functions for GEM drivers +* using the PRIME helpers. It is used as the default in +* drm_gem_prime_handle_to_fd(). */ struct dma_buf *drm_gem_prime_export (struct drm_gem_object *obj,int flags)@@ -962,9 +964,10 @@ EXPORT_SYMBOL(drm_gem_prime_import_dev);* @dev: drm_device to import into * @dma_buf: dma-buf object to import * -* This is the implementation of the gem_prime_import functions for GEM -* drivers using the PRIME helpers. It is the default for drivers that do -* not set their own &drm_driver.gem_prime_import. +* This is the implementation of the gem_prime_import functions for GEM drivers +* using the PRIME helpers. Drivers can use this as their +* &drm_driver.gem_prime_import implementation. It is used as the default +* implementation in drm_gem_prime_fd_to_handle(). * * Drivers must arrange to call drm_prime_gem_destroy() from their * &drm_gem_object_funcs.free hook when using this function. include/drm/drm_prime.h +7
-0@@ -60,12 +60,19 @@ enum dma_data_direction;struct drm_device ;struct drm_gem_object ; +struct drm_file ;/* core prime functions */ struct dma_buf *drm_gem_dmabuf_export (struct drm_device *dev,struct dma_buf_export_info *exp_info);void drm_gem_dmabuf_release (struct dma_buf *dma_buf); +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd,uint32_t *handle); +int drm_gem_prime_handle_to_fd (struct drm_device *dev, +struct drm_file *file_priv,uint32_t handle,uint32_t flags, +int *prime_fd); +/* helper functions for exporting */ int drm_gem_map_attach (struct dma_buf *dma_buf,struct dma_buf_attachment *attach);
Deucher, Alexander
maintainer[AMD Official Use Only - General]
Quoted 11 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Friday, December 1, 2023 6:40 PM
To: [email protected]; [email protected]; Deucher, Alexander <[email protected]>
Cc: Daniel Vetter <[email protected]>; Koenig, Christian <[email protected]>; Thomas Zimmermann <[email protected]>
Subject: Re: [PATCH 1/6] Revert "drm/prime: Unexport helpers for fd/handle conversion"
Quoted 6 lines
Hi Alex,
I'm about to push patches 1-3 to the rebased amd-staging-drm-next. It would be good to get patch 1 into drm-fixes so that Linux 6.6 will be the only kernel without these prime helpers. That would minimize the hassle for DKMS driver installations on future distros.
Alex
Quoted 152 lines
Thanks,
Felixdrivers/gpu/drm/drm_prime.c void drm_gem_dmabuf_release(struct dma_buf
Quoted 21 lines · Felix Kuehling
This reverts commit
71a7974ac7019afeec105a54447ae1dc7216cbb3.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.
Acked-by Christian König <[email protected]>Acked-by Daniel Vetter <[email protected]>Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/drm_prime.c | 33 ++++++++++++++++++--------------- include/drm/drm_prime.h | 7 +++++++ 2 files changed, 25 insertions(+), 15 deletions(-)drivers/gpu/drm/drm_prime.c +0
-0@@ -278,7 +278,7 @@ void drm_gem_dmabuf_release(struct dma_buf
*dma_buf)drivers/gpu/drm/drm_prime.c static int drm_gem_prime_fd_to_handle(struct
Quoted 22 lines
drivers/gpu/drm/drm_prime.c +1
-1}EXPORT_SYMBOL (drm_gem_dmabuf_release); -/* +/** * drm_gem_prime_fd_to_handle - PRIME import function for GEM drivers * @dev: drm_device to import into * @file_priv: drm file-private structure @@ -292,9 +292,9 @@ EXPORT_SYMBOL(drm_gem_dmabuf_release); * * Returns 0 on success or a negative error code on failure. */drivers/gpu/drm/drm_prime.c +3
-3-static int drm_gem_prime_fd_to_handle (struct drm_device *dev, -struct drm_file *file_priv,int prime_fd, -uint32_t *handle) +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd, +uint32_t *handle) {struct dma_buf *dma_buf;struct drm_gem_object *obj;@@ -360,6 +360,7 @@ static int drm_gem_prime_fd_to_handle(struct
drm_device*dev,drivers/gpu/drm/drm_prime.c static struct dma_buf
Quoted 8 lines
drivers/gpu/drm/drm_prime.c +1
-0dma_buf_put (dma_buf);return ret; } +EXPORT_SYMBOL (drm_gem_prime_fd_to_handle);int drm_prime_fd_to_handle_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv)@@ -408,7 +409,7 @@ static struct dma_buf*export_and_register_object(struct
drm_device*dev,drivers/gpu/drm/drm_prime.c
Quoted 33 lines
drivers/gpu/drm/drm_prime.c +1
-1return dmabuf; } -/* +/** * drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers * @dev: dev to export the buffer from * @file_priv: drm file-private structure @@ -421,10 +422,10 @@ static struct
dma_buf*export_and_register_object(structdrm_device*dev,
* The actual exporting from GEM object to a dma-buf is done through the
* &drm_gem_object_funcs.export callback.
*/drivers/gpu/drm/drm_prime.c +5
-4-static int drm_gem_prime_handle_to_fd (struct drm_device *dev, -struct drm_file *file_priv,uint32_t handle, -uint32_t flags, -int *prime_fd) +int drm_gem_prime_handle_to_fd (struct drm_device *dev, +struct drm_file *file_priv,uint32_t handle, +uint32_t flags, +int *prime_fd) {struct drm_gem_object *obj;int ret =0 ;@@ -506,6 +507,7 @@ static int drm_gem_prime_handle_to_fd(structdrm_device *dev, return ret; } +EXPORT_SYMBOL (drm_gem_prime_handle_to_fd); int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,struct
drm_file*file_priv)drivers/gpu/drm/drm_prime.c +0
-0@@ -864,9 +866,9 @@
EXPORT_SYMBOL(drm_prime_get_contiguous_size);Quoted 42 lines
drivers/gpu/drm/drm_prime.c +0
-1* @obj: GEM object to export * @flags: flags like DRM_CLOEXEC and DRM_RDWR * -* This is the implementation of the &drm_gem_object_funcs.export functions
- * for GEM drivers using the PRIME helpers. It is used as the default for
- * drivers that do not set their own.
+ * This is the implementation of the &drm_gem_object_funcs.export
+ functions for GEM drivers
+ * using the PRIME helpers. It is used as the default in
+ *drm_gem_prime_handle_to_fd().
*/
structdma_buf*drm_gem_prime_export(structdrm_gem_object*obj,
int flags)drivers/gpu/drm/drm_prime.c +0
-1@@ -962,9 +964,10 @@ EXPORT_SYMBOL(drm_gem_prime_import_dev);* @dev: drm_device to import into * @dma_buf: dma-buf object to import * -* This is the implementation of the gem_prime_import functions for GEM
- * drivers using the PRIME helpers. It is the default for drivers that do
- * not set their own &drm_driver.gem_prime_import.
+ * This is the implementation of thegem_prime_importfunctions for
+ GEM drivers
+ * using the PRIME helpers. Drivers can use this as their
+ * &drm_driver.gem_prime_import implementation. It is used as the
+ default
+ * implementation indrm_gem_prime_fd_to_handle().
*
* Drivers must arrange to calldrm_prime_gem_destroy()from their
* &drm_gem_object_funcs.free hook when using this function.include/drm/drm_prime.h index renamed from include/drm/drm_prime.h +0
-0
a7abf9f3e697..2a1d01e5b56b100644include/drm/drm_prime.h +1
-0@@ -60,12 +60,19 @@ enum dma_data_direction;struct drm_device ;struct drm_gem_object ; +struct drm_file ;include/drm/drm_prime.h enum dma_data_direction; · line 73
Quoted 10 lines
include/drm/drm_prime.h +4
-0/* core prime functions */ struct dma_buf *drm_gem_dmabuf_export (struct drm_device *dev,struct dma_buf_export_info *exp_info);void drm_gem_dmabuf_release (struct dma_buf *dma_buf); +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd,uint32_t +*handle); int drm_gem_prime_handle_to_fd(struct drm_device *dev, + struct drm_file *file_priv, uint32_t handle,
uint32_tflags,Quoted 5 lines
include/drm/drm_prime.h +2
-0+ int *prime_fd); +/* helper functions for exporting */ int drm_gem_map_attach (struct dma_buf *dma_buf,struct dma_buf_attachment *attach);
Felix Kuehling
maintainerQuoted 13 lines · Alexander
[AMD Official Use Only - General]
Quoted 11 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Friday, December 1, 2023 6:40 PM
To: [email protected]; [email protected]; Deucher, Alexander <[email protected]>
Cc: Daniel Vetter <[email protected]>; Koenig, Christian <[email protected]>; Thomas Zimmermann <[email protected]>
Subject: Re: [PATCH 1/6] Revert "drm/prime: Unexport helpers for fd/handle conversion"
Quoted 8 lines
Quoted 6 lines
Hi Alex,
I'm about to push patches 1-3 to the rebased amd-staging-drm-next. It would be good to get patch 1 into drm-fixes so that Linux 6.6 will be the only kernel without these prime helpers. That would minimize the hassle for DKMS driver installations on future distros.
Thank you, all! I also saw Sasha Levin is backporting it to 6.6.
Cheers,
Felix
Quoted 154 lines
Alex
Quoted 151 lines
Thanks,
Felixdrivers/gpu/drm/drm_prime.c void drm_gem_dmabuf_release(struct dma_buf
Quoted 21 lines · Felix Kuehling
This reverts commit
71a7974ac7019afeec105a54447ae1dc7216cbb3.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.
Acked-by Christian König <[email protected]>Acked-by Daniel Vetter <[email protected]>Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/drm_prime.c | 33 ++++++++++++++++++--------------- include/drm/drm_prime.h | 7 +++++++ 2 files changed, 25 insertions(+), 15 deletions(-)drivers/gpu/drm/drm_prime.c +0
-0@@ -278,7 +278,7 @@ void drm_gem_dmabuf_release(struct dma_buf
*dma_buf)drivers/gpu/drm/drm_prime.c static int drm_gem_prime_fd_to_handle(struct
Quoted 22 lines
drivers/gpu/drm/drm_prime.c +1
-1}EXPORT_SYMBOL (drm_gem_dmabuf_release); -/* +/** * drm_gem_prime_fd_to_handle - PRIME import function for GEM drivers * @dev: drm_device to import into * @file_priv: drm file-private structure @@ -292,9 +292,9 @@ EXPORT_SYMBOL(drm_gem_dmabuf_release); * * Returns 0 on success or a negative error code on failure. */drivers/gpu/drm/drm_prime.c +3
-3-static int drm_gem_prime_fd_to_handle (struct drm_device *dev, -struct drm_file *file_priv,int prime_fd, -uint32_t *handle) +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd, +uint32_t *handle) {struct dma_buf *dma_buf;struct drm_gem_object *obj;@@ -360,6 +360,7 @@ static int drm_gem_prime_fd_to_handle(struct
drm_device*dev,drivers/gpu/drm/drm_prime.c static struct dma_buf
Quoted 8 lines
drivers/gpu/drm/drm_prime.c +1
-0dma_buf_put (dma_buf);return ret; } +EXPORT_SYMBOL (drm_gem_prime_fd_to_handle);int drm_prime_fd_to_handle_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv)@@ -408,7 +409,7 @@ static struct dma_buf*export_and_register_object(struct
drm_device*dev,drivers/gpu/drm/drm_prime.c
Quoted 33 lines
drivers/gpu/drm/drm_prime.c +1
-1return dmabuf; } -/* +/** * drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers * @dev: dev to export the buffer from * @file_priv: drm file-private structure @@ -421,10 +422,10 @@ static struct
dma_buf*export_and_register_object(structdrm_device*dev,
* The actual exporting from GEM object to a dma-buf is done through the
* &drm_gem_object_funcs.export callback.
*/drivers/gpu/drm/drm_prime.c +5
-4-static int drm_gem_prime_handle_to_fd (struct drm_device *dev, -struct drm_file *file_priv,uint32_t handle, -uint32_t flags, -int *prime_fd) +int drm_gem_prime_handle_to_fd (struct drm_device *dev, +struct drm_file *file_priv,uint32_t handle, +uint32_t flags, +int *prime_fd) {struct drm_gem_object *obj;int ret =0 ;@@ -506,6 +507,7 @@ static int drm_gem_prime_handle_to_fd(structdrm_device *dev, return ret; } +EXPORT_SYMBOL (drm_gem_prime_handle_to_fd); int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,struct
drm_file*file_priv)drivers/gpu/drm/drm_prime.c +0
-0@@ -864,9 +866,9 @@
EXPORT_SYMBOL(drm_prime_get_contiguous_size);Quoted 42 lines
drivers/gpu/drm/drm_prime.c +0
-1* @obj: GEM object to export * @flags: flags like DRM_CLOEXEC and DRM_RDWR * -* This is the implementation of the &drm_gem_object_funcs.export functions
- * for GEM drivers using the PRIME helpers. It is used as the default for
- * drivers that do not set their own.
+ * This is the implementation of the &drm_gem_object_funcs.export
+ functions for GEM drivers
+ * using the PRIME helpers. It is used as the default in
+ *drm_gem_prime_handle_to_fd().*/struct
dma_buf*drm_gem_prime_export(structdrm_gem_object*obj,
int flags)drivers/gpu/drm/drm_prime.c +0
-1@@ -962,9 +964,10 @@ EXPORT_SYMBOL(drm_gem_prime_import_dev);* @dev: drm_device to import into * @dma_buf: dma-buf object to import * -* This is the implementation of the gem_prime_import functions for GEM
- * drivers using the PRIME helpers. It is the default for drivers that do
- * not set their own &drm_driver.gem_prime_import.
+ * This is the implementation of thegem_prime_importfunctions for
+ GEM drivers
+ * using the PRIME helpers. Drivers can use this as their
+ * &drm_driver.gem_prime_import implementation. It is used as the
+ default
+ * implementation indrm_gem_prime_fd_to_handle().
*
* Drivers must arrange to calldrm_prime_gem_destroy()from their
* &drm_gem_object_funcs.free hook when using this function.include/drm/drm_prime.h index renamed from include/drm/drm_prime.h +0
-0
a7abf9f3e697..2a1d01e5b56b100644include/drm/drm_prime.h +1
-0@@ -60,12 +60,19 @@ enum dma_data_direction;struct drm_device ;struct drm_gem_object ; +struct drm_file ;include/drm/drm_prime.h enum dma_data_direction; · line 73
Quoted 10 lines
include/drm/drm_prime.h +4
-0/* core prime functions */ struct dma_buf *drm_gem_dmabuf_export (struct drm_device *dev,struct dma_buf_export_info *exp_info);void drm_gem_dmabuf_release (struct dma_buf *dma_buf); +int drm_gem_prime_fd_to_handle (struct drm_device *dev, +struct drm_file *file_priv,int prime_fd,uint32_t +*handle); int drm_gem_prime_handle_to_fd(struct drm_device *dev, + struct drm_file *file_priv, uint32_t handle,
uint32_tflags,Quoted 5 lines
include/drm/drm_prime.h +2
-0+ int *prime_fd); +/* helper functions for exporting */ int drm_gem_map_attach (struct dma_buf *dma_buf,struct dma_buf_attachment *attach);