[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YheSBTJY216m6izG@MiWiFi-R3L-srv>
Date: Thu, 24 Feb 2022 22:11:17 +0800
From: Baoquan He <bhe@...hat.com>
To: Christoph Hellwig <hch@....de>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
akpm@...ux-foundation.org, cl@...ux.com, 42.hyeyoo@...il.com,
penberg@...nel.org, rientjes@...gle.com, iamjoonsoo.kim@....com,
vbabka@...e.cz, David.Laight@...lab.com, david@...hat.com,
herbert@...dor.apana.org.au, davem@...emloft.net,
linux-crypto@...r.kernel.org, steffen.klassert@...unet.com,
netdev@...r.kernel.org, hca@...ux.ibm.com, gor@...ux.ibm.com,
agordeev@...ux.ibm.com, borntraeger@...ux.ibm.com,
svens@...ux.ibm.com, linux-s390@...r.kernel.org, michael@...le.cc,
linux-i2c@...r.kernel.org, wsa@...nel.org
Subject: Re: [PATCH 1/2] dma-mapping: check dma_mask for streaming mapping
allocs
On 02/23/22 at 03:25pm, Christoph Hellwig wrote:
> On Wed, Feb 23, 2022 at 08:28:13AM +0800, Baoquan He wrote:
> > Could you tell more why this is wrong? According to
> > Documentation/core-api/dma-api.rst and DMA code, __dma_alloc_pages() is
> > the core function of dma_alloc_pages()/dma_alloc_noncoherent() which are
> > obviously streaming mapping,
>
> Why are they "obviously" streaming mappings?
Because they are obviously not coherent mapping?
With my understanding, there are two kinds of DMA mapping, coherent
mapping (which is also persistent mapping), and streaming mapping. The
coherent mapping will be handled during driver init, and released during
driver de-init. While streaming mapping will be done when needed at any
time, and released after usage.
Are we going to add another kind of mapping? It's not streaming mapping,
but use dev->coherent_dma_mask, just because it uses dma_alloc_xxx()
api.
>
> > why do we need to check
> > dev->coherent_dma_mask here? Because dev->coherent_dma_mask is the subset
> > of dev->dma_mask, it's safer to use dev->coherent_dma_mask in these
> > places? This is confusing, I talked to Hyeonggon in private mail, he has
> > the same feeling.
>
> Think of th coherent_dma_mask as dma_alloc_mask. It is the mask for the
> DMA memory allocator. dma_mask is the mask for the dma_map_* routines.
I will check code further. While this may need be noted in doc, e.g
dma_api.rst or dma-api-howto.rst.
If you have guide, I can try to add some words to make clear this. Or
leave this to people who knows this clearly. I believe it will be very
helpful to understand DMA api.
Powered by blists - more mailing lists