Skip to contentSkip to conversation

drm/amdkfd: lower the VAs base offset to 8KB

PATCH In review Alex Sierra 3 participants 5 messages Nov 5, 2021 – Nov 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: lower the VAs base offset to 8KB

The low 16MB of virtual address space are currently reserved for kernel mode allocations mapped into user virtual address space. This causes conflicts with HMM/SVM mappings at low virtual addresses. We tried to move those kernel mode allocations to the upper half of the 64-bit virtual address space for GFX9, which is naturally reserved for kernel use. However, TBA (trap handler code) has problems to access addresses in the high virtual space. We have decided to set this to 8KB of the lower address space as a temporary fix, while investigate TBA address problem. It is very unlikely for user space to map memory at this low region.

---
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +1 -1
index 2e86692def19..d1388896f9c1 100644
@@ -308,7 +308,7 @@
  * 16MB are reserved for kernel use (CWSR trap handler and kernel IB
  * for now).
  */
-#define SVM_USER_BASE 0x1000000ull
+#define SVM_USER_BASE (u64)(KFD_CWSR_TBA_TMA_SIZE + 2*PAGE_SIZE)
 #define SVM_CWSR_BASE (SVM_USER_BASE - KFD_CWSR_TBA_TMA_SIZE)
 #define SVM_IB_BASE   (SVM_CWSR_BASE - PAGE_SIZE)
 
Signature · 1 line
2.32.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Alex Sierra

The low 16MB of virtual address space are currently reserved for kernel mode allocations mapped into user virtual address space. This causes conflicts with HMM/SVM mappings at low virtual addresses. We tried to move those kernel mode allocations to the upper half of the 64-bit virtual address space for GFX9, which is naturally reserved for kernel use. However, TBA (trap handler code) has problems to access addresses in the high virtual space. We have decided to set this to 8KB of the lower address space as a temporary fix, while investigate TBA address problem. It is very unlikely for user space to map memory at this low region.

Quoted 1 line
Quoted 17 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +1 -1
index 2e86692def19..d1388896f9c1 100644
@@ -308,7 +308,7 @@
   * 16MB are reserved for kernel use (CWSR trap handler and kernel IB
   * for now).
   */
-#define SVM_USER_BASE 0x1000000ull
+#define SVM_USER_BASE (u64)(KFD_CWSR_TBA_TMA_SIZE + 2*PAGE_SIZE)
  #define SVM_CWSR_BASE (SVM_USER_BASE - KFD_CWSR_TBA_TMA_SIZE)
  #define SVM_IB_BASE   (SVM_CWSR_BASE - PAGE_SIZE)
 
#2 lore raw
In reply to Alex Sierra

Am 05.11.21 um 20:25 schrieb Alex Sierra:

Quoted 10 lines

The low 16MB of virtual address space are currently reserved for kernel mode allocations mapped into user virtual address space. This causes conflicts with HMM/SVM mappings at low virtual addresses. We tried to move those kernel mode allocations to the upper half of the 64-bit virtual address space for GFX9, which is naturally reserved for kernel use. However, TBA (trap handler code) has problems to access addresses in the high virtual space. We have decided to set this to 8KB of the lower address space as a temporary fix, while investigate TBA address problem. It is very unlikely for user space to map memory at this low region.

Unfortunately that is not correct. IIRC every program run inside wine maps something at the 16-64KiB addresses.

Don't ask me what that stuff is good for, but we already ran into problems because of exactly that.

Regards,
Christian.

Quoted 19 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +1 -1
index 2e86692def19..d1388896f9c1 100644
@@ -308,7 +308,7 @@
   * 16MB are reserved for kernel use (CWSR trap handler and kernel IB
   * for now).
   */
-#define SVM_USER_BASE 0x1000000ull
+#define SVM_USER_BASE (u64)(KFD_CWSR_TBA_TMA_SIZE + 2*PAGE_SIZE)
  #define SVM_CWSR_BASE (SVM_USER_BASE - KFD_CWSR_TBA_TMA_SIZE)
  #define SVM_IB_BASE   (SVM_CWSR_BASE - PAGE_SIZE)
 
