bge usage of bus_dma_tag_create?

John-Mark Gurney gurney_j at efn.org
Fri Dec 12 11:44:45 PST 2003


James Van Artsdalen wrote this message on Fri, Dec 12, 2003 at 02:23 -0600:
> I am confused by this code in sys/dev/bge/if_bge.c.
> Are the values for the lowaddr and highaddr args to
> bus_dma_tag_create () swapped?
> 
> The ata and aha drivers seem to have lowaddr <= highaddr,
> but on AMD64 that's not true below.
> 
> static int
> bge_dma_alloc(dev)
>         device_t dev;
> {
>         struct bge_softc *sc;
>         int nseg, i, error;
>         struct bge_dmamap_arg ctx;
> 
>         sc = device_get_softc(dev);
> 
>         /*
>          * Allocate the parent bus DMA tag appropriate for PCI.
>          */
> #define BGE_NSEG_NEW 32
>         error = bus_dma_tag_create(NULL,        /* parent */
>                         PAGE_SIZE, 0,           /* alignment, boundary */
>                         BUS_SPACE_MAXADDR,      /* lowaddr */
>                         BUS_SPACE_MAXADDR_32BIT,/* highaddr */

This really needs to be decided by the card, and if the card supports
64bit addressing or not..  but yes, this does look like they need to be
reversed.  If the card can support 64bit addressing, then they should
both be changed to BUS_SPACE_MAXADDR, but if the card only supports
32bit addressing then they should be swapped..

>From the bus_dma man page:
              lowaddr
              highaddr      Bounds of the window of bus address space that
                            cannot be directly accessed by the device.  The
                            window contains all address greater than lowaddr
                            and less than or equal to highaddr.  For example,
                            a device incapable of DMA above 4GB, would specify
                            a highaddr of BUS_SPACE_MAXADDR and a lowaddr of
                            BUS_SPACE_MAXADDR_32BIT.  Similarly a device that

Though why this would work on x86 isn't good, maybe we need to add an
assert in the bus_dma routines that lowaddr <= highaddr?

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-amd64 mailing list