From patchwork Wed Oct 19 08:27:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp213823wrs; Wed, 19 Oct 2022 02:11:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OufTeTD2tJzRdldsUPo0PsSxqeTHWqF7x6g05uujeB16X+IOKC81V+QIH6NkqztpVL3ln X-Received: by 2002:a17:906:8a55:b0:78d:b6db:a2d4 with SMTP id gx21-20020a1709068a5500b0078db6dba2d4mr5903336ejc.82.1666170659576; Wed, 19 Oct 2022 02:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170659; cv=none; d=google.com; s=arc-20160816; b=IdY0tlJE5srDeNAaL8H+zlZI7AOGXyNsG5kszdOWCAtF8YOtZnkP+edJibf/8TMFVW iC7M4lvq/RKmrj5eYTP7b/blxqhSBlg8zqEfRA6DOMxOTySSAfxmllw7Ve75GV9KU67h k5WWiJgc/tvsRWIQGLc0aULHUJtivUJekQj8eYKn+HHp6KLIod1zXefp3u/xE1cPku8K lRu2fDj9VhQ3YhmAXxbyfcpPwKlocuSMdJyExhDRuBlzq2KuHnC0kEUFKcpsqC2k1Q27 xxw3ncb9y9fwhH+nABrkInkDsJPObYNXNvqh6FzzsPPkQA6AfUFRhv7wkpmP6+ijkfUS EQmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bZ6WRl8TTvWfqx1TSSuyhFXXQNe2esm+8LhrQ7zciA0=; b=GXS99gT7atUtSw5FMozYTlM9f5cpBJA+syGttX0gJMQ1YAFz+oUdjeP8xF31M0Tp0c 7KdO54LyfKJT7RtWnboIzBjs/VuOz7rdd/4lxHTuaQrWgXxLT//YzYpt+6H03n/IOWfK Tmi4/BFGb3AI5nYYPlRMVCRUhC3ZUxkxhQaFYgpbxHfR607NZPIZDrIj4tJK6mtRACt/ A01rE7andAsLbUphEFdBA4GcE3n6Pd6FD+nMNKGmUzPfSDQGDXrc+khf3yZlpGb2TqU/ hyIWtAM9b6kMRFYW/oV9qKK5SIq23rW9dwSD3z4eNxptmfCI7m8q0H3ewnVZAADmpGws ngYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aJFgXf7O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs8-20020a1709072d0800b007825337afeesi16059954ejc.273.2022.10.19.02.10.33; Wed, 19 Oct 2022 02:10:59 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aJFgXf7O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232382AbiJSJFv (ORCPT + 99 others); Wed, 19 Oct 2022 05:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232416AbiJSJEN (ORCPT ); Wed, 19 Oct 2022 05:04:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBA15A8352; Wed, 19 Oct 2022 01:57:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 904FF61851; Wed, 19 Oct 2022 08:55:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A13DDC433C1; Wed, 19 Oct 2022 08:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169735; bh=goNWUmtCyQy3LmAC5CpO9eeEFfx49WATQu4/du69dXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aJFgXf7OQHapWD5XcM5TNpKGH4ozFCHsbkmvIgTxJEvytG+6Zkau0uF5qqLHAP53S /OwPER1Y+icsXwbHhB3En84b0sN8CGh0q3w0TqBoHF68CPihS1vHYqTXl9jfFRAmeB DaP4hwpYsosMlcYVPLnXYK9fe6y13z6LsMEFETyQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Judy Hsiao , Brian Norris , Mark Brown , Sasha Levin Subject: [PATCH 6.0 389/862] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR Date: Wed, 19 Oct 2022 10:27:56 +0200 Message-Id: <20221019083307.129986122@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106565750330474?= X-GMAIL-MSGID: =?utf-8?q?1747106565750330474?= From: Judy Hsiao [ Upstream commit fbb0ec656ee5ee43b4b3022fd8290707265c52df ] Use regmap_read_poll_timeout to poll I2S_CLR. It also fixes the 'rockchip-i2s ff070000.i2s; fail to clear' 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 Reviewed-by: Brian Norris Link: https://lore.kernel.org/r/20220914031234.2250298-1-judyhsiao@chromium.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/rockchip/rockchip_i2s.c | 41 ++++++++++++------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index f5f3540a9e18..28c86f5e435e 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -126,7 +126,6 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai) static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) { unsigned int val = 0; - int retry = 10; int ret = 0; spin_lock(&i2s->lock); @@ -163,18 +162,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--; - 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: %d\n", ret); } } end: @@ -188,7 +183,6 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) { unsigned int val = 0; - int retry = 10; int ret = 0; spin_lock(&i2s->lock); @@ -226,17 +220,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) { - 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: %d\n", ret); } } end: