All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	Christoph Hellwig <hch@lst.de>
Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	bart.vanassche@sandisk.com,
	Alexander Duyck <alexander.h.duyck@intel.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	lkml <linux-kernel@vger.kernel.org>,
	arcml <linux-snps-arc@lists.infradead.org>
Subject: Re: semantics of dma_map_single()
Date: Mon, 17 Jul 2017 09:46:30 -0700	[thread overview]
Message-ID: <1500309990.3244.2.camel@HansenPartnership.com> (raw)
In-Reply-To: <23203d16-da54-99c7-0eba-c082eba120d7@synopsys.com>

On Mon, 2017-07-17 at 09:06 -0700, Vineet Gupta wrote:
> Hi Christoph,
> 
> On 07/16/2017 11:42 PM, Christoph Hellwig wrote:
> > 
> > I would expect that it would support any contiguous range in
> > the kernel mapping (e.g. no vmalloc and friends).  But it's not
> > documented anywhere, and if no in kernel users makes use of that
> > fact at the moment it might be better to document a page size
> > limitation and add asserts to enforce it.
> 
> My first thought was indeed to add a BUG_ON for @size > PAGE_SIZE
> (also accounting for offset etc), but I have a feeling this will
> cause too many breakages. So perhaps it would be better to add the
> fact to Documentation that it can handle any physically contiguous
> range.

Actually, that's not historically right.  dma_map_single() was
originally designed to be called on any region that was kmalloc'd
meaning it was capable of mapping physically contiguous > PAGE_SIZE
regions.

For years (decades?) we've been eliminating the specialised
dma_map_single() calls in favour of dma_map_sg, so it's possible there
may not be any large region consumers anymore, so it *may* be safe to
enforce a PAGE_SIZE limit, but not without auditing the remaining
callers.

James

WARNING: multiple messages have this Message-ID (diff)
From: James.Bottomley@HansenPartnership.com (James Bottomley)
To: linux-snps-arc@lists.infradead.org
Subject: semantics of dma_map_single()
Date: Mon, 17 Jul 2017 09:46:30 -0700	[thread overview]
Message-ID: <1500309990.3244.2.camel@HansenPartnership.com> (raw)
In-Reply-To: <23203d16-da54-99c7-0eba-c082eba120d7@synopsys.com>

On Mon, 2017-07-17@09:06 -0700, Vineet Gupta wrote:
> Hi Christoph,
> 
> On 07/16/2017 11:42 PM, Christoph Hellwig wrote:
> > 
> > I would expect that it would support any contiguous range in
> > the kernel mapping (e.g. no vmalloc and friends).??But it's not
> > documented anywhere, and if no in kernel users makes use of that
> > fact at the moment it might be better to document a page size
> > limitation and add asserts to enforce it.
> 
> My first thought was indeed to add a BUG_ON for @size > PAGE_SIZE
> (also accounting for offset etc), but I have a feeling this will
> cause too many breakages. So perhaps it would be better to add the
> fact to Documentation that it can handle any physically contiguous
> range.

Actually, that's not historically right. ?dma_map_single() was
originally designed to be called on any region that was kmalloc'd
meaning it was capable of mapping physically contiguous > PAGE_SIZE
regions.

For years (decades?) we've been eliminating the specialised
dma_map_single() calls in favour of dma_map_sg, so it's possible there
may not be any large region consumers anymore, so it *may* be safe to
enforce a PAGE_SIZE limit, but not without auditing the remaining
callers.

James

WARNING: multiple messages have this Message-ID (diff)
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	Christoph Hellwig <hch@lst.de>
Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	bart.vanassche@sandisk.com,
	Alexander Duyck <alexander.h.duyck@intel.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	lkml <linux-kernel@vger.kernel.org>,
	arcml <linux-snps-arc@lists.infradead.org>
Subject: Re: semantics of dma_map_single()
Date: Mon, 17 Jul 2017 09:46:30 -0700	[thread overview]
Message-ID: <1500309990.3244.2.camel@HansenPartnership.com> (raw)
In-Reply-To: <23203d16-da54-99c7-0eba-c082eba120d7@synopsys.com>

On Mon, 2017-07-17 at 09:06 -0700, Vineet Gupta wrote:
> Hi Christoph,
> 
> On 07/16/2017 11:42 PM, Christoph Hellwig wrote:
> > 
> > I would expect that it would support any contiguous range in
> > the kernel mapping (e.g. no vmalloc and friends).A A But it's not
> > documented anywhere, and if no in kernel users makes use of that
> > fact at the moment it might be better to document a page size
> > limitation and add asserts to enforce it.
> 
> My first thought was indeed to add a BUG_ON for @size > PAGE_SIZE
> (also accounting for offset etc), but I have a feeling this will
> cause too many breakages. So perhaps it would be better to add the
> fact to Documentation that it can handle any physically contiguous
> range.

Actually, that's not historically right. A dma_map_single() was
originally designed to be called on any region that was kmalloc'd
meaning it was capable of mapping physically contiguous > PAGE_SIZE
regions.

For years (decades?) we've been eliminating the specialised
dma_map_single() calls in favour of dma_map_sg, so it's possible there
may not be any large region consumers anymore, so it *may* be safe to
enforce a PAGE_SIZE limit, but not without auditing the remaining
callers.

James

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-07-17 16:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-16  1:24 semantics of dma_map_single() Vineet Gupta
2017-07-16  1:24 ` Vineet Gupta
2017-07-16  1:24 ` Vineet Gupta
2017-07-16  1:24 ` Vineet Gupta
2017-07-17  6:42 ` Christoph Hellwig
2017-07-17  6:42   ` Christoph Hellwig
2017-07-17  6:42   ` Christoph Hellwig
2017-07-17 16:06   ` Vineet Gupta
2017-07-17 16:06     ` Vineet Gupta
2017-07-17 16:06     ` Vineet Gupta
2017-07-17 16:06     ` Vineet Gupta
2017-07-17 16:46     ` James Bottomley [this message]
2017-07-17 16:46       ` James Bottomley
2017-07-17 16:46       ` James Bottomley

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=1500309990.3244.2.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.h.duyck@intel.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=hch@lst.de \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-snps-arc@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.