Kernel Newbies archive mirror
 help / color / mirror / Atom feed
From: "Chan Kim" <ckim@etri.re.kr>
To: "'Valdis Klētnieks'" <valdis.kletnieks@vt.edu>
Cc: kernelnewbies@kernelnewbies.org
Subject: RE: returned dma address value of dma_alloc_coherent, is it always in the lower 4GB range?
Date: Tue, 14 Mar 2023 17:03:28 +0900	[thread overview]
Message-ID: <043801d9564b$766e5b20$634b1160$@etri.re.kr> (raw)
In-Reply-To: <687742.1678770890@turing-police>


Hello Valdis,

>-----Original Message-----
>From: Valdis Kletnieks <valdis@vt.edu> On Behalf Of Valdis Kl?tnieks
>Sent: Tuesday, March 14, 2023 2:15 PM
>To: Chan Kim <ckim@etri.re.kr>
>Cc: kernelnewbies@kernelnewbies.org
>Subject: Re: returned dma address value of dma_alloc_coherent, is it always
>in the lower 4GB range?
>
>On Mon, 13 Mar 2023 21:28:28 +0900, "Chan Kim" said:
>
>> 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.
>> ------------------------------
>
>> 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.
>
>No, you have that backwards.   It's not "even if".  It wil give you a
32-bit
>address *UNLESS* the driver has called dma_set_coherent_mask() to set a
>wider mask *and* the device indicates it supports more than 32 bit
>addresses...

I'm sorry but please allow me to ask one more time.
1. "The consistent DMA mapping interfaces, will by default return a DMA
address
which is 32-bit addressable."  
==> so by default consistent dma mapping API returns 32-bit address, and
this 32-bit address means dma address, not physical address. Am I correct?
(because the dma address will be translated to physical address by the iommu
anyway)

2. " 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." 
==> So I now understand the first 'even if' is for streaming dma mask
('dma_mask' in the struct device), and the second 'if' is for the
'coherent_dma_mask' in the struct device. And when coherent_dma_mask is not
set, by default, the coherent mapping returns 32 bit address, but if the
coherent_dma_mask is set to use wider than 32 bit addresses, it returns the
wider address which seems obvious now.

Please correct me if I'm wrong.
Thank you!

Chan Kim





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

      reply	other threads:[~2023-03-14  8:05 UTC|newest]

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

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='043801d9564b$766e5b20$634b1160$@etri.re.kr' \
    --to=ckim@etri.re.kr \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=valdis.kletnieks@vt.edu \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).