2023-10-31 02:56:06

by guanjun

[permalink] [raw]
Subject: [PATCH v4 0/2] Some fixes for idxd driver

From: Guanjun <[email protected]>

Hi Dave, Fenghua,
As we talked in v1 and v2, I add fixes tag in patch 0 and change some
descriptions in patch 1.
If there are no other issues, please queue it up.

Thanks,
Guanjun

Guanjun (2):
dmaengine: idxd: Protect int_handle field in hw descriptor
dmaengine: idxd: Fix incorrect descriptions for GRPCFG register

drivers/dma/idxd/registers.h | 12 +++++++-----
drivers/dma/idxd/submit.c | 14 +++++++-------
2 files changed, 14 insertions(+), 12 deletions(-)

--
2.39.3


2023-10-31 02:56:29

by guanjun

[permalink] [raw]
Subject: [PATCH v4 1/2] dmaengine: idxd: Protect int_handle field in hw descriptor

From: Guanjun <[email protected]>

The int_handle field in hw descriptor should also be protected
by wmb() before possibly triggering a DMA read.

Fixes: ec0d64231615 (dmaengine: idxd: embed irq_entry in idxd_wq struct)
Signed-off-by: Guanjun <[email protected]>
Reviewed-by: Dave Jiang <[email protected]>
Reviewed-by: Fenghua Yu <[email protected]>
---
drivers/dma/idxd/submit.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/idxd/submit.c b/drivers/dma/idxd/submit.c
index c01db23e3333..3f922518e3a5 100644
--- a/drivers/dma/idxd/submit.c
+++ b/drivers/dma/idxd/submit.c
@@ -182,13 +182,6 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc)

portal = idxd_wq_portal_addr(wq);

- /*
- * The wmb() flushes writes to coherent DMA data before
- * possibly triggering a DMA read. The wmb() is necessary
- * even on UP because the recipient is a device.
- */
- wmb();
-
/*
* Pending the descriptor to the lockless list for the irq_entry
* that we designated the descriptor to.
@@ -199,6 +192,13 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc)
llist_add(&desc->llnode, &ie->pending_llist);
}

+ /*
+ * The wmb() flushes writes to coherent DMA data before
+ * possibly triggering a DMA read. The wmb() is necessary
+ * even on UP because the recipient is a device.
+ */
+ wmb();
+
if (wq_dedicated(wq)) {
iosubmit_cmds512(portal, desc->hw, 1);
} else {
--
2.39.3

2023-10-31 15:58:16

by Lijun Pan

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dmaengine: idxd: Protect int_handle field in hw descriptor



On 10/30/2023 9:55 PM, 'Guanjun' wrote:
> From: Guanjun <[email protected]>
>
> The int_handle field in hw descriptor should also be protected
> by wmb() before possibly triggering a DMA read.
>
> Fixes: ec0d64231615 (dmaengine: idxd: embed irq_entry in idxd_wq struct)

I think the direct fix is to eb0cf33a91b4 which moves the interrupt
handle assignment to idxd_submit_desc() and has a write to
desc->hw->int_handle before submission of desc->hw.

Fixes: eb0cf33a91b4 ("dmaengine: idxd: move interrupt handle assignment")

Other than that,
Reviewed-by: Lijun Pan <[email protected]>


> Signed-off-by: Guanjun <[email protected]>
> Reviewed-by: Dave Jiang <[email protected]>
> Reviewed-by: Fenghua Yu <[email protected]>
> ---
> drivers/dma/idxd/submit.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/dma/idxd/submit.c b/drivers/dma/idxd/submit.c
> index c01db23e3333..3f922518e3a5 100644
> --- a/drivers/dma/idxd/submit.c
> +++ b/drivers/dma/idxd/submit.c
> @@ -182,13 +182,6 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc)
>
> portal = idxd_wq_portal_addr(wq);
>
> - /*
> - * The wmb() flushes writes to coherent DMA data before
> - * possibly triggering a DMA read. The wmb() is necessary
> - * even on UP because the recipient is a device.
> - */
> - wmb();
> -
> /*
> * Pending the descriptor to the lockless list for the irq_entry
> * that we designated the descriptor to.
> @@ -199,6 +192,13 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc)
> llist_add(&desc->llnode, &ie->pending_llist);
> }
>
> + /*
> + * The wmb() flushes writes to coherent DMA data before
> + * possibly triggering a DMA read. The wmb() is necessary
> + * even on UP because the recipient is a device.
> + */
> + wmb();
> +
> if (wq_dedicated(wq)) {
> iosubmit_cmds512(portal, desc->hw, 1);
> } else {