Skip to contentSkip to conversation

drm/amdkfd: enable heavy-weight TLB flush on Arcturus

PATCH In review Eric Huang 3 participants 7 messages Jan 18, 2022 – Jan 19, 2022

Subsystems (3)
lore
Share & tools
lore

Eric Huang

author
#0 lore raw

PATCH 1/1 drm/amdkfd: enable heavy-weight TLB flush on Arcturus

SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  6 ------
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c         | 10 ++++++++--
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -6
index a64cbbd943ba..acb4fd973e60 100644
@@ -1892,12 +1892,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 				true);
 	ret = unreserve_bo_and_vms(&ctx, false, false);
 
-	/* Only apply no TLB flush on Aldebaran to
-	 * workaround regressions on other Asics.
-	 */
-	if (table_freed && (adev->asic_type != CHIP_ALDEBARAN))
-		*table_freed = true;
-
 	goto out;
 
 out_unreserve:
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +8 -2
index b570c0454ce9..485d4c52c7de 100644
@@ -1596,6 +1596,12 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
 	return ret;
 }
 
+static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) {
+	return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
+	       (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
+	        dev->adev->sdma.instance[0].fw_version >= 18);
+}
+
 static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
 					struct kfd_process *p, void *data)
 {
@@ -1692,7 +1698,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
 	}
 
 	/* Flush TLBs after waiting for the page table updates to complete */
-	if (table_freed) {
+	if (table_freed || !kfd_flush_tlb_after_unmap(dev)) {
 		for (i = 0; i < args->n_devices; i++) {
 			peer = kfd_device_by_id(devices_arr[i]);
 			if (WARN_ON_ONCE(!peer))
@@ -1806,7 +1812,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
 	}
 	mutex_unlock(&p->mutex);
 
-	if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)) {
+	if (kfd_flush_tlb_after_unmap(dev)) {
 		err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev,
 				(struct kgd_mem *) mem, true);
 		if (err) {
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 2022-01-18 um 5:45 p.m. schrieb Eric Huang:

Quoted 4 lines

SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it.

Quoted 57 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  6 ------
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c         | 10 ++++++++--
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -6
index a64cbbd943ba..acb4fd973e60 100644
@@ -1892,12 +1892,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 				true);
 	ret = unreserve_bo_and_vms(&ctx, false, false);
 
-	/* Only apply no TLB flush on Aldebaran to
-	 * workaround regressions on other Asics.
-	 */
-	if (table_freed && (adev->asic_type != CHIP_ALDEBARAN))
-		*table_freed = true;
-
 	goto out;
 
 out_unreserve:
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +8 -2
index b570c0454ce9..485d4c52c7de 100644
@@ -1596,6 +1596,12 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
 	return ret;
 }
 
+static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) {
+	return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||
+	       (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
+	        dev->adev->sdma.instance[0].fw_version >= 18);
+}
+
 static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
 					struct kfd_process *p, void *data)
 {
@@ -1692,7 +1698,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
 	}
 
 	/* Flush TLBs after waiting for the page table updates to complete */
-	if (table_freed) {
+	if (table_freed || !kfd_flush_tlb_after_unmap(dev)) {
 		for (i = 0; i < args->n_devices; i++) {
 			peer = kfd_device_by_id(devices_arr[i]);
 			if (WARN_ON_ONCE(!peer))
@@ -1806,7 +1812,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
 	}
 	mutex_unlock(&p->mutex);
 
-	if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)) {
+	if (kfd_flush_tlb_after_unmap(dev)) {
 		err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev,
 				(struct kgd_mem *) mem, true);
 		if (err) {
Reviewed-by Felix Kuehling
#2 lore raw

One question inline

KENT RUSSELL
Sr. Software Engineer | Linux Compute Kernel
1 Commerce Valley Drive East
Markham, ON L3T 7X6
O +(1) 289-695-2122 | Ext 72122

________________________________
From: amd-gfx <[email protected]> on behalf of Felix Kuehling <[email protected]>
Sent: Tuesday, January 18, 2022 6:36 PM
To: Huang, JinHuiEric <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 5:45 p.m. schrieb Eric Huang:

Quoted 4 lines

SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it.

Quoted 27 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  6 ------
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c         | 10 ++++++++--
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -6
index a64cbbd943ba..acb4fd973e60 100644
@@ -1892,12 +1892,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
                               true);
       ret = unreserve_bo_and_vms(&ctx, false, false);
 
-     /* Only apply no TLB flush on Aldebaran to
-      * workaround regressions on other Asics.
-      */
-     if (table_freed && (adev->asic_type != CHIP_ALDEBARAN))
-             *table_freed = true;
-
       goto out;
 
 out_unreserve:
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
index b570c0454ce9..485d4c52c7de 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_free_memory_of_gpu(struct file *filep, · line 1600

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
@@ -1596,6 +1596,12 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep,
       return ret;
 }
 
+static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) {
+     return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)

