All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in rz_ssi_dma_request()
@ 2021-08-17  3:00 ` Yang Yingliang
  0 siblings, 0 replies; 4+ messages in thread
From: Yang Yingliang @ 2021-08-17  3:00 UTC (permalink / raw)
  To: linux-kernel, alsa-devel
  Cc: broonie, biju.das.jz, prabhakar.mahadev-lad.rj, lgirdwood

In case of error, the function dma_request_chan() returns ERR_PTR()
and never returns NULL. Set 'dma_ch' to NULL, if dma_request_chan()
returns error, so the code using 'dma_ch' can work correctly.

Fixes: 26ac471c5354 ("ASoC: sh: rz-ssi: Add SSI DMAC support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 sound/soc/sh/rz-ssi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c
index ea8d33ede5d2..5ec78fd94d94 100644
--- a/sound/soc/sh/rz-ssi.c
+++ b/sound/soc/sh/rz-ssi.c
@@ -676,11 +676,17 @@ static void rz_ssi_release_dma_channels(struct rz_ssi_priv *ssi)
 static int rz_ssi_dma_request(struct rz_ssi_priv *ssi, struct device *dev)
 {
 	ssi->playback.dma_ch = dma_request_chan(dev, "tx");
+	if (IS_ERR(ssi->playback.dma_ch))
+		ssi->playback.dma_ch = NULL;
 	ssi->capture.dma_ch = dma_request_chan(dev, "rx");
+	if (IS_ERR(ssi->capture.dma_ch))
+		ssi->capture.dma_ch = NULL;
 	if (!ssi->playback.dma_ch && !ssi->capture.dma_ch) {
 		ssi->playback.dma_ch = dma_request_chan(dev, "rt");
-		if (!ssi->playback.dma_ch)
+		if (IS_ERR(ssi->playback.dma_ch)) {
+			ssi->playback.dma_ch = NULL;
 			goto no_dma;
+		}
 
 		ssi->dma_rt = true;
 	}
-- 
2.25.1


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

* [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in rz_ssi_dma_request()
@ 2021-08-17  3:00 ` Yang Yingliang
  0 siblings, 0 replies; 4+ messages in thread
From: Yang Yingliang @ 2021-08-17  3:00 UTC (permalink / raw)
  To: linux-kernel, alsa-devel
  Cc: biju.das.jz, broonie, prabhakar.mahadev-lad.rj, lgirdwood

In case of error, the function dma_request_chan() returns ERR_PTR()
and never returns NULL. Set 'dma_ch' to NULL, if dma_request_chan()
returns error, so the code using 'dma_ch' can work correctly.

