From patchwork Thu Sep 7 17:10:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 721112 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 9C961EC8743 for ; Thu, 7 Sep 2023 17:12:11 +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 16C40A4B; Thu, 7 Sep 2023 19:11:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 16C40A4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106729; bh=qbGf9dTskivmBZH5bu+AEo0oFeT7I13FlT9OFQJZyls=; 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=NJ269Mjb0ed/ckac0/Cf8Px818ItnxTwjkY24skXUn53eaTzmZ/EUW3F/M/4cBdZM AEAxo6loQu0BjytXjn6041+XGuKoVVHizk+lfOfPD9VSYEKtcgBRa+HI72YktqOdFc VpnFNh+iygSCpEdl5uvWx8Nu69vj7998Vk/7opWE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 07658F80571; Thu, 7 Sep 2023 19:10:30 +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 5CAC2F80552; Thu, 7 Sep 2023 19:10:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DBF40F804F3; Thu, 7 Sep 2023 19:10:24 +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) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 161F5F8047D for ; Thu, 7 Sep 2023 19:10:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 161F5F8047D 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=LQRBunHi 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 EA96166072BA; Thu, 7 Sep 2023 18:10:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106618; bh=qbGf9dTskivmBZH5bu+AEo0oFeT7I13FlT9OFQJZyls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LQRBunHiDczrq43E+clWbn9RMyk+/WWLK3X5J7sAsRcgFttDr3Ng4pVKVpuS7U9Lg cERBQmBbo339i5OHr0Te8p6KuQCQb4MyFC8ApnCmoCJgwJ70F97SYkJ7rFKuRxINAP YzBqEn96OpxRqKUkMjdCboFagVqs8swhC+BMzdEpjixlGPZwGhHvB7XPHeesThRRMI I0xa1j8ddKYC+WAhm55RuQH9ZJKlRPWFE6I3043dWJA/aBb7wG95rg5g1QVsxoaG2k lRDVuqkeskvbQsMSvtzIUdXmYUCyWNwnfhvTWyCXV5+6+AR+VyLfXrqH82dSDRUG0L W4gsFq7wS8/nQ== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 01/11] ASoC: cs35l41: Handle mdsync_down reg write errors Date: Thu, 7 Sep 2023 20:10:00 +0300 Message-ID: <20230907171010.1447274-2-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: LBJZ5NUC5GPHGXTRWB53EEQYEMRSTDNA X-Message-ID-Hash: LBJZ5NUC5GPHGXTRWB53EEQYEMRSTDNA 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 Thu Sep 7 17:10:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 720639 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 C9D1AEC8742 for ; Thu, 7 Sep 2023 17:12:18 +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 23BC6DEC; Thu, 7 Sep 2023 19:11:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 23BC6DEC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106737; bh=LTYQlpYjRWHhuzVTDClSJzTinidzBZZBJA3f8dy37pI=; 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=fiVnWuRWPFXc592NhdI+HX8YmVfWjz1q7wmuNfiCSAEP8J2ZS+d40aAYz82ZvzKHy ATmtYlMMd8p7EOhfrul5pZHyC+9OS6VySsVMxAPjFVUgce60XymF5xq0AwJg7VERL5 bNXhpoCJmWKD3T/HaeGqggNd73cP3t2K2XRvCTeo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E097FF8057E; Thu, 7 Sep 2023 19:10:31 +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 3BB7CF80579; Thu, 7 Sep 2023 19:10:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E95ECF804F3; Thu, 7 Sep 2023 19:10:25 +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 EAE29F800F5 for ; Thu, 7 Sep 2023 19:10:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EAE29F800F5 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=E3FAUF13 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 CFC7466072E5; Thu, 7 Sep 2023 18:10:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106621; bh=LTYQlpYjRWHhuzVTDClSJzTinidzBZZBJA3f8dy37pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E3FAUF13OSTk1RLs/CeCermnjqevCEIh9qWcOU6CTBhA2Diwt80nW3OLY+wcNeta/ KXRJhZDKaAA/mkDgz3zFMYDXVVys8b/wAAG3PvsJEiyrQ60082aW4vnKySPNU1Hqg8 DWAwMs4kHlVs4t7gxXkxnBIpBRfMwefUPm/ML9LeWpwxY/oIKreIm3e/VWXXEm65Bx mvOasm+2UYtDIToSSL0Gq0oYcSDApcrYuOlCHGf0vk3HLhNmRryd3I0V+qLKANisOn lYlnliflUAhmuZW1TnkmC3g7ecPpQywNDfgqMMd5Zl4akcc3NW2ca526MaJeq4ejTV 90tdf9cBV66cg== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 02/11] ASoC: cs35l41: Handle mdsync_up reg write errors Date: Thu, 7 Sep 2023 20:10:01 +0300 Message-ID: <20230907171010.1447274-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: 76R5JLMTSXUDM45HG6GXUNSDNQ2MI5CP X-Message-ID-Hash: 76R5JLMTSXUDM45HG6GXUNSDNQ2MI5CP 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 Thu Sep 7 17:10:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 721111 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 135FEEC8743 for ; Thu, 7 Sep 2023 17:12:32 +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 3A54EDF3; Thu, 7 Sep 2023 19:11:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3A54EDF3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106750; bh=nGFk3rS7fAIR3MaWNggHlTaneMQ+Lj8aBg1pPKOxNfI=; 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=i/YVqONtel5ygTWno4twcp9XX0txtW+q3U2ytbv+eSLhSSwLFxzB0incFpyuYJYgF Lm8yLuXBAaSGfkUZ5/nqmvc6Wgs2d2eNVAL973sUbahbEtefJoaij/g8/YSEKoTTO5 JfMaK23HCebT7g6NX+Vi5Kqu72r729fQblxFS/do= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3C09AF805A9; Thu, 7 Sep 2023 19:10:34 +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 A341CF80588; Thu, 7 Sep 2023 19:10:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CA61AF8055A; Thu, 7 Sep 2023 19:10:27 +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 30976F800AA for ; Thu, 7 Sep 2023 19:10:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 30976F800AA 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=HLHsLVsm 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 7E20866072EC; Thu, 7 Sep 2023 18:10:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106623; bh=nGFk3rS7fAIR3MaWNggHlTaneMQ+Lj8aBg1pPKOxNfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HLHsLVsm2dcn3Uh9I48y2sx9s/qYXpkeDS4LMk1GUi7t5VjLRz64zwSawOKioJSM4 JSd6v36tBAwHgHZBnsU9+FhB+Oq3MNuJcYoyu79o3nqmCH3brC43y7k2PYCLu49A+Z xwIURVgTW9ES3X7rjEVkg+bbegxCICVAHWRKpSF0NQ6sVluQYoB/LejpHHoOZotSYa FtvsbWzB7DYvJVfcInVd1pGyL78TbU4jJfJbVAFDc2WzqDEpnESJY0sxsYa/c8sxbz zZUjQA/555dkelWJjVmK14tte6x5M8iTidVPzwWVYgEZ7ptxLj1/NCzKbiN/Y03+lV Wx9r0gwYd0oNg== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 03/11] ASoC: cs35l41: Initialize completion object before requesting IRQ Date: Thu, 7 Sep 2023 20:10:02 +0300 Message-ID: <20230907171010.1447274-4-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: L7J7WD6H2374OKKY43HPAVANHLYTL3T5 X-Message-ID-Hash: L7J7WD6H2374OKKY43HPAVANHLYTL3T5 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 Thu Sep 7 17:10:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 720638 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 A7739EC8742 for ; Thu, 7 Sep 2023 17:13:01 +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 EB08F886; Thu, 7 Sep 2023 19:12:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EB08F886 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106780; bh=v+KUOPMPCdqFTGL0GYSa2pPN6xNU4u2BRTjyZv9IMps=; 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=f7HtG2miF9i+cC4xs/gdANOys3Lf+GNbjxZ1QW2Nsl3zAC8JuUuwcUQwp69FW/eiT 3a3o9aR03BRSPD4Y1Dno16qapsv2OvnIfr+625j4PGnf6TZDRtY8Mj0j36SzHi+lBc z5+9UpapJQ1UBWwicBjjrKv0jg0mtSi/5icL7E5U= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 90C83F805AD; Thu, 7 Sep 2023 19:10:39 +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 C88F1F805AF; Thu, 7 Sep 2023 19:10:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29A48F805AB; Thu, 7 Sep 2023 19:10:35 +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 7E31EF8056F for ; Thu, 7 Sep 2023 19:10:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7E31EF8056F 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=aATWsOhH 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 44CDF66072EE; Thu, 7 Sep 2023 18:10:27 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106627; bh=v+KUOPMPCdqFTGL0GYSa2pPN6xNU4u2BRTjyZv9IMps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aATWsOhH7Gdi1uyd4fQM34ZPVrm5cancUJVVkfOX8yypo5C7qgV4WrjWkifK0ai+P k9snPO+mDf9gRMb/aJYCyEhFwdjShS6VPCL1IZ4YtsuFUQMshjsLTsBIfQRIa+BfNG CBK/fDPOJGtr3ssfY7kl1GKF6HoOUk3Rf28kcRnC38iRI1LjdBqz/jjtc+93ihbxQj 4T6nYiwCNRKiPdLwkkFDntC1pMItgUTdb3IpTMDPqbxQYPphPEgVTCxMDcoB00WRNl AtuO5f8aR8wbfQYL++HdIj5gd8X5MC8xJAb6e0hYWsCAptKIXH+qD+BzrE02V/bXAi 1KTo9YJ8qrhjw== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 04/11] ASoC: cs35l41: Fix broken shared boost activation Date: Thu, 7 Sep 2023 20:10:03 +0300 Message-ID: <20230907171010.1447274-5-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: P3PF3UCXHMEOF2TMLEU3Y5IUOBKI6TFV X-Message-ID-Hash: P3PF3UCXHMEOF2TMLEU3Y5IUOBKI6TFV 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 requires setting SYNC_EN, but *not* before receiving the PLL Lock signal. Due to improper error handling, it was not obvious that waiting for the completion operation times out and, consequently, the shared boost is never activated. 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 setting the SYNC_EN bit in PWR_CTRL3 register right after receiving the PLL Lock interrupt. Additionally, drop the unnecessary writes to PWR_CTRL1 register, part of the original mdsync_up_seq, which would have toggled GLOBAL_EN with unwanted consequences on PLL locking behavior. Fixes: f5030564938b ("ALSA: cs35l41: Add shared boost feature") Signed-off-by: Cristian Ciocaltea Reviewed-by: David Rhodes --- include/sound/cs35l41.h | 4 +-- sound/pci/hda/cs35l41_hda.c | 4 +-- sound/soc/codecs/cs35l41-lib.c | 61 ++++++++++++++++++++-------------- sound/soc/codecs/cs35l41.c | 24 ++++++++----- sound/soc/codecs/cs35l41.h | 1 - 5 files changed, 55 insertions(+), 39 deletions(-) diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h index 1bf757901d02..2fe8c6b0d4cf 100644 --- a/include/sound/cs35l41.h +++ b/include/sound/cs35l41.h @@ -11,7 +11,6 @@ #define __CS35L41_H #include -#include #include #define CS35L41_FIRSTREG 0x00000000 @@ -902,7 +901,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, bool firmware_running); #endif /* __CS35L41_H */ diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index f9b77353c266..09a9c135d9b6 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -527,7 +527,7 @@ static void cs35l41_hda_play_done(struct device *dev) dev_dbg(dev, "Play (Complete)\n"); - cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, NULL, + cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, cs35l41->firmware_running); if (cs35l41->firmware_running) { regmap_multi_reg_write(reg, cs35l41_hda_unmute_dsp, @@ -546,7 +546,7 @@ static void cs35l41_hda_pause_start(struct device *dev) dev_dbg(dev, "Pause (Start)\n"); regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute)); - cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, NULL, + cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, cs35l41->firmware_running); } diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index a6c6bb23b957..2ec5fdc875b1 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -1192,8 +1192,28 @@ bool cs35l41_safe_reset(struct regmap *regmap, enum cs35l41_boost_type b_type) } EXPORT_SYMBOL_GPL(cs35l41_safe_reset); +/* + * Enabling the CS35L41_SHD_BOOST_ACTV and CS35L41_SHD_BOOST_PASS shared boosts + * does also require a call to cs35l41_mdsync_up(), but not before getting the + * PLL Lock signal. + * + * PLL Lock 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(). + * + * This event handler is where cs35l41_global_enable() is normally called from, + * but waiting for PLL Lock here will time out. Increasing the wait duration + * will not help, as the only consequence of it 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. + * + * The current approach is to invoke cs35l41_mdsync_up() right after receiving + * the PLL Lock interrupt, in the IRQ handler. + */ 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, bool firmware_running) { int ret; unsigned int gpio1_func, pad_control, pwr_ctrl1, pwr_ctrl3, int_status, pup_pdn_mask; @@ -1203,11 +1223,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; @@ -1241,26 +1256,11 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 cs35l41_mdsync_down_seq[0].def = pwr_ctrl3; cs35l41_mdsync_down_seq[1].def = pad_control; 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) - 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; - } - - 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) + /* Activation to be completed later via cs35l41_mdsync_up() */ + if (ret || enable) return ret; ret = regmap_read_poll_timeout(regmap, CS35L41_IRQ1_STATUS1, @@ -1269,7 +1269,7 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 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: @@ -1351,6 +1351,17 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4 } EXPORT_SYMBOL_GPL(cs35l41_global_enable); +/* + * To be called after receiving the IRQ Lock interrupt, in order to complete + * any shared boost activation initiated by cs35l41_global_enable(). + */ +int cs35l41_mdsync_up(struct regmap *regmap) +{ + return regmap_update_bits(regmap, CS35L41_PWR_CTRL3, + CS35L41_SYNC_EN_MASK, CS35L41_SYNC_EN_MASK); +} +EXPORT_SYMBOL_GPL(cs35l41_mdsync_up); + int cs35l41_gpio_config(struct regmap *regmap, struct cs35l41_hw_cfg *hw_cfg) { struct cs35l41_gpio_cfg *gpio1 = &hw_cfg->gpio1; diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index fe5376b3e01b..12327b4c3d56 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -459,7 +459,19 @@ 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); + + if (cs35l41->hw_cfg.bst_type == CS35L41_SHD_BOOST_ACTV || + cs35l41->hw_cfg.bst_type == CS35L41_SHD_BOOST_PASS) { + ret = cs35l41_mdsync_up(cs35l41->regmap); + if (ret) + dev_err(cs35l41->dev, "MDSYNC-up failed: %d\n", ret); + else + dev_dbg(cs35l41->dev, "MDSYNC-up done\n"); + + dev_dbg(cs35l41->dev, "PUP-done status: %d\n", + !!(status[0] & CS35L41_PUP_DONE_MASK)); + } + ret = IRQ_HANDLED; } @@ -500,11 +512,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->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->dsp.cs_dsp.running); regmap_multi_reg_write_bypassed(cs35l41->regmap, cs35l41_pdn_patch, @@ -802,10 +814,6 @@ static const struct snd_pcm_hw_constraint_list cs35l41_constraints = { static int cs35l41_pcm_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); - - reinit_completion(&cs35l41->pll_lock); - if (substream->runtime) return snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, @@ -1273,8 +1281,6 @@ 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); diff --git a/sound/soc/codecs/cs35l41.h b/sound/soc/codecs/cs35l41.h index 34d967d4372b..c85cbc1dd333 100644 --- a/sound/soc/codecs/cs35l41.h +++ b/sound/soc/codecs/cs35l41.h @@ -33,7 +33,6 @@ struct cs35l41_private { int irq; /* GPIO for /RST */ struct gpio_desc *reset_gpio; - struct completion pll_lock; }; int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg); From patchwork Thu Sep 7 17:10:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 720637 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 B27C7EC8742 for ; Thu, 7 Sep 2023 17:13:28 +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 2141E93A; Thu, 7 Sep 2023 19:12:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2141E93A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106807; bh=al0e+KmaEmZIhVKCVtjP9iNhEGj5bzloAJ+lYxNnbIk=; 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=JEd6x0ArxnbiT5o5O8oE4ej5vsE4vpXH5Ins+R6nJtMLtIPuSk3jpHVNVnWInwSr+ CZBmLAPpXaFdwdNuXjkrmap9Nh+tjrlbSzAxsVYbfylGMKurTjGSGgp5FLS5CtXAd7 nTbt1oesNjxTXbCbfRSWdb4jlQARL1BrsP1Qtl2Y= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 35414F8056F; Thu, 7 Sep 2023 19:10:43 +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 3073DF805C6; Thu, 7 Sep 2023 19:10:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8F773F805AE; Thu, 7 Sep 2023 19:10:37 +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 7E277F805A8 for ; Thu, 7 Sep 2023 19:10:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7E277F805A8 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=cfN+i/tX 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 3908966072F0; Thu, 7 Sep 2023 18:10:30 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106630; bh=al0e+KmaEmZIhVKCVtjP9iNhEGj5bzloAJ+lYxNnbIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfN+i/tXAGmFgLedeeIDQKOa3hk7CoPzD4kJaGXco3pOXbGwMrlfpzajywg1XuMtw A395WFtSu9jn4b4ZjO+tYka/e0zeW/Evimvy1bJ0o0MD93OWEzIWetIcLBe9eN0RPO /gSF6zKTmtnHZupDzPT4V2ROm6E9YwJfpjq3h0NOeIyN4qkPWLz7NeQQ6UoljXwQcS jRD7sCh2eB1aRr/tUNMHLEhU8jJOHQ18QApjTwObESnRi7LcWjnVW3ChVf+ROrh2Rs c8wEh86SXXTrMTKKmHPG6L8tQ/0pbACSmvTJ7r1Mg1NDrtWB7slR2Tr8/bpPp0/IvL v1C6IGoapb55g== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 05/11] ASoC: cs35l41: Verify PM runtime resume errors in IRQ handler Date: Thu, 7 Sep 2023 20:10:04 +0300 Message-ID: <20230907171010.1447274-6-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: SFAUELFALEVXXVSDREP7LCIOBP736TDM X-Message-ID-Hash: SFAUELFALEVXXVSDREP7LCIOBP736TDM 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 12327b4c3d56..a31cb9ba7f7d 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 Thu Sep 7 17:10:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 721110 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 304E1EC8742 for ; Thu, 7 Sep 2023 17:13:07 +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 46CDFE0D; Thu, 7 Sep 2023 19:12:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 46CDFE0D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106785; bh=fBfsFcET+MCXlOleecv+XYcgSYKwelm2evWuMi6WZt4=; 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=uSKQylyOBunwBI65lvbAk2d7hHBZQQPFqzvwiqMkvNvkGnyOg0LEDHlkDGxPzQTqn 1JS3fP+6bjcGnGFSKpCpOiDAwBfMO+aT6ncmZOyGNsHIML2tP9+jcWUn4K/wT8Lskf hAAGZTdob0um9oEoR37cIMz/f0nVrbHMoKQnBnqQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 513E9F805BD; Thu, 7 Sep 2023 19:10:42 +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 CC495F805BE; Thu, 7 Sep 2023 19:10:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B71F8F805AB; Thu, 7 Sep 2023 19:10:36 +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 8EF36F80588 for ; Thu, 7 Sep 2023 19:10:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8EF36F80588 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=ouYnSJqB 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 EB51266072EF; Thu, 7 Sep 2023 18:10:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106633; bh=fBfsFcET+MCXlOleecv+XYcgSYKwelm2evWuMi6WZt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ouYnSJqBiL0WtmQqXcb+GIFgI1feIaQxestI0hqNbsnm43sm7CDBRsbUz9Azd+Esj BEzyO+Ecunp7TmN9ZuzL9oLnw04Ndjl5SWeBfnblfWoMi0+J0l/VMDTnJ/Ls0ZTzHa or/pma/AzJ5+5deXLcWJNcmwKD4tCbO0TAExV/jrOt4KrnvP2ZwDmY0oXtWeS0E3BD iZJbFL10PN94HLaqQqP/fiHGOR+MbbfGrvj8HItjrfwvK0R+Q7I/1fJjWWFgjHctIn hDnVhH21grdtoPyfdxkjYEYF2edTdVusj+VKTt61MbQbXSwy5KMhA/0QI1nAqiwUkK eUJzH4xn+/lBg== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 06/11] ASoC: cs35l41: Undo runtime PM changes at driver exit time Date: Thu, 7 Sep 2023 20:10:05 +0300 Message-ID: <20230907171010.1447274-7-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: HWAFUMOPNF7TUXCEJ6W6COY656RQEZPZ X-Message-ID-Hash: HWAFUMOPNF7TUXCEJ6W6COY656RQEZPZ 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: According to the documentation, drivers are responsible for undoing at removal time all runtime PM changes done during probing. Hence, add the missing calls to pm_runtime_dont_use_autosuspend(), which are necessary for undoing pm_runtime_use_autosuspend(). Note this would have been handled implicitly by devm_pm_runtime_enable(), but there is a need to continue using pm_runtime_enable()/pm_runtime_disable() in order to ensure the runtime PM is disabled as soon as the remove() callback is entered. Fixes: f517ba4924ad ("ASoC: cs35l41: Add support for hibernate memory retention mode") Signed-off-by: Cristian Ciocaltea --- sound/soc/codecs/cs35l41.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index a31cb9ba7f7d..5456e6bfa242 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -1334,6 +1334,7 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * return 0; err_pm: + pm_runtime_dont_use_autosuspend(cs35l41->dev); pm_runtime_disable(cs35l41->dev); pm_runtime_put_noidle(cs35l41->dev); @@ -1350,6 +1351,7 @@ EXPORT_SYMBOL_GPL(cs35l41_probe); void cs35l41_remove(struct cs35l41_private *cs35l41) { pm_runtime_get_sync(cs35l41->dev); + pm_runtime_dont_use_autosuspend(cs35l41->dev); pm_runtime_disable(cs35l41->dev); regmap_write(cs35l41->regmap, CS35L41_IRQ1_MASK1, 0xFFFFFFFF); From patchwork Thu Sep 7 17:10:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 721109 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 BC2FFEC874B for ; Thu, 7 Sep 2023 17:13:43 +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 A3686950; Thu, 7 Sep 2023 19:12:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A3686950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106821; bh=0iNfyxlEf9nQ9rzmSwa3q80tRzMXGzHMikIFLaPq9/A=; 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=Ho7z3bekJ3WidYdDfpJHXch+bZuSiCsSOJjfY2seSptYHjqD9szsBop53jrzWuKUE icXO/84ysBMNUS85S3gW2xPT2bEyKJQtFTG3lWwOUn5lYlr/UUGPEtib/DmBQ3WCVQ vdnAQRjyVele8Rk3v5EqDwRD/IkRJ5rrRpu3UB8Y= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA16BF805D9; Thu, 7 Sep 2023 19:10:46 +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 A5989F805D4; Thu, 7 Sep 2023 19:10:45 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B935AF805BF; Thu, 7 Sep 2023 19:10:41 +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 5115AF8056F for ; Thu, 7 Sep 2023 19:10:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5115AF8056F 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=GxGlyGld 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 3023A66072F1; Thu, 7 Sep 2023 18:10:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106636; bh=0iNfyxlEf9nQ9rzmSwa3q80tRzMXGzHMikIFLaPq9/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxGlyGldKVwEnWJcymdhIE4LiMEFIjKvBhnNPIPtAhL417z/zaykgkXg3stBtGx/e Wz32gDEvmunH5csGh4Spgn5OKZdKbTUWFMnn6Zo0A0jkng1r8+Qb8uljTcAJbq65BP mra2LrRO8DMcB+3TfhJoAuY+HbXVSBsNNr+eTSux2e1/bLzNziFSoUb1vv1I9WYkq7 33MsWwpN6WRBPD4hFj6pW26GIXrdnsNadWtpNV0WPpPpQ0Ljzabon5PS5rGVqY4FSn PpNrMYe9ZE6rjLumdhzVV+8G+eZEHN7rwiGw0ZMof5GhK9wALzCbLT38G3cyGxKsLk 6Di7jtGw7S7uw== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 07/11] ASoC: cs35l41: Make use of dev_err_probe() Date: Thu, 7 Sep 2023 20:10:06 +0300 Message-ID: <20230907171010.1447274-8-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: 3KEDUWDZJZZ43GRLUFD7KPH5XGBCMM4A X-Message-ID-Hash: 3KEDUWDZJZZ43GRLUFD7KPH5XGBCMM4A 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 5456e6bfa242..7ddaa9bd8911 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -1190,16 +1190,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", @@ -1211,8 +1209,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; } } @@ -1228,8 +1226,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; } @@ -1242,13 +1240,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; } @@ -1273,7 +1271,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; } @@ -1293,13 +1291,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; } @@ -1322,7 +1320,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 Thu Sep 7 17:10:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 720636 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 3463DEC8743 for ; Thu, 7 Sep 2023 17:13:54 +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 356DBDF8; Thu, 7 Sep 2023 19:13:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 356DBDF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106832; bh=cWhyxr36AR1ENWdvICbtj9KTZjepyfpK32OIZ3BkWNY=; 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=ZYvDgdlBBuLoMRtyR67EzjpgYFs9Gb6oop37ZoBnavUEdWXzB0GHYvTRC/PmWuYHb J5vUF9qjOkd7gPHgxuUgEDnZ9s+OeI9OCRdSnovpAzADH4yi+yUmb7WeqsK7v/7riJ 6z4PEk61yDI4M9s+V2+EKQWHvbEO2uWsjKc+Gy84= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8C6E2F805E3; Thu, 7 Sep 2023 19:10:50 +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 B6146F805E2; Thu, 7 Sep 2023 19:10:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4AA9FF805D5; Thu, 7 Sep 2023 19:10:44 +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 AAA77F805BA for ; Thu, 7 Sep 2023 19:10:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AAA77F805BA 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=WtPR6rLo 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 108A766072F2; Thu, 7 Sep 2023 18:10:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106639; bh=cWhyxr36AR1ENWdvICbtj9KTZjepyfpK32OIZ3BkWNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WtPR6rLopKNclAGAVCXqFCW9nGaB3Xb/6gDidhUwHzU52KEBQGLdxxAI5kHDAzSBU /x603gTM7glnFUTXtS7wKnDTYlfX6YSpXlNm5/CxueuRjXmnRtFhc2D+2dP+P37WTA +NsYeSpoIeBDrYsAJk9yQvZteniuRxdu7B1sY9YrDjEvX/5qKHMJBUicucpHMjoZmz IkXbwnExBOKQT3ZAkYF211ybeixARg5n7B8bHPdncgobgU7l5KoC2ATgTam9X/LHO3 +CBOOCtOq9N9jg94LIKO+fdLAigcEFKwUYNiohNIPSQ8l91pXYI/jQD91zoTZVqp3m cg0v7ncMNUO/Q== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 08/11] ASoC: cs35l41: Use modern pm_ops Date: Thu, 7 Sep 2023 20:10:07 +0300 Message-ID: <20230907171010.1447274-9-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: 4YYNJJYSDYD7BMSTEJ7MWEI6SLME2OS6 X-Message-ID-Hash: 4YYNJJYSDYD7BMSTEJ7MWEI6SLME2OS6 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 7ddaa9bd8911..4bc64ba71cd6 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -1368,7 +1368,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); @@ -1385,7 +1385,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; @@ -1414,7 +1414,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); @@ -1424,7 +1424,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); @@ -1434,7 +1434,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); @@ -1444,7 +1444,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); @@ -1454,13 +1454,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 Thu Sep 7 17:10:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 721108 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 862FCEC8743 for ; Thu, 7 Sep 2023 17:14:19 +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 58454AE8; Thu, 7 Sep 2023 19:13:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 58454AE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106857; bh=xCnO4kZnTTfiLFarcj0DdPXYKo5Wq4aT17BKxrFFaDs=; 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=UFv+kHgu6Sjhhn0/GlYMM/p0pmdKc06h8R1RcK8Ro9hpUOEjd9XjoGSS2IZ5WMHb1 fCmDGg36MRDixiFKgM2zuxtIiap+I5Z3PYYfhb5pJiAKjTsZgPIunT1AaO9vO4an+n q2uqHPjWSTlEezjQ/Udbhzr/POS7C50zA1IURUbI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A6420F805F0; Thu, 7 Sep 2023 19:10:52 +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 C8A88F805EF; Thu, 7 Sep 2023 19:10:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 19C60F805D4; Thu, 7 Sep 2023 19:10:45 +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 AEB36F805D2 for ; Thu, 7 Sep 2023 19:10:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AEB36F805D2 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=HJgEtVCA 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 762F566072F4; Thu, 7 Sep 2023 18:10:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106641; bh=xCnO4kZnTTfiLFarcj0DdPXYKo5Wq4aT17BKxrFFaDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HJgEtVCA+qN+J+SkwLyHkSm4H5oAXVS/ekNU9wN1B9xceWrjWmou6Pvolar4HkXIx h0wqrPE689J78gw5/D4a5TCujAKYqrPRZ52bOt+WwU4wb7xrwPGB7qVJMAEcF1wuKw kD0qvHC8W/EVxv/q/2VQ5bKXIdzbC/qQRq/FkbJF1n4zTt/iPv0JOiJpotAHizMIBx q89D/uSpSRY8JSrDQDHPVfKdivzOpYrKuuQ4JzaRizqBBUcCigQuOCQhr29JrWtTD+ HD54bZ75JJb8NBgkLutoO8q0kq2ACU/e56+Ne70k0UNK5J1vv0grFP0g5y+m/BsLtC 9TKrUCS8BRCHg== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 09/11] ALSA: hda: cs35l41: Fix unbalanced pm_runtime_get() Date: Thu, 7 Sep 2023 20:10:08 +0300 Message-ID: <20230907171010.1447274-10-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: IEMEKK2EWXNQVO3LZSMPCPV4RN6MXLHJ X-Message-ID-Hash: IEMEKK2EWXNQVO3LZSMPCPV4RN6MXLHJ 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: If component_add() fails, probe() returns without calling pm_runtime_put(), which leaves the runtime PM usage counter incremented. Fix the issue by jumping to err_pm label and drop the now unnecessary pm_runtime_disable() call. Fixes: 7b2f3eb492da ("ALSA: hda: cs35l41: Add support for CS35L41 in HDA systems") Signed-off-by: Cristian Ciocaltea --- sound/pci/hda/cs35l41_hda.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 09a9c135d9b6..6fd827093c92 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1625,8 +1625,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i ret = component_add(cs35l41->dev, &cs35l41_hda_comp_ops); if (ret) { dev_err(cs35l41->dev, "Register component failed: %d\n", ret); - pm_runtime_disable(cs35l41->dev); - goto err; + goto err_pm; } dev_info(cs35l41->dev, "Cirrus Logic CS35L41 (%x), Revision: %02X\n", regid, reg_revid); From patchwork Thu Sep 7 17:10:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 720635 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 EBF72EC874B for ; Thu, 7 Sep 2023 17:14:28 +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 1C2A8E0F; Thu, 7 Sep 2023 19:13:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1C2A8E0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106867; bh=ebjTOlKhI8W4zt2KLb9pyA5zxGnqWLuX8KAbomolyu8=; 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=iMtO3uisPuOaAeTGnISxUARL8+kQCoDi4xMdV30ZiWt1mwgYNJ1+avzWkGDeHDyie 8TadXqzvWa/2x8QZzhYslV+HVSq4bD81BFQNbofUQ+2mHGKECHA9sxPa8srTUsur0f WBMN9buGpdMd7uDKv5Piety+pTVKJa7VZlbjFA68= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0C5DAF805F1; Thu, 7 Sep 2023 19:10:55 +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 49E5CF805F8; Thu, 7 Sep 2023 19:10:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7C41DF805E1; Thu, 7 Sep 2023 19:10:47 +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 77D53F805E0 for ; Thu, 7 Sep 2023 19:10:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 77D53F805E0 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=eIsHJoKe 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 6468366072F6; Thu, 7 Sep 2023 18:10:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106644; bh=ebjTOlKhI8W4zt2KLb9pyA5zxGnqWLuX8KAbomolyu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eIsHJoKe89p6AZNI2jcZHGhVv4MPQa5q9p46uvQ8sFgCFwlpdPsRcHkX3dCMgh9wJ O6o+jDDv5FDaOZ25kDeRI3K82Y8F6BaU9WcLJYB/HZ+mSkTLUgMe7RSKbOg9Uj2ReY tT2czfmwjqhPAdUjzSGldkGo0b70PrObV/XmUVlAUKeSq7XQmnWgCsL13C4r5NmEvn b7ROTdmf+wzyOLhjrGvtnbWGgtY43YEHeyxzApWRfiIIoclw2ZRTyKr1y8cNa7fwWJ GKNJV1yv3Rlw9rTZroGp0pOAfv/mbDYaBmwzmaur+aEgC9i2wa+U/QMvyRQJQwy7e/ f/9nHk4Ct8A6g== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 10/11] ALSA: hda: cs35l41: Undo runtime PM changes at driver exit time Date: Thu, 7 Sep 2023 20:10:09 +0300 Message-ID: <20230907171010.1447274-11-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: QSC6SBV43AZS7ZBZJA7INJ6254AKQ4JU X-Message-ID-Hash: QSC6SBV43AZS7ZBZJA7INJ6254AKQ4JU 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: According to the documentation, drivers are responsible for undoing at removal time all runtime PM changes done during probing. Hence, add the missing calls to pm_runtime_dont_use_autosuspend(), which are necessary for undoing pm_runtime_use_autosuspend(). Fixes: 1873ebd30cc8 ("ALSA: hda: cs35l41: Support Hibernation during Suspend") Signed-off-by: Cristian Ciocaltea --- sound/pci/hda/cs35l41_hda.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 6fd827093c92..565f7b897436 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1633,6 +1633,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i return 0; err_pm: + pm_runtime_dont_use_autosuspend(cs35l41->dev); pm_runtime_disable(cs35l41->dev); pm_runtime_put_noidle(cs35l41->dev); @@ -1651,6 +1652,7 @@ void cs35l41_hda_remove(struct device *dev) struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); pm_runtime_get_sync(cs35l41->dev); + pm_runtime_dont_use_autosuspend(cs35l41->dev); pm_runtime_disable(cs35l41->dev); if (cs35l41->halo_initialized) From patchwork Thu Sep 7 17:10:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 721107 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 6EEE9EC8742 for ; Thu, 7 Sep 2023 17:14:48 +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 CA6EAE10; Thu, 7 Sep 2023 19:13:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CA6EAE10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694106886; bh=rIB839KbtT4M8CYKZ1SHwXmr9eGS1OcT+UowfodUupQ=; 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=c+A91p46snSMLfbJDchFwm6XQMCLw0JByq49NQAlDL05q3GyMY5qDXtl4StykYw2k Rd56t5L/Hv1NL8cmLjtOOzK/xdyW1t3eE4l4cWzgFJZoKqKegFFag3h0xvfmYsCQ6Z 9d4UKVmZ7VSazUKOg1TR8oYuCh8zpJUQRWFe/CRk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 49AC7F805F6; Thu, 7 Sep 2023 19:10:57 +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 B1689F80600; Thu, 7 Sep 2023 19:10:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6564DF805EF; Thu, 7 Sep 2023 19:10:51 +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 53D6DF805E0 for ; Thu, 7 Sep 2023 19:10:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 53D6DF805E0 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=YipAyS+s 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 A88C166072F7; Thu, 7 Sep 2023 18:10:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694106647; bh=rIB839KbtT4M8CYKZ1SHwXmr9eGS1OcT+UowfodUupQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YipAyS+s+34w+o5S1L4JGFAzu5i0XzX7Mm1+LeSjGSXnMAFaoUoQ1R7GKS+ZFf0Kh 67E41SgZlirlEk5cElfhVylwcu1tZlXJ/v9aoCTCFS5Z7d4NbKeFmJVBhLePQvKVgm gA/zkun9e+nM+pt8yxV69r6KgWbiakFkmtZYiqKhFBBwlXo60Ci91duDxUU9hSF0ny zcnggy+6OTxCaKO/gVNoFqvjGuGFQlHirPsLNsGwngFPMerC5UwONMjZZ9o0eg4AZL G1qA1LUqB97//C6rWkxVRUbL8uxCviOscdPOvBf9kzjO/6ukokLf6eOA7mZqd9uS0v d91xxPzjrtAaQ== From: Cristian Ciocaltea To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Stefan Binding , Charles Keepax , Vitaly Rodionov Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v2 11/11] ALSA: hda: cs35l41: Consistently use dev_err_probe() Date: Thu, 7 Sep 2023 20:10:10 +0300 Message-ID: <20230907171010.1447274-12-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> References: <20230907171010.1447274-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Message-ID-Hash: QL7KLN44U2VYJX46ISLE3TD2JL3PV7YD X-Message-ID-Hash: QL7KLN44U2VYJX46ISLE3TD2JL3PV7YD 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: Replace the remaining dev_err() calls in probe() with dev_err_probe(), to improve consistency. Signed-off-by: Cristian Ciocaltea --- sound/pci/hda/cs35l41_hda.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 565f7b897436..c74faa2ff46c 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1550,27 +1550,27 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, 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; } ret = regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_sts); if (ret || (int_sts & CS35L41_OTP_BOOT_ERR)) { - dev_err(cs35l41->dev, "OTP Boot status %x error: %d\n", - int_sts & CS35L41_OTP_BOOT_ERR, ret); + dev_err_probe(cs35l41->dev, ret, "OTP Boot status %x error\n", + int_sts & CS35L41_OTP_BOOT_ERR); ret = -EIO; goto err; } ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, ®id); if (ret) { - 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) { - dev_err(cs35l41->dev, "Get Revision ID failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "Get Revision ID failed\n"); goto err; } @@ -1593,7 +1593,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); if (ret) { - dev_err(cs35l41->dev, "OTP Unpack failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "OTP Unpack failed\n"); goto err; } @@ -1624,7 +1624,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i ret = component_add(cs35l41->dev, &cs35l41_hda_comp_ops); if (ret) { - dev_err(cs35l41->dev, "Register component failed: %d\n", ret); + dev_err_probe(cs35l41->dev, ret, "Register component failed\n"); goto err_pm; }