AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1
@ 2026-11-16 19:11 Kent Russell
  2026-11-16 19:33 ` sashiko-bot
  2026-11-17 16:54 ` Mukul Joshi
  0 siblings, 2 replies; 5+ messages in thread
From: Kent Russell @ 2026-11-16 19:11 UTC (permalink / raw)
  To: amd-gfx; +Cc: jay.cornwall, Kent Russell

This feature cannot be properly supported, so disable it both on the
amdgpu side and the amdkfd side.

Signed-off-by: Kent Russell <kent.russell@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c        |  7 +++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c         |  5 ++---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c       | 12 ++++++++++++
 .../amdkfd/kfd_device_queue_manager_v12_1.c    | 18 ++++--------------
 drivers/gpu/drm/amd/amdkfd/kfd_process.c       |  7 +++++++
 5 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 08d3ff61edcc..d0ede277aa85 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -1151,6 +1151,13 @@ void amdgpu_gmc_noretry_set(struct amdgpu_device *adev)
 		gmc->noretry = 1;
 	else
 		gmc->noretry = (amdgpu_noretry == -1) ? noretry_default : amdgpu_noretry;
+
+	/* XNACK cannot be enabled on GFX12.1, so keep noretry=1 */
+	if (gc_ver == IP_VERSION(12, 1, 0)) {
+		if (amdgpu_noretry == 0)
+			dev_warn(adev->dev, "Unable to set noretry = 0 on GFX12.1. Keeping noretry = 1");
+		gmc->noretry = 1;
+	}
 }
 
 void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
index 1f57d0fa2c04..034cc3fd07f3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
@@ -1518,9 +1518,8 @@ static u32 gfx_v12_1_get_sh_mem_config(struct amdgpu_device *adev)
 {
 	u32 sh_mem_config = DEFAULT_SH_MEM_CONFIG;
 
-	/* GC 12.1.0 A0 requires RETRY_DISABLE in SH_MEM_CONFIG. */
-	if (SOC_V1_0_DIE_REV_XCD(adev->rev_id) == 0)
-		sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
+	/* XNACK cannot be enabled for GFX12.1 */
+	sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
 
 	return sh_mem_config;
 }
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 3d2136adb62b..3b62b9e5ecda 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1766,6 +1766,8 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
 
 	mutex_lock(&p->mutex);
 	if (args->xnack_enabled >= 0) {
+		int i;
+
 		if (!list_empty(&p->pqm.queues)) {
 			pr_debug("Process has user queues running\n");
 			r = -EBUSY;
@@ -1780,6 +1782,16 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
 			goto out_unlock;
 		}
 
+		/* XNACK cannot be enabled for gfx12.1 */
+		for (i = 0; i < p->n_pdds; i++) {
+			struct kfd_node *dev = p->pdds[i]->dev;
+
+			if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0)) {
+				r = -EPERM;
+				goto out_unlock;
+			}
+		}
+
 		r = svm_range_switch_xnack_reserve_mem(p, args->xnack_enabled);
 	} else {
 		args->xnack_enabled = p->xnack_enabled;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
index 525989371378..63ba13a60b98 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
@@ -54,7 +54,6 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
 	struct kfd_process_device *pdd;
 	struct amdgpu_device *adev = dqm->dev->adev;
 	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)];
-	bool xnack_enabled;
 
 	pdd = qpd_to_pdd(qpd);
 	qpd->vm_cntx_cntl = hub->vm_cntx_cntl;
@@ -72,19 +71,10 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
 		qpd->sh_mem_ape1_base = 0;
 	}
 
-	xnack_enabled = KFD_SUPPORT_XNACK_PER_PROCESS(dqm->dev) ?
-			pdd->process->xnack_enabled :
-			!pdd->dev->kfd->noretry;
-
-	if (!xnack_enabled) {
-		qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
-		qpd->vm_cntx_cntl &=
-			~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
-	} else {
-		qpd->sh_mem_config &= ~(1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT);
-		qpd->vm_cntx_cntl |=
-			(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
-	}
+	/* XNACK cannot be enabled for gfx12.1 */
+	qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
+	qpd->vm_cntx_cntl &=
+		~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
 
 	qpd->sh_mem_bases = compute_sh_mem_bases_64bit(pdd);
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 546721b4d59a..059e22cd7f1a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -1670,6 +1670,13 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported)
 		    KFD_GC_VERSION(dev) < IP_VERSION(12, 1, 0))
 			return false;
 
