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



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

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.

have fun
Michael

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQEVAwUBSKAzQcpnzkX8Yg2nAQJboQgAiLWINL5lfcpCXoFrWt9bb3vhKld2WjQX
0G/UjWRSX6vuH2TUCsJCOAWw9xk+1cuaDLXyE8cIdjoIquWRodhb2Oj0xkq7urJv
++8vSzBnFfspArLjhm1/3Eb4t7x7F62wYbZmsGe4v96z1sfJ9LXOXt1thpMA6qPK
R6pxXNMbQz3uv2M3JX6PJ1Tq6uI1dCMX3KBcQQL6RVx5HrKlSMFito7gnNK57uSv
vKqfHcOfpqxL8G/stOm0p4B8dIP0dq40pGBv6E7ClERuasY0txHVFfNnnDlmYeEa
N7aWu9WJYpY9H/8lBK5MXOdubfKJgoOKmTpxztblVgQ6CcuE8szEpQ==
=ZnV7
-----END PGP SIGNATURE-----


Home | Main Index | Thread Index | Old Index