Re: [PATCH 0/3] hwmem: Hardware memory driver

Michał Nazarewicz
2010-11-16T15:34:58Z

On Tue, 16 Nov 2010 16:25:20 +0100, Johan MOSSBERG <johan.xx.mossberg@stericsson.com> wrote:

> Michał Nazarewicz wrote:
>> In particular, I'll try to figure out what you mean by defragmentation
>> and see whethe it could be added to CMA.
>
> I mean the ability to move allocated buffers to free more
> contiguous space. To support this in CMA the API(s) would have to
> change.
> * A buffer's physical address cannot be used to identify it as the
> physical address can change.
> * Pin/unpin functions would have to be added so that you can pin a
> buffer when hardware uses it.
> * The allocators needs to be able to inform CMA that they have
> moved a buffer. This is so that CMA can keep track of what memory
> is free so that it can supply the free memory to the kernel for
> temporary use there.

I don't think those are fundamentally against CMA and as such I see
no reason why such calls could not be added to CMA. Allocators that
do not support defragmentation could just ignore those calls.

In particular, a cma_alloc() could return a pointer to an opaque
struct cma and to get physical address user would have to pin the
buffer with, say, cma_pin() and then call cma_phys() to obtain
physical address.

As a matter of fact, in the version of CMA I'm currently working on,
cma_alloc() returns a pointer to a transparent structure, so the
above would not be a huge change.

I'm only wondering if treating "unpin" as "free" and pin as another
"alloc" would not suffice?

--
Best regards, _ _
| Humble Liege of Serenely Enlightened Majesty of o' \,=./ `o
| Computer Science, Michał "mina86" Nazarewicz (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--