From patchwork Sat Sep 2 21:06:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373161 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 C6C71C001DB for ; Sat, 2 Sep 2023 21:11:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 974F7DF3; Sat, 2 Sep 2023 23:10:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 974F7DF3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693689062; bh=pfmTebOGpABzh4OF3FG1M+nz4wpY8/aJTMADovLWHU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QH9b9/ndVNBO7qV0rGACLvI1ee4tEWGc4cBhw3rlhxBObMkP2pfCmaWOXJnwFrtyk 37zmCPwcjHBEluM37btqf6ab75HG4FXOhzVXWYUJJHtvExXfmeUlG5gV1tQNPp9zjr ZyOtXccLMJrpWU+EFLcIOkz6zNkytPDS5bzYP/i4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 98FD6F80587; Sat, 2 Sep 2023 23:09:13 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3C25FF80587; Sat, 2 Sep 2023 23:09:13 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 40007F8032D; Sat, 2 Sep 2023 23:09:08 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 13026F800F5 for ; Sat, 2 Sep 2023 23:06:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 13026F800F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=C3wnYF8v Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id CDFEA66072B5; Sat, 2 Sep 2023 22:06:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688789; bh=pfmTebOGpABzh4OF3FG1M+nz4wpY8/aJTMADovLWHU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C3wnYF8vYhZ2lV9m4HpScGFPalTHpVL0T11sUFCevzhvp0TikBFINuTA8pBFBwIWo NyKHvUITLRPBU/VnT5/odRtdndVEcM8ik4brEHaqWYW1/obvPbq6uV21qWHMa+nz6d UwlgH5xv7M+2F2MMpqnnWCoVl+JsLSpkx8oj9XEIObcAeL4advE2KUAFrhlbCBAZU5 EA9JW8VJVXget0vc4ZKWVtyiwry+O5dT+oydZ7AvXBRH/dqWJXyhUrH615BKO8UPnE jYj5qWhbaQlfBW0J5iQ6DoeC2WKuuD0NNertddz1jM4f3DLTfTA8jdNJMClwKjVf9P 1B/5JTRr7iTnA== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 1/9] ASoC: cs35l41: Handle mdsync_down reg write errors Date: Sun, 3 Sep 2023 00:06:13 +0300 Message-ID: <20230902210621.1184693-2-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: P2Y4B32FT2OYUDMLFPNDV2BX4HKH56FH X-Message-ID-Hash: P2Y4B32FT2OYUDMLFPNDV2BX4HKH56FH X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The return code of regmap_multi_reg_write() call related to "MDSYNC down" sequence is shadowed by the subsequent wait_for_completion_timeout() invocation, which is expected to time timeout in case the write operation failed. Let cs35l41_global_enable() return the correct error code instead of -ETIMEDOUT. Fixes: f5030564938b ("ALSA: cs35l41: Add shared boost feature") Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index 4ec306cd2f47..a018f1d98428 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -1243,7 +1243,7 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 cs35l41_mdsync_down_seq[2].def = pwr_ctrl1; ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_down_seq, ARRAY_SIZE(cs35l41_mdsync_down_seq)); - if (!enable) + if (ret || !enable) break; if (!pll_lock) From patchwork Sat Sep 2 21:06:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373153 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 AA18CC001DB for ; Sat, 2 Sep 2023 21:08:56 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4BFDC3E8; Sat, 2 Sep 2023 23:08:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4BFDC3E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693688934; bh=26NMKBPf7XsNqWOLU3lHGtCa6VNcw1e2kRl5lt256Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RAaxSZZL6tjffVRL8tmCdfK7z3HvQR5GMriNWNdLfqAXiHuWm7+yDsHXgy4nDX8h8 Bf3MWOmx3eZI8dsAJms9kJrzsHb4OSw532jRuYpdP6jZ9oSaqev3/oHqqhvS0fGPZj WmrbvSlRW0mA1vSz7pIWbpYkoLx6louUGl4INec8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E177AF8055C; Sat, 2 Sep 2023 23:08:02 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 313CBF80537; Sat, 2 Sep 2023 23:08:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AD008F804F3; Sat, 2 Sep 2023 23:06:38 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DDF69F8025F for ; Sat, 2 Sep 2023 23:06:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DDF69F8025F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=mJYLRed+ Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id B774F66072B7; Sat, 2 Sep 2023 22:06:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688791; bh=26NMKBPf7XsNqWOLU3lHGtCa6VNcw1e2kRl5lt256Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mJYLRed+Xn/OCGoqJANMJT+Qcbr1w0ZjRWsF/zTsV/tI/z7BQR7ktDyd9XSwsy9wt 70OXfwogFsS3sdAYL79mpZ/n679OjNp8YH8m0I1MlJIBcRtOOGqwcvBXQbv/J4ZCp6 BUacio4bBQAGkIPkMMGFY2ypgQ9g4SH3n8TL1takaT4f9tq5hO2m/gpi7Eea3FvNEr 7TVeyDP6GVrUJGxIDb5TrQz4y1mneqKWQeHJL0rZhaMx2oLxuypKwKdM1S+Wz+B/vK WQkajK7pwRp0fPXel0P6XSs9tYThnwMTB9Bnp/S1+Dkw7gzIwVo3TKV1PWSz9TnbX1 YRLfnt51RQifQ== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 2/9] ASoC: cs35l41: Handle mdsync_up reg write errors Date: Sun, 3 Sep 2023 00:06:14 +0300 Message-ID: <20230902210621.1184693-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: 7RZAB4YT73NV5U32INFD2CWQKN3CARAC X-Message-ID-Hash: 7RZAB4YT73NV5U32INFD2CWQKN3CARAC X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The return code of regmap_multi_reg_write() call related to "MDSYNC up" sequence is shadowed by the subsequent regmap_read_poll_timeout() invocation, which will hit a timeout in case the write operation above fails. Make sure cs35l41_global_enable() returns the correct error code instead of -ETIMEDOUT. Additionally, to be able to distinguish between the timeouts of wait_for_completion_timeout() and regmap_read_poll_timeout(), print an error message for the former and return immediately. This also avoids having to wait unnecessarily for the second time. Fixes: f8264c759208 ("ALSA: cs35l41: Poll for Power Up/Down rather than waiting a fixed delay") Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41-lib.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index a018f1d98428..a6c6bb23b957 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -1251,15 +1251,18 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 ret = wait_for_completion_timeout(pll_lock, msecs_to_jiffies(1000)); if (ret == 0) { - ret = -ETIMEDOUT; - } else { - regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); - pwr_ctrl3 |= CS35L41_SYNC_EN_MASK; - cs35l41_mdsync_up_seq[0].def = pwr_ctrl3; - ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, - ARRAY_SIZE(cs35l41_mdsync_up_seq)); + dev_err(dev, "Timed out waiting for pll_lock\n"); + return -ETIMEDOUT; } + regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); + pwr_ctrl3 |= CS35L41_SYNC_EN_MASK; + cs35l41_mdsync_up_seq[0].def = pwr_ctrl3; + ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, + ARRAY_SIZE(cs35l41_mdsync_up_seq)); + if (ret) + return ret; + ret = regmap_read_poll_timeout(regmap, CS35L41_IRQ1_STATUS1, int_status, int_status & pup_pdn_mask, 1000, 100000); From patchwork Sat Sep 2 21:06:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373159 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 49152C001DB for ; Sat, 2 Sep 2023 21:10:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 979CD3E8; Sat, 2 Sep 2023 23:09:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 979CD3E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693689031; bh=EIKQVEzIvsfCigiMKXYRAU8bDJtcz9v1w1No9Z6EJII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=bF66CR2hssk6sRiKd591YmgvNF4pp+8wuzDzPzwfhWMATLiW574cooEHv1V3G/tfx tDfgMiMdoclHEgx5jz8mPblmT5FnREcpXiJudNBKgZPg3QCs1swmUzrE0YfashCNer WKlWGxbxgeH1wsTOqTo5hikMZtpkeHg9VHSZU6LE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CCC42F804DA; Sat, 2 Sep 2023 23:09:10 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3B1DDF804DA; Sat, 2 Sep 2023 23:09:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A1321F80536; Sat, 2 Sep 2023 23:09:05 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0BD14F80249 for ; Sat, 2 Sep 2023 23:06:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0BD14F80249 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=kIg6hIb6 Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 6FD4866072B6; Sat, 2 Sep 2023 22:06:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688794; bh=EIKQVEzIvsfCigiMKXYRAU8bDJtcz9v1w1No9Z6EJII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kIg6hIb6YJvChqOHLmgZRHM6t+6lgXW0nWc5+QFgmoDU98F4hY6vU6CTDDydq9ZR9 x09pVplTOecbN5bkQUF57p8OZY/NmIWHE4i3/4UJQLKv+a6+H/axVo5BwqpGS4bMv0 YZKpzWOTm5iQq6+HqE+fi8lIWw2jyof60EaqH93IhBCLjXHyrX5LxMFQsCdX3+gRn1 IU5/l+UqsuSx9RImlyX0LJgPDBDbsCxhSJuPx4yEEmmHOusLWEBOPIavgT6/CIEHnX ODRnV/FgbYoTeh8CtjujAcETFiWnQQxtsM7qDnY3L9iEAMwghBi9Vsri/GRhtp4KIm UCG6/HY2kdq1w== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 3/9] ASoC: cs35l41: Initialize completion object before requesting IRQ Date: Sun, 3 Sep 2023 00:06:15 +0300 Message-ID: <20230902210621.1184693-4-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: P72ZYHSJ36U5UISTPZDT6KU6I4GPVYOA X-Message-ID-Hash: P72ZYHSJ36U5UISTPZDT6KU6I4GPVYOA X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Technically, an interrupt handler can be called before probe() finishes its execution, hence ensure the pll_lock completion object is always initialized before being accessed in cs35l41_irq(). Fixes: f5030564938b ("ALSA: cs35l41: Add shared boost feature") Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index 722b69a6de26..fe5376b3e01b 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -1273,6 +1273,8 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * regmap_update_bits(cs35l41->regmap, CS35L41_IRQ1_MASK3, CS35L41_INT3_PLL_LOCK_MASK, 0 << CS35L41_INT3_PLL_LOCK_SHIFT); + init_completion(&cs35l41->pll_lock); + ret = devm_request_threaded_irq(cs35l41->dev, cs35l41->irq, NULL, cs35l41_irq, IRQF_ONESHOT | IRQF_SHARED | irq_pol, "cs35l41", cs35l41); @@ -1295,8 +1297,6 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * if (ret < 0) goto err; - init_completion(&cs35l41->pll_lock); - pm_runtime_set_autosuspend_delay(cs35l41->dev, 3000); pm_runtime_use_autosuspend(cs35l41->dev); pm_runtime_mark_last_busy(cs35l41->dev); From patchwork Sat Sep 2 21:06:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373154 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 9A628C001DB for ; Sat, 2 Sep 2023 21:09:03 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 62D11846; Sat, 2 Sep 2023 23:08:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 62D11846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693688941; bh=iekwK11XbOskpf3xmL90QbHkzIoNYgnBqbKDM8TC4do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=o+06LeF7PDuTg4CTTqgCcJXuCyEJXe3LC0DYaA37f6ajoV70ITA/EHL2nHUn7HWI0 /Ot9aZapNXPAIPky91MRfUfl0dOTCXHZY/zMpZ6F/cC69zkSVBQubOroqZZQL6J9i1 EGQM3azUnplYpZMDzySmG5aN5HARJiejjO0UpkeU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6C021F8025F; Sat, 2 Sep 2023 23:08:04 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id DBD40F80563; Sat, 2 Sep 2023 23:08:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2EAF6F8032D; Sat, 2 Sep 2023 23:06:46 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A3255F8032D for ; Sat, 2 Sep 2023 23:06:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A3255F8032D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=kEQCHpSr Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 9031E66072B5; Sat, 2 Sep 2023 22:06:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688797; bh=iekwK11XbOskpf3xmL90QbHkzIoNYgnBqbKDM8TC4do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEQCHpSriKXpgzz8SYM6UDY3NfM2gzd31oZ9qyiEvlYODl7G9ehRlcdEmACivD4/z gX7q/cSkv3l0z2kLsFg09pflgPAc8LvvDTmFxQWbDVh3exCESVLFYOEtUCDfCQM8w2 SFpbRcwMTVMpVK7GQijRbYRaDIv6MDavavMI2japFEcux9BY1Bfj+q4qe4BEvHRCSy rj/I1d1sVmIUXPLn38tviW15zH04/1YZY5RPn4zLB7qV2jkFb+VxdcvJ8fZdTFE+dl TDzdFUx2eTF+tU/GwQWIfOuEbXq+5rmOc76h1QOgxFsSKAwUPkY6zyr6FQDBnZNabv 4xF9IPb72GJ4Q== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 4/9] ASoC: cs35l41: Fix broken shared boost activation Date: Sun, 3 Sep 2023 00:06:16 +0300 Message-ID: <20230902210621.1184693-5-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: YNXSB63WIJIPZ6P6HMECTF65RO74AFW7 X-Message-ID-Hash: YNXSB63WIJIPZ6P6HMECTF65RO74AFW7 X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Enabling the active/passive shared boosts involves writing the MDSYNC UP register sequence, which cannot be performed before receiving the PLL lock signal. Due to improper error handling, it was not obvious the wait operation times out and, consequently, the shared boost gets never enabled. Further investigations revealed the signal is triggered while snd_pcm_start() is executed, right after receiving the SNDRV_PCM_TRIGGER_START command, which happens long after the SND_SOC_DAPM_PRE_PMU event handler is invoked as part of snd_pcm_prepare(). That is where cs35l41_global_enable() is called from. Increasing the wait duration doesn't help, as it only causes an unnecessary delay in the invocation of snd_pcm_start(). Moving the wait and the subsequent regmap operations to the SNDRV_PCM_TRIGGER_START callback is not a solution either, since they would be executed in an IRQ-off atomic context. Solve the issue by deferring the processing to a workqueue task, which allows to correctly wait for the signal and then safely proceed with the required regmap operations. Fixes: f5030564938b ("ALSA: cs35l41: Add shared boost feature") Signed-off-by: Cristian Ciocaltea --- include/sound/cs35l41.h | 5 +- sound/soc/codecs/cs35l41-lib.c | 86 +++++++++++++++++++++++++--------- sound/soc/codecs/cs35l41.c | 38 ++++++++++++++- sound/soc/codecs/cs35l41.h | 2 + 4 files changed, 104 insertions(+), 27 deletions(-) diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h index 1bf757901d02..91024411f8a1 100644 --- a/include/sound/cs35l41.h +++ b/include/sound/cs35l41.h @@ -11,7 +11,7 @@ #define __CS35L41_H #include -#include +#include #include #define CS35L41_FIRSTREG 0x00000000 @@ -902,7 +902,8 @@ int cs35l41_exit_hibernate(struct device *dev, struct regmap *regmap); int cs35l41_init_boost(struct device *dev, struct regmap *regmap, struct cs35l41_hw_cfg *hw_cfg); bool cs35l41_safe_reset(struct regmap *regmap, enum cs35l41_boost_type b_type); +int cs35l41_mdsync_up(struct regmap *regmap); int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l41_boost_type b_type, - int enable, struct completion *pll_lock, bool firmware_running); + int enable, struct work_struct *mdsync_up_work, bool firmware_running); #endif /* __CS35L41_H */ diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index a6c6bb23b957..16e7f46d3853 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -1192,8 +1192,56 @@ bool cs35l41_safe_reset(struct regmap *regmap, enum cs35l41_boost_type b_type) } EXPORT_SYMBOL_GPL(cs35l41_safe_reset); +int cs35l41_mdsync_up(struct regmap *regmap) +{ + struct reg_sequence cs35l41_mdsync_up_seq[] = { + {CS35L41_PWR_CTRL3, 0}, + {CS35L41_PWR_CTRL1, 0x00000000, 3000}, + {CS35L41_PWR_CTRL1, 0x00000001, 3000}, + }; + unsigned int pwr_ctrl3, int_status; + int ret; + + regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); + pwr_ctrl3 |= CS35L41_SYNC_EN_MASK; + cs35l41_mdsync_up_seq[0].def = pwr_ctrl3; + + ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, + ARRAY_SIZE(cs35l41_mdsync_up_seq)); + if (ret < 0) + return ret; + + ret = regmap_read_poll_timeout(regmap, CS35L41_IRQ1_STATUS1, int_status, + int_status & CS35L41_PUP_DONE_MASK, + 1000, 100000); + + /* Clear PUP/PDN status */ + regmap_write(regmap, CS35L41_IRQ1_STATUS1, CS35L41_PUP_DONE_MASK); + return ret; +} +EXPORT_SYMBOL_GPL(cs35l41_mdsync_up); + +/* + * NOTE: Enabling the CS35L41_SHD_BOOST_ACTV and CS35L41_SHD_BOOST_PASS shared + * boosts involves writing the MDSYNC UP reg sequence, which must be performed + * only after getting the PLL lock signal. This signal seems to be triggered + * soon after snd_pcm_start() is executed and SNDRV_PCM_TRIGGER_START command + * is processed, which happens (long) after the SND_SOC_DAPM_PRE_PMU event + * handler is invoked as part of snd_pcm_prepare(). + * + * The event handler is where cs35l41_global_enable() should be normally called + * from, but waiting for the PLL lock signal here will time out. Increasing the + * wait duration will not help, as the only consequence of that would be to add + * an unnecessary delay in the invocation of snd_pcm_start(). + * + * Trying to move the wait in the SNDRV_PCM_TRIGGER_START callback is not a + * solution either, as the trigger is executed in an IRQ-off atomic context, + * hence the current approach is to defer the processing to a workqueue task. + * This allows to properly wait for the signal and then safely write the + * necessary MDSYNC sequence by calling cs35l41_mdsync_up() above. + */ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l41_boost_type b_type, - int enable, struct completion *pll_lock, bool firmware_running) + int enable, struct work_struct *mdsync_up_work, bool firmware_running) { int ret; unsigned int gpio1_func, pad_control, pwr_ctrl1, pwr_ctrl3, int_status, pup_pdn_mask; @@ -1203,11 +1251,6 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 {CS35L41_GPIO_PAD_CONTROL, 0}, {CS35L41_PWR_CTRL1, 0, 3000}, }; - struct reg_sequence cs35l41_mdsync_up_seq[] = { - {CS35L41_PWR_CTRL3, 0}, - {CS35L41_PWR_CTRL1, 0x00000000, 3000}, - {CS35L41_PWR_CTRL1, 0x00000001, 3000}, - }; pup_pdn_mask = enable ? CS35L41_PUP_DONE_MASK : CS35L41_PDN_DONE_MASK; @@ -1226,6 +1269,9 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 switch (b_type) { case CS35L41_SHD_BOOST_ACTV: case CS35L41_SHD_BOOST_PASS: + if (mdsync_up_work) + cancel_work_sync(mdsync_up_work); + regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); regmap_read(regmap, CS35L41_GPIO_PAD_CONTROL, &pad_control); @@ -1243,33 +1289,27 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 cs35l41_mdsync_down_seq[2].def = pwr_ctrl1; ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_down_seq, ARRAY_SIZE(cs35l41_mdsync_down_seq)); - if (ret || !enable) + if (ret) break; - if (!pll_lock) - return -EINVAL; - - ret = wait_for_completion_timeout(pll_lock, msecs_to_jiffies(1000)); - if (ret == 0) { - dev_err(dev, "Timed out waiting for pll_lock\n"); - return -ETIMEDOUT; + if (enable) { + if (mdsync_up_work) { + /* Call cs35l41_mdsync_up() after receiving PLL lock signal */ + schedule_work(mdsync_up_work); + } else { + dev_err(dev, "MDSYNC UP work not provided\n"); + ret = -EINVAL; + } + break; } - regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); - pwr_ctrl3 |= CS35L41_SYNC_EN_MASK; - cs35l41_mdsync_up_seq[0].def = pwr_ctrl3; - ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, - ARRAY_SIZE(cs35l41_mdsync_up_seq)); - if (ret) - return ret; - ret = regmap_read_poll_timeout(regmap, CS35L41_IRQ1_STATUS1, int_status, int_status & pup_pdn_mask, 1000, 100000); if (ret) dev_err(dev, "Enable(%d) failed: %d\n", enable, ret); - // Clear PUP/PDN status + /* Clear PUP/PDN status */ regmap_write(regmap, CS35L41_IRQ1_STATUS1, pup_pdn_mask); break; case CS35L41_INT_BOOST: diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index fe5376b3e01b..9bf70da03972 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -500,11 +500,11 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w, ARRAY_SIZE(cs35l41_pup_patch)); ret = cs35l41_global_enable(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type, - 1, &cs35l41->pll_lock, cs35l41->dsp.cs_dsp.running); + 1, &cs35l41->mdsync_up_work, cs35l41->dsp.cs_dsp.running); break; case SND_SOC_DAPM_POST_PMD: ret = cs35l41_global_enable(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type, - 0, &cs35l41->pll_lock, cs35l41->dsp.cs_dsp.running); + 0, &cs35l41->mdsync_up_work, cs35l41->dsp.cs_dsp.running); regmap_multi_reg_write_bypassed(cs35l41->regmap, cs35l41_pdn_patch, @@ -1155,6 +1155,36 @@ static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41) return 0; } +static void cs35l41_mdsync_up_work(struct work_struct *work) +{ + struct cs35l41_private *cs35l41 = container_of(work, + struct cs35l41_private, + mdsync_up_work); + int ret = wait_for_completion_timeout(&cs35l41->pll_lock, + msecs_to_jiffies(100)); + if (ret == 0) { + dev_err(cs35l41->dev, "Timed out waiting for pll_lock signal\n"); + return; + } + + dev_dbg(cs35l41->dev, "Received pll_lock signal\n"); + + ret = pm_runtime_resume_and_get(cs35l41->dev); + if (ret < 0) { + dev_err(cs35l41->dev, + "pm_runtime_resume_and_get failed in %s: %d\n", + __func__, ret); + return; + } + + ret = cs35l41_mdsync_up(cs35l41->regmap); + if (ret < 0) + dev_err(cs35l41->dev, "MDSYNC UP failed: %d\n", ret); + + pm_runtime_mark_last_busy(cs35l41->dev); + pm_runtime_put_autosuspend(cs35l41->dev); +} + int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg) { u32 regid, reg_revid, i, mtl_revid, int_status, chipid_match; @@ -1297,6 +1327,8 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * if (ret < 0) goto err; + INIT_WORK(&cs35l41->mdsync_up_work, cs35l41_mdsync_up_work); + pm_runtime_set_autosuspend_delay(cs35l41->dev, 3000); pm_runtime_use_autosuspend(cs35l41->dev); pm_runtime_mark_last_busy(cs35l41->dev); @@ -1335,6 +1367,8 @@ EXPORT_SYMBOL_GPL(cs35l41_probe); void cs35l41_remove(struct cs35l41_private *cs35l41) { + cancel_work_sync(&cs35l41->mdsync_up_work); + pm_runtime_get_sync(cs35l41->dev); pm_runtime_disable(cs35l41->dev); diff --git a/sound/soc/codecs/cs35l41.h b/sound/soc/codecs/cs35l41.h index 34d967d4372b..f9f85796a13a 100644 --- a/sound/soc/codecs/cs35l41.h +++ b/sound/soc/codecs/cs35l41.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,7 @@ struct cs35l41_private { /* GPIO for /RST */ struct gpio_desc *reset_gpio; struct completion pll_lock; + struct work_struct mdsync_up_work; }; int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg); From patchwork Sat Sep 2 21:06:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373155 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 62E82C001DB for ; Sat, 2 Sep 2023 21:09:29 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DB33EA4D; Sat, 2 Sep 2023 23:08:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DB33EA4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693688967; bh=ZFbrDlGsG1v2EjUCV6bCyGa1RigZq4UWK6ZhGbIVmVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=bnRXkYqUBgbkAoR2TOaeaapgyuyKdgktiA6saTpJjTbjZNAkf+mwIyGj5isrZ0MdH YJvhVdK4BrPbpWL2dDGsELuK/hrjmyRFyOQr7x4tX34NVQa3UYwjbMsCX1TNMBipmb Iw9iacjozBKhpW5RRmmXwLpqI1TbvhDKkOCE6ymE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 33EEEF8057F; Sat, 2 Sep 2023 23:08:06 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6BAEBF80579; Sat, 2 Sep 2023 23:08:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9A9FAF80527; Sat, 2 Sep 2023 23:06:47 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9D547F8025F for ; Sat, 2 Sep 2023 23:06:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9D547F8025F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=VOU3U94m Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id DF10866072B5; Sat, 2 Sep 2023 22:06:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688801; bh=ZFbrDlGsG1v2EjUCV6bCyGa1RigZq4UWK6ZhGbIVmVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VOU3U94md0KKyLr5WS0958ZrkDv99MLMNEw9B/4NusRC+u6XlZoqvf09dEyMVKyiE 77lY+xH6013b5Hy0fgcscC8DnauGlw5D4yIgIuY/HHH3h4sCg8aqJjQlGPaaB0A8tK 7WVPWkQAipbRYOrVBzm8xrVkg8iJIqjrI7HevXUwEaYrzfWtysorJgCSvnsV9TnjfV Tv9hif395vEJy9k3OsPHVA/WeTfj1m6ejgxu21PjInTPFPqcq38p4TDaZEo23ke2fO VmA6hxKSEXmy012ZqepADt3dbECOC0s9AMD/T/jmOUD0EiLC/CtohvPcFJG9YkWzyn dvhvGRrIoTgng== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 5/9] ASoC: cs35l41: Rename pll_lock to pll_lock_done Date: Sun, 3 Sep 2023 00:06:17 +0300 Message-ID: <20230902210621.1184693-6-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: IB3GNXI4CKFYVGVNHWBMZN4UHYEB5YWV X-Message-ID-Hash: IB3GNXI4CKFYVGVNHWBMZN4UHYEB5YWV X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Use a more intuitive name for 'pll_lock' completion, which helps improving code readability a bit. Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41.c | 8 ++++---- sound/soc/codecs/cs35l41.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index 9bf70da03972..e143b0e306b1 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -459,7 +459,7 @@ static irqreturn_t cs35l41_irq(int irq, void *data) if (status[2] & CS35L41_PLL_LOCK) { regmap_write(cs35l41->regmap, CS35L41_IRQ1_STATUS3, CS35L41_PLL_LOCK); - complete(&cs35l41->pll_lock); + complete(&cs35l41->pll_lock_done); ret = IRQ_HANDLED; } @@ -804,7 +804,7 @@ static int cs35l41_pcm_startup(struct snd_pcm_substream *substream, { struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); - reinit_completion(&cs35l41->pll_lock); + reinit_completion(&cs35l41->pll_lock_done); if (substream->runtime) return snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -1160,7 +1160,7 @@ static void cs35l41_mdsync_up_work(struct work_struct *work) struct cs35l41_private *cs35l41 = container_of(work, struct cs35l41_private, mdsync_up_work); - int ret = wait_for_completion_timeout(&cs35l41->pll_lock, + int ret = wait_for_completion_timeout(&cs35l41->pll_lock_done, msecs_to_jiffies(100)); if (ret == 0) { dev_err(cs35l41->dev, "Timed out waiting for pll_lock signal\n"); @@ -1303,7 +1303,7 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * regmap_update_bits(cs35l41->regmap, CS35L41_IRQ1_MASK3, CS35L41_INT3_PLL_LOCK_MASK, 0 << CS35L41_INT3_PLL_LOCK_SHIFT); - init_completion(&cs35l41->pll_lock); + init_completion(&cs35l41->pll_lock_done); ret = devm_request_threaded_irq(cs35l41->dev, cs35l41->irq, NULL, cs35l41_irq, IRQF_ONESHOT | IRQF_SHARED | irq_pol, diff --git a/sound/soc/codecs/cs35l41.h b/sound/soc/codecs/cs35l41.h index f9f85796a13a..fe61c11404e7 100644 --- a/sound/soc/codecs/cs35l41.h +++ b/sound/soc/codecs/cs35l41.h @@ -34,7 +34,7 @@ struct cs35l41_private { int irq; /* GPIO for /RST */ struct gpio_desc *reset_gpio; - struct completion pll_lock; + struct completion pll_lock_done; struct work_struct mdsync_up_work; }; From patchwork Sat Sep 2 21:06:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373160 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 602B4C001DB for ; Sat, 2 Sep 2023 21:10:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 41A6CAE9; Sat, 2 Sep 2023 23:09:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 41A6CAE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693689043; bh=w5FQqX5N0SNY30mh7ugIsBlhQQTzEUlaqCEU1kT1GFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=G8PUnPSKpojCYv90bOi1FzbAMo+ZI9oG6BMYWAEPw4fVF0/rh60clAsbnl20Onv21 nF6aErNCwcFWkuBGvSumhKb1x+jomgERjxZtTXHvlYRnZWgvmIBCoBhgYOx6QlbUNb YyJbF+hORj/mHMDLM8pK+zdSmFIxZDV4YlLrGM3c= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1F545F8032D; Sat, 2 Sep 2023 23:09:12 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B5775F8056F; Sat, 2 Sep 2023 23:09:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 10885F8032D; Sat, 2 Sep 2023 23:09:07 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1E52DF804DA for ; Sat, 2 Sep 2023 23:06:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1E52DF804DA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=SsV5Z5qX Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id EC9E366072B6; Sat, 2 Sep 2023 22:06:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688804; bh=w5FQqX5N0SNY30mh7ugIsBlhQQTzEUlaqCEU1kT1GFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SsV5Z5qXxHI1zSHIAWX75tvNJU3lFptraqm847T0X0jApT8o3TtarXt2lIAni6cYA zWoi/adINh/vCW9bvyQsNMGRqcFso3rmxgNOcit2Kxm02CQdSlF4N/HqgVqISFAykC wKCm3j/r+ROf4iBRKsRM412rvw4bLYyWhhHy5jBCZAtTUX/m4Ly0fuozAmS81chQv0 1zPdtb5MDfdrdpq+f9ZsvWPaZCuviWhzCMqKnW1raow5TNdgjJVMOKIydeDjUyY3uY XW1BAEzxzmNi3RDMMprX5rN3fJJhvWaSpzNL2kRPIm7v6xsI/VLhw2ln6moTppPEyp i7FqJXBmtj4nw== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 6/9] ASoC: cs35l41: Make use of dev_err_probe() Date: Sun, 3 Sep 2023 00:06:18 +0300 Message-ID: <20230902210621.1184693-7-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: A3RZXDGBNZP5MXXBPXEEKXA5OFUJLOT5 X-Message-ID-Hash: A3RZXDGBNZP5MXXBPXEEKXA5OFUJLOT5 X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Use dev_err_probe() helper where possible, to simplify error handling during probe. Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41-i2c.c | 9 +++------ sound/soc/codecs/cs35l41-spi.c | 9 +++------ sound/soc/codecs/cs35l41.c | 34 ++++++++++++++++------------------ 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/sound/soc/codecs/cs35l41-i2c.c b/sound/soc/codecs/cs35l41-i2c.c index 7ea890d7d387..9109203a7f25 100644 --- a/sound/soc/codecs/cs35l41-i2c.c +++ b/sound/soc/codecs/cs35l41-i2c.c @@ -35,7 +35,6 @@ static int cs35l41_i2c_probe(struct i2c_client *client) struct device *dev = &client->dev; struct cs35l41_hw_cfg *hw_cfg = dev_get_platdata(dev); const struct regmap_config *regmap_config = &cs35l41_regmap_i2c; - int ret; cs35l41 = devm_kzalloc(dev, sizeof(struct cs35l41_private), GFP_KERNEL); @@ -47,11 +46,9 @@ static int cs35l41_i2c_probe(struct i2c_client *client) i2c_set_clientdata(client, cs35l41); cs35l41->regmap = devm_regmap_init_i2c(client, regmap_config); - if (IS_ERR(cs35l41->regmap)) { - ret = PTR_ERR(cs35l41->regmap); - dev_err(cs35l41->dev, "Failed to allocate register map: %d\n", ret); - return ret; - } + if (IS_ERR(cs35l41->regmap)) + return dev_err_probe(cs35l41->dev, PTR_ERR(cs35l41->regmap), + "Failed to allocate register map\n"); return cs35l41_probe(cs35l41, hw_cfg); } diff --git a/sound/soc/codecs/cs35l41-spi.c b/sound/soc/codecs/cs35l41-spi.c index 5c8bb24909eb..28e9c9473e60 100644 --- a/sound/soc/codecs/cs35l41-spi.c +++ b/sound/soc/codecs/cs35l41-spi.c @@ -32,7 +32,6 @@ static int cs35l41_spi_probe(struct spi_device *spi) const struct regmap_config *regmap_config = &cs35l41_regmap_spi; struct cs35l41_hw_cfg *hw_cfg = dev_get_platdata(&spi->dev); struct cs35l41_private *cs35l41; - int ret; cs35l41 = devm_kzalloc(&spi->dev, sizeof(struct cs35l41_private), GFP_KERNEL); if (!cs35l41) @@ -43,11 +42,9 @@ static int cs35l41_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, cs35l41); cs35l41->regmap = devm_regmap_init_spi(spi, regmap_config); - if (IS_ERR(cs35l41->regmap)) { - ret = PTR_ERR(cs35l41->regmap); - dev_err(&spi->dev, "Failed to allocate register map: %d\n", ret); - return ret; - } + if (IS_ERR(cs35l41->regmap)) + return dev_err_probe(cs35l41->dev, PTR_ERR(cs35l41->regmap), + "Failed to allocate register map\n"); cs35l41->dev = &spi->dev; cs35l41->irq = spi->irq; diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index e143b0e306b1..6f2ad0d3a75c 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -1204,16 +1204,14 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * ret = devm_regulator_bulk_get(cs35l41->dev, CS35L41_NUM_SUPPLIES, cs35l41->supplies); - if (ret != 0) { - dev_err(cs35l41->dev, "Failed to request core supplies: %d\n", ret); - return ret; - } + if (ret != 0) + return dev_err_probe(cs35l41->dev, ret, + "Failed to request core supplies\n"); ret = regulator_bulk_enable(CS35L41_NUM_SUPPLIES, cs35l41->supplies); - if (ret != 0) { - dev_err(cs35l41->dev, "Failed to enable core supplies: %d\n", ret); - return ret; - } + if (ret != 0) + return dev_err_probe(cs35l41->dev, ret, + "Failed to enable core supplies\n"); /* returning NULL can be an option if in stereo mode */ cs35l41->reset_gpio = devm_gpiod_get_optional(cs35l41->dev, "reset", @@ -1225,8 +1223,8 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * dev_info(cs35l41->dev, "Reset line busy, assuming shared reset\n"); } else { - dev_err(cs35l41->dev, - "Failed to get reset GPIO: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, + "Failed to get reset GPIO\n"); goto err; } } @@ -1242,8 +1240,8 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * int_status, int_status & CS35L41_OTP_BOOT_DONE, 1000, 100000); if (ret) { - dev_err(cs35l41->dev, - "Failed waiting for OTP_BOOT_DONE: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, + "Failed waiting for OTP_BOOT_DONE\n"); goto err; } @@ -1256,13 +1254,13 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, ®id); if (ret < 0) { - dev_err(cs35l41->dev, "Get Device ID failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "Get Device ID failed\n"); goto err; } ret = regmap_read(cs35l41->regmap, CS35L41_REVID, ®_revid); if (ret < 0) { - dev_err(cs35l41->dev, "Get Revision ID failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "Get Revision ID failed\n"); goto err; } @@ -1287,7 +1285,7 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); if (ret < 0) { - dev_err(cs35l41->dev, "OTP Unpack failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "OTP Unpack failed\n"); goto err; } @@ -1309,13 +1307,13 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * IRQF_ONESHOT | IRQF_SHARED | irq_pol, "cs35l41", cs35l41); if (ret != 0) { - dev_err(cs35l41->dev, "Failed to request IRQ: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "Failed to request IRQ\n"); goto err; } ret = cs35l41_set_pdata(cs35l41); if (ret < 0) { - dev_err(cs35l41->dev, "Set pdata failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "Set pdata failed\n"); goto err; } @@ -1340,7 +1338,7 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * &soc_component_dev_cs35l41, cs35l41_dai, ARRAY_SIZE(cs35l41_dai)); if (ret < 0) { - dev_err(cs35l41->dev, "Register codec failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "Register codec failed\n"); goto err_pm; } From patchwork Sat Sep 2 21:06:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373156 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 9A464C001DB for ; Sat, 2 Sep 2023 21:09:45 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AA521AEA; Sat, 2 Sep 2023 23:08:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AA521AEA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693688983; bh=u8foQukjHiYH/O7gXYdWoKCmQhG0/XDI8XfTOo0YtW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Bg8VmOVBCVA9ij/hgC8VZq5lmiEqiUST8RPHD74y/tRsbnAS9ufGzAZjQSDxSZejx PqTZvfVqe89nBg63aJm/rysnfMYqAHvJs2IK6JPd5AGhahqspP9DKEx5hsKtcHXYJE DkMh1tGQxwbIPU7Grw2iIKAilSGlJFmrhfRWkXIY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 08C9AF80579; Sat, 2 Sep 2023 23:08:07 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 531A0F8057B; Sat, 2 Sep 2023 23:08:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B896BF80527; Sat, 2 Sep 2023 23:06:49 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3DC93F8032D for ; Sat, 2 Sep 2023 23:06:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3DC93F8032D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=RqsQcz2q Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id A69E466072B5; Sat, 2 Sep 2023 22:06:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688806; bh=u8foQukjHiYH/O7gXYdWoKCmQhG0/XDI8XfTOo0YtW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RqsQcz2qqfbwRmIUhx6YrMIkmgv6bEQVkFrpTJA7rCLoFX3xAkbtosy1tMAEwF+CW gQTRumGwMC04SMKtwqziHaAGzb9PJYxV4NDQPb8cdG7hEazhzxXcfxXqZT5TkmoOPt oAx9I/Ec9PVJOU2xV5Wm5X2UZfakzuPewFKO6wSiNzFCs6jwcQKm1WqP9WxuB8fJDi qBCIVrrpvOr1IoW/LrIhqN92gvSgfhhA4gn4kovuplAepIkq9AJDlC+Qinv2fuZ34Z bubUKCtBL1Ep/tXnj9Ff1XZyY5D5EVTOihdI6g5Goada+OEjxNIk2jbeSoo4abiI+z CimCviICtGRAg== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 7/9] ASoC: cs35l41: Verify PM runtime resume errors in IRQ handler Date: Sun, 3 Sep 2023 00:06:19 +0300 Message-ID: <20230902210621.1184693-8-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: UIPB7GUOEYBM72IPLSSDCYOJGMWZ42Z5 X-Message-ID-Hash: UIPB7GUOEYBM72IPLSSDCYOJGMWZ42Z5 X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The interrupt handler invokes pm_runtime_get_sync() without checking the returned error code. Add a proper verification and switch to pm_runtime_resume_and_get(), to avoid the need to call pm_runtime_put_noidle() for decrementing the PM usage counter before returning from the error condition. Fixes: f517ba4924ad ("ASoC: cs35l41: Add support for hibernate memory retention mode") Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index 6f2ad0d3a75c..66418547a4dd 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -386,10 +386,18 @@ static irqreturn_t cs35l41_irq(int irq, void *data) struct cs35l41_private *cs35l41 = data; unsigned int status[4] = { 0, 0, 0, 0 }; unsigned int masks[4] = { 0, 0, 0, 0 }; - int ret = IRQ_NONE; unsigned int i; + int ret; - pm_runtime_get_sync(cs35l41->dev); + ret = pm_runtime_resume_and_get(cs35l41->dev); + if (ret < 0) { + dev_err(cs35l41->dev, + "pm_runtime_resume_and_get failed in %s: %d\n", + __func__, ret); + return IRQ_NONE; + } + + ret = IRQ_NONE; for (i = 0; i < ARRAY_SIZE(status); i++) { regmap_read(cs35l41->regmap, From patchwork Sat Sep 2 21:06:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373157 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 0BFA4C83F2C for ; Sat, 2 Sep 2023 21:09:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3113E74C; Sat, 2 Sep 2023 23:09:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3113E74C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693688991; bh=tEMH7gxlfQzbbvPh3ZrLYJvkNudGdOtShkFuAU3tALI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rfuguwopc1LaO18fX9c+BVOTXTahKnhaoizwlD9KccjIXfnVAV7pSq0gktmxDzhUD yaUAFSMzuattdEBdBOibhcqzZ9bDwfpuKGzlqf3FiKYHb5PWAYJuhpwNs4IzuOgyWL kR1ePcC0DaD7Cs0vj91d1stIiMUg0L69pFZ9untQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA54DF805B3; Sat, 2 Sep 2023 23:08:09 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id DE75FF805AD; Sat, 2 Sep 2023 23:08:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 98568F80536; Sat, 2 Sep 2023 23:06:56 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ECDE9F8025F for ; Sat, 2 Sep 2023 23:06:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ECDE9F8025F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=lJ/DMTDr Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 28AF36607285; Sat, 2 Sep 2023 22:06:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688810; bh=tEMH7gxlfQzbbvPh3ZrLYJvkNudGdOtShkFuAU3tALI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJ/DMTDrah6kmvoCynnPx55LbGjSsfuv3LEMVpJa7qO2g2opQzLprOlevTQF+2aJF C9QDwpxmEjCEQAB9GhHJ5OGItG7HVJ8YiWq4cZBfpFFIH9gSjAgGFNmVTeh2YKFh2w Iev2PKqBF9qU+LuB3hATvVTw4MhXMJ4mboJGZE3LbVDaNrCJXpmWvqWslXnZ21EevW 68I/KSw4IYn/kmn5ZbWgPGkTT0dJI8SoA7ZTUngJ66JA+q772vdCFZANDZZiTRpLtX 4LOmh+G7fbQpVit2S7qbZorb6Xg8EIfv+uYjVzV56fsj7vrmPqixR8TbN+4Huc5kHg OG3u4H2Iaj1aQ== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 8/9] ASoC: cs35l41: Use modern pm_ops Date: Sun, 3 Sep 2023 00:06:20 +0300 Message-ID: <20230902210621.1184693-9-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: S55NEZEJQZ6RBF7AQDDGZWPJGOX3XKKL X-Message-ID-Hash: S55NEZEJQZ6RBF7AQDDGZWPJGOX3XKKL X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Make use of the recently introduced EXPORT_GPL_DEV_PM_OPS() macro, to conditionally export the runtime/system PM functions. Replace the old SET_{RUNTIME,SYSTEM_SLEEP,NOIRQ_SYSTEM_SLEEP}_PM_OPS() helpers with their modern alternatives and get rid of the now unnecessary '__maybe_unused' annotations on all PM functions. Additionally, use the pm_ptr() macro to fix the following errors when building with CONFIG_PM disabled: ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-spi.ko] undefined! ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-i2c.ko] undefined! Signed-off-by: Cristian Ciocaltea Acked-by: Charles Keepax --- sound/soc/codecs/cs35l41-i2c.c | 2 +- sound/soc/codecs/cs35l41-spi.c | 2 +- sound/soc/codecs/cs35l41.c | 21 ++++++++++----------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/cs35l41-i2c.c b/sound/soc/codecs/cs35l41-i2c.c index 9109203a7f25..96414ee35285 100644 --- a/sound/soc/codecs/cs35l41-i2c.c +++ b/sound/soc/codecs/cs35l41-i2c.c @@ -80,7 +80,7 @@ MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_match); static struct i2c_driver cs35l41_i2c_driver = { .driver = { .name = "cs35l41", - .pm = &cs35l41_pm_ops, + .pm = pm_ptr(&cs35l41_pm_ops), .of_match_table = of_match_ptr(cs35l41_of_match), .acpi_match_table = ACPI_PTR(cs35l41_acpi_match), }, diff --git a/sound/soc/codecs/cs35l41-spi.c b/sound/soc/codecs/cs35l41-spi.c index 28e9c9473e60..a6db44520c06 100644 --- a/sound/soc/codecs/cs35l41-spi.c +++ b/sound/soc/codecs/cs35l41-spi.c @@ -80,7 +80,7 @@ MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_match); static struct spi_driver cs35l41_spi_driver = { .driver = { .name = "cs35l41", - .pm = &cs35l41_pm_ops, + .pm = pm_ptr(&cs35l41_pm_ops), .of_match_table = of_match_ptr(cs35l41_of_match), .acpi_match_table = ACPI_PTR(cs35l41_acpi_match), }, diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index 66418547a4dd..5655758063ae 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -1394,7 +1394,7 @@ void cs35l41_remove(struct cs35l41_private *cs35l41) } EXPORT_SYMBOL_GPL(cs35l41_remove); -static int __maybe_unused cs35l41_runtime_suspend(struct device *dev) +static int cs35l41_runtime_suspend(struct device *dev) { struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); @@ -1411,7 +1411,7 @@ static int __maybe_unused cs35l41_runtime_suspend(struct device *dev) return 0; } -static int __maybe_unused cs35l41_runtime_resume(struct device *dev) +static int cs35l41_runtime_resume(struct device *dev) { struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); int ret; @@ -1440,7 +1440,7 @@ static int __maybe_unused cs35l41_runtime_resume(struct device *dev) return 0; } -static int __maybe_unused cs35l41_sys_suspend(struct device *dev) +static int cs35l41_sys_suspend(struct device *dev) { struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); @@ -1450,7 +1450,7 @@ static int __maybe_unused cs35l41_sys_suspend(struct device *dev) return 0; } -static int __maybe_unused cs35l41_sys_suspend_noirq(struct device *dev) +static int cs35l41_sys_suspend_noirq(struct device *dev) { struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); @@ -1460,7 +1460,7 @@ static int __maybe_unused cs35l41_sys_suspend_noirq(struct device *dev) return 0; } -static int __maybe_unused cs35l41_sys_resume_noirq(struct device *dev) +static int cs35l41_sys_resume_noirq(struct device *dev) { struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); @@ -1470,7 +1470,7 @@ static int __maybe_unused cs35l41_sys_resume_noirq(struct device *dev) return 0; } -static int __maybe_unused cs35l41_sys_resume(struct device *dev) +static int cs35l41_sys_resume(struct device *dev) { struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); @@ -1480,13 +1480,12 @@ static int __maybe_unused cs35l41_sys_resume(struct device *dev) return 0; } -const struct dev_pm_ops cs35l41_pm_ops = { - SET_RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL) +EXPORT_GPL_DEV_PM_OPS(cs35l41_pm_ops) = { + RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend, cs35l41_sys_resume) - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend_noirq, cs35l41_sys_resume_noirq) + SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend, cs35l41_sys_resume) + NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend_noirq, cs35l41_sys_resume_noirq) }; -EXPORT_SYMBOL_GPL(cs35l41_pm_ops); MODULE_DESCRIPTION("ASoC CS35L41 driver"); MODULE_AUTHOR("David Rhodes, Cirrus Logic Inc, "); From patchwork Sat Sep 2 21:06:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13373158 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 E7AB9C001DB for ; Sat, 2 Sep 2023 21:10:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 500C9DF2; Sat, 2 Sep 2023 23:09:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 500C9DF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693689011; bh=G+WVbRYmwmOF6B5vQfe9gXWVIMHqOGdNIKeuQZ/LSsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kceAgfOfmhdd1KaeGnjyN+GZu7tfazFFlujMqcojcnlRPkMr0uuDwFUzBgkrBea1C Vva5KHCW5gpbIPpKGfiXVRMIWd6kHB+XsEKwlSZhwwNUiTOjWZ4bQGZu3ZNsYM7CxP QCsg78xaNc0Ped7VE2BPZTkWTTt4nlb39ztyd+Aw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id DDCCEF805BF; Sat, 2 Sep 2023 23:08:11 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 5899BF805B5; Sat, 2 Sep 2023 23:08:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 83341F80527; Sat, 2 Sep 2023 23:06:57 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3E311F8032D for ; Sat, 2 Sep 2023 23:06:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3E311F8032D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=jQ/ossJI Received: from localhost (unknown [81.18.92.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 1BBAC66072B6; Sat, 2 Sep 2023 22:06:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693688813; bh=G+WVbRYmwmOF6B5vQfe9gXWVIMHqOGdNIKeuQZ/LSsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQ/ossJIPvU1/N8/hhVkj5SHf3GIFg3ann4S2qkCW5qI0OOBPItps/dGZ3GDWF27o K/qWgTSNAXflOjOM4iyCoyjIQzJSxYEu7PD8X3qjcs9mwruwTXDMoNOYW7jmsUtdXd OC7u8PlXxodjIV4NS2jQROy7CuS+Y87fXVOEJfYWuba06I/FpUhZGPRT2r1sECj3Z1 9dQw90HkJctdngMemAR49YWNq456EyXiMbI4Gcy0quEUENoOM3ASDBGTvtx/yPUXx8 FgXBaiE8owr5B6JwEI5TRHf1VyA3Y+rLyFE5G4XjaEJs6yGjksq4vW4j3JbJfns4D2 teeOW9W00VSTg== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 9/9] ASoC: cs35l41: Use devm_pm_runtime_enable() Date: Sun, 3 Sep 2023 00:06:21 +0300 Message-ID: <20230902210621.1184693-10-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> References: <20230902210621.1184693-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: ZMDAFYBV5SGSKFENC6WCVKQMNIQSBDPF X-Message-ID-Hash: ZMDAFYBV5SGSKFENC6WCVKQMNIQSBDPF X-MailFrom: cristian.ciocaltea@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Simplify runtime PM during probe by converting pm_runtime_enable() to the managed version. Signed-off-by: Cristian Ciocaltea --- sound/soc/codecs/cs35l41.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index 5655758063ae..2e5b4633e98d 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -1340,7 +1340,12 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * pm_runtime_mark_last_busy(cs35l41->dev); pm_runtime_set_active(cs35l41->dev); pm_runtime_get_noresume(cs35l41->dev); - pm_runtime_enable(cs35l41->dev); + + ret = devm_pm_runtime_enable(cs35l41->dev); + if (ret < 0) { + dev_err_probe(cs35l41->dev, ret, "Failed to enable PM runtime\n"); + goto err_pm; + } ret = devm_snd_soc_register_component(cs35l41->dev, &soc_component_dev_cs35l41, @@ -1358,9 +1363,7 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * return 0; err_pm: - pm_runtime_disable(cs35l41->dev); pm_runtime_put_noidle(cs35l41->dev); - wm_adsp2_remove(&cs35l41->dsp); err: cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); @@ -1376,7 +1379,6 @@ void cs35l41_remove(struct cs35l41_private *cs35l41) cancel_work_sync(&cs35l41->mdsync_up_work); pm_runtime_get_sync(cs35l41->dev); - pm_runtime_disable(cs35l41->dev); regmap_write(cs35l41->regmap, CS35L41_IRQ1_MASK1, 0xFFFFFFFF); if (cs35l41->hw_cfg.bst_type == CS35L41_SHD_BOOST_PASS ||