[SLOF] [PATCH slof] pci-phb: Reimplement dma-map-in/out
aik at ozlabs.ru
Fri Nov 15 10:33:58 AEDT 2019
On 14/11/2019 22:47, Segher Boessenkool wrote:
> On Thu, Nov 14, 2019 at 02:33:41PM +1100, Alexey Kardashevskiy wrote:
>> +: align-4k
>> + fff not and
> This is aligning down. "align" means "align upwards" normally. The word
> "align" aligns the data space, while "aligned" aligns a pointer. SLOF also
> has a utility word "#aligned" to align to some certain boundary. So you
> would do
> : align-4k ( a - a ) 1000 #aligned ;
> but that sligns *upwards*.
> : 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" :-/
>> +\ 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.
More information about the SLOF