Skip to contentSkip to conversation

dma: apbh: pass integer, not pointer as value to writel

PATCH Applied Ahmad Fatoum 2 participants 3 messages Jun 2, 2025

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

PATCH 1/2 dma: apbh: pass integer, not pointer as value to writel

In preparation for enforcing that at least the value of writeX is an integer, a number of places writing a pointer were noticed.

Add a virt_to_phys to paper over this with a comment that this is not completely correct.

---
 drivers/dma/apbh_dma.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/dma/apbh_dma.c +9 -2
index 298f706f1bcd..fb8b6b304cf0 100644
@@ -103,6 +103,7 @@ int mxs_dma_go(int chan, struct mxs_dma_cmd *cmd, int ncmds)
 	struct apbh_dma *apbh = apbh_dma;
 	uint32_t timeout = 10000;
 	int i, ret, channel_bit;
+	dma_addr_t dma;
 
 	ret = mxs_dma_validate_chan(chan);
 	if (ret)
@@ -113,12 +114,18 @@ int mxs_dma_go(int chan, struct mxs_dma_cmd *cmd, int ncmds)
 		cmd[i].data |= MXS_DMA_DESC_CHAIN;
 	}
 
+	/*
+	 * TODO: cmd is in DMA coherent memory, but it uses DMA_ADDRESS_BROKEN,
+	 * and thus assumes a 1:1 mapping here
+	 */
+	dma = virt_to_phys(cmd);
+
 	if (apbh_dma_is_imx23(apbh)) {
-		writel(cmd, apbh->regs + HW_APBHX_CHn_NXTCMDAR_MX23(chan));
+		writel(dma, apbh->regs + HW_APBHX_CHn_NXTCMDAR_MX23(chan));
 		writel(1, apbh->regs + HW_APBHX_CHn_SEMA_MX23(chan));
 		channel_bit = chan + BP_APBH_CTRL0_CLKGATE_CHANNEL;
 	} else {
-		writel(cmd, apbh->regs + HW_APBHX_CHn_NXTCMDAR_MX28(chan));
+		writel(dma, apbh->regs + HW_APBHX_CHn_NXTCMDAR_MX28(chan));
 		writel(1, apbh->regs + HW_APBHX_CHn_SEMA_MX28(chan));
 		channel_bit = chan;
 	}
Signature · 1 line
2.39.5
#1 lore raw

PATCH 2/2 ARM: Arria10: xload: don't check writel return value

No one checks a10_update_bits()'s return value, which is good as return value has no indication over operation success anyway.

Make it void and fix this.

---
 arch/arm/mach-socfpga/arria10-xload.c | 7 ++-----
 include/mach/socfpga/arria10-xload.h  | 2 +-
 2 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-socfpga/arria10-xload.c +2 -5
index fb87135ca94a..4c8f9c7f0e55 100644
@@ -16,20 +16,17 @@
 #include <mach/socfpga/generic.h>
 #include <linux/sizes.h>
 
-int a10_update_bits(unsigned int reg, unsigned int mask,
+void a10_update_bits(unsigned int reg, unsigned int mask,
 		    unsigned int val)
 {
 	unsigned int tmp, orig;
-	int ret = 0;
 
 	orig = readl(ARRIA10_FPGAMGRREGS_ADDR + reg);
 	tmp = orig & ~mask;
 	tmp |= val & mask;
 
 	if (tmp != orig)
-		ret = writel(tmp, ARRIA10_FPGAMGRREGS_ADDR + reg);
-
-	return ret;
+		writel(tmp, ARRIA10_FPGAMGRREGS_ADDR + reg);
 }
 
 static uint32_t socfpga_a10_fpga_read_stat(void)
include/mach/socfpga/arria10-xload.h +1 -1
index c58ab7f8cfd2..b7f100d90a96 100644
@@ -6,7 +6,7 @@
 void arria10_init_mmc(void);
 int arria10_prepare_mmc(int barebox_part, int rbf_part);
 int arria10_read_blocks(void *dst, int blocknum, size_t len);
-int a10_update_bits(unsigned int reg, unsigned int mask, unsigned int val);
+void a10_update_bits(unsigned int reg, unsigned int mask, unsigned int val);
 
 struct partition {
 	uint64_t first_sec;
Signature · 1 line
2.39.5
Applied
#2 lore raw
In reply to Ahmad Fatoum
Quoted 8 lines · Ahmad Fatoum

In preparation for enforcing that at least the value of writeX is an integer, a number of places writing a pointer were noticed.

Add a virt_to_phys to paper over this with a comment that this is not completely correct.

[...]

Applied, thanks!

[1/2] dma: apbh: pass integer, not pointer as value to writel
https://git.pengutronix.de/cgit/barebox/commit/?id=5b273a2603da (link may not be stable)
[2/2] ARM: Arria10: xload: don't check writel return value
https://git.pengutronix.de/cgit/barebox/commit/?id=b887a5b9297f (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>