Fixes: 26ac471c5354 ("ASoC: sh: rz-ssi: Add SSI DMAC support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 sound/soc/sh/rz-ssi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c
index ea8d33ede5d2..5ec78fd94d94 100644
--- a/sound/soc/sh/rz-ssi.c
+++ b/sound/soc/sh/rz-ssi.c
@@ -676,11 +676,17 @@ static void rz_ssi_release_dma_channels(struct rz_ssi_priv *ssi)
 static int rz_ssi_dma_request(struct rz_ssi_priv *ssi, struct device *dev)
 {
 	ssi->playback.dma_ch = dma_request_chan(dev, "tx");
+	if (IS_ERR(ssi->playback.dma_ch))
+		ssi->playback.dma_ch = NULL;
 	ssi->capture.dma_ch = dma_request_chan(dev, "rx");
+	if (IS_ERR(ssi->capture.dma_ch))
+		ssi->capture.dma_ch = NULL;
 	if (!ssi->playback.dma_ch && !ssi->capture.dma_ch) {
 		ssi->playback.dma_ch = dma_request_chan(dev, "rt");
-		if (!ssi->playback.dma_ch)
+		if (IS_ERR(ssi->playback.dma_ch)) {
+			ssi->playback.dma_ch = NULL;
 			goto no_dma;
+		}
 
 		ssi->dma_rt = true;
 	}
-- 
2.25.1


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

* RE: [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in rz_ssi_dma_request()
  2021-08-17  3:00 ` Yang Yingliang
  (?)
@ 2021-08-17  6:41 ` Biju Das
  2021-08-18  6:43   ` Biju Das
  -1 siblings, 1 reply; 4+ messages in thread
From: Biju Das @ 2021-08-17  6:41 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, alsa-devel
  Cc: broonie, Prabhakar Mahadev Lad, lgirdwood

Hi Yang Yingliang,

Thanks for your patch.

Already I have posted a patch for fixing it.

https://patchwork.kernel.org/project/alsa-devel/patch/20210814180120.18082-1-biju.das.jz@bp.renesas.com/

Since you posted a similar patch as Reported-by: Hulk Robot <hulkci@huawei.com>,
I am adding my Rb tag for this patch.

Regards,
Biju


> -----Original Message-----
> From: Yang Yingliang <yangyingliang@huawei.com>
> Sent: 17 August 2021 04:00
> To: linux-kernel@vger.kernel.org; alsa-devel@alsa-project.org
> Cc: broonie@kernel.org; Biju Das <biju.das.jz@bp.renesas.com>; Prabhakar
> Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>; lgirdwood@gmail.com
> Subject: [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in
> rz_ssi_dma_request()
> 
> In case of error, the function dma_request_chan() returns ERR_PTR() and
> never returns NULL. Set 'dma_ch' to NULL, if dma_request_chan() returns
> error, so the code using 'dma_ch' can work correctly.
> 
> Fixes: 26ac471c5354 ("ASoC: sh: rz-ssi: Add SSI DMAC support")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

> ---
>  sound/soc/sh/rz-ssi.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index
> ea8d33ede5d2..5ec78fd94d94 100644
> --- a/sound/soc/sh/rz-ssi.c
> +++ b/sound/soc/sh/rz-ssi.c
> @@ -676,11 +676,17 @@ static void rz_ssi_release_dma_channels(struct
> rz_ssi_priv *ssi)  static int rz_ssi_dma_request(struct rz_ssi_priv *ssi,
> struct device *dev)  {
>  	ssi->playback.dma_ch = dma_request_chan(dev, "tx");
> +	if (IS_ERR(ssi->playback.dma_ch))
> +		ssi->playback.dma_ch = NULL;
>  	ssi->capture.dma_ch = dma_request_chan(dev, "rx");
> +	if (IS_ERR(ssi->capture.dma_ch))
> +		ssi->capture.dma_ch = NULL;
>  	if (!ssi->playback.dma_ch && !ssi->capture.dma_ch) {
>  		ssi->playback.dma_ch = dma_request_chan(dev, "rt");
> -		if (!ssi->playback.dma_ch)
> +		if (IS_ERR(ssi->playback.dma_ch)) {
> +			ssi->playback.dma_ch = NULL;
>  			goto no_dma;
> +		}
> 
>  		ssi->dma_rt = true;
>  	}
> --
> 2.25.1


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

* RE: [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in rz_ssi_dma_request()
  2021-08-17  6:41 ` Biju Das
@ 2021-08-18  6:43   ` Biju Das
  0 siblings, 0 replies; 4+ messages in thread
From: Biju Das @ 2021-08-18  6:43 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, alsa-devel
  Cc: broonie, Prabhakar Mahadev Lad, lgirdwood

Hi Yang Yingliang,

Still some improvements to be done on this patch.
If one of the dma channel is failed, we should fallback that channel to PIO.

Something like below. I will post a new patch after testing this.

ssi->playback.transfer = rz_ssi_pio_send;
ssi->capture.transfer = rz_ssi_pio_recv;

/* Detect DMA support */
ret = rz_ssi_dma_request(ssi, &pdev->dev);
if (ret < 0) {
	dev_warn(&pdev->dev, "DMA not available, using PIO\n");
} else {
	dev_info(&pdev->dev, "DMA enabled");
	if (ssi->playback.dma_ch)
		ssi->playback.transfer = rz_ssi_dma_transfer;
	if (ssi->capture.dma_ch)
		ssi->capture.transfer = rz_ssi_dma_transfer;
}

Regards,
Biju


> Subject: RE: [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in
> rz_ssi_dma_request()
> 
> Hi Yang Yingliang,
> 
> Thanks for your patch.
> 
> Already I have posted a patch for fixing it.
> 
> https://patchwork.kernel.org/project/alsa-
> devel/patch/20210814180120.18082-1-biju.das.jz@bp.renesas.com/
> 
> Since you posted a similar patch as Reported-by: Hulk Robot
> <hulkci@huawei.com>, I am adding my Rb tag for this patch.
> 
> Regards,
> Biju
> 
> 
> > -----Original Message-----
> > From: Yang Yingliang <yangyingliang@huawei.com>
> > Sent: 17 August 2021 04:00
> > To: linux-kernel@vger.kernel.org; alsa-devel@alsa-project.org
> > Cc: broonie@kernel.org; Biju Das <biju.das.jz@bp.renesas.com>;
> > Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>;
> > lgirdwood@gmail.com
> > Subject: [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in
> > rz_ssi_dma_request()
> >
> > In case of error, the function dma_request_chan() returns ERR_PTR()
> > and never returns NULL. Set 'dma_ch' to NULL, if dma_request_chan()
> > returns error, so the code using 'dma_ch' can work correctly.
> >
> > Fixes: 26ac471c5354 ("ASoC: sh: rz-ssi: Add SSI DMAC support")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> 
> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> > ---
> >  sound/soc/sh/rz-ssi.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index
> > ea8d33ede5d2..5ec78fd94d94 100644
> > --- a/sound/soc/sh/rz-ssi.c
> > +++ b/sound/soc/sh/rz-ssi.c
> > @@ -676,11 +676,17 @@ static void rz_ssi_release_dma_channels(struct
> > rz_ssi_priv *ssi)  static int rz_ssi_dma_request(struct rz_ssi_priv
> > *ssi, struct device *dev)  {
> >  	ssi->playback.dma_ch = dma_request_chan(dev, "tx");
> > +	if (IS_ERR(ssi->playback.dma_ch))
> > +		ssi->playback.dma_ch = NULL;
> >  	ssi->capture.dma_ch = dma_request_chan(dev, "rx");
> > +	if (IS_ERR(ssi->capture.dma_ch))
> > +		ssi->capture.dma_ch = NULL;
> >  	if (!ssi->playback.dma_ch && !ssi->capture.dma_ch) {
> >  		ssi->playback.dma_ch = dma_request_chan(dev, "rt");
> > -		if (!ssi->playback.dma_ch)
> > +		if (IS_ERR(ssi->playback.dma_ch)) {
> > +			ssi->playback.dma_ch = NULL;
> >  			goto no_dma;
> > +		}
> >
> >  		ssi->dma_rt = true;
> >  	}
> > --
> > 2.25.1


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

end of thread, other threads:[~2021-08-18  6:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17  3:00 [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in rz_ssi_dma_request() Yang Yingliang
2021-08-17  3:00 ` Yang Yingliang
2021-08-17  6:41 ` Biju Das
2021-08-18  6:43   ` Biju Das

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.