Port-macppc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: use of malloc(9) for DMA buffers
Hi,
On Mon, Aug 11, 2008 at 2:40 PM, Michael Lorenz <macallan%netbsd.org@localhost>
wrote:
> On Aug 11, 2008, at 8:17 AM, Marco Trillo wrote:
>> I have a doubt regarding dbdma.c dbdma_alloc(). It uses malloc(9) to
>> allocate the buffer for the DMA command descriptors:
>>
>> 122: dbdma_command_t *
>> 123: dbdma_alloc(size)
>> 124: int size;
>> 125: {
>> 126: u_int buf;
>> 127:
>> 128: buf = (u_int)malloc(size + 0x0f, M_DEVBUF, M_WAITOK);
>> 129: buf = (buf + 0x0f) & ~0x0f;
>> 130:
>> 131: return (dbdma_command_t *)buf;
>> 132: }
>>
>> Since these descriptors are directly accessed by hardware, wouldn't
>> this cause problems if the buffer crosses a page boundary and so it's
>> not contiguous in physical memory? Or does this never happen?
>
> On macppc that's safe ( kernel virtual addresses are identical to physical
> addresses ) but on most other platforms it would likely blow up in your
> face.
Hmm... I've done a test using buf = malloc(8192, M_DEVBUF) and vtophys():
buf = d0024000, vtophys(buf) = 2fb13000
buf + NBPG = d0025000, vtophys(buf + NBPG) = 2fb12000
Is the fact that malloc(9) returns page-aligned buffers even when
allocating small quantities reliable for use in functions such as
dbdma_alloc() ?
Thanks,
Marco.
Home |
Main Index |
Thread Index |
Old Index