|
|
Subscribe / Log in / New account

Contiguous memory allocation for drivers

Contiguous memory allocation for drivers

Posted Jul 23, 2010 22:55 UTC (Fri) by giraffedata (guest, #1954)
Parent article: Contiguous memory allocation for drivers

I don't get it. How is this better than the driver allocating the memory at boot time? In the example, it looks like there is 10 MB reserved for the camera for the life of the kernel instance. What am I missing?


to post comments

Contiguous memory allocation for drivers

Posted Jul 25, 2010 10:52 UTC (Sun) by mina86 (guest, #68442) [Link] (1 responses)

The driver don't need to allocate memory. It is my experience that allocating memory at boot time is not that trivial, i.e. you don't have a one “allocate that amount of memory at boot time” function call. With CMA driver don't have to worry where to get the memory region from -- driver merely uses it.

This is a rather minor point though. More importantly, drivers can easily share the same region of memory without even knowing about it. The example I keep giving is a system with a camera and a video decoder which never run at the same time. If each driver were to allocate space for themselves twice the amount of memory would be reserved then really needed. It's of course only a simple example and one could show many more.

Also, as a freebie, drivers get allocators that are implemented in CMA. This may not always be an advantage since not all drivers will need it but nonetheless some may benefit.

So to sum things up, all the complexity of reserving and allocating memory is moved from the drivers to the framework plus centralised management gives greater flexibility for platform architects.

Contiguous memory allocation for drivers

Posted Jul 25, 2010 14:31 UTC (Sun) by giraffedata (guest, #1954) [Link]

Those are good reasons for CMA, but don't seem to be what the article is about. In the example in the article, it appears that a region is dedicated to the camera -- there's no opportunity to share with another driver. And the article starts off by saying the problem to be solved is that if you allocate the memory at boot time, you waste the memory when you aren't using the camera, but if you allocate it later, you might not be able to get it because of fragmentation.

I have now read the linked CMA documentation as well, and I think the article just missed the point of CMA.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds