diff -Naur amdgpu-19.20-812932.bak/amd/amdgpu/amdgpu_mn.c amdgpu-19.20-812932/amd/amdgpu/amdgpu_mn.c --- amdgpu-19.20-812932.bak/amd/amdgpu/amdgpu_mn.c 2019-05-10 19:57:47.000000000 +0200 +++ amdgpu-19.20-812932/amd/amdgpu/amdgpu_mn.c 2019-07-11 08:30:51.916515905 +0200 @@ -257,7 +257,8 @@ } } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) +//#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) /** * amdgpu_mn_invalidate_range_start_gfx - callback to notify about mm change * @@ -365,10 +366,11 @@ * Block for operations on BOs to finish and mark pages as accessed and * potentially dirty. */ -static void amdgpu_mn_invalidate_range_start_gfx(struct mmu_notifier *mn, +static int amdgpu_mn_invalidate_range_start_gfx(struct mmu_notifier *mn, struct mm_struct *mm, unsigned long start, - unsigned long end) + unsigned long end, + bool blockable) { struct amdgpu_mn *amn = container_of(mn, struct amdgpu_mn, mn); struct interval_tree_node *it; @@ -376,17 +378,27 @@ /* notification is exclusive, but interval is inclusive */ end -= 1; - amdgpu_mn_read_lock(amn); + /* TODO we should be able to split locking for interval tree and + * amdgpu_mn_invalidate_node + */ + if (amdgpu_mn_read_lock(amn, blockable)) + return -EAGAIN; it = interval_tree_iter_first(&amn->objects, start, end); while (it) { struct amdgpu_mn_node *node; + if (!blockable) { + amdgpu_mn_read_unlock(amn); + return -EAGAIN; + } + node = container_of(it, struct amdgpu_mn_node, it); it = interval_tree_iter_next(it, start, end); amdgpu_mn_invalidate_node(node, start, end); } + return 0; } @@ -402,10 +414,11 @@ * necessitates evicting all user-mode queues of the process. The BOs * are restorted in amdgpu_mn_invalidate_range_end_hsa. */ -static void amdgpu_mn_invalidate_range_start_hsa(struct mmu_notifier *mn, +static int amdgpu_mn_invalidate_range_start_hsa(struct mmu_notifier *mn, struct mm_struct *mm, unsigned long start, - unsigned long end) + unsigned long end, + bool blockable) { struct amdgpu_mn *amn = container_of(mn, struct amdgpu_mn, mn); struct interval_tree_node *it; @@ -413,13 +426,19 @@ /* notification is exclusive, but interval is inclusive */ end -= 1; - amdgpu_mn_read_lock(amn); + if (amdgpu_mn_read_lock(amn, blockable)) + return -EAGAIN; it = interval_tree_iter_first(&amn->objects, start, end); while (it) { struct amdgpu_mn_node *node; struct amdgpu_bo *bo; + if (!blockable) { + amdgpu_mn_read_unlock(amn); + return -EAGAIN; + } + node = container_of(it, struct amdgpu_mn_node, it); it = interval_tree_iter_next(it, start, end); @@ -431,6 +450,7 @@ amdgpu_amdkfd_evict_userptr(mem, mm); } } + return 0; } #endif diff -Naur amdgpu-19.20-812932.bak/Makefile amdgpu-19.20-812932/Makefile --- amdgpu-19.20-812932.bak/Makefile 2019-05-10 19:57:47.000000000 +0200 +++ amdgpu-19.20-812932/Makefile 2019-07-11 07:51:58.646571741 +0200 @@ -33,6 +33,9 @@ DRM_VER=$(shell sed -n 's/^VERSION = \(.*\)/\1/p' $(kdir)/Makefile) DRM_PATCH=$(shell sed -n 's/^PATCHLEVEL = \(.*\)/\1/p' $(kdir)/Makefile) endif +else +DRM_VER=$(shell make kernelversion | sed -n 's/\(.*\)\.\(.*\)\.\(.*\)/\1/p') +DRM_PATCH=$(shell make kernelversion | sed -n 's/\(.*\)\.\(.*\)\.\(.*\)/\2/p') endif subdir-ccflags-y += \