Re: [PATCH v1 08/11] media: intel/ipu6: return an error from ipu6_dma_map_sgtable() on failure
From: Sakari Ailus
Date: Fri Oct 30 2026 - 18:46:52 EST
Hi Valerii,
Thank you for the set. These are really nice fixes!
On Fri, Oct 23, 2026 at 07:55:58PM +0000, Valerii Sokolov wrote:
> ipu6_dma_map_sg() returns 0 when ipu6_mmu_map() fails, but
> ipu6_dma_map_sgtable() only treats negative values as errors. On failure
> it therefore sets sgt->nents to 0 and returns success, and callers such
> as ipu6_isys_buf_init() and ipu6_map_fw_region() go on to hand the
> hardware an address that is not mapped in the IPU MMU.
>
> Return -ENOMEM when ipu6_dma_map_sg() maps no entries.
>
> Fixes: daabc5c64703 ("media: ipu6: not override the dma_ops of device in driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Valerii Sokolov <valerii.sokolov@xxxxx>
> ---
> drivers/media/pci/intel/ipu6/ipu6-dma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/pci/intel/ipu6/ipu6-dma.c b/drivers/media/pci/intel/ipu6/ipu6-dma.c
> index a923a1e4bd..37b5c25259 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6-dma.c
> +++ b/drivers/media/pci/intel/ipu6/ipu6-dma.c
> @@ -459,8 +459,8 @@ int ipu6_dma_map_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
> int nents;
>
> nents = ipu6_dma_map_sg(sys, sgt->sgl, sgt->nents, dir, attrs);
> - if (nents < 0)
> - return nents;
> + if (nents <= 0)
> + return nents < 0 ? nents : -ENOMEM;
I think this has been written as-is since the thinking has been a negative
error code is returned on error. So I'd fix this on ipu6_dma_map_sg() side
instead.
dma_map_sg() returns 0 on error (which is probably the source of this
discrepancy) but I don't think we need to align the error codes to that.
>
> sgt->nents = nents;
>
--
Kind regards,
Sakari Ailus