Subject: Re: bus_dmamap_load: struct proc *p: finding process p
To: David Young <dyoung@pobox.com>
From: Sam Thigpen <sthigpen@sdf.lonestar.org>
List: tech-kern
Date: 10/04/2004 17:48:52
On Mon, 4 Oct 2004, David Young wrote:

> Date: Mon, 4 Oct 2004 11:41:50 -0500
> From: David Young <dyoung@pobox.com>
> To: tech-kern@NetBSD.org
> Subject: Re: bus_dmamap_load: struct proc *p: finding process p
> 
> On Mon, Oct 04, 2004 at 04:36:49PM +0000, Sam Thigpen wrote:
>> On Mon, 4 Oct 2004, David Young wrote:
>>> You're reading the wrong code. In the #ifdef __NetBSD__ portion, it says:
>>>
>>>       if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_ddmamap,
>>>       sc->sc_desc,
>>>           sc->sc_desc_len, NULL, 0)) != 0) {
>>>               printf("%s: unable to load control data DMA map, error =
>>>               %d\n",
>>>                   sc->sc_dev.dv_xname, error);
>>>               goto fail3;
>>>       }
>>
>> So for NetBSD the buffer is typically in kernel space by default?  Are
>> there cases where it isn't?
>>
>
> In this case, bus_dmamap_load operates on the Tx/Rx descriptor rings.
> The rings are shared between the kernel and the adapter; they are not
> shared with userland.

for FreeBSD acx(100)() the rx/tx (tx here) loads as:

/* map virtual memory address to real memory address for allocated segments */
     if( bus_dmamap_load(
         /* dmat */          sc->dma_desctag,
         /* map */           sc->dma_map_txdesc,
         /* buf */           sc->dma_vaddr_txdesc,
         /* buflen */        ACX_PACKET_DESCSIZE * ACX_PACKET_RINGSIZE,
         /* callback */      acx_packet_map_addr,
         /* callback_arg */  &sc->dma_paddr_txdesc,
         /* flags */         0) != 0 )
     {
         device_printf(sc->dev, "failed to determine dma memory address\n");
         goto error_dmafree_txdesc;
     }

the FreeBSD callback is acx_packet_map_addr -- but I'm assuming NULL for 
NetBSD in this case as well..

ath.c uses the same rx/tx descriptor, so for NetBSD acx(100)():

error = bus_dmamap_load(sc->sc_dmat, sc->sc_ddmamap,
                         sc->sc_desc, sc->sc_desc_len,
                         NULL, &sc->sc_desc_paddr,
                      // ^^^^ assuming this is not shared with userland
                         BUS_DMA_NOWAIT);
         if (error != 0)
                 goto error_dmamapdestroy_txdescA;

...so as stated I'm referencing ath.c as a "template" for acx(100)() busdma calls.

Thanks,
-sa.
sthigpen@freeshell.org
http://sthigpen.freeshell.org/code/acx/netbsd