mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Petr Tesarik <ptesarik@suse.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Randy Dunlap <rdunlap@infradead.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	"open list:MEMORY MANAGEMENT" <linux-mm@kvack.org>,
	iommu@lists.linux.dev
Subject: Re: [PATCH v2 7/8] docs: dma-api: update streaming DMA physical address constraints
Date: Mon, 30 Jun 2025 08:32:18 +0700	[thread overview]
Message-ID: <aGHpIiKWDr0T-FLN@archie.me> (raw)
In-Reply-To: <20250627101015.1600042-8-ptesarik@suse.com>

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

On Fri, Jun 27, 2025 at 12:10:14PM +0200, Petr Tesarik wrote:
> diff --git a/Documentation/core-api/dma-api.rst b/Documentation/core-api/dma-api.rst
> index 9fcdb160638e0..a075550ebbb54 100644
> --- a/Documentation/core-api/dma-api.rst
> +++ b/Documentation/core-api/dma-api.rst
> @@ -184,6 +184,26 @@ segments, the function returns 0.
>  Part Id - Streaming DMA mappings
>  --------------------------------
>  
> +Streaming DMA allows to map an existing buffer for DMA transfers and then
> +unmap it when finished.  Map functions are not guaranteed to succeed, so the
> +return value must be checked.
> +
> +.. note::
> +
> +	In particular, mapping may fail for memory not addressable by the
> +	device, e.g. if it is not within the DMA mask of the device and/or a
> +	connecting bus bridge.  Streaming DMA functions try to overcome such
> +	addressing constraints, either by using an IOMMU (a device which maps
> +	I/O DMA addresses to physical memory addresses), or by copying the
> +	data to/from a bounce buffer if the kernel is configured with a
> +	:doc:`SWIOTLB <swiotlb>`.  However, these methods are not always
> +	available, and even if they are, they may still fail for a number of
> +	reasons.
> +
> +	In short, a device driver may need to be wary of where buffers are
> +	located in physical memory, especially if the DMA mask is less than 32
> +	bits.
> +
>  ::
>  
>  	dma_addr_t
> @@ -204,27 +224,13 @@ DMA_BIDIRECTIONAL	direction isn't known
>  
>  .. note::
>  
> -	Not all memory regions in a machine can be mapped by this API.
> -	Further, contiguous kernel virtual space may not be contiguous as
> +	Contiguous kernel virtual space may not be contiguous as
>  	physical memory.  Since this API does not provide any scatter/gather
>  	capability, it will fail if the user tries to map a non-physically
>  	contiguous piece of memory.  For this reason, memory to be mapped by
>  	this API should be obtained from sources which guarantee it to be
>  	physically contiguous (like kmalloc).
>  
> -	Further, the DMA address of the memory must be within the dma_mask of
> -	the device.  To ensure that the memory allocated by kmalloc is within
> -	the dma_mask, the driver may specify various platform-dependent flags
> -	to restrict the DMA address range of the allocation (e.g., on x86,
> -	GFP_DMA guarantees to be within the first 16MB of available DMA
> -	addresses, as required by ISA devices).
> -
> -	Note also that the above constraints on physical contiguity and
> -	dma_mask may not apply if the platform has an IOMMU (a device which
> -	maps an I/O DMA address to a physical memory address).  However, to be
> -	portable, device driver writers may *not* assume that such an IOMMU
> -	exists.
> -
>  .. warning::
>  
>  	Memory coherency operates at a granularity called the cache

The wording looks good, thanks!

Reviewed-by: Bagas Sanjaya <bagasdotme@gmail.com>

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  parent reply	other threads:[~2025-06-30  1:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250627101022eucas1p2f3715c9c9439ca986217e380d4d3e254@eucas1p2.samsung.com>
2025-06-27 10:10 ` [PATCH v2 0/8] update DMA API documentation Petr Tesarik
2025-06-27 10:10   ` [PATCH v2 1/8] docs: dma-api: use "DMA API" consistently throughout the document Petr Tesarik
2025-06-28 18:56     ` Randy Dunlap
2025-06-27 10:10   ` [PATCH v2 2/8] docs: dma-api: replace consistent with coherent Petr Tesarik
2025-06-28 18:57     ` Randy Dunlap
2025-06-27 10:10   ` [PATCH v2 3/8] docs: dma-api: remove remnants of PCI DMA API Petr Tesarik
2025-06-28 18:58     ` Randy Dunlap
2025-06-27 10:10   ` [PATCH v2 4/8] docs: dma-api: add a kernel-doc comment for dma_pool_zalloc() Petr Tesarik
2025-06-28 19:04     ` Randy Dunlap
2025-07-01 11:38       ` Petr Tesarik
2025-07-01 12:54         ` Jonathan Corbet
2025-07-01 15:46           ` Petr Tesarik
2025-06-27 10:10   ` [PATCH v2 5/8] docs: dma-api: remove duplicate description of the DMA pool API Petr Tesarik
2025-06-28 19:01     ` Randy Dunlap
2025-06-27 10:10   ` [PATCH v2 6/8] docs: dma-api: clarify DMA addressing limitations Petr Tesarik
2025-06-28 18:58     ` Randy Dunlap
2025-06-27 10:10   ` [PATCH v2 7/8] docs: dma-api: update streaming DMA physical address constraints Petr Tesarik
2025-06-28 18:59     ` Randy Dunlap
2025-06-30  1:32     ` Bagas Sanjaya [this message]
2025-06-27 10:10   ` [PATCH v2 8/8] docs: dma-api: clean up documentation of dma_map_sg() Petr Tesarik
2025-06-28 19:00     ` Randy Dunlap
2025-06-27 17:03   ` [PATCH v2 0/8] update DMA API documentation Marek Szyprowski
2025-07-01 19:53   ` Jonathan Corbet

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=aGHpIiKWDr0T-FLN@archie.me \
    --to=bagasdotme@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=corbet@lwn.net \
    --cc=iommu@lists.linux.dev \
    --cc=kbusch@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=ptesarik@suse.com \
    --cc=rdunlap@infradead.org \
    --cc=robin.murphy@arm.com \
    /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

all inboxes | Powered by JetHome®