Skip to contentSkip to conversation

drm/amdkfd: set coherent host access capability flag

PATCH In review Alex Sierra 2 participants 4 messages Jun 15, 2023 – Jun 16, 2023

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

PATCH 1/1 drm/amdkfd: set coherent host access capability flag

This flag determines whether the host possesses coherent access to the memory of the device.

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +4 -0
index 90b86a6ac7bd..7ede3de4f7fb 100644
@@ -2107,6 +2107,10 @@ int kfd_topology_add_device(struct kfd_node *gpu)
 	if (KFD_IS_SVM_API_SUPPORTED(dev->gpu->adev))
 		dev->node_props.capability |= HSA_CAP_SVMAPI_SUPPORTED;
 
+	if (dev->gpu->adev->gmc.is_app_apu |
+		dev->gpu->adev->gmc.xgmi.connected_to_cpu)
+		dev->node_props.capability |= HSA_CAP_FLAGS_COHERENTHOSTACCESS;
+
 	kfd_debug_print_topology();
 
 	kfd_notify_gpu_change(gpu_id, 1);
Signature · 1 line
2.32.0
#1 lore raw

[AMD Official Use Only - General]

CC Rajneesh
Quoted 37 lines

-----Original Message-----
From: Sierra Guiza, Alejandro (Alex) <[email protected]>
Sent: Thursday, June 15, 2023 5:55 PM
To: [email protected]; Kuehling, Felix <[email protected]>
Cc: Yat Sin, David <[email protected]>; Sierra Guiza, Alejandro (Alex) <[email protected]>
Subject: [PATCH] drm/amdkfd: set coherent host access capability flag

This flag determines whether the host possesses coherent access to the memory of the device.

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +4 -0
index 90b86a6ac7bd..7ede3de4f7fb 100644
@@ -2107,6 +2107,10 @@ int kfd_topology_add_device(struct kfd_node
 *gpu)
      if (KFD_IS_SVM_API_SUPPORTED(dev->gpu->adev))
              dev->node_props.capability |=
 HSA_CAP_SVMAPI_SUPPORTED;
 
+     if (dev->gpu->adev->gmc.is_app_apu |
+             dev->gpu->adev->gmc.xgmi.connected_to_cpu)
+             dev->node_props.capability |=
 HSA_CAP_FLAGS_COHERENTHOSTACCESS;
+
      kfd_debug_print_topology();

      kfd_notify_gpu_change(gpu_id, 1);

--
2.32.0

maintainer
#2 lore raw
In reply to Alex Sierra

Am 2023-06-15 um 18:54 schrieb Alex Sierra:

Quoted 13 lines

This flag determines whether the host possesses coherent access to the memory of the device.

---
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0 -0
index 90b86a6ac7bd..7ede3de4f7fb 100644

drivers/gpu/drm/amd/amdkfd/kfd_topology.c int kfd_topology_add_device(struct kfd_node *gpu) · line 2112

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +3 -0
@@ -2107,6 +2107,10 @@ int kfd_topology_add_device(struct kfd_node *gpu)
  	if (KFD_IS_SVM_API_SUPPORTED(dev->gpu->adev))
  		dev->node_props.capability |= HSA_CAP_SVMAPI_SUPPORTED;
 
+	if (dev->gpu->adev->gmc.is_app_apu |
+		dev->gpu->adev->gmc.xgmi.connected_to_cpu)
+		dev->node_props.capability |= HSA_CAP_FLAGS_COHERENTHOSTACCESS;

I believe this is not true for "small APUs" because they map the framebuffer as WC on the CPU. I think you need to check specifically for APP APU.

Regards,
  Felix

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -0
+
  	kfd_debug_print_topology();
 
  	kfd_notify_gpu_change(gpu_id, 1);
maintainer Reviewed-by
#3 lore raw

Am 2023-06-16 um 00:29 schrieb Felix Kuehling:

Quoted 10 lines

Am 2023-06-15 um 18:54 schrieb Alex Sierra:

Quoted 8 lines

This flag determines whether the host possesses coherent access to the memory of the device.

---
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 4 ++++

  1 file changed, 4 insertions(+)
Quoted 12 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0 -0
index 90b86a6ac7bd..7ede3de4f7fb 100644
@@ -2107,6 +2107,10 @@ int kfd_topology_add_device(struct kfd_node *gpu)
       if (KFD_IS_SVM_API_SUPPORTED(dev->gpu->adev))
           dev->node_props.capability |= HSA_CAP_SVMAPI_SUPPORTED;

  +    if (dev->gpu->adev->gmc.is_app_apu |
+        dev->gpu->adev->gmc.xgmi.connected_to_cpu)
+        dev->node_props.capability |= HSA_CAP_FLAGS_COHERENTHOSTACCESS;

I believe this is not true for "small APUs" because they map the framebuffer as WC on the CPU. I think you need to check specifically for APP APU.

Never mind, I read it wrong. You are checking the correct APP APU flag. Just one more nit-pick, in the condition you should use logical OR (a || b), not bit-wise OR (a | b). With that fixed, the patch is

Quoted 8 lines

Regards,
  Felix

Quoted 3 lines

+
      kfd_debug_print_topology();
        kfd_notify_gpu_change(gpu_id, 1);