mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] dmaengine: idxd: drain ATS translations when disabling WQ
@ 2025-10-01  1:22 Vinicius Costa Gomes
  2025-10-01 15:42 ` Dave Jiang
  2025-10-16 15:02 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Vinicius Costa Gomes @ 2025-10-01  1:22 UTC (permalink / raw)
  To: dmaengine; +Cc: dave.jiang, vkoul, linux-kernel, Vinicius Costa Gomes

From: Nikhil Rao <nikhil.rao@intel.com>

There's an errata[1], for the Disable WQ command that it
does not guaranteee that address translations are drained. If WQ
configuration is updated, pending address translations can use an
updated WQ configuration, resulting an invalid translation response
that is cached in the device translation cache.

Replace the Disable WQ command with a Drain WQ command followed by a
Reset WQ command, this guarantees that all ATS translations are
drained from the device before changing WQ configuration.

[1] https://cdrdv2.intel.com/v1/dl/getcontent/843306 ("Intel DSA May
Cause Invalid Translation Caching")

Signed-off-by: Nikhil Rao <nikhil.rao@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
---
 drivers/dma/idxd/device.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
index 5cf419fe6b46..c2cdf41b6e57 100644
--- a/drivers/dma/idxd/device.c
+++ b/drivers/dma/idxd/device.c
@@ -16,6 +16,7 @@ static void idxd_cmd_exec(struct idxd_device *idxd, int cmd_code, u32 operand,
 			  u32 *status);
 static void idxd_device_wqs_clear_state(struct idxd_device *idxd);
 static void idxd_wq_disable_cleanup(struct idxd_wq *wq);
+static int idxd_wq_config_write(struct idxd_wq *wq);
 
 /* Interrupt control bits */
 void idxd_unmask_error_interrupts(struct idxd_device *idxd)
@@ -215,14 +216,28 @@ int idxd_wq_disable(struct idxd_wq *wq, bool reset_config)
 		return 0;
 	}
 
+	/*
+	 * Disable WQ does not drain address translations, if WQ attributes are
+	 * changed before translations are drained, pending translations can
+	 * be issued using updated WQ attibutes, resulting in invalid
+	 * translations being cached in the device translation cache.
+	 *
+	 * To make sure pending translations are drained before WQ
+	 * attributes are changed, we use a WQ Drain followed by WQ Reset and
+	 * then restore the WQ configuration.
+	 */
+	idxd_wq_drain(wq);
+
 	operand = BIT(wq->id % 16) | ((wq->id / 16) << 16);
-	idxd_cmd_exec(idxd, IDXD_CMD_DISABLE_WQ, operand, &status);
+	idxd_cmd_exec(idxd, IDXD_CMD_RESET_WQ, operand, &status);
 
 	if (status != IDXD_CMDSTS_SUCCESS) {
-		dev_dbg(dev, "WQ disable failed: %#x\n", status);
+		dev_dbg(dev, "WQ reset failed: %#x\n", status);
 		return -ENXIO;
 	}
 
+	idxd_wq_config_write(wq);
+
 	if (reset_config)
 		idxd_wq_disable_cleanup(wq);
 	clear_bit(wq->id, idxd->wq_enable_map);
-- 
2.51.0


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

* Re: [PATCH v1] dmaengine: idxd: drain ATS translations when disabling WQ
  2025-10-01  1:22 [PATCH v1] dmaengine: idxd: drain ATS translations when disabling WQ Vinicius Costa Gomes
@ 2025-10-01 15:42 ` Dave Jiang
  2025-10-16 15:02 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2025-10-01 15:42 UTC (permalink / raw)
  To: Vinicius Costa Gomes, dmaengine; +Cc: vkoul, linux-kernel



On 9/30/25 6:22 PM, Vinicius Costa Gomes wrote:
> From: Nikhil Rao <nikhil.rao@intel.com>
> 
> There's an errata[1], for the Disable WQ command that it
> does not guaranteee that address translations are drained. If WQ
> configuration is updated, pending address translations can use an
> updated WQ configuration, resulting an invalid translation response
> that is cached in the device translation cache.
> 
> Replace the Disable WQ command with a Drain WQ command followed by a
> Reset WQ command, this guarantees that all ATS translations are
> drained from the device before changing WQ configuration.
> 
> [1] https://cdrdv2.intel.com/v1/dl/getcontent/843306 ("Intel DSA May
> Cause Invalid Translation Caching")
> 
> Signed-off-by: Nikhil Rao <nikhil.rao@intel.com>
> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/dma/idxd/device.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
> index 5cf419fe6b46..c2cdf41b6e57 100644
> --- a/drivers/dma/idxd/device.c
> +++ b/drivers/dma/idxd/device.c
> @@ -16,6 +16,7 @@ static void idxd_cmd_exec(struct idxd_device *idxd, int cmd_code, u32 operand,
>  			  u32 *status);
>  static void idxd_device_wqs_clear_state(struct idxd_device *idxd);
>  static void idxd_wq_disable_cleanup(struct idxd_wq *wq);
> +static int idxd_wq_config_write(struct idxd_wq *wq);
>  
>  /* Interrupt control bits */
>  void idxd_unmask_error_interrupts(struct idxd_device *idxd)
> @@ -215,14 +216,28 @@ int idxd_wq_disable(struct idxd_wq *wq, bool reset_config)
>  		return 0;
>  	}
>  
> +	/*
> +	 * Disable WQ does not drain address translations, if WQ attributes are
> +	 * changed before translations are drained, pending translations can
> +	 * be issued using updated WQ attibutes, resulting in invalid
> +	 * translations being cached in the device translation cache.
> +	 *
> +	 * To make sure pending translations are drained before WQ
> +	 * attributes are changed, we use a WQ Drain followed by WQ Reset and
> +	 * then restore the WQ configuration.
> +	 */
> +	idxd_wq_drain(wq);
> +
>  	operand = BIT(wq->id % 16) | ((wq->id / 16) << 16);
> -	idxd_cmd_exec(idxd, IDXD_CMD_DISABLE_WQ, operand, &status);
> +	idxd_cmd_exec(idxd, IDXD_CMD_RESET_WQ, operand, &status);
>  
>  	if (status != IDXD_CMDSTS_SUCCESS) {
> -		dev_dbg(dev, "WQ disable failed: %#x\n", status);
> +		dev_dbg(dev, "WQ reset failed: %#x\n", status);
>  		return -ENXIO;
>  	}
>  
> +	idxd_wq_config_write(wq);
> +
>  	if (reset_config)
>  		idxd_wq_disable_cleanup(wq);
>  	clear_bit(wq->id, idxd->wq_enable_map);


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

* Re: [PATCH v1] dmaengine: idxd: drain ATS translations when disabling WQ
  2025-10-01  1:22 [PATCH v1] dmaengine: idxd: drain ATS translations when disabling WQ Vinicius Costa Gomes
  2025-10-01 15:42 ` Dave Jiang
@ 2025-10-16 15:02 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2025-10-16 15:02 UTC (permalink / raw)
  To: dmaengine, Vinicius Costa Gomes; +Cc: dave.jiang, linux-kernel


On Tue, 30 Sep 2025 18:22:26 -0700, Vinicius Costa Gomes wrote:
> There's an errata[1], for the Disable WQ command that it
> does not guaranteee that address translations are drained. If WQ
> configuration is updated, pending address translations can use an
> updated WQ configuration, resulting an invalid translation response
> that is cached in the device translation cache.
> 
> Replace the Disable WQ command with a Drain WQ command followed by a
> Reset WQ command, this guarantees that all ATS translations are
> drained from the device before changing WQ configuration.
> 
> [...]

Applied, thanks!

[1/1] dmaengine: idxd: drain ATS translations when disabling WQ
      commit: f80ea8566917c4bb680911db839a170873e5d17c

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2025-10-16 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-01  1:22 [PATCH v1] dmaengine: idxd: drain ATS translations when disabling WQ Vinicius Costa Gomes
2025-10-01 15:42 ` Dave Jiang
2025-10-16 15:02 ` Vinod Koul

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

all inboxes | Powered by JetHome®