From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9BB75ECAAD8 for ; Wed, 14 Sep 2022 00:45:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8AA5317A7; Wed, 14 Sep 2022 02:44:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8AA5317A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1663116341; bh=NQGLMVxgIwAob8cSZjuzreY4ksDuKijALHzW8anBaSM=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=q7dZwoWJ7GeUWtG+UZberpry2qW1VtFXGYcx4xe972wRWDOyedT9y+TY5xiZiSfzT /4/dyV5yVn0XI3khNF0A9p5vAZ1bYV0zDEPUZc90gFTSpTLwD1HPVG0IBU46RrUsfX 8pZEpstBr43GpTi2CWHA4FGe2x2oLmjLdHncBJTM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1F099F801EC; Wed, 14 Sep 2022 02:44:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 93BEEF80224; Wed, 14 Sep 2022 02:44:49 +0200 (CEST) Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3BD96F8008E for ; Wed, 14 Sep 2022 02:44:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3BD96F8008E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QaZWAqqj" Received: by mail-pg1-x534.google.com with SMTP id s206so12881995pgs.3 for ; Tue, 13 Sep 2022 17:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=QaZWAqqjlNSnM9eoLwGlfdcvS5Nm3ykDJiGkepiKjoJDuzOmgk+LeqWTuJlwQ2hnrN 8RdxOL9ObiMEmA6sPW8bi2Iq/ETi05CQIn5QvWwuchqlHThXGXJWIPupmIWIdEzmbqqI FV9XsXAZ5+surbB9bBKoTYDFfdxjtW8Rx1wpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=o3XefjzlncJQn2iPQys9pIZUQc6lTQIC1ytqeQZObTNGl7693Zqkp2HvSphdBsQxLd 6j4jcpyz4hQATbx8OmJC/VcI68Y1vkINSPCVgO2BVgLDIofTIhGU8OOu+wM7G8VRHcHY M1Cg08KOOIipL/ZVw3xsfYYRzyW1g8J+ObIoFGw2LQnXsV+0FrmGqTMazptSWTZ7apxY dKRUBqtwtWWPDo5QYelYDliOWZ4wciiig446kkiCyHkRea/8gc+JaZ5rcA1mG9MS64uW OFziekv+DujqkD/GPUCd2Nti3nXCnaykDJ5GuThS2TZhQ4dj6r3ZIoZm3SgcQllbqlJq y9/w== X-Gm-Message-State: ACgBeo1RsuwjlT7scVXHtpmFTBOe1mQx3N8U9jUyTr2t7ixLBwAMKFcc z+3SL3rnG9uA5B0cCUlLFdPggg== X-Google-Smtp-Source: AA6agR6ajxSwu4MvfAwZmD5yw6opa0TwZ5rTZVuxPSBg77ll7+TMZQhGr2Z2ZdDujviVh4x3iCUFeg== X-Received: by 2002:a63:698a:0:b0:41c:8dfa:e622 with SMTP id e132-20020a63698a000000b0041c8dfae622mr29387714pgc.465.1663116275332; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) Received: from google.com ([2620:15c:202:201:c6e2:a019:5c54:fb4c]) by smtp.gmail.com with ESMTPSA id 21-20020a621515000000b0053e5ebafd5csm8462402pfv.189.2022.09.13.17.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 17:44:34 -0700 (PDT) Date: Tue, 13 Sep 2022 17:44:32 -0700 From: Brian Norris To: Judy Hsiao Subject: Re: [PATCH v1] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR Message-ID: References: <20220908151142.1479810-1-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220908151142.1479810-1-judyhsiao@chromium.org> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , linux-rockchip@lists.infradead.org, Mark Brown , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DFBF3C54EE9 for ; Wed, 14 Sep 2022 00:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8ap7erX6wcm0oExfokVv3moG8IjdC2AB9q7TyntN80s=; b=f5vS4UZsGuww0Y 7BKg4szoXwzpYlCDmqIGmsLe666DAKV/TMyGtlJcRXE97YiosYa5aiP8VHT8ywRXnnnK9Nmc1KENY 6KY3J3mmfXxMSn8lpFRar6J2A1Ifk0wUkkkJng7W6vEcLw8GrZPFiWTZaWgg+EKXgUlm5lJT9YcdP UCKCMjAjo8NkofftF1Wmp7Dbl/ImMu6NHTqw5ITXsensE64YqHwv5uCOOHv+TJ2LPi3NitFcTOouv 4tS65UC7/6jy8vKj2TnRNoYUK4BrYhR/Jhu/0M3BQzjtuzjUmcnlHkkg84rsXqfOll+qkR5ZaRVe5 kroxiiV0yBG9LyMv3ORA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYGWL-002crX-Ko; Wed, 14 Sep 2022 00:44:53 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYGW5-002cOB-GG for linux-rockchip@lists.infradead.org; Wed, 14 Sep 2022 00:44:39 +0000 Received: by mail-pg1-x52e.google.com with SMTP id bh13so12876309pgb.4 for ; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=QaZWAqqjlNSnM9eoLwGlfdcvS5Nm3ykDJiGkepiKjoJDuzOmgk+LeqWTuJlwQ2hnrN 8RdxOL9ObiMEmA6sPW8bi2Iq/ETi05CQIn5QvWwuchqlHThXGXJWIPupmIWIdEzmbqqI FV9XsXAZ5+surbB9bBKoTYDFfdxjtW8Rx1wpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=OgBkvhWnwMeyCf6m0dF5ImBjL80ASS6PzsfBL/UUPr17mzsrSbYNi2orRXpYTIun3y LWa9RFFUid3bKXzzwWiYN0rowELfgba0qCzoQvMhul0y2nkPn+Og2lqmT9sTZDmDvgEz J7JMqS4z5GRmKj2e8IX740537Q8tK/hhydMFRna0lh0rU6e8UwpLvVQIYYPDKndvRh/m cRlo29F1RyB/CPSTebIxEn8CMkRwAykfnPY0UF+B7+NnxDj/KzHDs6Mkvm/LUcCPJr9h JYIH1g+52c9pnPOn6VZqXgasW2hBtAAXhhHm0xRm27HvEz9AHlI/zQyQzn0jj7JTZvXk aonQ== X-Gm-Message-State: ACgBeo1GSQbr0KMdC8aRXz7Qf+R7hhxmFvMAvPU/V6dffF/JEQs2dmL+ +pbJ/oZ9sprM1SvmjJQmenvweA== X-Google-Smtp-Source: AA6agR6ajxSwu4MvfAwZmD5yw6opa0TwZ5rTZVuxPSBg77ll7+TMZQhGr2Z2ZdDujviVh4x3iCUFeg== X-Received: by 2002:a63:698a:0:b0:41c:8dfa:e622 with SMTP id e132-20020a63698a000000b0041c8dfae622mr29387714pgc.465.1663116275332; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) Received: from google.com ([2620:15c:202:201:c6e2:a019:5c54:fb4c]) by smtp.gmail.com with ESMTPSA id 21-20020a621515000000b0053e5ebafd5csm8462402pfv.189.2022.09.13.17.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 17:44:34 -0700 (PDT) Date: Tue, 13 Sep 2022 17:44:32 -0700 From: Brian Norris To: Judy Hsiao Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Chen-Yu Tsai , 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 Message-ID: References: <20220908151142.1479810-1-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220908151142.1479810-1-judyhsiao@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_174437_576396_96F832C8 X-CRM114-Status: GOOD ( 23.16 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.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 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 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47BD7C54EE9 for ; Wed, 14 Sep 2022 00:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PnlAmSnqHTZUWreFEfosA4bedwJSdCU3tNXA5Wqp+vc=; b=uuVdcL/YVR5FzZ 6SMEed3JAKxqQ8DbHgQHoH8BRM28c31nmcGTay6Qkn76XduuG4GkGOB0MjCo0cF3bldGf/FOqMJQG Ci1meBgHzzbbj+JPJycpGjOQpdOdyhDeoo2dys7vEHMHf7mZBGRf5F158jJdfPw+vfaJ7j1hPwuqy sXcS1NgwMa29f8leS09VAN79BLq2WQARo1irngkMnW3RNY7EiAwyiAp7edq/VF/HaGICeX+MBh6UI 48g0A4A8pRToJYzCrjjWPQR0vDDhPyebJl92CSWxgx6/P5/sDEWpwyRdLU79WqwdwZknY+Vz8hUhA h1PnV7GQMqZvk1bG9Kwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYGW9-002cUS-EL; Wed, 14 Sep 2022 00:44:41 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYGW5-002cOH-FV for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2022 00:44:39 +0000 Received: by mail-pf1-x42a.google.com with SMTP id w2so3040314pfb.0 for ; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=QaZWAqqjlNSnM9eoLwGlfdcvS5Nm3ykDJiGkepiKjoJDuzOmgk+LeqWTuJlwQ2hnrN 8RdxOL9ObiMEmA6sPW8bi2Iq/ETi05CQIn5QvWwuchqlHThXGXJWIPupmIWIdEzmbqqI FV9XsXAZ5+surbB9bBKoTYDFfdxjtW8Rx1wpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=xtHb7R0hhbnskugOlAAtrPGaULxvwWxEiWB+mmqH5or6pLSsjR5EgFjFbyo/TNPZyb mQBjJTeohDtbsENOgEROQo/vlZR8nCjItDaZrLURgurUkkgu9fzbC80YkpJy0riFvxZw 2vZ1UZC0TiffcNz5zF7MItThxVCOMNHmRmUiDJJXTXyWyiLy/dByZiSehuNxDaDXl3Ki ENVnD54Y/Afu+U9NPUfiRmjAVMMwl7zpQKi0rjNIE6I2nntEg/4qsLlipiZ4bivEzzBB HOU3MtbzWeg0sGqkYP8k5Q2qpWHDCgTsuV9NM23pK2Due2xzLohCySn2dPKSfUu2Ju/5 hn5g== X-Gm-Message-State: ACgBeo0e8X4b11kQO8TcTbPbTKo30cnsbMQ5wV+6vSgMtrkEjr91J6/1 PCRr4vb4iQAUWgGtezT2Ps1C/iR3+tsPW+Vu X-Google-Smtp-Source: AA6agR6ajxSwu4MvfAwZmD5yw6opa0TwZ5rTZVuxPSBg77ll7+TMZQhGr2Z2ZdDujviVh4x3iCUFeg== X-Received: by 2002:a63:698a:0:b0:41c:8dfa:e622 with SMTP id e132-20020a63698a000000b0041c8dfae622mr29387714pgc.465.1663116275332; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) Received: from google.com ([2620:15c:202:201:c6e2:a019:5c54:fb4c]) by smtp.gmail.com with ESMTPSA id 21-20020a621515000000b0053e5ebafd5csm8462402pfv.189.2022.09.13.17.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 17:44:34 -0700 (PDT) Date: Tue, 13 Sep 2022 17:44:32 -0700 From: Brian Norris To: Judy Hsiao Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Chen-Yu Tsai , 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 Message-ID: References: <20220908151142.1479810-1-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220908151142.1479810-1-judyhsiao@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_174437_575211_6D16EE1A X-CRM114-Status: GOOD ( 24.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9656ECAAD8 for ; Wed, 14 Sep 2022 00:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229521AbiINAoj (ORCPT ); Tue, 13 Sep 2022 20:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiINAoh (ORCPT ); Tue, 13 Sep 2022 20:44:37 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F7F117D for ; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id e5so13325147pfl.2 for ; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=QaZWAqqjlNSnM9eoLwGlfdcvS5Nm3ykDJiGkepiKjoJDuzOmgk+LeqWTuJlwQ2hnrN 8RdxOL9ObiMEmA6sPW8bi2Iq/ETi05CQIn5QvWwuchqlHThXGXJWIPupmIWIdEzmbqqI FV9XsXAZ5+surbB9bBKoTYDFfdxjtW8Rx1wpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=JXX2yS5w/1K++xKOiGHpDn/FwBROGsdDBxX7sv52/PA=; b=PryTJBriHpFeNiIE/WZGU4lms0K3v/UidzL1NUBI7bPzwEX6YhXphrbPj5izyvGFfF Rgm675bghvjn/a9V77+Bpuq3odHVUXzWfd40vHCNlTcAguI1gMaQ4lnrCqqc9T9itdX+ ZOSI+uLcVgnvyVUny7HZYX9Sv6OwNckLa3DzRZeNQitFi0mbWRaUFvfY2KNVQCr25RR5 yIviVw7dZGU/mWYXQHO0oIf/oGUfB6U5suC9x8fn0bDKw8oZWFEBmAoI8eWEpFYTywe3 srFKIy+oIP6bzu0G5DVaZtl+8qUANatFi6IZw89XjvDCSuC/GzSSCNhwclEeD1ngbEPY irRg== X-Gm-Message-State: ACgBeo3te047bAxPIJpLp1lsd9DwXX2I6NO/9P12lWXKCthZKf6PxBw+ uRV5f3rqsrG7vqLW+br6/WXI0w== X-Google-Smtp-Source: AA6agR6ajxSwu4MvfAwZmD5yw6opa0TwZ5rTZVuxPSBg77ll7+TMZQhGr2Z2ZdDujviVh4x3iCUFeg== X-Received: by 2002:a63:698a:0:b0:41c:8dfa:e622 with SMTP id e132-20020a63698a000000b0041c8dfae622mr29387714pgc.465.1663116275332; Tue, 13 Sep 2022 17:44:35 -0700 (PDT) Received: from google.com ([2620:15c:202:201:c6e2:a019:5c54:fb4c]) by smtp.gmail.com with ESMTPSA id 21-20020a621515000000b0053e5ebafd5csm8462402pfv.189.2022.09.13.17.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 17:44:34 -0700 (PDT) Date: Tue, 13 Sep 2022 17:44:32 -0700 From: Brian Norris To: Judy Hsiao Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Chen-Yu Tsai , 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 Message-ID: References: <20220908151142.1479810-1-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220908151142.1479810-1-judyhsiao@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 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