public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian King <brking@us.ibm.com>
To: James Bottomley <James.Bottomley@SteelEye.com>
Cc: Hugh Dickins <hugh@veritas.com>,
	"David S. Miller" <davem@davemloft.net>, Andi Kleen <ak@suse.de>,
	akpm@osdl.org, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org,
	Linux Arch list <linux-arch@vger.kernel.org>
Subject: Re: [PATCH] ipr: don't doublefree pages from scatterlist
Date: Mon, 06 Feb 2006 13:15:57 -0600	[thread overview]
Message-ID: <43E7A06D.80901@us.ibm.com> (raw)
In-Reply-To: <1139247516.3022.6.camel@mulgrave.il.steeleye.com>

[-- Attachment #1: Type: text/plain, Size: 1827 bytes --]

James Bottomley wrote:
> On Mon, 2006-02-06 at 16:45 +0000, Hugh Dickins wrote:
>> But I'd also want James or someone to clarify the paragraph
>> "Please note that the sg cannot be mapped again if it has been mapped once.
>>  The mapping process is allowed to destroy information in the sg."
>> which I took as explicitly allowing what x86_64 does in gart_map_sg.
>> I thought James had a scenario in mind which demands this wholesale
>> destruction, but it seems not; and I now read that first sentence as
>> saying the sg must be unmapped before it can be mapped a second time,
>> not that it can only be mapped once.
>>
>> And add a paragraph explaining that really the one array of scatterlist
>> entries should be regarded as two arrays of possibly different lengths,
>> the page,offset,length array and the dma_address,dma_length array:
>> because entries of the latter may be coalesced, so that in the end
>> the dma_address in a scatterlength entry may bear no relation to the
>> page pointer in that same entry, but to the page pointer in a later entry.
>> Though it gets hard to explain given that not all architectures coalesce,
>> so may not even have a separate dma_length field; or use different naming.
>> If you can express this better than I, please do!
> 
> Yes, I added that piece after the x86_64 problem.  The original x86_64
> bug was that you couldn't do dma_map_sg() then dma_unmap_sg() then
> dma_map_sg() on the same scatterlist (the map was destroying information
> which wasn't restored on the unmap, so the second map produced an
> incorrect scatterlist), which was causing a bug in all SCSI drivers
> (because that's the way SCSI requeueing works).

Here is a second try at a documentation update. Any takers to fixup x86_64?

Brian

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dma_mapping_clarification.patch --]
[-- Type: text/x-patch; name="dma_mapping_clarification.patch", Size: 2407 bytes --]


The current pci_map_sg API is a bit unclear what it is allowed
to modify in the passed scatterlist when coalescing entries.
Clarify the pci_map_sg API to prevent it from modifying
the page, offset, and length fields in the scatterlist.

Signed-off-by: Brian King <brking@us.ibm.com>
---

 linux-2.6-bjking1/Documentation/DMA-API.txt     |    5 +++--
 linux-2.6-bjking1/Documentation/DMA-mapping.txt |    5 ++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff -puN Documentation/DMA-mapping.txt~dma_mapping_clarification Documentation/DMA-mapping.txt
--- linux-2.6/Documentation/DMA-mapping.txt~dma_mapping_clarification	2006-02-06 13:05:52.000000000 -0600
+++ linux-2.6-bjking1/Documentation/DMA-mapping.txt	2006-02-06 13:05:52.000000000 -0600
@@ -513,7 +513,10 @@ consecutive sglist entries can be merged
 ends and the second one starts on a page boundary - in fact this is a huge
 advantage for cards which either cannot do scatter-gather or have very
 limited number of scatter-gather entries) and returns the actual number
-of sg entries it mapped them to. On failure 0 is returned.
+of sg entries it mapped them to. The implementation is free to do this
+by modifying the scatterlist fields specified for DMA. The scatterlist
+fields used as an input to this function (i.e. page, offset, and length)
+will NOT be modified. On failure 0 is returned.
 
 Then you should loop count times (note: this can be less than nents times)
 and use sg_dma_address() and sg_dma_len() macros where you previously
diff -puN Documentation/DMA-API.txt~dma_mapping_clarification Documentation/DMA-API.txt
--- linux-2.6/Documentation/DMA-API.txt~dma_mapping_clarification	2006-02-06 13:06:17.000000000 -0600
+++ linux-2.6-bjking1/Documentation/DMA-API.txt	2006-02-06 13:07:40.000000000 -0600
@@ -318,8 +318,9 @@ than <nents> passed in if the block laye
 elements of the scatter/gather list are physically adjacent and thus
 may be mapped with a single entry).
 
-Please note that the sg cannot be mapped again if it has been mapped once.
-The mapping process is allowed to destroy information in the sg.
+Please note that the sg can be mapped again, as long as it is unmapped
+first. The mapping process is only allowed to modify the scatterlist
+fields related to DMA.
 
 As with the other mapping interfaces, dma_map_sg can fail. When it
 does, 0 is returned and a driver must take appropriate action. It is
