mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.com>
To: 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>,
	Bagas Sanjaya <bagasdotme@gmail.com>,
	linux-doc@vger.kernel.org (open list:DOCUMENTATION),
	linux-kernel@vger.kernel.org (open list),
	linux-mm@kvack.org (open list:MEMORY MANAGEMENT),
	Petr Tesarik <ptesarik@suse.com>
Subject: [PATCH v2 6/8] docs: dma-api: clarify DMA addressing limitations
Date: Fri, 27 Jun 2025 12:10:13 +0200	[thread overview]
Message-ID: <20250627101015.1600042-7-ptesarik@suse.com> (raw)
In-Reply-To: <20250627101015.1600042-1-ptesarik@suse.com>

Move the description of DMA mask from the documentation of dma_map_single()
to Part Ic - DMA addressing limitations and improve the wording.

Explain when a mask setting function may fail, and do not repeat this
explanation for each individual function.

Clarify which device parameters are updated by each mask setting function.

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
Reviewed-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 Documentation/core-api/dma-api.rst | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/Documentation/core-api/dma-api.rst b/Documentation/core-api/dma-api.rst
index bed6e8fdf56e2..9fcdb160638e0 100644
--- a/Documentation/core-api/dma-api.rst
+++ b/Documentation/core-api/dma-api.rst
@@ -92,13 +92,20 @@ for alignment, like queue heads needing to be aligned on N-byte boundaries.
 Part Ic - DMA addressing limitations
 ------------------------------------
 
+DMA mask is a bit mask of the addressable region for the device. In other words,
+if applying the DMA mask (a bitwise AND operation) to the DMA address of a
+memory region does not clear any bits in the address, then the device can
+perform DMA to that memory region.
+
+All the below functions which set a DMA mask may fail if the requested mask
+cannot be used with the device, or if the device is not capable of doing DMA.
+
 ::
 
 	int
 	dma_set_mask_and_coherent(struct device *dev, u64 mask)
 
-Checks to see if the mask is possible and updates the device
-streaming and coherent DMA mask parameters if it is.
+Updates both streaming and coherent DMA masks.
 
 Returns: 0 if successful and a negative error if not.
 
@@ -107,8 +114,7 @@ Returns: 0 if successful and a negative error if not.
 	int
 	dma_set_mask(struct device *dev, u64 mask)
 
-Checks to see if the mask is possible and updates the device
-parameters if it is.
+Updates only the streaming DMA mask.
 
 Returns: 0 if successful and a negative error if not.
 
@@ -117,8 +123,7 @@ Returns: 0 if successful and a negative error if not.
 	int
 	dma_set_coherent_mask(struct device *dev, u64 mask)
 
-Checks to see if the mask is possible and updates the device
-parameters if it is.
+Updates only the coherent DMA mask.
 
 Returns: 0 if successful and a negative error if not.
 
@@ -173,7 +178,7 @@ transfer memory ownership.  Returns %false if those calls can be skipped.
 	unsigned long
 	dma_get_merge_boundary(struct device *dev);
 
-Returns the DMA merge boundary. If the device cannot merge any the DMA address
+Returns the DMA merge boundary. If the device cannot merge any DMA address
 segments, the function returns 0.
 
 Part Id - Streaming DMA mappings
@@ -207,16 +212,12 @@ DMA_BIDIRECTIONAL	direction isn't known
 	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 (the dma_mask is a bit mask of the
-	addressable region for the device, i.e., if the DMA address of
-	the memory ANDed with the dma_mask is still equal to the DMA
-	address, then the device can perform DMA to the memory).  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).
+	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
-- 
2.49.0


  parent reply	other threads:[~2025-06-27 10:10 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   ` Petr Tesarik [this message]
2025-06-28 18:58     ` [PATCH v2 6/8] docs: dma-api: clarify DMA addressing limitations 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
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=20250627101015.1600042-7-ptesarik@suse.com \
    --to=ptesarik@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bagasdotme@gmail.com \
    --cc=corbet@lwn.net \
    --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=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®