[SLOF] [PATCH slof] pci-phb: Reimplement dma-map-in/out

Segher Boessenkool segher at kernel.crashing.org
Wed Nov 20 05:10:41 AEDT 2019


On Fri, Nov 15, 2019 at 10:33:58AM +1100, Alexey Kardashevskiy wrote:
> On 14/11/2019 22:47, Segher Boessenkool wrote:
> > : trunc-4k  ( a - a ) -1000 and ;
> > 
> > if you want a lower address, instead (less often useful, btw).
> > 
> > (OF always is two's complement, you can write -1000 instead of fff invert).
> 
> I am really not used to "-1000" :-/

-N reads a bit nicer than ~(N-1), but it is the same thing.  I find it
easier to read  -1000 and   instead of  fff invert and  but that is for
a big part just what you are used to.

> >> +\ grub does not align allocated addresses to the size
> >> +\ so when mapping in dma-map-in, sometime we call H_PUT_TCE more than
> >> +\ bm-alloc allocated
> >> +: dma-align ( virt size -- virt aligned-size )
> >> +    over fff and + fff + fff not and
> >> +;
> > 
> > : dma-align  ( virt size -- virt a-size )  over fff and +  1000 @aligned ;
> > 
> > fff + fff not and   is just  1000 #aligned  .
> > 
> > I don't understand why you are adding the low twelve bits of the address
> > to the size as well?
> 
> Because everything from the beginning of 4K chunk need to be included
> into the DMA mapping - the IOMMU pages are 4K aligned.

Ah, tricky, so virt has to be rounded down to 4k as well?


Segher


More information about the SLOF mailing list