Skip to contentSkip to conversation

n64cart: fix the dma address in n64cart_do_bvec

PATCH Applied Christoph Hellwig 3 participants 5 messages Aug 4, 2021 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 n64cart: fix the dma address in n64cart_do_bvec

dma_map_bvec already takes bv_offset into account.

Fixes 9b2a2bbbb4d0 ("block: Add n64 cart driver")
---
 drivers/block/n64cart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/n64cart.c +1 -1
index 7b4dd10af9ec..c84be0028f63 100644
@@ -74,7 +74,7 @@ static bool n64cart_do_bvec(struct device *dev, struct bio_vec *bv, u32 pos)
 
 	n64cart_wait_dma();
 
-	n64cart_write_reg(PI_DRAM_REG, dma_addr + bv->bv_offset);
+	n64cart_write_reg(PI_DRAM_REG, dma_addr);
 	n64cart_write_reg(PI_CART_REG, (bstart | CART_DOMAIN) & CART_MAX);
 	n64cart_write_reg(PI_WRITE_REG, bv->bv_len - 1);
 
Signature · 1 line
2.30.2
#1 lore raw
Quoted 13 lines · On Wed, 4 Aug 2021 11:49:58 +0200 Christoph Hellwig <[email protected]> wrote:

dma_map_bvec already takes bv_offset into account.

Fixes 9b2a2bbbb4d0 ("block: Add n64 cart driver")
---
 drivers/block/n64cart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/n64cart.c +0 -0
index 7b4dd10af9ec..c84be0028f63 100644

drivers/block/n64cart.c static bool n64cart_do_bvec(struct device *dev, struct bio_vec *bv, u32 pos) · line 79

Quoted 7 lines
drivers/block/n64cart.c +1 -1
@@ -74,7 +74,7 @@ static bool n64cart_do_bvec(struct device *dev, struct bio_vec *bv, u32 pos)
 
 	n64cart_wait_dma();
 
-	n64cart_write_reg(PI_DRAM_REG, dma_addr + bv->bv_offset);
+	n64cart_write_reg(PI_DRAM_REG, dma_addr);
 	n64cart_write_reg(PI_CART_REG, (bstart | CART_DOMAIN) & CART_MAX);
 	n64cart_write_reg(PI_WRITE_REG, bv->bv_len - 1);

Hm, then how did it work? Does it always happen to be zero?

Have you tested this? I don't have the equipment currently.

- Lauri

#2 lore raw
Quoted 6 lines · Lauri Kasanen
Quoted 6 lines
drivers/block/n64cart.c +0 -0
index 7b4dd10af9ec..c84be0028f63 100644
@@ -74,7 +74,7 @@ static bool n64cart_do_bvec(struct device *dev, struct bio_vec *bv, u32 pos)
 
Quoted 8 lines

drivers/block/n64cart.c static bool n64cart_do_bvec(struct device *dev, struct bio_vec *bv, u32 pos) · line 79

Quoted 6 lines
drivers/block/n64cart.c +1 -1
 	n64cart_wait_dma();
 
-	n64cart_write_reg(PI_DRAM_REG, dma_addr + bv->bv_offset);
+	n64cart_write_reg(PI_DRAM_REG, dma_addr);
 	n64cart_write_reg(PI_CART_REG, (bstart | CART_DOMAIN) & CART_MAX);
 	n64cart_write_reg(PI_WRITE_REG, bv->bv_len - 1);

Hm, then how did it work? Does it always happen to be zero?

It isn't always zero, but for your use cases it might. That is if you have a page aligned buffer (e.g. the page cache) it tends to be zero.

Quoted 1 line

Have you tested this? I don't have the equipment currently.

No, I don't. I'm just auditing uses of bv_offset and this one is clearly bogus.

#3 lore raw
Quoted 4 lines · On Wed, 4 Aug 2021 12:02:03 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 1 line

Have you tested this? I don't have the equipment currently.

No, I don't. I'm just auditing uses of bv_offset and this one is clearly bogus.

I won't have the chance to test until about two months from now. So I can't ack it until then. But it's probably fine to apply now.

- Lauri