diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3043-drm-amdkfd-Fail-public-mem-alloc-on-small-bar-dev.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3043-drm-amdkfd-Fail-public-mem-alloc-on-small-bar-dev.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3043-drm-amdkfd-Fail-public-mem-alloc-on-small-bar-dev.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3043-drm-amdkfd-Fail-public-mem-alloc-on-small-bar-dev.patch new file mode 100644 index 00000000..eefb8dc7 --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3043-drm-amdkfd-Fail-public-mem-alloc-on-small-bar-dev.patch @@ -0,0 +1,69 @@ +From d718c6ae2e402ed46e1eb692ae41880c115ae3b1 Mon Sep 17 00:00:00 2001 +From: Oak Zeng <Oak.Zeng@amd.com> +Date: Fri, 8 Dec 2017 10:45:30 -0500 +Subject: [PATCH 3043/4131] drm/amdkfd: Fail public mem alloc on small-bar dev + +Host accessible memory allocation on none-large bar +device node is not allowed. Fail it in alloc ioctl. + +Change-Id: Iffd8260d5b6ef1a8858d5cc2e3c64bcc9028ea4b +Signed-off-by: Oak Zeng <Oak.Zeng@amd.com> +--- + drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 27 +++++++++++++++++++++++++++ + 1 file changed, 27 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +index c36d546..7e63b8b 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +@@ -46,6 +46,7 @@ + static long kfd_ioctl(struct file *, unsigned int, unsigned long); + static int kfd_open(struct inode *, struct file *); + static int kfd_mmap(struct file *, struct vm_area_struct *); ++static bool kfd_dev_is_large_bar(struct kfd_dev *dev); + + static const char kfd_dev_name[] = "kfd"; + +@@ -1124,6 +1125,25 @@ static int kfd_ioctl_alloc_scratch_memory(struct file *filep, + return -EFAULT; + } + ++bool kfd_dev_is_large_bar(struct kfd_dev *dev) ++{ ++ struct kfd_local_mem_info mem_info; ++ ++ if (debug_largebar) { ++ pr_debug("Simulate large-bar allocation on non large-bar machine\n"); ++ return true; ++ } ++ ++ if (dev->device_info->is_need_iommu_device) ++ return false; ++ ++ dev->kfd2kgd->get_local_mem_info(dev->kgd, &mem_info); ++ if (mem_info.local_mem_size_private == 0 && ++ mem_info.local_mem_size_public > 0) ++ return true; ++ return false; ++} ++ + static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, + struct kfd_process *p, void *data) + { +@@ -1144,6 +1164,13 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, + if (!dev) + return -EINVAL; + ++ if ((flags & KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC) && ++ (flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) && ++ !kfd_dev_is_large_bar(dev)) { ++ pr_err("Alloc host visible vram on small bar is not allowed\n"); ++ return -EINVAL; ++ } ++ + if (flags & KFD_IOC_ALLOC_MEM_FLAGS_USERPTR) { + /* Check if the userptr corresponds to another (or third-party) + * device local memory. If so treat is as a doorbell. User +-- +2.7.4 + |