public inbox for kernelnewbies@kernelnewbies.org
 help / color / mirror / Atom feed
From: "Chan Kim" <ckim@etri.re.kr>
To: <kernelnewbies@kernelnewbies.org>
Subject: returned dma address value of dma_alloc_coherent, is it always in the lower 4GB range?
Date: Mon, 13 Mar 2023 21:28:28 +0900	[thread overview]
Message-ID: <034901d955a7$50a377d0$f1ea6770$@etri.re.kr> (raw)

Hello experts,

I was reading the well known DMA-API-HOWTO document
(https://www.kernel.org/doc/Documentation/DMA-API-HOWTO.txt),
(I've read this document a couple of times before in the past.)

In the " Using Consistent DMA mappings" section it says :
-----------------------------
	dma_addr_t dma_handle;

	cpu_addr = dma_alloc_coherent(dev, size, &dma_handle, gfp);
...
The consistent DMA mapping interfaces, will by default return a DMA address
which is 32-bit addressable.  Even if the device indicates (via the DMA
mask)
that it may address the upper 32-bits, consistent allocation will only
return > 32-bit addresses for DMA if the consistent DMA mask has been
explicitly changed via dma_set_coherent_mask().  This is true of the
dma_pool interface as well.
------------------------------

I understand by 'DMA address', it means dma_handle (the address the device
will use for DMA).
I can't understand the expression "consistent allocation will only return >
32-bit addresses".
Does it mean that when the driver sets the coherent_dma_mask, for example,
to DMA_BIT_MAST(64) and it was successful, does it return the dma_handle in
lower 32 bit address? What does "return > 32-bit addresses" mean? The ">"
syntax here is so obscure with no clear definition of usage.
By context I guess it returns the address in lower 32bit address range even
it the coherent_dma_mask is set to some bigger value.
(And I know generally, dma address(= bus address) is not equal to the
physical address and is assigned by the OS for convenience)

Thank you.
Chan Kim




_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

             reply	other threads:[~2023-03-13 12:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 12:28 Chan Kim [this message]
2023-03-14  5:14 ` returned dma address value of dma_alloc_coherent, is it always in the lower 4GB range? Valdis Klētnieks
2023-03-14  8:03   ` Chan Kim

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='034901d955a7$50a377d0$f1ea6770$@etri.re.kr' \
    --to=ckim@etri.re.kr \
    --cc=kernelnewbies@kernelnewbies.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