Revert "drm/amdkfd: Relocate TBA/TMA to opposite side of VM hole"
authorjsg <jsg@openbsd.org>
Mon, 29 Jan 2024 01:54:54 +0000 (01:54 +0000)
committerjsg <jsg@openbsd.org>
Mon, 29 Jan 2024 01:54:54 +0000 (01:54 +0000)
From Kaibo Ma
3a99f15ce9d01bcce4f1f260194f964523f5c07a in linux-6.6.y/6.6.14
0f35b0a7b8fa402adbffa2565047cdcc4c480153 in mainline linux

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

index 62b205d..6604a3f 100644 (file)
@@ -330,12 +330,6 @@ static void kfd_init_apertures_vi(struct kfd_process_device *pdd, uint8_t id)
        pdd->gpuvm_limit =
                pdd->dev->kfd->shared_resources.gpuvm_size - 1;
 
-       /* dGPUs: the reserved space for kernel
-        * before SVM
-        */
-       pdd->qpd.cwsr_base = SVM_CWSR_BASE;
-       pdd->qpd.ib_base = SVM_IB_BASE;
-
        pdd->scratch_base = MAKE_SCRATCH_APP_BASE_VI();
        pdd->scratch_limit = MAKE_SCRATCH_APP_LIMIT(pdd->scratch_base);
 }
@@ -345,18 +339,18 @@ static void kfd_init_apertures_v9(struct kfd_process_device *pdd, uint8_t id)
        pdd->lds_base = MAKE_LDS_APP_BASE_V9();
        pdd->lds_limit = MAKE_LDS_APP_LIMIT(pdd->lds_base);
 
-       pdd->gpuvm_base = PAGE_SIZE;
+        /* Raven needs SVM to support graphic handle, etc. Leave the small
+         * reserved space before SVM on Raven as well, even though we don't
+         * have to.
+         * Set gpuvm_base and gpuvm_limit to CANONICAL addresses so that they
+         * are used in Thunk to reserve SVM.
+         */
+        pdd->gpuvm_base = SVM_USER_BASE;
        pdd->gpuvm_limit =
                pdd->dev->kfd->shared_resources.gpuvm_size - 1;
 
        pdd->scratch_base = MAKE_SCRATCH_APP_BASE_V9();
        pdd->scratch_limit = MAKE_SCRATCH_APP_LIMIT(pdd->scratch_base);
-
-       /*
-        * Place TBA/TMA on opposite side of VM hole to prevent
-        * stray faults from triggering SVM on these pages.
-        */
-       pdd->qpd.cwsr_base = pdd->dev->kfd->shared_resources.gpuvm_size;
 }
 
 int kfd_init_apertures(struct kfd_process *process)
@@ -413,6 +407,12 @@ int kfd_init_apertures(struct kfd_process *process)
                                        return -EINVAL;
                                }
                        }
+
+                        /* dGPUs: the reserved space for kernel
+                         * before SVM
+                         */
+                        pdd->qpd.cwsr_base = SVM_CWSR_BASE;
+                        pdd->qpd.ib_base = SVM_IB_BASE;
                }
 
                dev_dbg(kfd_device, "node id %u\n", id);