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

Johan MOSSBERG
2010-11-16T16:16:36Z

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1890 bytes --]

MichaÅ‚ Nazarewicz wrote:
> > 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.

Sounds good.

> 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.

I think cma_phys() is redundant, cma_pin() can return the physical
address, that's how we did it in hwmem.

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

I don't understand. Wouldn't you lose all the data in the buffer
when you free it? How would we handle something like the desktop
image which is blitted to the display all the time but never
changes? We'd have to keep a scattered version and then copy it
into a temporary contiguous buffer which is not optimal
performance wise. The other alternative would be to keep the
allocation but then we would get fragmentation problems.

/Johan Mossberg
N‹§²æìr¸›zÇ§u©ž²Æ {\b­†éì¹»\x1c®&Þ–)îÆi¢žØ^n‡r¶‰šŽŠÝ¢j$½§$¢¸\x05¢¹¨­è§~Š'.)îÄÃ,yèm¶ŸÿÃ\f%Š{±šj+ƒñb‚^[nö¢®×¥yÊ&¦‰bs(§ ©Úu«"‚xm¶Ÿÿv+,¢[Þ¶\x17œ®×\x1ckðèž×¦j)Z†·Ÿ