public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Cma mem map to cpu address when allocated in ion driver, why do this design?
@ 2016-09-01 12:46 Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept)
  2016-09-01 14:45 ` gregkh
  2016-09-01 15:16 ` Laura Abbott
  0 siblings, 2 replies; 3+ messages in thread
From: Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept) @ 2016-09-01 12:46 UTC (permalink / raw)
  To: labbott@redhat.com, sumit.semwal@linaro.org, arve@android.com,
	riandrews@android.com, gregkh@linuxfoundation.org
  Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Chenhao (benjamin), Zengtao (B)

Hi  all,

When I review ion code in linux-3.18.y, I find a design that may cause a problem in our product. In the design, cma mem is allocated via the interface of dma_alloc_coherent ,

and this function will create a map to cpu. Sometimes, we just need cma phys addr, do not need cpu address.

In our product, We need to map many discontinuous phy mem in kernel space, and those mem will use much vmalloc area. When cma mem is in highmem, it also need to use vmalloc area when

Allocated, but we just use cma phys addr, the cpu virtual addr is not need. In linux-3.18.y, cma will reserved in high mem zone firstly. If cma mem is allocated more,and more vmalloc area will be used.

This may cause a problem that the vmalloc area will not enough when discontinuous phys mem need to map.

So,  why dose cma mem need to map to cpu address when allocated ?   As mem allocated in system heap, it does not map to cpu address at that time, and we can map it whenever we use it by map_kernel function dynamically.

So,  why cma heap is not designed like system heap?



Best regards,
Wei.Yang

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cma mem map to cpu address when allocated in ion driver, why do this design?
  2016-09-01 12:46 Cma mem map to cpu address when allocated in ion driver, why do this design? Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept)
@ 2016-09-01 14:45 ` gregkh
  2016-09-01 15:16 ` Laura Abbott
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2016-09-01 14:45 UTC (permalink / raw)
  To: Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept)
  Cc: labbott@redhat.com, sumit.semwal@linaro.org, arve@android.com,
	riandrews@android.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, Zengtao (B), Chenhao (benjamin)

On Thu, Sep 01, 2016 at 12:46:32PM +0000, Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept) wrote:
> Hi  all,
> 
> When I review ion code in linux-3.18.y, I find a design that may cause
> a problem in our product. In the design, cma mem is allocated via the
> interface of dma_alloc_coherent ,

3.18 is old and obsolete and isn't supported by the kernel community for
anything except bug fixes.  I suggest you work with whatever group is
forcing you to use this old kernel version as they are the ones that you
are paying to support this kernel for you.

If you wish to discuss the 4.7 or newer kernel versions, and how ion
works there (look in linux-next for the most recent changes in that
area), we would be glad to help you out.

Best of luck!

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cma mem map to cpu address when allocated in ion driver, why do this design?
  2016-09-01 12:46 Cma mem map to cpu address when allocated in ion driver, why do this design? Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept)
  2016-09-01 14:45 ` gregkh
@ 2016-09-01 15:16 ` Laura Abbott
  1 sibling, 0 replies; 3+ messages in thread
From: Laura Abbott @ 2016-09-01 15:16 UTC (permalink / raw)
  To: Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept),
	sumit.semwal@linaro.org, arve@android.com, riandrews@android.com,
	gregkh@linuxfoundation.org
  Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Chenhao (benjamin), Zengtao (B)

On 09/01/2016 05:46 AM, Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept) wrote:
> Hi  all,
>
> When I review ion code in linux-3.18.y, I find a design that may cause a problem in our product. In the design, cma mem is allocated via the interface of dma_alloc_coherent ,
>
> and this function will create a map to cpu. Sometimes, we just need cma phys addr, do not need cpu address.
>
> In our product, We need to map many discontinuous phy mem in kernel space, and those mem will use much vmalloc area. When cma mem is in highmem, it also need to use vmalloc area when
>
> Allocated, but we just use cma phys addr, the cpu virtual addr is not need. In linux-3.18.y, cma will reserved in high mem zone firstly. If cma mem is allocated more,and more vmalloc area will be used.
>
> This may cause a problem that the vmalloc area will not enough when discontinuous phys mem need to map.
>
> So,  why dose cma mem need to map to cpu address when allocated ?   As mem allocated in system heap, it does not map to cpu address at that time, and we can map it whenever we use it by map_kernel function dynamically.
>
> So,  why cma heap is not designed like system heap?
>
>
>
> Best regards,
> Wei.Yang
>


The simple answer is that CMA is tied to dma_alloc_coherent and
Ion went with the default behavior there which gives a CPU side mapping.

The follow up question is "Could Ion support not having a CPU side
mapping from dma_alloc_coherent". The answer to that question is
yes with some additional patches.

Take a look at DMA_ATTR_NO_KERNEL_MAPPING, this option does what
you describe: it allocates the physical memory but does not
create a CPU side mapping. This could be added to the dma_alloc_coherent
call. You would need to be careful that what you implement would
support CMA areas in lowmem as well, DMA_ATTR_NO_KERNEL_MAPPING
does not clear the mapping from lowmem areas and you could end
up with two different map types to the same region.

Longer term, I hope to drop Ion's dependency on dma_alloc all
together and just use the cma_alloc APIs. You could also take
this more difficult approach and help speed up the architecture
rework.

Thanks,
Laura

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-01 15:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-01 12:46 Cma mem map to cpu address when allocated in ion driver, why do this design? Yangwei (Yang Wei, Device Chipset Key Technologies Platform Development Dept)
2016-09-01 14:45 ` gregkh
2016-09-01 15:16 ` Laura Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox