Re: [PATCH 1/4] media: venus: use dma_iova_size() to check the reserved IOVA size

From: Leon Romanovsky

Date: Fri Nov 27 2026 - 10:24:50 EST


On Fri, Nov 27, 2026 at 10:29:12AM -0400, Jason Gunthorpe wrote:
> On Fri, Nov 27, 2026 at 12:58:45PM +0100, Marek Szyprowski wrote:
> > The IOVA reservation code compares dma_iova_state::__size directly with
> > the requested chunk size. __size is internal to the DMA IOVA API and may
> > carry flags in its upper bits, so use the dma_iova_size() accessor
> > instead.
>
> WTF is this even doing?
>
> Fix this by reserving the 0-600MB range, below the boundary the
> non-pixel stream cannot address, using dma_iova_try_alloc() so the
> IOMMU-DMA core never hands that range out to a real DMA mapping. This
> reserves only IOVA space, it does not allocate any physical memory.
>
> That isn't what this API is for, and it isn't how it even works! It is
> pure luck that the first call to it happens to take out the lower
> address space.
>
> We even had a long discussion about this driver and this need in
> another thread and this is the hack job you guys merged?

You should also mention that NONE of the DMA/IOMMU developers or the authors
of that API were CCed when the change was merged.
https://lore.kernel.org/all/20260818-reserve_iova_in_driver-v2-2-5005a1154408@xxxxxxxxxxxxxxxx/

>
> And it couldn't even use the right APIs??!

And proposed for the stable@ :(

>
> Jason