[PATCH 5/5] drm/amdgpu: expand mapping ioctl to return fence to UMD by using syncfile
Chunming Zhou
David1.Zhou at amd.com
Tue Sep 12 10:23:47 UTC 2017
Change-Id: I88e56d34ec5e90fe8001e73d52e893a38938361e
Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 24 +++++++++++++++++++-----
include/uapi/drm/amdgpu_drm.h | 4 +++-
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 973c0f0..bf37279 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -27,6 +27,7 @@
*/
#include <linux/ktime.h>
#include <linux/pagemap.h>
+#include <linux/sync_file.h>
#include <drm/drmP.h>
#include <drm/amdgpu_drm.h>
#include "amdgpu.h"
@@ -693,7 +694,8 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
struct amdgpu_vm *vm,
struct amdgpu_bo_va *bo_va,
struct list_head *list,
- uint32_t operation)
+ uint32_t operation,
+ int *sf_fd)
{
int r;
@@ -709,9 +711,18 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
goto error;
if (operation == AMDGPU_VA_OP_MAP ||
- operation == AMDGPU_VA_OP_REPLACE)
- r = amdgpu_vm_bo_update(adev, bo_va, false);
+ operation == AMDGPU_VA_OP_REPLACE) {
+ int fd;
+ struct sync_file *sync_file;
+ r = amdgpu_vm_bo_update(adev, bo_va, false);
+ sync_file = sync_file_create(bo_va->last_pt_update);
+ if (!sync_file)
+ goto error;
+ fd = get_unused_fd_flags(O_CLOEXEC);
+ fd_install(fd, sync_file->file);
+ *sf_fd = fd;
+ }
error:
if (r && r != -ERESTARTSYS)
DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
@@ -737,6 +748,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
struct ww_acquire_ctx ticket;
struct list_head list, duplicates;
uint64_t va_flags;
+ int sf_fd;
int r = 0;
if (args->va_address < AMDGPU_VA_RESERVED_SIZE) {
@@ -839,9 +851,11 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
default:
break;
}
- if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE) && !amdgpu_vm_debug)
+ if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE) && !amdgpu_vm_debug) {
amdgpu_gem_va_update_vm(adev, &fpriv->vm, bo_va, &list,
- args->operation);
+ args->operation, &sf_fd);
+ args->sf_fd = sf_fd;
+ }
error_backoff:
ttm_eu_backoff_reservation(&ticket, &list);
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index cf3fb62..6b97d33 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -487,7 +487,9 @@ struct drm_amdgpu_gem_op {
struct drm_amdgpu_gem_va {
/** GEM object handle */
__u32 handle;
- __u32 _pad;
+ /** sf_fd is an OUTPUT from syncfile, it's present to mapping completion
+ */
+ int32_t sf_fd;
/** AMDGPU_VA_OP_* */
__u32 operation;
/** AMDGPU_VM_PAGE_* */
--
1.9.1
More information about the amd-gfx
mailing list