2022-01-06 03:10:10

by Jiasheng Jiang

[permalink] [raw]
Subject: [PATCH] dmaengine: sh: rcar-dmac: Check for error num after setting mask

Because of the possible failure of the dma_supported(), the
dma_set_mask_and_coherent() may return error num.
Therefore, it should be better to check it and return the error if
fails.

Fixes: dc312349e875 ("dmaengine: rcar-dmac: Widen DMA mask to 40 bits")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/dma/sh/rcar-dmac.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 6885b3dcd7a9..79901d0e9fbf 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1869,7 +1869,9 @@ static int rcar_dmac_probe(struct platform_device *pdev)
dmac->dev = &pdev->dev;
platform_set_drvdata(pdev, dmac);
dma_set_max_seg_size(dmac->dev, RCAR_DMATCR_MASK);
- dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
+ ret = dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
+ if (ret)
+ return ret;

ret = rcar_dmac_parse_of(&pdev->dev, dmac);
if (ret < 0)
--
2.25.1



2022-01-10 09:38:37

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] dmaengine: sh: rcar-dmac: Check for error num after setting mask

Hi Jiasheng,

On Thu, Jan 6, 2022 at 4:09 AM Jiasheng Jiang <[email protected]> wrote:
> Because of the possible failure of the dma_supported(), the
> dma_set_mask_and_coherent() may return error num.
> Therefore, it should be better to check it and return the error if
> fails.
>
> Fixes: dc312349e875 ("dmaengine: rcar-dmac: Widen DMA mask to 40 bits")
> Signed-off-by: Jiasheng Jiang <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1869,7 +1869,9 @@ static int rcar_dmac_probe(struct platform_device *pdev)
> dmac->dev = &pdev->dev;
> platform_set_drvdata(pdev, dmac);
> dma_set_max_seg_size(dmac->dev, RCAR_DMATCR_MASK);

dma_set_max_seg_size() can fail, too.

> - dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
> + ret = dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
> + if (ret)
> + return ret;
>
> ret = rcar_dmac_parse_of(&pdev->dev, dmac);
> if (ret < 0)
> --
> 2.25.1
>


--
Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2022-01-10 10:17:05

by Jiasheng Jiang

[permalink] [raw]
Subject: Re: Re: [PATCH] dmaengine: sh: rcar-dmac: Check for error num after setting mask

On Mon, Jan 10, 2022 at 05:37:34PM +0800, Geert Uytterhoeven wrote:
>> --- a/drivers/dma/sh/rcar-dmac.c
>> +++ b/drivers/dma/sh/rcar-dmac.c
>> @@ -1869,7 +1869,9 @@ static int rcar_dmac_probe(struct platform_device *pdev)
>> dmac->dev = &pdev->dev;
>> platform_set_drvdata(pdev, dmac);
>> dma_set_max_seg_size(dmac->dev, RCAR_DMATCR_MASK);
>
> dma_set_max_seg_size() can fail, too.

Thanks for your reminder.
I will submit another patch to fix it and add
"Reported-by: Geert Uytterhoeven <[email protected]>".

Sincerely thanks,
Jiang


2022-02-15 08:03:56

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH] dmaengine: sh: rcar-dmac: Check for error num after setting mask

On 06-01-22, 11:09, Jiasheng Jiang wrote:
> Because of the possible failure of the dma_supported(), the
> dma_set_mask_and_coherent() may return error num.
> Therefore, it should be better to check it and return the error if
> fails.

Applied, thanks

--
~Vinod