Do we need to add a check for sdma ver >=8 here?

||
> +            (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> +             dev->adev->sdma.instance[0].fw_version >= 18);
Quoted 23 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +4 -2
+}
+
 static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
                                       struct kfd_process *p, void *data)
 {
@@ -1692,7 +1698,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
       }
 
       /* Flush TLBs after waiting for the page table updates to complete */
-     if (table_freed) {
+     if (table_freed || !kfd_flush_tlb_after_unmap(dev)) {
               for (i = 0; i < args->n_devices; i++) {
                       peer = kfd_device_by_id(devices_arr[i]);
                       if (WARN_ON_ONCE(!peer))
@@ -1806,7 +1812,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
       }
       mutex_unlock(&p->mutex);
 
-     if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)) {
+     if (kfd_flush_tlb_after_unmap(dev)) {
               err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev,
                               (struct kgd_mem *) mem, true);
               if (err) {
maintainer
#3 lore raw

Am 2022-01-18 um 7:08 p.m. schrieb Russell, Kent:

Quoted 62 lines

One question inline

*KENT RUSSELL***

Sr. Software Engineer | Linux Compute Kernel

1 Commerce Valley Drive East

Markham, ON L3T 7X6

*O*+(1) 289-695-2122**| Ext 72122

------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Felix Kuehling <[email protected]>
*Sent:* Tuesday, January 18, 2022 6:36 PM
*To:* Huang, JinHuiEric <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 5:45 p.m. schrieb Eric Huang:

Quoted 4 lines

SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it.

Review

Quoted 6 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  6 ------ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c         | 10 ++++++++--

  2 files changed, 8 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

Quoted 16 lines

index a64cbbd943ba..acb4fd973e60 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
@@ -1892,12 +1892,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
                                 true);
         ret = unreserve_bo_and_vms(&ctx, false, false);


-     /* Only apply no TLB flush on Aldebaran to
-      * workaround regressions on other Asics.
-      */
-     if (table_freed && (adev->asic_type != CHIP_ALDEBARAN)) -             *table_freed = true;
-
        goto out;

  out_unreserve:

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 4 lines

index b570c0454ce9..485d4c52c7de 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
@@ -1596,6 +1596,12 @@ static int

kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 7 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
         return ret;
   }


+static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) { +     return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)

Do we need to add a check for sdma ver >=8 here?

What's the significance of version 8 for Aldebaran? This code was working on Aldebaran without a version check before. Did we ever publicly release an SDMA firmware older than version 8 that for Aldebaran?

Regards,
  Felix

Quoted 31 lines


||

Quoted 6 lines

+            (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) && +             dev->adev->sdma.instance[0].fw_version >= 18);

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+}
+

  static int kfd_ioctl_map_memory_to_gpu(struct file *filep, struct kfd_process *p, void

*data)

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_map_memory_to_gpu(struct

Quoted 2 lines

  {

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
@@ -1692,7 +1698,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct

file *filep,

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
         }


        /* Flush TLBs after waiting for the page table updates to

complete */

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 6 lines

-     if (table_freed) {
+     if (table_freed || !kfd_flush_tlb_after_unmap(dev)) { for (i = 0; i < args->n_devices; i++) { peer = kfd_device_by_id(devices_arr[i]); if (WARN_ON_ONCE(!peer))

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
@@ -1806,7 +1812,7 @@ static int

kfd_ioctl_unmap_memory_from_gpu(struct file *filep,

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
         }
         mutex_unlock(&p->mutex);


-     if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)) { +     if (kfd_flush_tlb_after_unmap(dev)) {
                err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev, (struct kgd_mem *) mem, true); if (err) {

#4 lore raw

[AMD Official Use Only]

Quoted 73 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, January 18, 2022 7:16 PM
To: Russell, Kent <[email protected]>; Huang, JinHuiEric <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 7:08 p.m. schrieb Russell, Kent:

Quoted 65 lines

One question inline

*KENT RUSSELL***

Sr. Software Engineer | Linux Compute Kernel

1 Commerce Valley Drive East

Markham, ON L3T 7X6

*O*+(1) 289-695-2122**| Ext 72122

------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Felix Kuehling <[email protected]>
*Sent:* Tuesday, January 18, 2022 6:36 PM
*To:* Huang, JinHuiEric <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 5:45 p.m. schrieb Eric Huang:

Quoted 4 lines

SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it.

Review

Quoted 6 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  6 ------
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c         | 10 ++++++++--
 2 files changed, 8 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

Review

Quoted 17 lines

index a64cbbd943ba..acb4fd973e60 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -6
@@ -1892,12 +1892,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
                               true);
       ret = unreserve_bo_and_vms(&ctx, false, false);
 
-     /* Only apply no TLB flush on Aldebaran to
-      * workaround regressions on other Asics.
-      */
-     if (table_freed && (adev->asic_type != CHIP_ALDEBARAN))
-             *table_freed = true;
-
       goto out;
 
 out_unreserve:
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 4 lines

index b570c0454ce9..485d4c52c7de 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
@@ -1596,6 +1596,12 @@ static int

kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
       return ret;
 }
 
Quoted 8 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int · line 1600

Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) {
+     return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)

Do we need to add a check for sdma ver >=8 here?

What's the significance of version 8 for Aldebaran? This code was working on Aldebaran without a version check before. Did we ever publicly release an SDMA firmware older than version 8 that for Aldebaran?

We released v5 for Aldebaran SDMA in ROCm 4.5 . If I remember the ticket correctly, the same fix for Arcturus was required for Aldebaran and was part of SDMA v8. But Eric is obviously watching the ticket more closely than I, so I'll defer to him there.

Kent

Quoted 36 lines

Regards,
Felix

Quoted 31 lines
||
> +            (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> +             dev->adev->sdma.instance[0].fw_version >= 18);

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+}
+
 static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
                                       struct kfd_process *p, void

