diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/2764-drm-amdkfd-Expose-HDP-registers-to-user-space.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/2764-drm-amdkfd-Expose-HDP-registers-to-user-space.patch | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/2764-drm-amdkfd-Expose-HDP-registers-to-user-space.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/2764-drm-amdkfd-Expose-HDP-registers-to-user-space.patch new file mode 100644 index 00000000..6c88ab52 --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/2764-drm-amdkfd-Expose-HDP-registers-to-user-space.patch @@ -0,0 +1,126 @@ +From 556857cd366a6527c5a42d897b16d7990247e65d Mon Sep 17 00:00:00 2001 +From: Oak Zeng <Oak.Zeng@amd.com> +Date: Thu, 11 Apr 2019 14:43:39 -0500 +Subject: [PATCH 2764/2940] drm/amdkfd: Expose HDP registers to user space + +Introduce a new memory type (KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP) and +expose mmio page of HDP registers to user space through this new +memory type. + +v2: moved remapped hdp regs to adev struct +v3: rename the new memory type to ALLOC_MEM_FLAGS_MMIO_REMAP +v4: use more generic function name +v5: Fail remapped mmio allocation for asics before gfx9 + +Change-Id: If5ac13c46ea7fbd2194ddc8b2ece26ef4f76c330 +Signed-off-by: Oak Zeng <Oak.Zeng@amd.com> +Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 7 +++++++ + drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 ++ + drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 7 ++++--- + drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 ++++++ + drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 1 + + include/uapi/linux/kfd_ioctl.h | 1 + + 6 files changed, 21 insertions(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +index c8cef41926ce..6cd2054d4713 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +@@ -494,6 +494,13 @@ uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd) + return usage; + } + ++uint64_t amdgpu_amdkfd_get_mmio_remap_phys_addr(struct kgd_dev *kgd) ++{ ++ struct amdgpu_device *adev = (struct amdgpu_device *)kgd; ++ ++ return adev->rmmio_remap.bus_addr; ++} ++ + int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine, + uint32_t vmid, uint64_t gpu_addr, + uint32_t *ib_cmd, uint32_t ib_len) +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +index b4a0ddaabea7..4939c3c5e610 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +@@ -158,6 +158,8 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd, + uint32_t *flags); + uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd); + ++uint64_t amdgpu_amdkfd_get_mmio_remap_phys_addr(struct kgd_dev *kgd); ++ + #define read_user_wptr(mmptr, wptr, dst) \ + ({ \ + bool valid = false; \ +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +index c0bdf560c033..21fb0eebc240 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +@@ -1222,7 +1222,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( + if (!offset || !*offset) + return -EINVAL; + user_addr = *offset; +- } else if (flags & ALLOC_MEM_FLAGS_DOORBELL) { ++ } else if (flags & (ALLOC_MEM_FLAGS_DOORBELL | ++ ALLOC_MEM_FLAGS_MMIO_REMAP)) { + domain = AMDGPU_GEM_DOMAIN_GTT; + alloc_domain = AMDGPU_GEM_DOMAIN_CPU; + bo_type = ttm_bo_type_sg; +@@ -1416,8 +1417,8 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( + /* Free the sync object */ + amdgpu_sync_free(&mem->sync); + +- /* If the SG is not NULL, it's one we created for a doorbell +- * BO. We need to free it. ++ /* If the SG is not NULL, it's one we created for a doorbell or mmio ++ * remap BO. We need to free it. + */ + if (mem->bo->tbo.sg) { + sg_free_table(mem->bo->tbo.sg); +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +index 49d4f3cf5afd..4de6eb6779d4 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +@@ -1303,6 +1303,12 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, + if (args->size != kfd_doorbell_process_slice(dev)) + return -EINVAL; + offset = kfd_get_process_doorbells(dev, p); ++ } else if (flags & KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP) { ++ if (args->size != PAGE_SIZE) ++ return -EINVAL; ++ offset = amdgpu_amdkfd_get_mmio_remap_phys_addr(dev->kgd); ++ if (!offset) ++ return -ENOMEM; + } + + mutex_lock(&p->mutex); +diff --git a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h +index 681af275e9f4..fca84236d847 100644 +--- a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h ++++ b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h +@@ -161,6 +161,7 @@ struct tile_config { + #define ALLOC_MEM_FLAGS_GTT (1 << 1) + #define ALLOC_MEM_FLAGS_USERPTR (1 << 2) + #define ALLOC_MEM_FLAGS_DOORBELL (1 << 3) ++#define ALLOC_MEM_FLAGS_MMIO_REMAP (1 << 4) + + /* + * Allocation flags attributes/access options. +diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h +index ba28ac7ae892..f273d05708b6 100644 +--- a/include/uapi/linux/kfd_ioctl.h ++++ b/include/uapi/linux/kfd_ioctl.h +@@ -404,6 +404,7 @@ struct kfd_ioctl_acquire_vm_args { + #define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1) + #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2) + #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3) ++#define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP (1 << 4) + /* Allocation flags: attributes/access options */ + #define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE (1 << 31) + #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE (1 << 30) +-- +2.17.1 + |