[PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

Subsystems: freescale soc sound drivers, sound, sound - soc layer / dynamic audio power management (asoc), the rest

STALE1430d

7 messages, 3 authors, 2022-09-06 · open the first message on its own page

[PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

From: Shengjiu Wang <hidden>
Date: 2022-09-05 10:48:04

If the initialization is not finished, then filling input data to
the FIFO may fail. So it is better to add initialization finishing
check in the runtime resume for suspend & resume case.

And consider the case of three instances working in parallel,
increase the retry times to 50 for more initialization time.

Signed-off-by: Shengjiu Wang <redacted>
---
 sound/soc/fsl/fsl_asrc.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index aa5edf32d988..bae263b90ac1 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -20,6 +20,7 @@
 
 #define IDEAL_RATIO_DECIMAL_DEPTH 26
 #define DIVIDER_NUM  64
+#define INIT_TRY_NUM 50
 
 #define pair_err(fmt, ...) \
 	dev_err(&asrc->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
@@ -579,7 +580,7 @@ static void fsl_asrc_start_pair(struct fsl_asrc_pair *pair)
 {
 	struct fsl_asrc *asrc = pair->asrc;
 	enum asrc_pair_index index = pair->index;
-	int reg, retry = 10, i;
+	int reg, retry = INIT_TRY_NUM, i;
 
 	/* Enable the current pair */
 	regmap_update_bits(asrc->regmap, REG_ASRCTR,
@@ -592,6 +593,10 @@ static void fsl_asrc_start_pair(struct fsl_asrc_pair *pair)
 		reg &= ASRCFG_INIRQi_MASK(index);
 	} while (!reg && --retry);
 
+	/* FIXME: Doesn't treat initialization timeout as error */
+	if (!retry)
+		dev_warn(&asrc->pdev->dev, "initialization isn't finished\n");
+
 	/* Make the input fifo to ASRC STALL level */
 	regmap_read(asrc->regmap, REG_ASRCNCR, &reg);
 	for (i = 0; i < pair->channels * 4; i++)
@@ -1257,6 +1262,7 @@ static int fsl_asrc_runtime_resume(struct device *dev)
 {
 	struct fsl_asrc *asrc = dev_get_drvdata(dev);
 	struct fsl_asrc_priv *asrc_priv = asrc->private;
+	int reg, retry = INIT_TRY_NUM;
 	int i, ret;
 	u32 asrctr;
 
@@ -1295,6 +1301,17 @@ static int fsl_asrc_runtime_resume(struct device *dev)
 	regmap_update_bits(asrc->regmap, REG_ASRCTR,
 			   ASRCTR_ASRCEi_ALL_MASK, asrctr);
 
+	/* Wait for status of initialization for every enabled pairs */
+	do {
+		udelay(5);
+		regmap_read(asrc->regmap, REG_ASRCFG, &reg);
+		reg = (reg >> ASRCFG_INIRQi_SHIFT(0)) & 0x7;
+	} while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) & 0x7)) && --retry);
+
+	/* FIXME: Doesn't treat initialization timeout as error */
+	if (!retry)
+		dev_warn(dev, "initialization isn't finished\n");
+
 	return 0;
 
 disable_asrck_clk:
-- 
2.34.1

Re: [PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

From: Nicolin Chen <nicoleotsuka@gmail.com>
Date: 2022-09-05 13:15:54

On Mon, Sep 5, 2022 at 3:47 AM Shengjiu Wang [off-list ref] wrote:
quoted hunk
@@ -1295,6 +1301,17 @@ static int fsl_asrc_runtime_resume(struct device *dev)
        regmap_update_bits(asrc->regmap, REG_ASRCTR,
                           ASRCTR_ASRCEi_ALL_MASK, asrctr);

+       /* Wait for status of initialization for every enabled pairs */
+       do {
+               udelay(5);
+               regmap_read(asrc->regmap, REG_ASRCFG, &reg);
+               reg = (reg >> ASRCFG_INIRQi_SHIFT(0)) & 0x7;
+       } while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) & 0x7)) && --retry);
+
+       /* FIXME: Doesn't treat initialization timeout as error */
+       if (!retry)
+               dev_warn(dev, "initialization isn't finished\n");
Any reason why not just dev_err?

Re: [PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

From: Shengjiu Wang <shengjiu.wang@gmail.com>
Date: 2022-09-06 02:58:52

On Mon, Sep 5, 2022 at 9:15 PM Nicolin Chen [off-list ref] wrote:
On Mon, Sep 5, 2022 at 3:47 AM Shengjiu Wang [off-list ref]
wrote:
quoted
@@ -1295,6 +1301,17 @@ static int fsl_asrc_runtime_resume(struct device
*dev)
quoted
        regmap_update_bits(asrc->regmap, REG_ASRCTR,
                           ASRCTR_ASRCEi_ALL_MASK, asrctr);

+       /* Wait for status of initialization for every enabled pairs */
+       do {
+               udelay(5);
+               regmap_read(asrc->regmap, REG_ASRCFG, &reg);
+               reg = (reg >> ASRCFG_INIRQi_SHIFT(0)) & 0x7;
+       } while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) & 0x7)) &&
--retry);
quoted
+
+       /* FIXME: Doesn't treat initialization timeout as error */
+       if (!retry)
+               dev_warn(dev, "initialization isn't finished\n");
Any reason why not just dev_err?

Just hesitate to use dev_err. if use dev_err, then should return an error.
May one of the pairs is finished, it still can continue.

Best regards
Wang Shengjiu

Re: [PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

From: Nicolin Chen <nicoleotsuka@gmail.com>
Date: 2022-09-06 09:51:02

On Mon, Sep 5, 2022 at 6:54 PM Shengjiu Wang [off-list ref] wrote:
quoted
quoted
+       /* Wait for status of initialization for every enabled pairs */
+       do {
+               udelay(5);
+               regmap_read(asrc->regmap, REG_ASRCFG, &reg);
+               reg = (reg >> ASRCFG_INIRQi_SHIFT(0)) & 0x7;
+       } while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) & 0x7)) && --retry);
+
+       /* FIXME: Doesn't treat initialization timeout as error */
+       if (!retry)
+               dev_warn(dev, "initialization isn't finished\n");
Any reason why not just dev_err?
Just hesitate to use dev_err. if use dev_err, then should return an error.
May one of the pairs is finished, it still can continue.
Makes sense. In that case, why "FIXME" :)

Re: [PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

From: Nicolin Chen <nicoleotsuka@gmail.com>
Date: 2022-09-06 11:42:17

On Tue, Sep 6, 2022 at 3:50 AM Shengjiu Wang [off-list ref] wrote:
quoted
quoted
quoted
quoted
+       /* Wait for status of initialization for every enabled pairs */
+       do {
+               udelay(5);
+               regmap_read(asrc->regmap, REG_ASRCFG, &reg);
+               reg = (reg >> ASRCFG_INIRQi_SHIFT(0)) & 0x7;
+       } while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) & 0x7)) && --retry);
+
+       /* FIXME: Doesn't treat initialization timeout as error */
+       if (!retry)
+               dev_warn(dev, "initialization isn't finished\n");
Any reason why not just dev_err?
Just hesitate to use dev_err. if use dev_err, then should return an error.
May one of the pairs is finished, it still can continue.
Makes sense. In that case, why "FIXME" :)
Just want to have a record/note here, need to care about this warning.
"FIXME" feels like something is wrong and literally means that it is
waiting for a fix/solution. In your case, it's not waiting for a fix
at all, but just an annotation? So, shouldn't it be just "Note:"?

Re: [PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

From: Shengjiu Wang <shengjiu.wang@gmail.com>
Date: 2022-09-06 12:24:04

On Tue, Sep 6, 2022 at 5:50 PM Nicolin Chen [off-list ref] wrote:
On Mon, Sep 5, 2022 at 6:54 PM Shengjiu Wang [off-list ref]
wrote:
quoted
quoted
quoted
+       /* Wait for status of initialization for every enabled pairs
*/
quoted
quoted
quoted
+       do {
+               udelay(5);
+               regmap_read(asrc->regmap, REG_ASRCFG, &reg);
+               reg = (reg >> ASRCFG_INIRQi_SHIFT(0)) & 0x7;
+       } while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) & 0x7))
&& --retry);
quoted
quoted
quoted
+
+       /* FIXME: Doesn't treat initialization timeout as error */
+       if (!retry)
+               dev_warn(dev, "initialization isn't finished\n");
Any reason why not just dev_err?
Just hesitate to use dev_err. if use dev_err, then should return an
error.
quoted
May one of the pairs is finished, it still can continue.
Makes sense. In that case, why "FIXME" :)
Just want to have a record/note here, need to care about this warning.

Best regards
Wang shengjiu

Re: [PATCH] ASoC: fsl_asrc: Add initialization finishing check in runtime resume

From: Shengjiu Wang <shengjiu.wang@gmail.com>
Date: 2022-09-06 21:58:31

On Tue, Sep 6, 2022 at 7:42 PM Nicolin Chen [off-list ref] wrote:
On Tue, Sep 6, 2022 at 3:50 AM Shengjiu Wang [off-list ref]
wrote:
quoted
quoted
quoted
quoted
quoted
+       /* Wait for status of initialization for every enabled
pairs */
quoted
quoted
quoted
quoted
quoted
+       do {
+               udelay(5);
+               regmap_read(asrc->regmap, REG_ASRCFG, &reg);
+               reg = (reg >> ASRCFG_INIRQi_SHIFT(0)) & 0x7;
+       } while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) &
0x7)) && --retry);
quoted
quoted
quoted
quoted
quoted
+
+       /* FIXME: Doesn't treat initialization timeout as error */
+       if (!retry)
+               dev_warn(dev, "initialization isn't finished\n");
Any reason why not just dev_err?
Just hesitate to use dev_err. if use dev_err, then should return an
error.
quoted
quoted
quoted
May one of the pairs is finished, it still can continue.
Makes sense. In that case, why "FIXME" :)
quoted
Just want to have a record/note here, need to care about this warning.
"FIXME" feels like something is wrong and literally means that it is
waiting for a fix/solution. In your case, it's not waiting for a fix
at all, but just an annotation? So, shouldn't it be just "Note:"?
ok, let me update it.

best regards
wang shengjiu
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help