public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, tomof@acm.org
Subject: Re: [PATCH] SPARC64: fix iommu sg chaining
Date: Wed, 17 Oct 2007 13:41:17 +0200	[thread overview]
Message-ID: <20071017114117.GA5043@kernel.dk> (raw)
In-Reply-To: <20071017203758E.fujita.tomonori@lab.ntt.co.jp>

On Wed, Oct 17 2007, FUJITA Tomonori wrote:
> On Wed, 17 Oct 2007 13:01:42 +0200
> Jens Axboe <jens.axboe@oracle.com> wrote:
> 
> > On Wed, Oct 17 2007, Jens Axboe wrote:
> > > On Wed, Oct 17 2007, David Miller wrote:
> > > > From: Jens Axboe <jens.axboe@oracle.com>
> > > > Date: Wed, 17 Oct 2007 11:16:29 +0200
> > > > 
> > > > > On Wed, Oct 17 2007, David Miller wrote:
> > > > > > From: Jens Axboe <jens.axboe@oracle.com>
> > > > > > Date: Wed, 17 Oct 2007 10:45:28 +0200
> > > > > > 
> > > > > > > Righto, it's invalid to call sg_next() on the last entry!
> > > > > > 
> > > > > > Unfortunately, that's what the sparc64 code wanted to do, this
> > > > > > transformation in the sparc64 sg chaining patch is not equilavent:
> > > > > > 
> > > > > > -	struct scatterlist *sg_end = sg + nelems;
> > > > > > +	struct scatterlist *sg_end = sg_last(sg, nelems);
> > > > > >  ...
> > > > > > -			while (sg < sg_end &&
> > > > > > +			while (sg != sg_end &&
> > > > > 
> > > > > Auch indeed. That'd probably be better as a
> > > > > 
> > > > >         do {
> > > > >                 ...
> > > > >         } while (sg != sg_end);
> > > > 
> > > > Ok, next bug, introduced by this change:
> > > > 
> > > > commit f565913ef8a8d0cfa46a1faaf8340cc357a46f3a
> > > > Author: Jens Axboe <jens.axboe@oracle.com>
> > > > Date:   Fri Sep 21 10:44:19 2007 +0200
> > > > 
> > > >     block: convert to using sg helpers
> > > >     
> > > >     Convert the main rq mapper (blk_rq_map_sg()) to the sg helper setup.
> > > >     
> > > >     Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> > > > 
> > > > Specifically this part:
> > > > 
> > > >  new_segment:
> > > > -			memset(&sg[nsegs],0,sizeof(struct scatterlist));
> > > > -			sg[nsegs].page = bvec->bv_page;
> > > > -			sg[nsegs].length = nbytes;
> > > > -			sg[nsegs].offset = bvec->bv_offset;
> > > > +			sg = next_sg;
> > > > +			next_sg = sg_next(sg);
> > > >  
> > > > +			sg->page = bvec->bv_page;
> > > > +			sg->length = nbytes;
> > > > +			sg->offset = bvec->bv_offset;
> > > > 
> > > > You can't remove that memset(), it's there for a reason.  The IOMMU
> > > > layers depended upon the code zero'ing out the whole scatterlist
> > > > struct, there might be more to it than page, length and offset :-)
> > > 
> > > I realize that, and I was pretty worried about this specific change. But
> > > there's only been one piece of fallout because if it until now - well
> > > two, with the sparc64 stuff.
> > > 
> > > The problem is that you cannot zero the entire sg entry, because then
> > > you'd potentially overwrite the chain pointer.
> > > 
> > > I'd propose just adding a
> > > 
> > >         sg_dma_address(sg) = 0;
> > >         sg_dma_len(sg) = 0;
> > > 
> > > there for now, or provide an arch_clear_sg_entry() helper if we need
> > > more killed.
> > 
> > Actually, just clearing AFTER sg_next() would be fine, since we know
> > that is not a link entry. Duh...
> > 
> > diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
> > index 9eabac9..1014d34 100644
> > --- a/block/ll_rw_blk.c
> > +++ b/block/ll_rw_blk.c
> > @@ -1352,6 +1352,7 @@ new_segment:
> >  			sg = next_sg;
> >  			next_sg = sg_next(sg);
> >  
> > +			memset(sg, 0, sizeof(*sg));
> >  			sg->page = bvec->bv_page;
> >  			sg->length = nbytes;
> >  			sg->offset = bvec->bv_offset;
> > 
> > -- 
> 
> So now how about removing zero'ing out sglist in scsi-ml?
> 
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index aac8a02..0c86be7 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -764,8 +764,6 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
>  		if (unlikely(!sgl))
>  			goto enomem;
>  
> -		memset(sgl, 0, sizeof(*sgl) * sgp->size);
> -
>  		/*
>  		 * first loop through, set initial index and return value
>  		 */

Sure, that should be quite alright then. I'll add it.

-- 
Jens Axboe


  reply	other threads:[~2007-10-17 11:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17  5:07 [PATCH] SPARC64: fix iommu sg chaining FUJITA Tomonori
2007-10-17  7:21 ` Jens Axboe
2007-10-17  8:33   ` David Miller
2007-10-17  8:42     ` David Miller
2007-10-17  8:45       ` Jens Axboe
2007-10-17  9:13         ` David Miller
2007-10-17  9:16           ` Jens Axboe
2007-10-17  9:24             ` FUJITA Tomonori
2007-10-17  9:27               ` Jens Axboe
2007-10-17  9:45               ` David Miller
2007-10-17 11:08                 ` FUJITA Tomonori
2007-10-17 11:13                   ` Jens Axboe
2007-10-17 11:16                     ` Jens Axboe
2007-10-17 10:54             ` David Miller
2007-10-17 10:58               ` Jens Axboe
2007-10-17 11:01                 ` Jens Axboe
2007-10-17 11:10                   ` David Miller
2007-10-17 11:11                     ` Jens Axboe
2007-10-17 11:18                       ` David Miller
2007-10-17 11:27                         ` Jens Axboe
2007-10-17 11:37                   ` FUJITA Tomonori
2007-10-17 11:41                     ` Jens Axboe [this message]
2007-10-17 11:57                       ` FUJITA Tomonori
2007-10-17 12:05                         ` FUJITA Tomonori
2007-10-17 14:36                           ` Jens Axboe
2007-10-17 23:01                     ` FUJITA Tomonori
2007-10-17 11:04                 ` David Miller
2007-10-17 11:04                   ` Jens Axboe
2007-10-17 11:04                 ` FUJITA Tomonori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071017114117.GA5043@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=davem@davemloft.net \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tomof@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox