linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] n64cart: fix the dma address in n64cart_do_bvec
@ 2021-08-04  9:49 Christoph Hellwig
  2021-08-04 10:01 ` Lauri Kasanen
  2021-08-04 17:15 ` Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-08-04  9:49 UTC (permalink / raw)
  To: cand, axboe; +Cc: linux-block

dma_map_bvec already takes bv_offset into account.

Fixes: 9b2a2bbbb4d0 ("block: Add n64 cart driver")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/n64cart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/n64cart.c b/drivers/block/n64cart.c
index 7b4dd10af9ec..c84be0028f63 100644
--- a/drivers/block/n64cart.c
+++ b/drivers/block/n64cart.c
@@ -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);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] n64cart: fix the dma address in n64cart_do_bvec
  2021-08-04  9:49 [PATCH] n64cart: fix the dma address in n64cart_do_bvec Christoph Hellwig
@ 2021-08-04 10:01 ` Lauri Kasanen
  2021-08-04 10:02   ` Christoph Hellwig
  2021-08-04 17:15 ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Lauri Kasanen @ 2021-08-04 10:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, linux-block

On Wed,  4 Aug 2021 11:49:58 +0200
Christoph Hellwig <hch@lst.de> wrote:

> dma_map_bvec already takes bv_offset into account.
>
> Fixes: 9b2a2bbbb4d0 ("block: Add n64 cart driver")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/block/n64cart.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/n64cart.c b/drivers/block/n64cart.c
> index 7b4dd10af9ec..c84be0028f63 100644
> --- a/drivers/block/n64cart.c
> +++ b/drivers/block/n64cart.c
> @@ -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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] n64cart: fix the dma address in n64cart_do_bvec
  2021-08-04 10:01 ` Lauri Kasanen
@ 2021-08-04 10:02   ` Christoph Hellwig
  2021-08-04 10:16     ` Lauri Kasanen
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-08-04 10:02 UTC (permalink / raw)
  To: Lauri Kasanen; +Cc: Christoph Hellwig, axboe, linux-block

On Wed, Aug 04, 2021 at 01:01:36PM +0300, Lauri Kasanen wrote:
> > diff --git a/drivers/block/n64cart.c b/drivers/block/n64cart.c
> > index 7b4dd10af9ec..c84be0028f63 100644
> > --- a/drivers/block/n64cart.c
> > +++ b/drivers/block/n64cart.c
> > @@ -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?

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.

> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] n64cart: fix the dma address in n64cart_do_bvec
  2021-08-04 10:02   ` Christoph Hellwig
@ 2021-08-04 10:16     ` Lauri Kasanen
  0 siblings, 0 replies; 5+ messages in thread
From: Lauri Kasanen @ 2021-08-04 10:16 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, linux-block

On Wed, 4 Aug 2021 12:02:03 +0200
Christoph Hellwig <hch@lst.de> wrote:

> > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] n64cart: fix the dma address in n64cart_do_bvec
  2021-08-04  9:49 [PATCH] n64cart: fix the dma address in n64cart_do_bvec Christoph Hellwig
  2021-08-04 10:01 ` Lauri Kasanen
@ 2021-08-04 17:15 ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2021-08-04 17:15 UTC (permalink / raw)
  To: Christoph Hellwig, cand; +Cc: linux-block

On 8/4/21 3:49 AM, Christoph Hellwig wrote:
> dma_map_bvec already takes bv_offset into account.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-04 17:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04  9:49 [PATCH] n64cart: fix the dma address in n64cart_do_bvec Christoph Hellwig
2021-08-04 10:01 ` Lauri Kasanen
2021-08-04 10:02   ` Christoph Hellwig
2021-08-04 10:16     ` Lauri Kasanen
2021-08-04 17:15 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).