+		/* XNACK cannot be enabled on GFX12.1 . While dev->kfd->noretry
+		 * should propagate this requirement, adding it explicitly here
+		 * will help cover any possible future reworks
+		 */
+		if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0))
+			return false;
+
 		if (dev->kfd->noretry)
 			return false;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1
  2026-11-16 19:11 [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1 Kent Russell
@ 2026-11-16 19:33 ` sashiko-bot
  2026-11-17 16:54 ` Mukul Joshi
  1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-16 19:33 UTC (permalink / raw)
  To: Kent Russell, amd-gfx

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/amdkfd: unreachable duplicate GFX12.1 check in
  kfd_ioctl_set_xnack_mode()
--

commit 34665c5afc18630d5c2e3d3dd0b64b6b650cafc2
Author: Kent Russell <kent.russell@amd.com>

drm/amdgpu: Disable XNACK retry on GFX12.1

This commit disables XNACK retry on GFX12.1 in both amdgpu and amdkfd by
forcing noretry=1, setting RETRY_DISABLE in SH_MEM_CONFIG, and rejecting
XNACK mode enablement for GFX12.1 devices.

[ ... ]

> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 5a7f4f0cd0ce7..0728271f8c087 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1766,6 +1766,8 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
>  
>  	mutex_lock(&p->mutex);
>  	if (args->xnack_enabled >= 0) {
> +		int i;
> +
>  		if (!list_empty(&p->pqm.queues)) {
>  			pr_debug("Process has user queues running\n");
>  			r = -EBUSY;
> @@ -1780,6 +1782,16 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
>  			goto out_unlock;
>  		}
>  
> +		/* XNACK cannot be enabled for gfx12.1 */
> +		for (i = 0; i < p->n_pdds; i++) {
> +			struct kfd_node *dev = p->pdds[i]->dev;
> +
> +			if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0)) {
> +				r = -EPERM;
> +				goto out_unlock;
> +			}
> +		}

[Severity: Low]
Is this loop in kfd_ioctl_set_xnack_mode() reachable?

Immediately above it, enabling XNACK checks kfd_process_xnack_mode(p,
true), which already iterates over p->pdds[] and returns false when
KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0) (or dev->kfd->noretry is set):

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c:kfd_ioctl_set_xnack_mode() {
	...
		if (p->xnack_enabled == args->xnack_enabled)
			goto out_unlock;

		if (args->xnack_enabled && !kfd_process_xnack_mode(p, true)) {
			r = -EPERM;
			goto out_unlock;
		}
	...
}

When args->xnack_enabled is 0, p->xnack_enabled is already initialized to
false on GFX12.1, so the p->xnack_enabled == args->xnack_enabled check
exits early (and if p->xnack_enabled were ever true, this unguarded loop
would reject disabling XNACK with -EPERM).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116191141.145348-1-kent.russell@amd.com?part=1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1
@ 2026-11-16 21:55 Kent Russell
  0 siblings, 0 replies; 5+ messages in thread
From: Kent Russell @ 2026-11-16 21:55 UTC (permalink / raw)
  To: amd-gfx; +Cc: Kent Russell

This feature cannot be properly supported, so disable it both on the
amdgpu side and the amdkfd side.

v2: Remove unreachable loop (thanks Sashiko-bot)

Signed-off-by: Kent Russell <kent.russell@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c        |  7 +++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c         |  5 ++---
 .../amdkfd/kfd_device_queue_manager_v12_1.c    | 18 ++++--------------
 drivers/gpu/drm/amd/amdkfd/kfd_process.c       |  7 +++++++
 4 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 08d3ff61edcc..d0ede277aa85 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -1151,6 +1151,13 @@ void amdgpu_gmc_noretry_set(struct amdgpu_device *adev)
 		gmc->noretry = 1;
 	else
 		gmc->noretry = (amdgpu_noretry == -1) ? noretry_default : amdgpu_noretry;
+
+	/* XNACK cannot be enabled on GFX12.1, so keep noretry=1 */
+	if (gc_ver == IP_VERSION(12, 1, 0)) {
+		if (amdgpu_noretry == 0)
+			dev_warn(adev->dev, "Unable to set noretry = 0 on GFX12.1. Keeping noretry = 1");
+		gmc->noretry = 1;
+	}
 }
 
 void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
