public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@steeleye.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Linux SCSI list <linux-scsi@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH] tmscsim: 64-bit cleanup
Date: 05 Jun 2004 09:02:28 -0500	[thread overview]
Message-ID: <1086444149.1999.13.camel@mulgrave> (raw)
In-Reply-To: <Pine.LNX.4.44.0406042357001.5107-200000@poirot.grange>

On Fri, 2004-06-04 at 17:17, Guennadi Liakhovetski wrote:
> On 21 May 2004, James Bottomley wrote:
> > On Wed, 2004-05-19 at 14:50, Guennadi Liakhovetski wrote:
> > > Ok, here comes the first one. I chose this one because it fixes an actual
> > > bug in the driver. This bug was (partially) introduced by myself when
> > > porting to 2.6. Partly the reason was that I disliked using
> > > function-like macros as lvalues:
> > >
> > > sg_dma_address(x) = ...
> > > sg_dma_len(x) = ...
> > >
> > > [OT] wouldn't it be better to introduce some macros like
> > > set_sg_dma_{address|len}(x, y)?
> >
> > Actually, no.  struct scatterlist is for the OS platform to use to
> > characterise DMA; it's actually a private structure entirely within the
> > gift of the architecture to define.  It usually contains bits of
> > extraneous data that the driver never sees.  The driver should convert
> > struct scatterlist into its own version of the scatterlist that needs
> > feeding to the hardware rather than try and use struct scatterlist.
> 
> Well, I don't quite understand. What about this code in block/ll_rw_blk.c:
> 	sg[nsegs].page = bvec->bv_page;
> 	sg[nsegs].length = nbytes;
> 	sg[nsegs].offset = bvec->bv_offset;
> ? So, looks like all architectures should implement these fields in struct
> scatterlist, and use them in map_sg. So, isn't it safe to use them from
> drivers in a similar way (see patch attached).

No.

struct scatterlist is defined by the platform in two halves: the block
side, which uses the three members you list above, and which, as you
say, all architectures are required to provide and the platform side
which define extra elements but use the macro accessors sg_dma_len() and
sg_dma_address().

However, if you tamper with the block side of this, you'll loose
idempotence (the property that
dma_map_sg()->dma_unmap_sg()->dma_map_sg() works).  Without this none of
the retryable error paths will work.

You should simply treat the scatterlist as an information providing
opaque structure you examine with the provided accessors.  If you try to
alter it, you'll get into trouble with the platform layer, the block
layer or both.

James



  parent reply	other threads:[~2004-06-05 14:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040518184527.GC4859@tpkurt.garloff.de>
2004-05-18 19:47 ` [BK PATCH] SCSI updates for 2.6.6 Guennadi Liakhovetski
2004-05-18 20:38   ` James Bottomley
2004-05-19 19:50     ` [PATCH] tmscsim: 64-bit cleanup Guennadi Liakhovetski
2004-05-19 21:34       ` [PATCH] tmscsim: no internal queue Guennadi Liakhovetski
2004-05-21 15:15       ` [PATCH] tmscsim: 64-bit cleanup James Bottomley
2004-05-21 22:53         ` Guennadi Liakhovetski
2004-05-22  8:09         ` Kurt Garloff
2004-05-22 15:43           ` James Bottomley
2004-05-22 18:10             ` Kurt Garloff
2004-05-22 19:34             ` [PATCH] tmscsim: new interfaces Guennadi Liakhovetski
2004-05-23 10:37               ` Christoph Hellwig
2004-05-23 21:19                 ` Guennadi Liakhovetski
2004-05-26 11:45                   ` Christoph Hellwig
2004-05-26 19:37                     ` [PATCH] fix comment in scsi_host.h Guennadi Liakhovetski
2004-05-26 21:07                     ` [PATCH] tmscsim: new interfaces Guennadi Liakhovetski
2004-05-27 21:20                     ` Guennadi Liakhovetski
2004-05-28 13:00                       ` Christoph Hellwig
2004-05-29 15:36                       ` James Bottomley
2004-05-30 21:01                 ` [PATCH] tmscsim: Store pDCB in device->hostdata Guennadi Liakhovetski
2004-05-31  9:22                   ` Christoph Hellwig
2004-05-31 21:13                 ` [PATCH] tmscsim: init / exit cleanup Guennadi Liakhovetski
2004-06-03 13:38                   ` Christoph Hellwig
2004-06-03 20:23                     ` Guennadi Liakhovetski
2004-06-06 17:09                       ` Christoph Hellwig
2004-06-08  6:37                   ` Kurt Garloff
2004-05-22 19:38             ` [PATCH] tmscsim: 64-bit cleanup Guennadi Liakhovetski
2004-06-04 22:17         ` Guennadi Liakhovetski
2004-06-05  8:12           ` Guennadi Liakhovetski
2004-06-05 14:02           ` James Bottomley [this message]
2004-06-05 20:37             ` Guennadi Liakhovetski
2004-06-05 21:06               ` James Bottomley
2004-06-06 15:06                 ` Guennadi Liakhovetski
2004-06-14 21:37                   ` Guennadi Liakhovetski
2004-05-21  1:06     ` [BK PATCH] SCSI updates for 2.6.6 Chiaki
2004-05-18 22:17   ` Matthew Wilcox

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=1086444149.1999.13.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=hch@infradead.org \
    --cc=linux-scsi@vger.kernel.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