Re: [PATCH 00/18] Convert arch/arm to use iommu-dma

Marek Szyprowski
2020-09-18T15:13:27Z

Hi all,

On 24.08.2020 13:40, Marek Szyprowski wrote:
> On 20.08.2020 17:08, Robin Murphy wrote:
>> After 5 years or so of intending to get round to this, finally the
>> time comes! The changes themselves actualy turn out to be relatively
>> mechanical; the bigger concern appears to be how to get everything
>> merged across about 5 diffferent trees given the dependencies.
>>
>> I've lightly boot-tested things on Rockchip RK3288 and Exynos 4412
>> (Odroid-U3), to the degree that their display drivers should be using
>> IOMMU-backed buffers and don't explode (the Odroid doesn't manage to
>> send a working HDMI signal to the one monitor I have that it actually
>> detects, but that's a pre-existing condition...) Confirmation that the
>> Mediatek, OMAP and Tegra changes work will be most welcome.
>>
>> Patches are based on 5.9-rc1, branch available here:
>>
>>    git://linux-arm.org/linux-rm arm/dma
>
> Well, my first proposal for the ARM and ARM64 DMA-mapping unification
> has been posted long time ago: https://lkml.org/lkml/2016/2/19/79
>
> Thanks for resurrecting it! :)
>
> I've tested this patchset on various ARM32bit Exynos based boards (not
> only Exynos4412) and most of them works fine after your conversion.
> However there are issues you cannot learn from the code.
>
> Conversion of the Exynos DRM was straightforward (thanks!), but there
> are other Exynos drivers that depends on the old ARM implementation.
> The S5P-MFC (only for the v5 hardware) and Exynos4 FIMC-ISP drivers
> depends on the first-fit IOVA allocation algorithm in the old ARM
> DMA-mapping. This was the main reason I've didn't continue my initial
> conversion attempt.
>
> Both drivers allocate a buffer for their firmware and then in the
> hardware registers address video buffers as an offset from the
> begginning of the firmware. This doesn't work when underlying
> DMA-mapping allocates IOVA with the last-fit algorithm, what the
> drivers/iommu/dma-iommu.c does. So far I didn't find a good solution
> for that issue.
>
> I'm open for suggestions. One more limitation for the S5P-MFC driver
> is that the hardware is capable only for addressing 128MiB. They will
> probably need to call IOMMU API directly, but I would like to keep as
> much from the IOMMU/DMA-mapping code as possible.

Just for the record. I've finally managed to add needed workarounds to
the both problematic Exynos4 drivers, so they work fine with this
patchset. It turned out that it wasn't that hard:

https://lore.kernel.org/linux-samsung-soc/20200918144833.14618-1-m.szyprowski@samsung.com/T/#t

So from my side you have a green light to go ahead and switch ARM 32bit
to generic code. Time to say good bye to the one of my biggest
architecture related things merged once to mainline Linux. ;)

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland