Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5171910rwb; Tue, 6 Sep 2022 20:51:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR6xsArGio54CpKRNrydpf3ZAZ2GI+ygHH0IY8WT7LnaG5j7EHOAPrPIse2rkKhAYsiW0M17 X-Received: by 2002:a05:6402:5207:b0:448:73ba:e5e5 with SMTP id s7-20020a056402520700b0044873bae5e5mr1344169edd.321.1662522711873; Tue, 06 Sep 2022 20:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662522711; cv=none; d=google.com; s=arc-20160816; b=qW6oyFqDEIWr6nnKMK6+IvmEeT+U9B/7YhtgyC12IZ7F1toVc7wkyzeg7F2eFlkA8y GkfDj2A7uLkGlk59qHC8NIJX9BG3bGj+Ba6PmUyu9HB3oPH73fZGYM0WAVNtkt77UekU UO+zHOC4y99LiD07JaksB5e3p3N1y+6I6+oJ9gqyt5ucqSGPjLR1Uqdopd0cCs4VXqQ+ sLcprjv9JVDocqnh3LJub1Q7+vWbJf7zuKMaNtFXWtrLxRAzoD/XObnziYzq0/+7gwJ2 G6f4lnEL4ESJLKp/WOVAKmZhsqFjWfICPiViFymFFcOEAey9KugYR1N0wXldFfwBtMHZ jFyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=FqlCOjJ9q0NMObiIC+LG4V3eBmCc/V/yziHuuariaD8=; b=CdLlMZGURyZ64RULWeUy6fj/tiyyphI3MYCs2Y1LdvkbmosCX9XdE2C5rJ62NVFoLH 97WtYuecb4BRHUdwr8b3v6NoUWGlixogXUgwvDhx7cIvxhnH59CPItHvuyvQe68bbrBb BKzTc00oVEwfGeYEov9sTVzlqdHADNVU6bF2PSr7YnVnoQvxFr0t8Q80QNwJbe4oU/Df WAVBC7HK/H3OH0wf76ZR5kncVAvIzgIa2c/6UClvB5ww5xvaznJ8Njo6dgh4HCC52IHJ 1+F+tmfCqVxbzDQbGZcrrNHXhj+QUwOwoZgxFxSGBf7Lrd/b9ggwR1e4VAzkKcWjTCT1 jY7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p35-20020a056402502300b0044875bb5c8esi3595038eda.488.2022.09.06.20.51.27; Tue, 06 Sep 2022 20:51:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230064AbiIGDUI (ORCPT + 99 others); Tue, 6 Sep 2022 23:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbiIGDUE (ORCPT ); Tue, 6 Sep 2022 23:20:04 -0400 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95D743FA00 for ; Tue, 6 Sep 2022 20:20:01 -0700 (PDT) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 7C8B61A0365; Wed, 7 Sep 2022 05:20:00 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4F19A1A03B2; Wed, 7 Sep 2022 05:20:00 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id D24CE180031F; Wed, 7 Sep 2022 11:19:58 +0800 (+08) From: Shengjiu Wang To: nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, shengjiu.wang@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ASoC: fsl_asrc: Add initialization finishing check in runtime resume Date: Wed, 7 Sep 2022 11:01:55 +0800 Message-Id: <1662519715-21891-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- changes in v2: - update comments. sound/soc/fsl/fsl_asrc.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index aa5edf32d988..b394b762025d 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); + /* NOTE: 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, ®); 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,20 @@ 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 >> ASRCFG_INIRQi_SHIFT(0)) & 0x7; + } while ((reg != ((asrctr >> ASRCTR_ASRCEi_SHIFT(0)) & 0x7)) && --retry); + + /* + * NOTE: Doesn't treat initialization timeout as error + * Some of pair maybe success, then still can continue. + */ + if (!retry) + dev_warn(dev, "initialization isn't finished\n"); + return 0; disable_asrck_clk: -- 2.34.1