Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdkfd: Handle drain retry fault race with XNACK mode change

Application could change XNACK enabled to disabled while KFD is draining
stale retry fault, therefore the check for whether to drain retry faults
must be before the check for whether xnack_enabled, to avoid report
incorrect vm fault after application changes XNACK mode.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Philip Yang and committed by
Alex Deucher
edd11922 73bce7a4

+6 -5
+6 -5
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
··· 2685 2685 pr_debug("kfd process not founded pasid 0x%x\n", pasid); 2686 2686 return 0; 2687 2687 } 2688 - if (!p->xnack_enabled) { 2689 - pr_debug("XNACK not enabled for pasid 0x%x\n", pasid); 2690 - r = -EFAULT; 2691 - goto out; 2692 - } 2693 2688 svms = &p->svms; 2694 2689 2695 2690 pr_debug("restoring svms 0x%p fault address 0x%llx\n", svms, addr); ··· 2692 2697 if (atomic_read(&svms->drain_pagefaults)) { 2693 2698 pr_debug("draining retry fault, drop fault 0x%llx\n", addr); 2694 2699 r = 0; 2700 + goto out; 2701 + } 2702 + 2703 + if (!p->xnack_enabled) { 2704 + pr_debug("XNACK not enabled for pasid 0x%x\n", pasid); 2705 + r = -EFAULT; 2695 2706 goto out; 2696 2707 } 2697 2708