*data)

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_map_memory_to_gpu(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
 {
@@ -1692,7 +1698,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct

file *filep,

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_map_memory_to_gpu(struct · line 1700

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
       }
 
       /* Flush TLBs after waiting for the page table updates to

complete */

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
-     if (table_freed) {
+     if (table_freed || !kfd_flush_tlb_after_unmap(dev)) {
               for (i = 0; i < args->n_devices; i++) {
                       peer = kfd_device_by_id(devices_arr[i]);
                       if (WARN_ON_ONCE(!peer))
@@ -1806,7 +1812,7 @@ static int

kfd_ioctl_unmap_memory_from_gpu(struct file *filep,

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
       }
       mutex_unlock(&p->mutex);
 
-     if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)) {
+     if (kfd_flush_tlb_after_unmap(dev)) {
               err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev,
                               (struct kgd_mem *) mem, true);
               if (err) {
author
#5 lore raw
Quoted 74 lines · Kent

[AMD Official Use Only]

Quoted 72 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, January 18, 2022 7:16 PM
To: Russell, Kent <[email protected]>; Huang, JinHuiEric <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 7:08 p.m. schrieb Russell, Kent:

Quoted 64 lines

One question inline

*KENT RUSSELL***

Sr. Software Engineer | Linux Compute Kernel

1 Commerce Valley Drive East

Markham, ON L3T 7X6

*O*+(1) 289-695-2122**| Ext 72122

------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Felix Kuehling <[email protected]>
*Sent:* Tuesday, January 18, 2022 6:36 PM
*To:* Huang, JinHuiEric <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 5:45 p.m. schrieb Eric Huang:

Quoted 4 lines

SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it.

Review

Quoted 6 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  6 ------
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c         | 10 ++++++++--
  2 files changed, 8 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

Review

Quoted 17 lines

index a64cbbd943ba..acb4fd973e60 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -6
@@ -1892,12 +1892,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
                                true);
        ret = unreserve_bo_and_vms(&ctx, false, false);
 
-     /* Only apply no TLB flush on Aldebaran to
-      * workaround regressions on other Asics.
-      */
-     if (table_freed && (adev->asic_type != CHIP_ALDEBARAN))
-             *table_freed = true;
-
        goto out;
 
  out_unreserve:
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 4 lines

index b570c0454ce9..485d4c52c7de 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
@@ -1596,6 +1596,12 @@ static int

kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
        return ret;
  }
 
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int · line 1600

Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) {
+     return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)

Do we need to add a check for sdma ver >=8 here?

What's the significance of version 8 for Aldebaran? This code was working on Aldebaran without a version check before. Did we ever publicly release an SDMA firmware older than version 8 that for Aldebaran?

We released v5 for Aldebaran SDMA in ROCm 4.5 . If I remember the ticket correctly, the same fix for Arcturus was required for Aldebaran and was part of SDMA v8. But Eric is obviously watching the ticket more closely than I, so I'll defer to him there.

Yes. Aldebaran has the same bug as Arcturus in SDMA, but the bug doesn't cause GPU hang on Aldebaran. As Felix said heavy-weight TLB flush have been working on Aldebaran since it was enabled, so we don't need to check the version for it.

Regards,
Eric

Quoted 37 lines

Kent

Quoted 34 lines

Regards,
Felix

Quoted 30 lines
||
> +            (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> +             dev->adev->sdma.instance[0].fw_version >= 18);

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+}
+
  static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
                                        struct kfd_process *p, void

*data)

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_map_memory_to_gpu(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
  {
@@ -1692,7 +1698,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct

file *filep,

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_map_memory_to_gpu(struct · line 1700

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
        }
 
        /* Flush TLBs after waiting for the page table updates to

complete */

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
-     if (table_freed) {
+     if (table_freed || !kfd_flush_tlb_after_unmap(dev)) {
                for (i = 0; i < args->n_devices; i++) {
                        peer = kfd_device_by_id(devices_arr[i]);
                        if (WARN_ON_ONCE(!peer))
@@ -1806,7 +1812,7 @@ static int

kfd_ioctl_unmap_memory_from_gpu(struct file *filep,

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
        }
        mutex_unlock(&p->mutex);
 
-     if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)) {
+     if (kfd_flush_tlb_after_unmap(dev)) {
                err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev,
                                (struct kgd_mem *) mem, true);
                if (err) {
#6 lore raw

[AMD Official Use Only]

Quoted 90 lines

-----Original Message-----
From: Huang, JinHuiEric <[email protected]>
Sent: Wednesday, January 19, 2022 10:01 AM
To: Russell, Kent <[email protected]>; Kuehling, Felix <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Quoted 80 lines · Kent

[AMD Official Use Only]

Quoted 78 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, January 18, 2022 7:16 PM
To: Russell, Kent <[email protected]>; Huang, JinHuiEric <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 7:08 p.m. schrieb Russell, Kent:

Quoted 61 lines

One question inline

*KENT RUSSELL***

Sr. Software Engineer | Linux Compute Kernel

1 Commerce Valley Drive East

Markham, ON L3T 7X6

*O*+(1) 289-695-2122**| Ext 72122

------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Felix Kuehling <[email protected]>
*Sent:* Tuesday, January 18, 2022 6:36 PM
*To:* Huang, JinHuiEric <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [PATCH] drm/amdkfd: enable heavy-weight TLB flush on Arcturus

Am 2022-01-18 um 5:45 p.m. schrieb Eric Huang:

Quoted 4 lines

SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it.

Review

Quoted 6 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  6 ------
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c         | 10 ++++++++--
  2 files changed, 8 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

Review

Quoted 17 lines

index a64cbbd943ba..acb4fd973e60 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -6
@@ -1892,12 +1892,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
                                true);
        ret = unreserve_bo_and_vms(&ctx, false, false);
 
-     /* Only apply no TLB flush on Aldebaran to
-      * workaround regressions on other Asics.
-      */
-     if (table_freed && (adev->asic_type != CHIP_ALDEBARAN))
-             *table_freed = true;
-
        goto out;
 
  out_unreserve:
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 4 lines

index b570c0454ce9..485d4c52c7de 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
@@ -1596,6 +1596,12 @@ static int

kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
        return ret;
  }
 
+static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) {
+     return KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)

Do we need to add a check for sdma ver >=8 here?

What's the significance of version 8 for Aldebaran? This code was working on Aldebaran without a version check before. Did we ever publicly release an SDMA firmware older than version 8 that for Aldebaran?

Quoted 7 lines
Quoted 1 line

We released v5 for Aldebaran SDMA in ROCm 4.5 . If I remember the ticket correctly, the

same fix for Arcturus was required for Aldebaran and was part of SDMA v8. But Eric is obviously watching the ticket more closely than I, so I'll defer to him there. Yes. Aldebaran has the same bug as Arcturus in SDMA, but the bug doesn't cause GPU hang on Aldebaran. As Felix said heavy-weight TLB flush have been working on Aldebaran since it was enabled, so we don't need to check the version for it.

Ah perfect, thanks for the clarification!

Kent

Quoted 40 lines

Regards,
Eric

Quoted 37 lines

Kent

Quoted 34 lines

Regards,
Felix

Quoted 30 lines
||
> +            (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1) &&
> +             dev->adev->sdma.instance[0].fw_version >= 18);

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_free_memory_of_gpu(struct file *filep,

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+}
+
  static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
                                        struct kfd_process *p, void

*data)

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_map_memory_to_gpu(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
  {
@@ -1692,7 +1698,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct

file *filep,

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_map_memory_to_gpu(struct · line 1700

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
        }
 
        /* Flush TLBs after waiting for the page table updates to

complete */

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
-     if (table_freed) {
+     if (table_freed || !kfd_flush_tlb_after_unmap(dev)) {
                for (i = 0; i < args->n_devices; i++) {
                        peer = kfd_device_by_id(devices_arr[i]);
                        if (WARN_ON_ONCE(!peer))
@@ -1806,7 +1812,7 @@ static int

kfd_ioctl_unmap_memory_from_gpu(struct file *filep,

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
        }
        mutex_unlock(&p->mutex);
 
-     if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2)) {
+     if (kfd_flush_tlb_after_unmap(dev)) {
                err = amdgpu_amdkfd_gpuvm_sync_memory(dev->adev,
                                (struct kgd_mem *) mem, true);
                if (err) {