From: Brian Norris <briannorris@chromium.org>
To: Judy Hsiao <judyhsiao@chromium.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>, Chen-Yu Tsai <wenst@chromium.org>,
alsa-devel@alsa-project.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR
Date: Tue, 13 Sep 2022 17:44:32 -0700 [thread overview]
Message-ID: <YyEj8FC9YtnCScWW@google.com> (raw)
In-Reply-To: <20220908151142.1479810-1-judyhsiao@chromium.org>
Hi Judy,
On Thu, Sep 08, 2022 at 03:11:42PM +0000, Judy Hsiao wrote:
> Use regmap_read_poll_timeout to poll I2S_CLR.
> It also fixes the 'rockchip-i2s ff070000.i2s; fail to clear' and
> return -EBUSY when the read of I2S_CLR exceeds the retry limit.
>
> Fixes: 0ff9f8b9f592 ("ASoC: rockchip: i2s: Fix error code when fail
> to read I2S_CLR")
> Signed-off-by: Judy Hsiao <judyhsiao@chromium.org>
Thanks for the patch!
> ---
> sound/soc/rockchip/rockchip_i2s.c | 39 +++++++++++++------------------
> 1 file changed, 16 insertions(+), 23 deletions(-)
>
> diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
> index f5f3540a9e18..02905eec615e 100644
> --- a/sound/soc/rockchip/rockchip_i2s.c
> +++ b/sound/soc/rockchip/rockchip_i2s.c
> @@ -163,18 +163,14 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
> I2S_CLR_TXC | I2S_CLR_RXC);
> if (ret < 0)
> goto end;
> - regmap_read(i2s->regmap, I2S_CLR, &val);
> -
> - /* Should wait for clear operation to finish */
> - while (val) {
> - regmap_read(i2s->regmap, I2S_CLR, &val);
> - retry--;
I think you're leaving |retry| as a "set but unused" variable now.
Presumably some compile-testing bots will eventually complain at you
about that.
> - if (!retry) {
> - dev_warn(i2s->dev, "fail to clear\n");
> - ret = -EBUSY;
> - break;
> - }
> - }
> + ret = regmap_read_poll_timeout(i2s->regmap,
> + I2S_CLR,
> + val,
> + val != 0,
> + 20,
> + 200);
> + if (ret < 0)
> + dev_warn(i2s->dev, "fail to clear\n");
Now would be a good time to print the return code, I think:
dev_warn(i2s->dev, "fail to clear: %d\n", ret);
> }
> }
> end:
> @@ -226,17 +222,14 @@ static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
> I2S_CLR_TXC | I2S_CLR_RXC);
> if (ret < 0)
> goto end;
> - regmap_read(i2s->regmap, I2S_CLR, &val);
> - /* Should wait for clear operation to finish */
> - while (val) {
> - regmap_read(i2s->regmap, I2S_CLR, &val);
> - retry--;
> - if (!retry) {
Same.
> - dev_warn(i2s->dev, "fail to clear\n");
> - ret = -EBUSY;
> - break;
> - }
> - }
> + ret = regmap_read_poll_timeout(i2s->regmap,
> + I2S_CLR,
> + val,
> + val != 0,
> + 20,
> + 200);
> + if (ret < 0)
> + dev_warn(i2s->dev, "fail to clear\n");
Same.
> }
> }
> end:
Otherwise, this is definitely a good change, since we have no timing
guarantee on the existing retry loop, which will surely make it flaky.
So, with those fixups:
Reviewed-by: Brian Norris <briannorris@chromium.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2022-09-14 0:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 15:11 [PATCH v1] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR Judy Hsiao
2022-09-14 0:44 ` Brian Norris [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YyEj8FC9YtnCScWW@google.com \
--to=briannorris@chromium.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=judyhsiao@chromium.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=wenst@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).