maintainer
#3 lore raw

Am 2021-11-08 um 5:22 a.m. schrieb Christian König:

Quoted 12 lines

Am 05.11.21 um 20:25 schrieb Alex Sierra:

Quoted 10 lines

The low 16MB of virtual address space are currently reserved for kernel mode allocations mapped into user virtual address space. This causes conflicts with HMM/SVM mappings at low virtual addresses. We tried to move those kernel mode allocations to the upper half of the 64-bit virtual address space for GFX9, which is naturally reserved for kernel use. However, TBA (trap handler code) has problems to access addresses in the high virtual space. We have decided to set this to 8KB of the lower address space as a temporary fix, while investigate TBA address problem. It is very unlikely for user space to map memory at this low region.

Quoted 5 lines

Unfortunately that is not correct. IIRC every program run inside wine maps something at the 16-64KiB addresses.

Don't ask me what that stuff is good for, but we already ran into problems because of exactly that.

It's only a problem if the application tries to map that memory on the GPU through the HMM/SVM API. As long as there is no conflict with GPU mappings created by the application, the GPU can safely use those addresses for its purposes.

Regards,
  Felix

Quoted 25 lines

Regards,
Christian.

Quoted 20 lines

---
  drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +1 -1
index 2e86692def19..d1388896f9c1 100644
@@ -308,7 +308,7 @@
    * 16MB are reserved for kernel use (CWSR trap handler and kernel IB
    * for now).
    */
-#define SVM_USER_BASE 0x1000000ull
+#define SVM_USER_BASE (u64)(KFD_CWSR_TBA_TMA_SIZE + 2*PAGE_SIZE)
   #define SVM_CWSR_BASE (SVM_USER_BASE - KFD_CWSR_TBA_TMA_SIZE)
   #define SVM_IB_BASE   (SVM_CWSR_BASE - PAGE_SIZE)

#4 lore raw

Am 08.11.21 um 15:35 schrieb Felix Kuehling:

Quoted 15 lines

Am 2021-11-08 um 5:22 a.m. schrieb Christian König:

Quoted 14 lines

Am 05.11.21 um 20:25 schrieb Alex Sierra:

Quoted 10 lines

The low 16MB of virtual address space are currently reserved for kernel mode allocations mapped into user virtual address space. This causes conflicts with HMM/SVM mappings at low virtual addresses. We tried to move those kernel mode allocations to the upper half of the 64-bit virtual address space for GFX9, which is naturally reserved for kernel use. However, TBA (trap handler code) has problems to access addresses in the high virtual space. We have decided to set this to 8KB of the lower address space as a temporary fix, while investigate TBA address problem. It is very unlikely for user space to map memory at this low region.

Unfortunately that is not correct. IIRC every program run inside wine maps something at the 16-64KiB addresses.

Quoted 6 lines
Quoted 2 lines

Don't ask me what that stuff is good for, but we already ran into problems because of exactly that.

It's only a problem if the application tries to map that memory on the GPU through the HMM/SVM API. As long as there is no conflict with GPU mappings created by the application, the GPU can safely use those addresses for its purposes.

Yeah, it's perfectly up to you if you want to risk that.

I've just double checked with running LTspice in wine and that indeed maps a lot of stuff starting at the 16KiB offset.

Not sure if that will ever collide with this, but I think that could indeed happen.

Regards,
Christian.

Quoted 27 lines

Regards,
  Felix

Quoted 22 lines

Regards,
Christian.

Quoted 19 lines
---
   drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +1 -1
index 2e86692def19..d1388896f9c1 100644
@@ -308,7 +308,7 @@
    * 16MB are reserved for kernel use (CWSR trap handler and kernel IB
    * for now).
    */
-#define SVM_USER_BASE 0x1000000ull
+#define SVM_USER_BASE (u64)(KFD_CWSR_TBA_TMA_SIZE + 2*PAGE_SIZE)
   #define SVM_CWSR_BASE (SVM_USER_BASE - KFD_CWSR_TBA_TMA_SIZE)
   #define SVM_IB_BASE   (SVM_CWSR_BASE - PAGE_SIZE)