_

  reply	other threads:[~2006-02-06 19:16 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20051129092432.0f5742f0.akpm@osdl.org>
2005-11-29 18:34 ` Fw: crash on x86_64 - mm related? Ryan Richter
     [not found] ` <Pine.LNX.4.63.0511292147120.5739@kai.makisara.local>
2005-11-29 20:31   ` Ryan Richter
2005-11-29 20:48     ` Kai Makisara
2005-11-29 20:58       ` Ryan Richter
2005-11-29 21:36         ` Kai Makisara
2005-11-30  5:12       ` Kai Makisara
2005-12-01 19:18 ` Kai Makisara
2005-12-01 19:38   ` Linus Torvalds
2005-12-01 19:56     ` Ryan Richter
2005-12-01 20:21       ` Hugh Dickins
2005-12-01 21:44         ` Kai Makisara
2005-12-02 18:03         ` Ryan Richter
2005-12-02 18:43           ` Jesper Juhl
2005-12-02 19:12           ` Hugh Dickins
2005-12-02 19:44             ` Ryan Richter
2005-12-02 20:40               ` Hugh Dickins
2005-12-03 17:29                 ` Ryan Richter
2005-12-06 16:08                 ` Ryan Richter
2005-12-06 20:31                   ` Hugh Dickins
2005-12-06 20:43                     ` Ryan Richter
2005-12-07 18:37                       ` Hugh Dickins
2005-12-08  2:26                         ` Ryan Richter
2005-12-12 16:54                         ` Ryan Richter
2005-12-12 17:40                           ` Linus Torvalds
2005-12-12 17:45                             ` James Bottomley
2005-12-12 18:04                               ` Ryan Richter
2005-12-12 18:09                               ` Linus Torvalds
2005-12-12 18:24                                 ` James Bottomley
2005-12-15 19:09                                   ` Ryan Richter
2005-12-16  4:01                                     ` James Bottomley
2005-12-17  3:31                                       ` Ryan Richter
2005-12-26 23:42                                       ` Ryan Richter
2005-12-27 16:21                                         ` Kai Makisara
2006-01-03 19:03                                           ` Ryan Richter
2006-01-04 17:27                                           ` Ryan Richter
2006-01-04 21:48                                             ` Kai Makisara
2006-01-05  5:40                                               ` Ryan Richter
2006-01-05 20:12                                               ` Ryan Richter
2006-01-05 21:18                                                 ` Linus Torvalds
2006-01-08 22:36                                                   ` Ryan Richter
2006-01-09  3:31                                                   ` Ryan Richter
2006-01-09  4:07                                                     ` Linus Torvalds
2006-01-09  5:13                                                       ` Andrew Morton
2006-01-09  5:45                                                         ` Ryan Richter
2006-01-09  5:57                                                           ` Andrew Morton
2006-01-09  9:44                                                       ` Hugh Dickins
2006-01-09 18:53                                                         ` Ryan Richter
2006-01-09 19:31                                                           ` Hugh Dickins
2006-01-09 20:05                                                             ` Ryan Richter
2006-01-18  0:12                                                             ` Ryan Richter
2006-01-18 16:00                                                               ` Hugh Dickins
2006-02-03 19:46                                                                 ` Hugh Dickins
2006-02-03 19:51                                                                   ` [PATCH] ib: don't doublefree pages from scatterlist Hugh Dickins
2006-02-03 23:13                                                                     ` Roland Dreier
2006-02-03 19:53                                                                   ` [PATCH] st: " Hugh Dickins
2006-02-03 20:38                                                                     ` Mike Christie
2006-02-03 21:16                                                                       ` Hugh Dickins
2006-02-04 12:10                                                                         ` Kai Makisara
2006-02-04 15:01                                                                           ` Hugh Dickins
2006-02-03 19:55                                                                   ` [PATCH] ipr: " Hugh Dickins
2006-02-03 22:06                                                                     ` Brian King
2006-02-04  0:26                                                                       ` Hugh Dickins
2006-02-05 21:35                                                                         ` Brian King
2006-02-06  9:32                                                                           ` Hugh Dickins
2006-02-06  9:46                                                                             ` David S. Miller
2006-02-06 14:46                                                                               ` Brian King
2006-02-06 16:45                                                                                 ` Hugh Dickins
2006-02-06 17:38                                                                                   ` James Bottomley
2006-02-06 19:15                                                                                     ` Brian King [this message]
2006-02-06 21:11                                                                                   ` Andi Kleen
2006-02-06 21:49                                                                                     ` David S. Miller
2006-02-06 22:11                                                                                     ` Hugh Dickins
2006-02-06 22:13                                                                                       ` Andi Kleen
2006-02-07  3:09                                                                                       ` Ryan Richter
2006-02-11 22:38                                                                                       ` Ryan Richter
2006-02-12 18:57                                                                                         ` Hugh Dickins
2006-02-12 21:29                                                                                           ` Andi Kleen
2006-02-13 17:21                                                                                             ` Hugh Dickins
2006-02-06 15:02                                                                               ` James Bottomley
2006-02-06 17:01                                                                                 ` Hugh Dickins
2006-02-03 19:56                                                                   ` [PATCH] osst: " Hugh Dickins
2006-02-03 21:10                                                                   ` Fw: crash on x86_64 - mm related? Ryan Richter
2006-02-04 11:58                                                                   ` Kai Makisara
2006-02-04 14:46                                                                     ` Hugh Dickins
2006-01-05 22:09                                                 ` Kai Makisara
2006-01-04 18:26                                           ` Ryan Richter
2005-12-07 18:30                     ` Ryan Richter
2005-12-07 18:56                       ` Hugh Dickins
2005-12-07 19:06                         ` Ryan Richter
2005-12-06 17:57                 ` Ryan Richter
2005-12-01 20:28     ` James Bottomley
2005-12-01 21:17       ` Kai Makisara
2005-12-02 13:45         ` Hugh Dickins
2005-12-02 17:59           ` Kai Makisara
2005-12-02 18:55             ` Hugh Dickins
2005-12-02 19:46               ` Kai Makisara
2005-12-02 20:47                 ` Hugh Dickins
2005-12-04  9:29                   ` Kai Makisara
2005-12-01 19:53   ` Ryan Richter

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=43E7A06D.80901@us.ibm.com \
    --to=brking@us.ibm.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=davem@davemloft.net \
    --cc=hugh@veritas.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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