drm/amdkfd: svm range always mapped flag not working on APU
authorjsg <jsg@openbsd.org>
Mon, 22 Jan 2024 03:09:50 +0000 (03:09 +0000)
committerjsg <jsg@openbsd.org>
Mon, 22 Jan 2024 03:09:50 +0000 (03:09 +0000)
From Philip Yang
bd443910debf71a1c0140c148ffb4f048fff3c2b in linux-6.6.y/6.6.13
ebab8c3eb6a6515dc14cd93fc29dd287709da6d3 in mainline linux

sys/dev/pci/drm/amd/amdkfd/kfd_svm.c

index 63ce30e..8e368e4 100644 (file)
@@ -1632,18 +1632,24 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
                        if (test_bit(gpuidx, prange->bitmap_access))
                                bitmap_set(ctx->bitmap, gpuidx, 1);
                }
+
+               /*
+                * If prange is already mapped or with always mapped flag,
+                * update mapping on GPUs with ACCESS attribute
+                */
+               if (bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) {
+                       if (prange->mapped_to_gpu ||
+                           prange->flags & KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED)
+                               bitmap_copy(ctx->bitmap, prange->bitmap_access, MAX_GPU_INSTANCE);
+               }
        } else {
                bitmap_or(ctx->bitmap, prange->bitmap_access,
                          prange->bitmap_aip, MAX_GPU_INSTANCE);
        }
 
        if (bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) {
-               bitmap_copy(ctx->bitmap, prange->bitmap_access, MAX_GPU_INSTANCE);
-               if (!prange->mapped_to_gpu ||
-                   bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE)) {
-                       r = 0;
-                       goto free_ctx;
-               }
+               r = 0;
+               goto free_ctx;
        }
 
        if (prange->actual_loc && !prange->ttm_res) {