Re: [Question] devm_kmalloc() for DMA ?

2017-03-09 Thread Robin Murphy
On 08/03/17 18:06, Masahiro Yamada wrote: > Hi Robin, > > > 2017-03-08 20:15 GMT+09:00 Robin Murphy : >> On 08/03/17 10:59, Masahiro Yamada wrote: >>> Hi experts, >>> >>> I have a question about >>> how to allocate DMA-safe buffer. >>> >>> >>> In my understanding, kmalloc() returns >>> memory wit

Re: [Question] devm_kmalloc() for DMA ?

2017-03-09 Thread Russell King - ARM Linux
On Thu, Mar 09, 2017 at 12:25:07PM +0900, Masahiro Yamada wrote: > (c) Use kmalloc() and kfree(). (be careful for memory leak) This is quite simple. For the first one, it doesn't seem that it's DMA'd into, so there's no need to use GFP_DMA. - /* allocate a temporary buffer for nand_scan_

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Masahiro Yamada
Hi Russell, Lars-Peter, Thanks for your expert comments. 2017-03-09 6:33 GMT+09:00 Lars-Peter Clausen : > On 03/08/2017 10:19 PM, Russell King - ARM Linux wrote: >> On Wed, Mar 08, 2017 at 09:44:17PM +0100, Lars-Peter Clausen wrote: >>> On 03/08/2017 08:59 PM, Russell King - ARM Linux wrote: >>>

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Lars-Peter Clausen
On 03/08/2017 10:19 PM, Russell King - ARM Linux wrote: > On Wed, Mar 08, 2017 at 09:44:17PM +0100, Lars-Peter Clausen wrote: >> On 03/08/2017 08:59 PM, Russell King - ARM Linux wrote: >>> On Wed, Mar 08, 2017 at 08:48:31PM +0100, Lars-Peter Clausen wrote: When the DMA memory is mapped for rea

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Russell King - ARM Linux
On Wed, Mar 08, 2017 at 09:44:17PM +0100, Lars-Peter Clausen wrote: > On 03/08/2017 08:59 PM, Russell King - ARM Linux wrote: > > On Wed, Mar 08, 2017 at 08:48:31PM +0100, Lars-Peter Clausen wrote: > >> When the DMA memory is mapped for reading from the device the associated > >> cachelines are inv

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Lars-Peter Clausen
On 03/08/2017 07:06 PM, Masahiro Yamada wrote: > Hi Robin, > > > 2017-03-08 20:15 GMT+09:00 Robin Murphy : >> On 08/03/17 10:59, Masahiro Yamada wrote: >>> Hi experts, >>> >>> I have a question about >>> how to allocate DMA-safe buffer. >>> >>> >>> In my understanding, kmalloc() returns >>> memor

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Lars-Peter Clausen
On 03/08/2017 08:59 PM, Russell King - ARM Linux wrote: > On Wed, Mar 08, 2017 at 08:48:31PM +0100, Lars-Peter Clausen wrote: >> When the DMA memory is mapped for reading from the device the associated >> cachelines are invalidated without writeback. There is no guarantee that >> the changes made t

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Russell King - ARM Linux
On Wed, Mar 08, 2017 at 08:48:31PM +0100, Lars-Peter Clausen wrote: > When the DMA memory is mapped for reading from the device the associated > cachelines are invalidated without writeback. There is no guarantee that > the changes made to the devres_node have made it to main memory yet, or > is th

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Masahiro Yamada
Hi Robin, 2017-03-08 20:15 GMT+09:00 Robin Murphy : > On 08/03/17 10:59, Masahiro Yamada wrote: >> Hi experts, >> >> I have a question about >> how to allocate DMA-safe buffer. >> >> >> In my understanding, kmalloc() returns >> memory with DMA safe alignment >> in order to avoid cache-sharing pro

Re: [Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Robin Murphy
On 08/03/17 10:59, Masahiro Yamada wrote: > Hi experts, > > I have a question about > how to allocate DMA-safe buffer. > > > In my understanding, kmalloc() returns > memory with DMA safe alignment > in order to avoid cache-sharing problem when used for DMA. > > The alignment is decided by ARCH_

[Question] devm_kmalloc() for DMA ?

2017-03-08 Thread Masahiro Yamada
Hi experts, I have a question about how to allocate DMA-safe buffer. In my understanding, kmalloc() returns memory with DMA safe alignment in order to avoid cache-sharing problem when used for DMA. The alignment is decided by ARCH_DMA_MINALIGN. For example, on modern ARM 32bit boards, this valu