Re: [PATCH] media: intel/ipu6: Fix dma mask for non-secure mode

Stanislaw Gruszka
2025-04-10T08:52:24Z

Hi Bingbu,

On Thu, Apr 10, 2025 at 02:53:45PM +0800, Bingbu Cao wrote:
> Stanislaw,
>
> Thanks for the patch.
>
> On 4/9/25 5:58 PM, Stanislaw Gruszka wrote:
> > We use dma_get_mask() of auxdev device for calculate iova pfn limit.
> > This is always 32 bit mask as we do not initialize the mask (and we can
> > not do so, since dev->dev_mask is NULL anyways for auxdev).
>
> Indeed.
>
> >
> > Since we need 31 bit mask for non-secure mode create wrapper of
> > alloc_iova() which use mmu_info->aperture_end. This give us always
> > the correct mask.
> >
> > Fixes: daabc5c64703 ("media: ipu6: not override the dma_ops of device in driver")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
> > ---
> > drivers/media/pci/intel/ipu6/ipu6-dma.c | 6 ++----
> > drivers/media/pci/intel/ipu6/ipu6-dma.h | 7 -------
> > drivers/media/pci/intel/ipu6/ipu6-mmu.c | 3 +--
> > drivers/media/pci/intel/ipu6/ipu6-mmu.h | 13 +++++++++++++
> > 4 files changed, 16 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/media/pci/intel/ipu6/ipu6-dma.c b/drivers/media/pci/intel/ipu6/ipu6-dma.c
> > index b34022bad83b..a1d4ec35f802 100644
> > --- a/drivers/media/pci/intel/ipu6/ipu6-dma.c
> > +++ b/drivers/media/pci/intel/ipu6/ipu6-dma.c
> > @@ -171,8 +171,7 @@ void *ipu6_dma_alloc(struct ipu6_bus_device *sys, size_t size,
> > size = PAGE_ALIGN(size);
> > count = PHYS_PFN(size);
> >
> > - iova = alloc_iova(&mmu->dmap->iovad, count,
> > - PHYS_PFN(dma_get_mask(dev)), 0);
>
> How about directly call?
> iova = alloc_iova(&mmu->dmap->iovad, count,
> PHYS_PFN(mmu->dmap->mmu_info->aperture_end), 0);
>
> Less change, better.

Yes, direct call results in smaller/nicer fix, I will do this in v2.

Regards
Stanislaw