index 1f57d0fa2c04..034cc3fd07f3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
@@ -1518,9 +1518,8 @@ static u32 gfx_v12_1_get_sh_mem_config(struct amdgpu_device *adev)
 {
 	u32 sh_mem_config = DEFAULT_SH_MEM_CONFIG;
 
-	/* GC 12.1.0 A0 requires RETRY_DISABLE in SH_MEM_CONFIG. */
-	if (SOC_V1_0_DIE_REV_XCD(adev->rev_id) == 0)
-		sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
+	/* XNACK cannot be enabled for GFX12.1 */
+	sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
 
 	return sh_mem_config;
 }
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
index 525989371378..63ba13a60b98 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
@@ -54,7 +54,6 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
 	struct kfd_process_device *pdd;
 	struct amdgpu_device *adev = dqm->dev->adev;
 	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)];
-	bool xnack_enabled;
 
 	pdd = qpd_to_pdd(qpd);
 	qpd->vm_cntx_cntl = hub->vm_cntx_cntl;
@@ -72,19 +71,10 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
 		qpd->sh_mem_ape1_base = 0;
 	}
 
-	xnack_enabled = KFD_SUPPORT_XNACK_PER_PROCESS(dqm->dev) ?
-			pdd->process->xnack_enabled :
-			!pdd->dev->kfd->noretry;
-
-	if (!xnack_enabled) {
-		qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
-		qpd->vm_cntx_cntl &=
-			~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
-	} else {
-		qpd->sh_mem_config &= ~(1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT);
-		qpd->vm_cntx_cntl |=
-			(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
-	}
+	/* XNACK cannot be enabled for gfx12.1 */
+	qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
+	qpd->vm_cntx_cntl &=
+		~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
 
 	qpd->sh_mem_bases = compute_sh_mem_bases_64bit(pdd);
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 546721b4d59a..059e22cd7f1a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -1670,6 +1670,13 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported)
 		    KFD_GC_VERSION(dev) < IP_VERSION(12, 1, 0))
 			return false;
 
+		/* XNACK cannot be enabled on GFX12.1 . While dev->kfd->noretry
+		 * should propagate this requirement, adding it explicitly here
+		 * will help cover any possible future reworks
+		 */
+		if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0))
+			return false;
+
 		if (dev->kfd->noretry)
 			return false;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1
  2026-11-16 19:11 [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1 Kent Russell
  2026-11-16 19:33 ` sashiko-bot
@ 2026-11-17 16:54 ` Mukul Joshi
  2026-11-17 21:36   ` Philip Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Mukul Joshi @ 2026-11-17 16:54 UTC (permalink / raw)
  To: amd-gfx


On 11/16/2026 2:11 PM, Kent Russell wrote:
> This feature cannot be properly supported, so disable it both on the
> amdgpu side and the amdkfd side.
>
> Signed-off-by: Kent Russell <kent.russell@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c        |  7 +++++++
>  drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c         |  5 ++---
>  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c       | 12 ++++++++++++
>  .../amdkfd/kfd_device_queue_manager_v12_1.c    | 18 ++++--------------
>  drivers/gpu/drm/amd/amdkfd/kfd_process.c       |  7 +++++++
>  5 files changed, 32 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index 08d3ff61edcc..d0ede277aa85 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -1151,6 +1151,13 @@ void amdgpu_gmc_noretry_set(struct amdgpu_device *adev)
>  		gmc->noretry = 1;
>  	else
>  		gmc->noretry = (amdgpu_noretry == -1) ? noretry_default : amdgpu_noretry;
> +
> +	/* XNACK cannot be enabled on GFX12.1, so keep noretry=1 */
> +	if (gc_ver == IP_VERSION(12, 1, 0)) {
> +		if (amdgpu_noretry == 0)
> +			dev_warn(adev->dev, "Unable to set noretry = 0 on GFX12.1. Keeping noretry = 1");
> +		gmc->noretry = 1;
> +	}
>  }
>  
>  void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
> index 1f57d0fa2c04..034cc3fd07f3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
> @@ -1518,9 +1518,8 @@ static u32 gfx_v12_1_get_sh_mem_config(struct amdgpu_device *adev)
>  {
>  	u32 sh_mem_config = DEFAULT_SH_MEM_CONFIG;
>  
> -	/* GC 12.1.0 A0 requires RETRY_DISABLE in SH_MEM_CONFIG. */
> -	if (SOC_V1_0_DIE_REV_XCD(adev->rev_id) == 0)
> -		sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
> +	/* XNACK cannot be enabled for GFX12.1 */
> +	sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;

I think we only the above 2 changes. I don't think we need the changes
below.

noretry=1 should handle the conditions below correctly anyways.

Regards,

Mukul

>  	return sh_mem_config;
>  }
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 3d2136adb62b..3b62b9e5ecda 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1766,6 +1766,8 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
>  
>  	mutex_lock(&p->mutex);
>  	if (args->xnack_enabled >= 0) {
> +		int i;
> +
>  		if (!list_empty(&p->pqm.queues)) {
>  			pr_debug("Process has user queues running\n");
>  			r = -EBUSY;
> @@ -1780,6 +1782,16 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
>  			goto out_unlock;
>  		}
>  
> +		/* XNACK cannot be enabled for gfx12.1 */
> +		for (i = 0; i < p->n_pdds; i++) {
> +			struct kfd_node *dev = p->pdds[i]->dev;
> +
> +			if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0)) {
> +				r = -EPERM;
> +				goto out_unlock;
> +			}
> +		}
> +
>  		r = svm_range_switch_xnack_reserve_mem(p, args->xnack_enabled);
>  	} else {
>  		args->xnack_enabled = p->xnack_enabled;
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
> index 525989371378..63ba13a60b98 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
> @@ -54,7 +54,6 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
>  	struct kfd_process_device *pdd;
>  	struct amdgpu_device *adev = dqm->dev->adev;
>  	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)];
> -	bool xnack_enabled;
>  
>  	pdd = qpd_to_pdd(qpd);
>  	qpd->vm_cntx_cntl = hub->vm_cntx_cntl;
> @@ -72,19 +71,10 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
>  		qpd->sh_mem_ape1_base = 0;
>  	}
>  
> -	xnack_enabled = KFD_SUPPORT_XNACK_PER_PROCESS(dqm->dev) ?
> -			pdd->process->xnack_enabled :
> -			!pdd->dev->kfd->noretry;
> -
> -	if (!xnack_enabled) {
> -		qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
> -		qpd->vm_cntx_cntl &=
> -			~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
> -	} else {
> -		qpd->sh_mem_config &= ~(1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT);
> -		qpd->vm_cntx_cntl |=
> -			(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
> -	}
> +	/* XNACK cannot be enabled for gfx12.1 */
> +	qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
> +	qpd->vm_cntx_cntl &=
> +		~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
>  
>  	qpd->sh_mem_bases = compute_sh_mem_bases_64bit(pdd);
>  
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 546721b4d59a..059e22cd7f1a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -1670,6 +1670,13 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported)
>  		    KFD_GC_VERSION(dev) < IP_VERSION(12, 1, 0))
>  			return false;
>  
> +		/* XNACK cannot be enabled on GFX12.1 . While dev->kfd->noretry
> +		 * should propagate this requirement, adding it explicitly here
> +		 * will help cover any possible future reworks
> +		 */
> +		if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0))
> +			return false;
> +
>  		if (dev->kfd->noretry)
>  			return false;
>  	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1
  2026-11-17 16:54 ` Mukul Joshi
@ 2026-11-17 21:36   ` Philip Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Philip Yang @ 2026-11-17 21:36 UTC (permalink / raw)
  To: Mukul Joshi, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 6037 bytes --]



On 2026-11-17 11:54, Mukul Joshi wrote:
> On 11/16/2026 2:11 PM, Kent Russell wrote:
>> This feature cannot be properly supported, so disable it both on the
>> amdgpu side and the amdkfd side.
>>
>> Signed-off-by: Kent Russell<kent.russell@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c        |  7 +++++++
>>   drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c         |  5 ++---
>>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c       | 12 ++++++++++++
>>   .../amdkfd/kfd_device_queue_manager_v12_1.c    | 18 ++++--------------
>>   drivers/gpu/drm/amd/amdkfd/kfd_process.c       |  7 +++++++
>>   5 files changed, 32 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> index 08d3ff61edcc..d0ede277aa85 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> @@ -1151,6 +1151,13 @@ void amdgpu_gmc_noretry_set(struct amdgpu_device *adev)
>>   		gmc->noretry = 1;
>>   	else
>>   		gmc->noretry = (amdgpu_noretry == -1) ? noretry_default : amdgpu_noretry;
>> +
>> +	/* XNACK cannot be enabled on GFX12.1, so keep noretry=1 */
>> +	if (gc_ver == IP_VERSION(12, 1, 0)) {
>> +		if (amdgpu_noretry == 0)
>> +			dev_warn(adev->dev, "Unable to set noretry = 0 on GFX12.1. Keeping noretry = 1");
>> +		gmc->noretry = 1;
>> +	}
>>   }
>>   
>>   void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
>> index 1f57d0fa2c04..034cc3fd07f3 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
>> @@ -1518,9 +1518,8 @@ static u32 gfx_v12_1_get_sh_mem_config(struct amdgpu_device *adev)
>>   {
>>   	u32 sh_mem_config = DEFAULT_SH_MEM_CONFIG;
>>   
>> -	/* GC 12.1.0 A0 requires RETRY_DISABLE in SH_MEM_CONFIG. */
>> -	if (SOC_V1_0_DIE_REV_XCD(adev->rev_id) == 0)
>> -		sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
>> +	/* XNACK cannot be enabled for GFX12.1 */
>> +	sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
> I think we only the above 2 changes. I don't think we need the changes
> below.
>
> noretry=1 should handle the conditions below correctly anyways.
yes, I think change are limited in function kfd_process_xnack_mode() and 
function update_qpd_v12_1(), then set XNACK+ will return failure and 
qpd->sh_mem_config is always set to xnack- regardless of boottime 
noretry parameter. Regards, Philip
>
> Regards,
>
> Mukul
>
>>   	return sh_mem_config;
>>   }
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> index 3d2136adb62b..3b62b9e5ecda 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
>> @@ -1766,6 +1766,8 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
>>   
>>   	mutex_lock(&p->mutex);
>>   	if (args->xnack_enabled >= 0) {
>> +		int i;
>> +
>>   		if (!list_empty(&p->pqm.queues)) {
>>   			pr_debug("Process has user queues running\n");
>>   			r = -EBUSY;
>> @@ -1780,6 +1782,16 @@ static int kfd_ioctl_set_xnack_mode(struct file *filep,
>>   			goto out_unlock;
>>   		}
>>   
>> +		/* XNACK cannot be enabled for gfx12.1 */
>> +		for (i = 0; i < p->n_pdds; i++) {
>> +			struct kfd_node *dev = p->pdds[i]->dev;
>> +
>> +			if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0)) {
>> +				r = -EPERM;
>> +				goto out_unlock;
>> +			}
>> +		}
>> +
>>   		r = svm_range_switch_xnack_reserve_mem(p, args->xnack_enabled);
>>   	} else {
>>   		args->xnack_enabled = p->xnack_enabled;
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
>> index 525989371378..63ba13a60b98 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v12_1.c
>> @@ -54,7 +54,6 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
>>   	struct kfd_process_device *pdd;
>>   	struct amdgpu_device *adev = dqm->dev->adev;
>>   	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB(0)];
>> -	bool xnack_enabled;
>>   
>>   	pdd = qpd_to_pdd(qpd);
>>   	qpd->vm_cntx_cntl = hub->vm_cntx_cntl;
>> @@ -72,19 +71,10 @@ static int update_qpd_v12_1(struct device_queue_manager *dqm,
>>   		qpd->sh_mem_ape1_base = 0;
>>   	}
>>   
>> -	xnack_enabled = KFD_SUPPORT_XNACK_PER_PROCESS(dqm->dev) ?
>> -			pdd->process->xnack_enabled :
>> -			!pdd->dev->kfd->noretry;
>> -
>> -	if (!xnack_enabled) {
>> -		qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
>> -		qpd->vm_cntx_cntl &=
>> -			~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
>> -	} else {
>> -		qpd->sh_mem_config &= ~(1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT);
>> -		qpd->vm_cntx_cntl |=
>> -			(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
>> -	}
>> +	/* XNACK cannot be enabled for gfx12.1 */
>> +	qpd->sh_mem_config |= 1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;
>> +	qpd->vm_cntx_cntl &=
>> +		~(1 << GCVM_CONTEXT0_CNTL__RETRY_PERMISSION_OR_INVALID_PAGE_FAULT__SHIFT);
>>   
>>   	qpd->sh_mem_bases = compute_sh_mem_bases_64bit(pdd);
>>   
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>> index 546721b4d59a..059e22cd7f1a 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>> @@ -1670,6 +1670,13 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported)
>>   		    KFD_GC_VERSION(dev) < IP_VERSION(12, 1, 0))
>>   			return false;
>>   
>> +		/* XNACK cannot be enabled on GFX12.1 . While dev->kfd->noretry
>> +		 * should propagate this requirement, adding it explicitly here
>> +		 * will help cover any possible future reworks
>> +		 */
>> +		if (KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0))
>> +			return false;
>> +
>>   		if (dev->kfd->noretry)
>>   			return false;
>>   	}

[-- Attachment #2: Type: text/html, Size: 6855 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-17 21:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 19:11 [PATCH] drm/amdgpu: Disable XNACK retry on GFX12.1 Kent Russell
2026-11-16 19:33 ` sashiko-bot
2026-11-17 16:54 ` Mukul Joshi
2026-11-17 21:36   ` Philip Yang
  -- strict thread matches above, loose matches on Subject: below --
2026-11-16 21:55 Kent Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox