dmaengine: switchtec-dma: fix FIELD_GET misuse when programming SE threshold
Subsystems (2)
PATCH 1/1 dmaengine: switchtec-dma: fix FIELD_GET misuse when programming SE threshold
FIELD_GET(SE_THRESH_MASK, thresh) extracts bits [31:23] from thresh and right-shifts them, which is the inverse of the intended operation. Since thresh is derived from se_buf_len / 2 (at most 255), bits [31:23] are always zero, so the SE threshold is never actually programmed into the register.
Use FIELD_PREP() instead to correctly left-shift thresh into bits [31:23] of the valid_en_se register, consistent with the FIELD_PREP usage for the perf tuner config just above.
--- drivers/dma/switchtec_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/switchtec_dma.c +1 -1
@@ -1099,7 +1099,7 @@ static int switchtec_dma_chan_init(struct switchtec_dma_dev *swdma_dev,dev_dbg (&pdev->dev,"Channel %d: SE buffer count %d\n" , i, se_buf_len); thresh = se_buf_len /2 ; - valid_en_se |=FIELD_GET (SE_THRESH_MASK , thresh); + valid_en_se |=FIELD_PREP (SE_THRESH_MASK , thresh);writel (valid_en_se, &swdma_chan->mmio_chan_fw->valid_en_se);/* request irqs */
Signature · 1 line
2.53.0
Logan Gunthorpe
maintainerQuoted 6 lines · David Carlier
FIELD_GET(SE_THRESH_MASK, thresh)extracts bits [31:23] from thresh and right-shifts them, which is the inverse of the intended operation. Since thresh is derived fromse_buf_len/ 2 (at most 255), bits [31:23] are always zero, so the SE threshold is never actually programmed into the register.
Quoted 6 lines
Use
FIELD_PREP()instead to correctly left-shift thresh into bits [31:23] of thevalid_en_seregister, consistent with theFIELD_PREPusage for the perf tuner config just above.Fixes 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")Signed-off-by David Carlier <[email protected]>
Sorry for the delay for me to look at this, I just got back from vacation.
Butt yes this looks correct.
Thanks for the quick catch on that mistake!
Quoted 6 lines · David Carlier
FIELD_GET(SE_THRESH_MASK, thresh)extracts bits [31:23] from thresh and right-shifts them, which is the inverse of the intended operation. Since thresh is derived fromse_buf_len/ 2 (at most 255), bits [31:23] are always zero, so the SE threshold is never actually programmed into the register.
Quoted 7 lines
Use
FIELD_PREP()instead to correctly left-shift thresh into bits [31:23] of thevalid_en_seregister, consistent with theFIELD_PREPusage for the perf tuner config just above.Fixes 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")Signed-off-by David Carlier <[email protected]>---
Quoted 19 lines
drivers/dma/switchtec_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/switchtec_dma.c +1
-2@@ -1099,7 +1099,7 @@ static int switchtec_dma_chan_init(struct switchtec_dma_dev *swdma_dev,dev_dbg (&pdev->dev,"Channel %d: SE buffer count %d\n" , i, se_buf_len); thresh = se_buf_len /2 ; - valid_en_se |=FIELD_GET (SE_THRESH_MASK , thresh); + valid_en_se |=FIELD_PREP (SE_THRESH_MASK , thresh);writel (valid_en_se, &swdma_chan->mmio_chan_fw->valid_en_se);/* request irqs */ --2.53.0
Hi Vinod,
Following up on this one-line fix. The bug is still present in linux-next as of next-20260521 at drivers/dma/switchtec_dma.c:1102 — FIELD_GET extracts a zero from the 9-bit thresh value against the bits 23-31 mask, so the SE threshold field is never actually written.
Original posting:
https://lore.kernel.org/dmaengine/[email protected]/
Thanks,
David
Quoted 11 lines · David Carlier
FIELD_GET(SE_THRESH_MASK, thresh)extracts bits [31:23] from thresh and right-shifts them, which is the inverse of the intended operation. Since thresh is derived fromse_buf_len/ 2 (at most 255), bits [31:23] are always zero, so the SE threshold is never actually programmed into the register.Use
FIELD_PREP()instead to correctly left-shift thresh into bits [31:23] of thevalid_en_seregister, consistent with theFIELD_PREPusage for the perf tuner config just above.[...]
Applied, thanks!
[1/1] dmaengine: switchtec-dma: fix FIELD_GET misuse when programming SE threshold
commit: 9d12eb98582fec2578d17e025b13740dcfb57d8e
Best regards,
Signature · 1 line
~Vinod