From patchwork Thu May 18 15:02:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 684499 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 42F47C77B7D for ; Thu, 18 May 2023 15:04: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 3B2A51F1; Thu, 18 May 2023 17:03:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3B2A51F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1684422256; bh=l3daJNWGegZLobyS+ov/3vUKMlFuFKS35b61iLEl6k0=; 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=kt9pGKUS7tAkcTzqTVjpzoOxZyDQPuh4HDebCnpUlFXsFpUBkAiSEkwSJHuwHF8Nj dJhcPh9fnfeWbOU2YsaEQmDq0/5eHk9unR4HO6tjgYIev37t/RLi0QjKXFRcNFXRHt qBkXQ+MHG5AMHDIePcYLiwH9MP6BCdkJYMbcvZgA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 45289F80548; Thu, 18 May 2023 17:03:03 +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 CED37F80542; Thu, 18 May 2023 17:03:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 09FDCF8053D; Thu, 18 May 2023 17:02:59 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 15D29F80087 for ; Thu, 18 May 2023 17:02:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 15D29F80087 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=VTVOmCuo Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34IBl9Gk018534; Thu, 18 May 2023 10:02:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=NDpb5Ha4ivNLgiiO+Ax/3NhCQbVV5MgVjXtVoyK70Bw=; b=VTVOmCuoH2nRtMoZQXsgWZl4NyutzptR8Po4MDKYqOfAT1qs07vAZ/SLU3xllQ0b0UxG wci6CGWk3t6edH4WzMYSsJ6Yk+svcu1ySuAwpsP/fmS3V9L/1GN8aWqP+oqQx53KnRsA m4iuBWSSfvzDKldb5wmplMZpu/dXbjHP7m7leAyW+qKhq6/6TP0Q9FVcYX8MxaDP6+yb RTlJlEHeDK4FUTaugA5C0vzBtZ4uFaE9aOBAk02th897rXRx7U0oXjRaFjVnrzm8M/Gj ePrUYoLMWIel7JDCiQMixEnRiFv8ytaMrZpa/7JBopKY/fNi3fDnHIA3TCMQL7NObu1u EA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3qngq1ghun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 10:02:51 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 18 May 2023 10:02:50 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 18 May 2023 10:02:50 -0500 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 2C21015A2; Thu, 18 May 2023 15:02:50 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , Simon Trimmer , Richard Fitzgerald Subject: [PATCH 1/3] ASoC: cs35l56: Move DSP part string generation so that it is done only once Date: Thu, 18 May 2023 16:02:48 +0100 Message-ID: <20230518150250.1121006-2-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230518150250.1121006-1-rf@opensource.cirrus.com> References: <20230518150250.1121006-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: cPFI_s6E6LErWfHaMMWNtxjjOKU7s3cM X-Proofpoint-ORIG-GUID: cPFI_s6E6LErWfHaMMWNtxjjOKU7s3cM X-Proofpoint-Spam-Reason: safe Message-ID-Hash: FJHIZAMA5BPQCZBB6A6MIT5BBX62TEG2 X-Message-ID-Hash: FJHIZAMA5BPQCZBB6A6MIT5BBX62TEG2 X-MailFrom: prvs=05023014f4=rf@opensource.cirrus.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: From: Simon Trimmer Each time we go through dsp_work() it does a devm_kasprintf() to allocate memory to hold the part name string. It's not strictly a memory leak because devm will free it all if the driver is removed. But we keep allocating more and more memory to hold the same string. Move the allocation so that it is performed after the version and secured state information is gathered and handle allocation errors. Signed-off-by: Simon Trimmer Signed-off-by: Richard Fitzgerald --- sound/soc/codecs/cs35l56.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index d1677d76d018..906aa416879b 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -837,12 +837,6 @@ static void cs35l56_dsp_work(struct work_struct *work) if (!cs35l56->init_done) return; - cs35l56->dsp.part = devm_kasprintf(cs35l56->dev, GFP_KERNEL, "cs35l56%s-%02x", - cs35l56->secured ? "s" : "", cs35l56->rev); - - if (!cs35l56->dsp.part) - return; - pm_runtime_get_sync(cs35l56->dev); /* @@ -1508,6 +1502,12 @@ int cs35l56_init(struct cs35l56_private *cs35l56) dev_info(cs35l56->dev, "Cirrus Logic CS35L56%s Rev %02X OTP%d\n", cs35l56->secured ? "s" : "", cs35l56->rev, otpid); + /* Populate the DSP information with the revision and security state */ + cs35l56->dsp.part = devm_kasprintf(cs35l56->dev, GFP_KERNEL, "cs35l56%s-%02x", + cs35l56->secured ? "s" : "", cs35l56->rev); + if (!cs35l56->dsp.part) + return -ENOMEM; + /* Wake source and *_BLOCKED interrupts default to unmasked, so mask them */ regmap_write(cs35l56->regmap, CS35L56_IRQ1_MASK_20, 0xffffffff); regmap_update_bits(cs35l56->regmap, CS35L56_IRQ1_MASK_1, From patchwork Thu May 18 15:02:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 684498 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 F2E98C7EE23 for ; Thu, 18 May 2023 15:04:52 +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 D2579828; Thu, 18 May 2023 17:04:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D2579828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1684422290; bh=80c2bgdvmHbS1lxXVpKM2KVfCpBgitmwrxKWwZ6FygY=; 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=Sa8ZZSArIYtCQeJVo8tfjtDk27SSGMGXkwAqtXq+tKR6BUIJAOF51EtqznJ4ymCGJ YbCJyVLNFivGsM8wV5UjwOWlLl15Xbzo+eGYZ6VjjWJauoUa2PRR/dUYLwsR0u3h1U lDI6Xy6RtdEetdMvr29PZinrgCAt7d1EWDoVXTGE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0A75CF80570; Thu, 18 May 2023 17:03:08 +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 8469CF8056F; Thu, 18 May 2023 17:03:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6CFD4F802E8; Thu, 18 May 2023 17:03:01 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 60DE6F80272 for ; Thu, 18 May 2023 17:02:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 60DE6F80272 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=DcfYb17z Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34IBl9Gl018534; Thu, 18 May 2023 10:02:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=9VFpFPgEoHqPkXngB8mLww3M78YV7Ay78b5OSGxLAQk=; b=DcfYb17zHbduk9hIZzU4/KoI+Me+3J1g5gzmOFm2ekHSH064b2f79mpoSdYYysFj9SDN GxzdwcZ7SewgW9p7TGNsJ3lEEEnSfixwjkd5SKxyzaA/EgzApkjiieNw8UztKnGt4tpJ yhRxawyrFtpOWIwO7TI7FY1ozX1BGqDBQRikanySPyMP1z6peCsDkamqqzYgeptotUsw HRCN5mnwcYjqtdIxFbhS0dIx3dLyRJ/B5QjhsBhCBumzQLvKT7rpkolF692etOg0biZa gpqGyP9Dbxa9mZmOgn0r9Gnsu0TAyNFSeX3XxRgL8P1KQQSBxXOeapfwvkepK6Wrj+Er OQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3qngq1ghum-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 10:02:52 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 18 May 2023 10:02:50 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 18 May 2023 10:02:50 -0500 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 36FA9468; Thu, 18 May 2023 15:02:50 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , Simon Trimmer , Richard Fitzgerald Subject: [PATCH 2/3] ASoC: cs35l56: sdw_write_no_pm() should be performed under a pm_runtime request Date: Thu, 18 May 2023 16:02:49 +0100 Message-ID: <20230518150250.1121006-3-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230518150250.1121006-1-rf@opensource.cirrus.com> References: <20230518150250.1121006-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: HeMTtZiSETusfRvKc2rfNgNW62xe9dvb X-Proofpoint-ORIG-GUID: HeMTtZiSETusfRvKc2rfNgNW62xe9dvb X-Proofpoint-Spam-Reason: safe Message-ID-Hash: HJO3AL6UYHFKZNNIU5NXJ5EEH4BU245Q X-Message-ID-Hash: HJO3AL6UYHFKZNNIU5NXJ5EEH4BU245Q X-MailFrom: prvs=05023014f4=rf@opensource.cirrus.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: From: Simon Trimmer SoundWire bus accesses must be performed under the guard of a pm_runtime request, in this case the write was being performed just after the request had been put() and so the bus could not be guaranteed to be available. Signed-off-by: Simon Trimmer Signed-off-by: Richard Fitzgerald --- sound/soc/codecs/cs35l56.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index 906aa416879b..255c442308f2 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -904,15 +904,15 @@ static void cs35l56_dsp_work(struct work_struct *work) err_unlock: mutex_unlock(&cs35l56->irq_lock); err: - pm_runtime_mark_last_busy(cs35l56->dev); - pm_runtime_put_autosuspend(cs35l56->dev); - /* Re-enable SoundWire interrupts */ if (cs35l56->sdw_peripheral) { cs35l56->sdw_irq_no_unmask = false; sdw_write_no_pm(cs35l56->sdw_peripheral, CS35L56_SDW_GEN_INT_MASK_1, CS35L56_SDW_INT_MASK_CODEC_IRQ); } + + pm_runtime_mark_last_busy(cs35l56->dev); + pm_runtime_put_autosuspend(cs35l56->dev); } static int cs35l56_component_probe(struct snd_soc_component *component) From patchwork Thu May 18 15:02:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 683395 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 9772DC7EE23 for ; Thu, 18 May 2023 15:05:14 +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 59C876C0; Thu, 18 May 2023 17:04:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 59C876C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1684422312; bh=ziJ6fK5xKCWmSOaqgMNufdY1/tOLco89X22UsmUfUPg=; 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=a678+UXSFymN2doJcHypZJS6tabMwm/HDRo4LlB6KO9mW81dGbHfpZdTcZxOzL9Fs Q/GaCfX88hxX2fPWiLgQA/X2zp2X8n8Ojc/x5H3Ah6G4T/aV+TEWgnfisT/yeGOAaD YajqufLEX2zRD+IcF35GmHr1FPg8rB1Wm4XnEH28= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B0E44F80580; Thu, 18 May 2023 17:03: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 506BBF8057B; Thu, 18 May 2023 17:03:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D82B2F80552; Thu, 18 May 2023 17:03:03 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 78B4DF8016D for ; Thu, 18 May 2023 17:02:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 78B4DF8016D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=fMuF/p+i Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34IBl9Gn018534; Thu, 18 May 2023 10:02:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=if4MXmKxN3SfnqhLmxf1Quq7P4ZDofQ6rP+3VpvG0WQ=; b=fMuF/p+iARjNTSTcJNbumJrZX4/Bo/+ubBbiypjCMgeGgxZ+rFGbbG94Jzbb03IjUDBe h8EXrmKyfb54gTQl9le+5vihXtCUhACMUNuQAwVLpMCdL1xS08Bzb/QVisj+SQPxjtdI QRuwhhD7icwuRG+YjDtcZXKIBo4YIs+XEoy9xW8rK4s/VRIQ//FOvkbMoMWgILRH5Tqb eQelmCR1urApm/eGpmO7fqN9yYuZZNQmZw6pfzMjqjA4XG3zj/2KFRQ3bhTe9Qho5yhp uJiCTTVyOeUXNKbbLcKOxJoXVE5dTrp0AID9GfPO13uK7UnQiOVCqoPMJc5HNVDKLtKL qQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3qngq1ghum-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 10:02:53 -0500 Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 18 May 2023 10:02:50 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 18 May 2023 10:02:50 -0500 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 460DD15B7; Thu, 18 May 2023 15:02:50 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , Simon Trimmer , Richard Fitzgerald Subject: [PATCH 3/3] ASoC: cs35l56: In secure mode skip SHUTDOWN and RESET around fw download Date: Thu, 18 May 2023 16:02:50 +0100 Message-ID: <20230518150250.1121006-4-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230518150250.1121006-1-rf@opensource.cirrus.com> References: <20230518150250.1121006-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: jvAwPQdb-Y1Fr8jO6yD6teUP0pedceX6 X-Proofpoint-ORIG-GUID: jvAwPQdb-Y1Fr8jO6yD6teUP0pedceX6 X-Proofpoint-Spam-Reason: safe Message-ID-Hash: ZKIQSAHQDXVUIDT4K6SBR7SDGH3DNTAA X-Message-ID-Hash: ZKIQSAHQDXVUIDT4K6SBR7SDGH3DNTAA X-MailFrom: prvs=05023014f4=rf@opensource.cirrus.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: From: Simon Trimmer If the device is in secure mode it's unnecessary to send a SHUTDOWN and SYSTEM_RESET around the firmware download. It could only be patching insecure tunings. A tuning patch doesn't need a SHUTDOWN and only needs a REINIT afterwards. This will reduce the overhead of exiting system suspend in secure mode. Signed-off-by: Simon Trimmer Signed-off-by: Richard Fitzgerald --- include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56.c | 47 ++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h index 002042b1c73c..1f9713d7ca76 100644 --- a/include/sound/cs35l56.h +++ b/include/sound/cs35l56.h @@ -223,6 +223,7 @@ #define CS35L56_MBOX_CMD_AUDIO_PLAY 0x0B000001 #define CS35L56_MBOX_CMD_AUDIO_PAUSE 0x0B000002 +#define CS35L56_MBOX_CMD_AUDIO_REINIT 0x0B000003 #define CS35L56_MBOX_CMD_HIBERNATE_NOW 0x02000001 #define CS35L56_MBOX_CMD_WAKEUP 0x02000002 #define CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE 0x02000003 diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index 255c442308f2..3c07bd1e959e 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -825,19 +825,23 @@ static void cs35l56_system_reset(struct cs35l56_private *cs35l56) regcache_cache_only(cs35l56->regmap, false); } -static void cs35l56_dsp_work(struct work_struct *work) +static void cs35l56_secure_patch(struct cs35l56_private *cs35l56) +{ + int ret; + + /* Use wm_adsp to load and apply the firmware patch and coefficient files */ + ret = wm_adsp_power_up(&cs35l56->dsp); + if (ret) + dev_dbg(cs35l56->dev, "%s: wm_adsp_power_up ret %d\n", __func__, ret); + else + cs35l56_mbox_send(cs35l56, CS35L56_MBOX_CMD_AUDIO_REINIT); +} + +static void cs35l56_patch(struct cs35l56_private *cs35l56) { - struct cs35l56_private *cs35l56 = container_of(work, - struct cs35l56_private, - dsp_work); unsigned int reg; unsigned int val; - int ret = 0; - - if (!cs35l56->init_done) - return; - - pm_runtime_get_sync(cs35l56->dev); + int ret; /* * Disable SoundWire interrupts to prevent race with IRQ work. @@ -910,6 +914,29 @@ static void cs35l56_dsp_work(struct work_struct *work) sdw_write_no_pm(cs35l56->sdw_peripheral, CS35L56_SDW_GEN_INT_MASK_1, CS35L56_SDW_INT_MASK_CODEC_IRQ); } +} + +static void cs35l56_dsp_work(struct work_struct *work) +{ + struct cs35l56_private *cs35l56 = container_of(work, + struct cs35l56_private, + dsp_work); + + if (!cs35l56->init_done) + return; + + pm_runtime_get_sync(cs35l56->dev); + + /* + * When the device is running in secure mode the firmware files can + * only contain insecure tunings and therefore we do not need to + * shutdown the firmware to apply them and can use the lower cost + * reinit sequence instead. + */ + if (cs35l56->secured) + cs35l56_secure_patch(cs35l56); + else + cs35l56_patch(cs35l56); pm_runtime_mark_last_busy(cs35l56->dev); pm_runtime_put_autosuspend(cs35l56->dev);