Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()
@ 2024-06-26  8:45 Ma Ke
  2024-06-26  9:02 ` Peng Fan
  2024-06-26 11:15 ` Markus Elfring
  0 siblings, 2 replies; 4+ messages in thread
From: Ma Ke @ 2024-06-26  8:45 UTC (permalink / raw)
  To: vkoul, shawnguo, s.hauer, kernel, festevam
  Cc: dmaengine, imx, linux-arm-kernel, linux-kernel, Ma Ke

As the possible failure of the dma_set_max_seg_size(), we should better
check the return value of the dma_set_max_seg_size().

Fixes: a580b8c5429a ("dmaengine: mxs-dma: add dma support for i.MX23/28")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/dma/mxs-dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index cfb9962417ef..90cbb9b04b02 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -798,7 +798,9 @@ static int mxs_dma_probe(struct platform_device *pdev)
 	mxs_dma->dma_device.dev = &pdev->dev;
 
 	/* mxs_dma gets 65535 bytes maximum sg size */
-	dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
+	ret = dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
+	if (ret)
+		return ret;
 
 	mxs_dma->dma_device.device_alloc_chan_resources = mxs_dma_alloc_chan_resources;
 	mxs_dma->dma_device.device_free_chan_resources = mxs_dma_free_chan_resources;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()
  2024-06-26  8:45 [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe() Ma Ke
@ 2024-06-26  9:02 ` Peng Fan
  2024-06-26  9:07   ` Michael Nazzareno Trimarchi
  2024-06-26 11:15 ` Markus Elfring
  1 sibling, 1 reply; 4+ messages in thread
From: Peng Fan @ 2024-06-26  9:02 UTC (permalink / raw)
  To: Ma Ke, vkoul@kernel.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com
  Cc: dmaengine@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org

> Subject: [PATCH] dmaengine: mxs-dma: Add check for
> dma_set_max_seg_size in mxs_dma_probe()

Please read
https://lore.kernel.org/all/ZiocjS6tbeTt2mPD@matsya/

Regards,
Peng.

> 
> As the possible failure of the dma_set_max_seg_size(), we should
> better check the return value of the dma_set_max_seg_size().
> 
> Fixes: a580b8c5429a ("dmaengine: mxs-dma: add dma support for
> i.MX23/28")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  drivers/dma/mxs-dma.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index
> cfb9962417ef..90cbb9b04b02 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -798,7 +798,9 @@ static int mxs_dma_probe(struct
> platform_device *pdev)
>  	mxs_dma->dma_device.dev = &pdev->dev;
> 
>  	/* mxs_dma gets 65535 bytes maximum sg size */
> -	dma_set_max_seg_size(mxs_dma->dma_device.dev,
> MAX_XFER_BYTES);
> +	ret = dma_set_max_seg_size(mxs_dma->dma_device.dev,
> MAX_XFER_BYTES);
> +	if (ret)
> +		return ret;
> 
>  	mxs_dma->dma_device.device_alloc_chan_resources =
> mxs_dma_alloc_chan_resources;
>  	mxs_dma->dma_device.device_free_chan_resources =
> mxs_dma_free_chan_resources;
> --
> 2.25.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()
  2024-06-26  9:02 ` Peng Fan
@ 2024-06-26  9:07   ` Michael Nazzareno Trimarchi
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Nazzareno Trimarchi @ 2024-06-26  9:07 UTC (permalink / raw)
  To: Peng Fan
  Cc: Ma Ke, vkoul@kernel.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com,
	dmaengine@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org

Hi

On Wed, Jun 26, 2024 at 11:02 AM Peng Fan <peng.fan@nxp.com> wrote:
>
> > Subject: [PATCH] dmaengine: mxs-dma: Add check for
> > dma_set_max_seg_size in mxs_dma_probe()
>
> Please read
> https://lore.kernel.org/all/ZiocjS6tbeTt2mPD@matsya/
>
> Regards,
> Peng.
>
> >
> > As the possible failure of the dma_set_max_seg_size(), we should
> > better check the return value of the dma_set_max_seg_size().
> >
> > Fixes: a580b8c5429a ("dmaengine: mxs-dma: add dma support for
> > i.MX23/28")
> > Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> > ---
> >  drivers/dma/mxs-dma.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index
> > cfb9962417ef..90cbb9b04b02 100644
> > --- a/drivers/dma/mxs-dma.c
> > +++ b/drivers/dma/mxs-dma.c
> > @@ -798,7 +798,9 @@ static int mxs_dma_probe(struct
> > platform_device *pdev)
> >       mxs_dma->dma_device.dev = &pdev->dev;
> >
> >       /* mxs_dma gets 65535 bytes maximum sg size */
> > -     dma_set_max_seg_size(mxs_dma->dma_device.dev,
> > MAX_XFER_BYTES);
> > +     ret = dma_set_max_seg_size(mxs_dma->dma_device.dev,
> > MAX_XFER_BYTES);
> > +     if (ret)
> > +             return ret;
> >

If the function returns an error then you should check for it. If it's
not logical to have it, then you could
make void the function that is called and WARN_ON on an illogical situation

Michael

> >       mxs_dma->dma_device.device_alloc_chan_resources =
> > mxs_dma_alloc_chan_resources;
> >       mxs_dma->dma_device.device_free_chan_resources =
> > mxs_dma_free_chan_resources;
> > --
> > 2.25.1
> >
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe()
  2024-06-26  8:45 [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe() Ma Ke
  2024-06-26  9:02 ` Peng Fan
@ 2024-06-26 11:15 ` Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-06-26 11:15 UTC (permalink / raw)
  To: Ma Ke, dmaengine, linux-arm-kernel, imx, kernel, Fabio Estevam,
	Sascha Hauer, Shawn Guo, Vinod Koul
  Cc: LKML

> As the possible failure of the dma_set_max_seg_size(), we should better
> check the return value of the dma_set_max_seg_size().

Please avoid the repetition of a function name in such a change description.
Can it be improved with a corresponding imperative wording?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n94

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-26 11:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26  8:45 [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size in mxs_dma_probe() Ma Ke
2024-06-26  9:02 ` Peng Fan
2024-06-26  9:07   ` Michael Nazzareno Trimarchi
2024-06-26 11:15 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox