[SLOF] [PATCH slof] pci-phb: Reimplement dma-map-in/out
Alexey Kardashevskiy
aik at ozlabs.ru
Wed Nov 20 11:25:20 AEDT 2019
On 20/11/2019 05:10, Segher Boessenkool wrote:
> 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.
Well, I did not see this being used anywhere else, like, in linux.
>>>> +\ 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?
The virt address passed to H_PUT_TCE - yes it has but the dma-map-in
helper still should return nonaligned address so I keep the page offset
around until return. I'll try to make this clearer. Thanks,
--
Alexey
More information about the SLOF
mailing list