Subject: Re: Valid use of bus_dma(9)?
To: Jochen Kunz <jkunz@unixag-kl.fh-kl.de>
From: john heasley <heas@shrubbery.net>
List: tech-kern
Date: 07/22/2004 06:50:09
Thu, Jul 22, 2004 at 03:13:10PM +0200, Jochen Kunz:
> Hi.
> 
> Is this a valid use of bus_dma(9)?
> 
> 	bus_dmamem_alloc(x_segs)
> 	bus_dmamem_map(x_segs)
> 	bus_dmamap_create(x_map)
> 	bus_dmamap_load(x_map)
> I.e. the usual way to get some DMA memory and later...
> 	y_segs[0] = x_segs[0]
> 	y_segs[0].ds_addr += sizeof(some_thing);
> 	y_segs[0].ds_len = sizeof(some_other_thing);
> 	bus_dmamem_map(y_segs)
> 	bus_dmamap_create(y_map)
> 	bus_dmamap_load(y_map)
> 
> Thus resulting in a double mapping of the previously allocated and maped
> "x" DMA memory. The physical "y" memory is subregion of the physical "x"
> memory mapped at a different KVA.
> 
> To me this looks wrong. The "y" memory should be handled as an offset of
> the "x" memory and a driver should never modify or "self create" a DMA
> segment / map. (At least that is the way I understand bus_dma(9).)
> 
> Background: fpa(4) does the above. It fails on hp700 for this reason.
> I now need to decide if the hp700 bus_dma(9) code needs fixing (my
> problem) or if fpa(4) needs fixing (not my problem ;-) ). 

I believe thats the purpose of

bus_space(9):

     Some drivers need to be able to pass a subregion of already-mapped bus
     space to another driver or module within a driver.  The
     bus_space_subregion() function allows such subregions to be created.