Skip to contentSkip to conversation

dmaengine: switchtec-dma: fix FIELD_GET misuse when programming SE threshold

PATCH Applied David Carlier 4 participants 5 messages Mar 17 – Jul 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")
---
 drivers/dma/switchtec_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/switchtec_dma.c +1 -1
index 3ef928640615..71d9868ce613 100644
@@ -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
maintainer
#1 lore raw
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 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.

Quoted 6 lines

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.

Fixes 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")

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!

Reviewed-by on v1 1/1
#2 lore raw
In reply to David Carlier
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 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.

Quoted 7 lines

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.

Fixes 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")

---

Quoted 19 lines
 drivers/dma/switchtec_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/switchtec_dma.c +1 -2
index 3ef928640615..71d9868ce613 100644
@@ -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

maintainer Applied
#4 lore raw
In reply to David Carlier
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 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.

[...]

Applied, thanks!

[1/1] dmaengine: switchtec-dma: fix FIELD_GET misuse when programming SE threshold

      commit: 9d12eb98582fec2578d17e025b13740dcfb57d8e

Best regards,

Signature · 1 line
~Vinod