From patchwork Mon Jul 31 16:57:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335073 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 D0E9CC001DC for ; Mon, 31 Jul 2023 16:59:27 +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 7CEA8836; Mon, 31 Jul 2023 18:58:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7CEA8836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822765; bh=K/EwlJSno/B6oU05nONp0qDj4l/4FXlHsv3sVYQrheg=; 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=jh1fJJqpKdtGtDpOLGpq5zdHd5G66smFD7CZc0h2Hh2dSrjdkF5i9AfaPFhavx+8A 0VTRhWg+9CzWpu2EkX9m8agAlV6hkWEq+ps/56yRPjpSESG09w7eHu80fsbgUH21c+ ND4WDUmOGfa7eIG0mLeJesP8H9nXc/Qj3JJnlo+g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E38AFF80558; Mon, 31 Jul 2023 18:57:47 +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 4353FF8055C; Mon, 31 Jul 2023 18:57:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A8731F80544; Mon, 31 Jul 2023 18:57:41 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 E01C7F8015B for ; Mon, 31 Jul 2023 18:57:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E01C7F8015B 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=WejIqFMA Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJJ017071; Mon, 31 Jul 2023 11:57:32 -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=7tXYtuHPujqaVHNe1XUnRwtzdST6xCvteK767YL3cjc=; b= WejIqFMAROEQlAOXVyi1lqXeaNMgfmBqJXKhpNwtVcwr4zPSjSjQ6xO8PsyeHmNl +SG5J4Ux85UvpCZRHN8OL6Di8RufFUclI7+3k219Mjhl3gLNEOT7sD7qIze9QFMg A+ciAKy/vMbnKLTvWDNFks2Cf2t0XFRJgpfbNvJUcRbQL/wMgXNWyZzItTt6kVZz DWQ4wF0oR4i1yzfAWP15sB8Ul59vSZawA0/4ZSAzRdeglm7rjjpNqtWEMbyaav0t TZNkZ2PoLYnKBBMR8TpTQxqceGfXs5NOKt+kph/JNARNMgheJRQWl/Bk3aAYLCis gWEyjlXbYSJs01U5i0dGIg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:32 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:30 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:30 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 013A7475; Mon, 31 Jul 2023 16:57:29 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 1/9] ALSA: hda/cs35l56: Complete firmware reboot before calling cs_dsp_run() Date: Mon, 31 Jul 2023 17:57:18 +0100 Message-ID: <20230731165726.7940-2-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: 25uoaoNGsvz6CN9TtIiilzY2EMDVF4nX X-Proofpoint-ORIG-GUID: 25uoaoNGsvz6CN9TtIiilzY2EMDVF4nX X-Proofpoint-Spam-Reason: safe Message-ID-Hash: HV33TYWIGBKORWHQ2J3FTYVCALUMVW3H X-Message-ID-Hash: HV33TYWIGBKORWHQ2J3FTYVCALUMVW3H X-MailFrom: prvs=3576b45159=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: Move the call to cs_dsp_run() in cs35l56_hda_fw_load() so that it is after the CS35L56 has been reset/reinit'd and the regmap cache has been synced. cs_dsp_run() syncs up ALSA control cache values with the DSP memory so this must not be done until the firmware has reinitialized. Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index 4c3279f61b94..c3acda2daeeb 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -562,12 +562,6 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) if (coeff_filename) dev_dbg(cs35l56->base.dev, "Loaded Coefficients: %s\n", coeff_filename); - ret = cs_dsp_run(&cs35l56->cs_dsp); - if (ret) { - dev_dbg(cs35l56->base.dev, "%s: cs_dsp_run ret %d\n", __func__, ret); - goto err; - } - if (cs35l56->base.secured) { ret = cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_REINIT); if (ret) @@ -591,6 +585,11 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) regmap_clear_bits(cs35l56->base.regmap, CS35L56_PROTECTION_STATUS, CS35L56_FIRMWARE_MISSING); cs35l56->base.fw_patched = true; + + ret = cs_dsp_run(&cs35l56->cs_dsp); + if (ret) + dev_dbg(cs35l56->base.dev, "%s: cs_dsp_run ret %d\n", __func__, ret); + err: pm_runtime_put(cs35l56->base.dev); mutex_unlock(&cs35l56->base.irq_lock); From patchwork Mon Jul 31 16:57:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335076 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 99A23C001DC for ; Mon, 31 Jul 2023 17:00: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 74E11828; Mon, 31 Jul 2023 18:59:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 74E11828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822816; bh=DuMMA4WT1tv4Jl18z/UfV1EBLNhUtnYsMQ9eAdW9cP8=; 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=Gj9Mnx01ysYnZN5P3uL7o3VoelvHsIpni2/RcJnNtrACKzl7K5R9KST7WhRR28ugz VJF503llRtHzucC2RiuEShxWz2WM3T5rpZ4jAImuFOlPkdZUovm076NWyS19aqCiG2 NZkeJXhbKv0eUnFwXfP36qWDmkG3rs2jHTF9LG8s= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8BAD2F805B0; Mon, 31 Jul 2023 18:57:56 +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 D9A95F80588; Mon, 31 Jul 2023 18:57:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 401EEF8025A; Mon, 31 Jul 2023 18:57:46 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 34633F80163 for ; Mon, 31 Jul 2023 18:57:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 34633F80163 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=A9dafwKH Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJK017071; Mon, 31 Jul 2023 11:57:33 -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=COsUQaN/ErqOVMioTgwxTBAOGWPa/9gsBLSsEI2cT2A=; b= A9dafwKHWVwmWHxQyv/TdC6e8R+dzdJDt49STc7fSw2q/XQXVO0ECaFOx4SKySmm M1yozutFbDSUsLi9XxSsTGBvnctBmNoS9i3aBGhjjRsGQ3BSxDqtE6ixaZ37cBAN lk5Rdy+kXQVor6332GqARJiJ0fVEoWs8oxoDmYcG+t9GnvP9Yw3R3n9DICqS5cIZ H2NY3jgc5JRe89waXHeUuEWjbvpkqBelva0rC2bw2AtQqnKURdsyZnDg0PCz4Z4l fyPgn3AbVSYFgzIH11p7ew+bnrCKEsGFyNGLUvptymCEFjAqebh+pTcqD9G6d+cr OQ95okiKLwocbSmCvdLisQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:33 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:30 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:30 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 55A3D45D; Mon, 31 Jul 2023 16:57:30 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 2/9] ALSA: hda/cs35l56: Do not mark cache dirty after REINIT Date: Mon, 31 Jul 2023 17:57:19 +0100 Message-ID: <20230731165726.7940-3-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: kFB1f_oNiNMpBEAsCAcGXST23BTvhCOS X-Proofpoint-ORIG-GUID: kFB1f_oNiNMpBEAsCAcGXST23BTvhCOS X-Proofpoint-Spam-Reason: safe Message-ID-Hash: HLVNFMRTQ2AB744M6FAFK4FES7NBRTUN X-Message-ID-Hash: HLVNFMRTQ2AB744M6FAFK4FES7NBRTUN X-MailFrom: prvs=3576b45159=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: Only call regcache_mark_dirty() in cs35l56_hda_fw_load() if the CS35L56 was SYSTEM_RESET. recache_mark_dirty() changes the behaviour of regcache_sync() to write out cache values that are not the default value, and skip cache values that are the default. AUDIO_REINIT does not reset the registers. regcache_mark_dirty() after AUDIO_REINIT could cause the regcache_sync() to sync registers incorrectly because it will assume that all registers have reset to default. Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index c3acda2daeeb..fda716e0db09 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -569,6 +569,7 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) } else { /* Reset the device and wait for it to boot */ cs35l56_system_reset(&cs35l56->base, false); + regcache_mark_dirty(cs35l56->base.regmap); ret = cs35l56_wait_for_firmware_boot(&cs35l56->base); if (ret) goto err; @@ -579,7 +580,6 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) if (ret) goto err; - regcache_mark_dirty(cs35l56->base.regmap); regcache_sync(cs35l56->base.regmap); regmap_clear_bits(cs35l56->base.regmap, CS35L56_PROTECTION_STATUS, From patchwork Mon Jul 31 16:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335075 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 D6BBEC001DE for ; Mon, 31 Jul 2023 16:59: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 13AA2850; Mon, 31 Jul 2023 18:59:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 13AA2850 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822791; bh=IyJfsigd4+829FJmgHuDda4IWBtjDOLWqBUgN4NP6VE=; 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=aJU/7Oq07rUmsH23jgdWa5qbkt8CD7Ax5gJRpk4ro1BMapAV43sGidCS8yiYVKcKD Mf+uHDLX0rPPkn+4sC4AK8MnJuvjnv+TbalLtsIvR19kNz9mC1EWEPm0BDuf/b0FOz wNZbcdahK2nB/zFDCWRhgoytzJ2pTvVFThetY4z8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 35241F805A8; Mon, 31 Jul 2023 18:57:53 +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 198F7F80587; Mon, 31 Jul 2023 18:57:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8E6F0F80551; Mon, 31 Jul 2023 18:57:44 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 0555EF8025A for ; Mon, 31 Jul 2023 18:57:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0555EF8025A 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=dR3leKCT Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJL017071; Mon, 31 Jul 2023 11:57:34 -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=AXY+yhAp337Xwcjj3zvet6CtUqG0Njj546QB9XWh5P4=; b= dR3leKCTZAVrxwO0wPK+UWwW3uv94qwZytByxI1VNDrgjUIld+LaOg3VSFvq2hEY gsi9PJRFqeakomq5K22j6ALxETFbYrdnfmRu+KoITHpQQPyX1zL373aWg1GkGwgv 0SMnFX2tNyPOY+gdVS2cpA3IHqtfp8MVt8aVvoUuzSgUL1+w4dhg3QqQnIwq36+G MXXkAf+0nckqRsfYqbrpj3J9sevjUTAgzEDKbwFuld6TEoHkvFiD0JpJ9YFabMFF uymVysTy77zAdAtemnmO/C4UiaFjiQFiN6aCpSpdmnkLuUySKhHi/fudSe3zEKsr gmOUdjQHVcKTGSPrzh+GpA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:33 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:30 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:30 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id AEBFF11CA; Mon, 31 Jul 2023 16:57:30 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 3/9] ALSA: hda/cs35l56: Call cs_dsp_power_down() before reloading firmware Date: Mon, 31 Jul 2023 17:57:20 +0100 Message-ID: <20230731165726.7940-4-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: OyU2U_LcCaKSimPOtdrXDTdjC5YFF-F0 X-Proofpoint-ORIG-GUID: OyU2U_LcCaKSimPOtdrXDTdjC5YFF-F0 X-Proofpoint-Spam-Reason: safe Message-ID-Hash: N52UZECMUGMOIJDNSLI5VBK2KIU5JAFF X-Message-ID-Hash: N52UZECMUGMOIJDNSLI5VBK2KIU5JAFF X-MailFrom: prvs=3576b45159=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: When firmware is reloaded after a system resume cs_dsp_power_down() should be called before calling cs_dsp_power_up(). The fw_patched flag should also be cleared and only set again if the firmware download succeeded. Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index fda716e0db09..b6b8cb21da75 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -527,6 +527,12 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) char *wmfw_filename = NULL; int ret = 0; + /* Prepare for a new DSP power-up */ + if (cs35l56->base.fw_patched) + cs_dsp_power_down(&cs35l56->cs_dsp); + + cs35l56->base.fw_patched = false; + cs35l56_hda_request_firmware_files(cs35l56, &wmfw_firmware, &wmfw_filename, &coeff_firmware, &coeff_filename); From patchwork Mon Jul 31 16:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335080 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 2D9BBC001DC for ; Mon, 31 Jul 2023 17:01:25 +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 6CB88823; Mon, 31 Jul 2023 19:00:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6CB88823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822883; bh=+6/F9BvjOsZKrvTIMEr/XFkR0SJRrjtLMPXlNYyvXgs=; 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=IP4aPkgh71Wp3nciSoP2YUWVMEP9Jnr6RezyvylQlxU1pUvQJslgQv6COGjMJFRHX QLCmKs4NFqtj5QdtB+puBdrYBjReN0+ozIBVc0/f4pSz/KYSNugiYNw+UqzW9pDy8l 15A5H9RddLecbKcWC/6H/GOl8KwBlUMU2ej0DCuo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B2EDCF805E6; Mon, 31 Jul 2023 18:58:33 +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 4B021F805DF; Mon, 31 Jul 2023 18:58:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 83A66F805D3; Mon, 31 Jul 2023 18:58:27 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 203EAF80425 for ; Mon, 31 Jul 2023 18:57:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 203EAF80425 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=mpl4OXY9 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJM017071; Mon, 31 Jul 2023 11:57:35 -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=B1C4dVatnD+uffpp5pD3N1ldXPScWgM6kyZfR+HGa+s=; b= mpl4OXY9B0oU0cjBazfalZ/A8CoYebXC1RbxoQ98HdDRxW5Oti2AyHxabXZzgYz4 gHrMP33fud0BN+gDsiTBq0XsNQ4Ci3osTqWPOQzbsVGI60xaKQ8fZ6HApWxTVqhl xZwbUPDZ0Ouv+iZu73zCYrxtiDUrHi0yhcf21rLX+IOqTE8afTIjQGFlA9/s2mVv Xfx6/bD7IoD5J35d5arsGqwHHpMHuAwqFiEX/W+TAVeraaCJDsBwrlgbULhVKUkC iTmuCg/NXYRNJk2jrlhJ5fMm3RZi857a7B/C7ZW/8ZJMKGPB/Ie/yO1owDl5S9OP bqsCkGaAv64jmitNjRlmXA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:35 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:31 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:31 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 145CB475; Mon, 31 Jul 2023 16:57:31 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 4/9] ALSA: hda/cs35l56: Always power-up and start cs_dsp Date: Mon, 31 Jul 2023 17:57:21 +0100 Message-ID: <20230731165726.7940-5-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: WNdFe9nyl-Xi5Oa92oRKJiEztYsxl5-p X-Proofpoint-ORIG-GUID: WNdFe9nyl-Xi5Oa92oRKJiEztYsxl5-p X-Proofpoint-Spam-Reason: safe Message-ID-Hash: LKZR34M4S4N325JMPK4BKECSAZ73OO7U X-Message-ID-Hash: LKZR34M4S4N325JMPK4BKECSAZ73OO7U X-MailFrom: prvs=3576b45159=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: Always call cs_dsp_power_up() and cs_dsp_run() in cs35l56_hda_fw_load() even if there aren't any firmware files to download. Also, if there aren't any firmware files to download there is no need to do cs35l56_firmware_shutdown() and cs35l56_system_reset(). If there aren't any firmware files there's no need to write anything to the CS35L56 registers to make it work - it will already be running the ROM firmware. So it's not strictly necessary to start cs_dsp. But it's perfectly ok to call cs_dsp_power_up() and cs_dsp_run() without downloading any firmware. This avoids having to support a state where audio is playing but cs_dsp is not running. Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index b6b8cb21da75..2870f82bfa45 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -536,10 +536,6 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) cs35l56_hda_request_firmware_files(cs35l56, &wmfw_firmware, &wmfw_filename, &coeff_firmware, &coeff_filename); - /* Nothing to do - no firmware files were found to download */ - if (!wmfw_filename && !coeff_filename) - return 0; - mutex_lock(&cs35l56->base.irq_lock); pm_runtime_get_sync(cs35l56->base.dev); @@ -549,7 +545,7 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) * shutdown the firmware to apply them and can use the lower cost * reinit sequence instead. */ - if (!cs35l56->base.secured) { + if (!cs35l56->base.secured && (wmfw_firmware || coeff_firmware)) { ret = cs35l56_firmware_shutdown(&cs35l56->base); if (ret) goto err; @@ -572,8 +568,8 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) ret = cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_REINIT); if (ret) goto err; - } else { - /* Reset the device and wait for it to boot */ + } else if (wmfw_firmware || coeff_firmware) { + /* If we downloaded firmware, reset the device and wait for it to boot */ cs35l56_system_reset(&cs35l56->base, false); regcache_mark_dirty(cs35l56->base.regmap); ret = cs35l56_wait_for_firmware_boot(&cs35l56->base); From patchwork Mon Jul 31 16:57:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335074 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 8B586C001DC for ; Mon, 31 Jul 2023 16:59: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 600D784A; Mon, 31 Jul 2023 18:58:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 600D784A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822770; bh=Jb6aLZPK4CwvetGQrTqSldlZPCKgqDm0ez1lpYXX2yE=; 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=VDBe19SWMgfZL6n3N6VbvkunWCGFlw/0Grkp5CLc4QlJKuBY5Kb+jWtsNqSPcxeQh 5SzzDOvD6K4pcXkxDiDgrFlCliwT4zLpMXpx8N6snA0BLAU39d7wbq6GxoaDIy92WL eQWAS0Wg7e5o1KyTZdr02RvVmbYRKPBbbuBA8w0g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 001DCF8056F; Mon, 31 Jul 2023 18:57:49 +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 150BDF8056F; Mon, 31 Jul 2023 18:57:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E6AFFF80544; Mon, 31 Jul 2023 18:57:42 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 97A5CF8016D for ; Mon, 31 Jul 2023 18:57:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 97A5CF8016D 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=pgWhXHho Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36VDp2Y2022362; Mon, 31 Jul 2023 11:57:34 -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=uIxcNFIlhCWl+DHFeYj1CnUBImgYJ6FmRvXCKssmj0Y=; b= pgWhXHhoM571lbT5+7eFEG99yK8Y0Zy/5q+7ey11g/2RUMB61bfa+ZPtP/QZQFgj 4qOVAYm0ddVNUMwRT+qy3pnq3eKqSEK/twLAKrBD3y+OqBitRA/Ln6NT2/m2URPq 82iucUFPpcWd6v2EO1TRKcOfEgnQdXFVzcg2IxaveqeGpdtFrgahQ+2ygmQ/mU/b lYPxP0OPA5K3Zz8ZcWRc/R9ITGfrSECvXkNxzn8jWq50qmY8PVMKyxsfaNLLalPk oCPwI/fCNefjCz4Cvv7jO5XafoWSREB3BI8xrY1W4CAIHj3YkMku0Pt1g9Uo5yCi Up6yWGbLEeXqLSYqGzEksw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg46-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:33 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) 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.30; Mon, 31 Jul 2023 17:57:31 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:31 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 70B6311D3; Mon, 31 Jul 2023 16:57:31 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 5/9] ALSA: hda/cs35l56: Call cs_dsp_power_down() before calling cs_dsp_remove() Date: Mon, 31 Jul 2023 17:57:22 +0100 Message-ID: <20230731165726.7940-6-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: GwJk94tO8R7z1VWfOhv5pfJ5SXsoxW-V X-Proofpoint-ORIG-GUID: GwJk94tO8R7z1VWfOhv5pfJ5SXsoxW-V X-Proofpoint-Spam-Reason: safe Message-ID-Hash: A2CJTOJOZN6CN6EEIU47MIBUA5PIZGI7 X-Message-ID-Hash: A2CJTOJOZN6CN6EEIU47MIBUA5PIZGI7 X-MailFrom: prvs=3576b45159=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: In cs35l56_hda_unbind() cs_dsp_power_down() must be called to cleanup before calling cs_dsp_remove cs_dsp_remove(). Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index 2870f82bfa45..e8c41a4a0c40 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -649,6 +649,9 @@ static void cs35l56_hda_unbind(struct device *dev, struct device *master, void * debugfs_remove_recursive(cs35l56->debugfs_root); #endif + if (cs35l56->base.fw_patched) + cs_dsp_power_down(&cs35l56->cs_dsp); + cs_dsp_remove(&cs35l56->cs_dsp); if (comps[cs35l56->index].dev == dev) From patchwork Mon Jul 31 16:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335081 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 E7A84C001DC for ; Mon, 31 Jul 2023 17:01: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 94DA1AE8; Mon, 31 Jul 2023 19:00:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 94DA1AE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822901; bh=u87Pr1O7Hl4rKiv7kc2px8tp6+12lmYBZXtNJK/4A1A=; 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=i5Ed6QrxhDI1qOBAnGuzLf/rvM5+sag7KMRu1DvkRKUDOHOcmy9GKJRtDeEsFtLhs 1B6E9LpZKr0OYVqieOJ4nh9zlPdmX6sKuNakaaTD47RaA0LnF3jiuNk0NkSt5hMo04 iOLnhGMHbHIAbymwZZX6captcRcdcSjmmm+BF9WA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 05B1BF80567; Mon, 31 Jul 2023 18:58:36 +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 91D96F8053B; Mon, 31 Jul 2023 18:58:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8F7BCF80553; Mon, 31 Jul 2023 18:58:29 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 31CFFF801D5 for ; Mon, 31 Jul 2023 18:57:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 31CFFF801D5 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=oLjutGfm Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJN017071; Mon, 31 Jul 2023 11:57:36 -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=R7ZjjUfa6yJOj++gCN2+TabvdRaWxzaSedPyz17+U0k=; b= oLjutGfmin0E7RLlySjbfdbDa+44PhaRSXLZYdAAMUmSF/GvUGRRZHgdsOCafOCl Ejgrk3ZW+tSrGQtFR58CvV4+cRNPxDInLVviCiSoxB1yS0RaAikpyq6nrjnpChj9 l0DWmBOPSRd3QZGBxkEbeYtjICZRznrlzTtnwiVLUzendX95Mdrkm7eVrOcLUI3N 2nrSFdKBzm5MjPIbPoLkw+AOaGYkUPz+dvZSI8fOgcPUQCuzH9gOuhASUcLLlCte kUJQ5+LnjPaIz/UPrCiA3ODrfYWJ637+Qsbl97SEFUZNf07e0ftbazJDSeEoXYkt keMuQKhUl435GnYzWxW9MQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:35 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:32 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:32 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id CEA4E45D; Mon, 31 Jul 2023 16:57:31 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 6/9] ALSA: hda/cs35l56: cs_dsp_power_down() on cs35l56_hda_fw_load() error path Date: Mon, 31 Jul 2023 17:57:23 +0100 Message-ID: <20230731165726.7940-7-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: bB_xhwoyVLFnhBvAfJRqahOqp3F2rvgI X-Proofpoint-ORIG-GUID: bB_xhwoyVLFnhBvAfJRqahOqp3F2rvgI X-Proofpoint-Spam-Reason: safe Message-ID-Hash: YGRZMQ3UPIWXQPA54GVZ53Z5OH4SOOGO X-Message-ID-Hash: YGRZMQ3UPIWXQPA54GVZ53Z5OH4SOOGO X-MailFrom: prvs=3576b45159=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: If cs35l56_hda_fw_load() successfully called cs_dsp_power_up() the error path must balance that with a call to cs_dsp_power_down(). Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index e8c41a4a0c40..803fa2da9ea4 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -567,20 +567,20 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) if (cs35l56->base.secured) { ret = cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_REINIT); if (ret) - goto err; + goto err_powered_up; } else if (wmfw_firmware || coeff_firmware) { /* If we downloaded firmware, reset the device and wait for it to boot */ cs35l56_system_reset(&cs35l56->base, false); regcache_mark_dirty(cs35l56->base.regmap); ret = cs35l56_wait_for_firmware_boot(&cs35l56->base); if (ret) - goto err; + goto err_powered_up; } /* Disable auto-hibernate so that runtime_pm has control */ ret = cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE); if (ret) - goto err; + goto err_powered_up; regcache_sync(cs35l56->base.regmap); @@ -592,6 +592,9 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) if (ret) dev_dbg(cs35l56->base.dev, "%s: cs_dsp_run ret %d\n", __func__, ret); +err_powered_up: + if (!cs35l56->base.fw_patched) + cs_dsp_power_down(&cs35l56->cs_dsp); err: pm_runtime_put(cs35l56->base.dev); mutex_unlock(&cs35l56->base.irq_lock); From patchwork Mon Jul 31 16:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335079 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 66958C001E0 for ; Mon, 31 Jul 2023 17:01:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8A8BD832; Mon, 31 Jul 2023 19:00:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8A8BD832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822871; bh=HvFBGCFP+p8mCT+m3rY5jD+yRPApp9InbENtx358KpQ=; 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=FSsfO6rw60uaf3TCQaW6CCAjmUBjyvLBwu2/6RgHEhM7rCmMCHpOD4ue3tN85O9t7 NWlyjWVrxs9Mo0MfIyNVLYOAayGQBQeI4XvZEUTKwziGtMy6oZwxdACtH962xM9REO W+8mx7WXCdWeYFvtiNIZVCWvAsuW9qynjZowrVl0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 56F0DF805D4; Mon, 31 Jul 2023 18:58: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 AC953F80149; Mon, 31 Jul 2023 18:58:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 21222F805D4; Mon, 31 Jul 2023 18:58:26 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 F0D9CF80149 for ; Mon, 31 Jul 2023 18:57:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F0D9CF80149 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=GXj7G97G Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJO017071; Mon, 31 Jul 2023 11:57:37 -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=DFQy9O4rVl1fkUzjYQguq6VsjkwR+stb5618BZFSP9g=; b= GXj7G97GLpBXmDuPdeCnNCloJ7nG4k+fnNYQtwHw8TdnH2/uXLD9hsZHSGB53SWa fR20aHMQoV6yrS4l7oJD9HnPlSGGOngmjg8p1rOfmBadxWBLxvFizVqBR4UzHQYF qC5CEAYz+0AuMSMwfKmTjnKAxk2aJpUSeog8CFY1NUC97OLnHzA0hgNjQqSz4WjQ nvzlcMcEMZHyXiQvEzuup0ypYx8SfBFdy9mQmBYQqWoMdd6sK6Q3IB1LVI90WJdI hJjUmLYAM1dtaPYyzgMZw5vd8Oe/m4LQgDmU6IdcL4NmPuCFcoaqoqwZWNVENpm1 xLh/DA8ZTOWNl5/uLIWXag== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:36 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:32 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:32 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 3C28C475; Mon, 31 Jul 2023 16:57:32 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 7/9] ALSA: hda/cs35l56: Do not download firmware over existing RAM firmware Date: Mon, 31 Jul 2023 17:57:24 +0100 Message-ID: <20230731165726.7940-8-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: VQTKml7zteD00oUvbI_K6i472yRGO6xo X-Proofpoint-ORIG-GUID: VQTKml7zteD00oUvbI_K6i472yRGO6xo X-Proofpoint-Spam-Reason: safe Message-ID-Hash: 4MTVB4ASC5IHNLUDSYRECCTZJVDHNN4I X-Message-ID-Hash: 4MTVB4ASC5IHNLUDSYRECCTZJVDHNN4I X-MailFrom: prvs=3576b45159=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: A RAM firmware can only be downloaded if the CS35L56 is currently running from ROM firmware. The driver must not try to overwrite the RAM if the CS35L56 is already running from that RAM. Firmware can be downloaded in these two cases: - The BIOS has already patched the firmware (secured mode). In this case the firmware files will only contain tunings that are safe to overwrite. - The CS35L56 is running the built-in ROM firmware. After a RAM firmware has been downloaded it can only be cleared by hard resetting CS35L56. Some systems only hard-reset during power-on and do not give the driver control of hard reset. Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index 803fa2da9ea4..8f1665d38c92 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -525,6 +525,7 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) const struct firmware *wmfw_firmware = NULL; char *coeff_filename = NULL; char *wmfw_filename = NULL; + unsigned int firmware_missing; int ret = 0; /* Prepare for a new DSP power-up */ @@ -533,11 +534,28 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) cs35l56->base.fw_patched = false; - cs35l56_hda_request_firmware_files(cs35l56, &wmfw_firmware, &wmfw_filename, - &coeff_firmware, &coeff_filename); + pm_runtime_get_sync(cs35l56->base.dev); + + ret = regmap_read(cs35l56->base.regmap, CS35L56_PROTECTION_STATUS, &firmware_missing); + if (ret) { + dev_err(cs35l56->base.dev, "Failed to read PROTECTION_STATUS: %d\n", ret); + goto err_pm_put; + } + + firmware_missing &= CS35L56_FIRMWARE_MISSING; + + /* + * Firmware can only be downloaded if the CS35L56 is secured or is + * running from the built-in ROM. If it is secured the BIOS will have + * downloaded firmware, and the wmfw/bin files will only contain + * tunings that are safe to download with the firmware running. + */ + if (cs35l56->base.secured || firmware_missing) { + cs35l56_hda_request_firmware_files(cs35l56, &wmfw_firmware, &wmfw_filename, + &coeff_firmware, &coeff_filename); + } mutex_lock(&cs35l56->base.irq_lock); - pm_runtime_get_sync(cs35l56->base.dev); /* * When the device is running in secure mode the firmware files can @@ -596,11 +614,12 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) if (!cs35l56->base.fw_patched) cs_dsp_power_down(&cs35l56->cs_dsp); err: - pm_runtime_put(cs35l56->base.dev); mutex_unlock(&cs35l56->base.irq_lock); cs35l56_hda_release_firmware_files(wmfw_firmware, wmfw_filename, coeff_firmware, coeff_filename); +err_pm_put: + pm_runtime_put(cs35l56->base.dev); return ret; } From patchwork Mon Jul 31 16:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335078 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 DB9E8C001DE for ; Mon, 31 Jul 2023 17:00:44 +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 D5D651E7; Mon, 31 Jul 2023 18:59:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D5D651E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822842; bh=bYzEbm5bPLL8j8Wf8WFHKWMSQUTjzMP3pvETvY/mp8s=; 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=nnvDmg9tLtSkNd+/PGst6Mstk3MY6qKIkPtncJCT6LDzDkiENro1TXtULV5+QQcEl GIJW9zkYT6S0WfEZdkqxpsZn02ALMy6puO6P2TC3l12Uk1vgbh2zwZiHC1kRaDjZyc Sad02YIkt7a5woYDwkxxVwM9TCEEw7Ppu5qO9GmY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id DDAAEF805C1; Mon, 31 Jul 2023 18:58:00 +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 75BCFF805C1; Mon, 31 Jul 2023 18:58:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3E74DF8057D; Mon, 31 Jul 2023 18:57:50 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 B792FF80520 for ; Mon, 31 Jul 2023 18:57:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B792FF80520 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=ZCja9J4L Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJP017071; Mon, 31 Jul 2023 11:57:37 -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-type:content-transfer-encoding; s= PODMain02222019; bh=kRJVBU+w59VixbMTEBoEeJzDYTKtrgAfvQuFksOXNx0=; b= ZCja9J4LUmngD4dKpu4UV4uTEGLSZPaw56mjm4odBmi7vOm1ioEEwiOynETFu+L+ 0SsehrOJmveWuyWa3ro9AyZ8Z1hpYmE5Vo+xjjAmaCuKHexCE7yxF2KPXbi17l2A roSDAvemQrBs26Gk8Z4+VizY/fydbkBP6WJ8d6SePhFCRAACPlaP2ZDsD1kTak3r x3/aBrfDLzJHmnPF6aazYANOsjyB56u3zJnWdM57mmtDXqOCc0OFYdilYTPra8xu FkCTztR/+5D2yr+nK+P+iEKbkdxN00uOnWvZlaT8IJ3VXyBgW3A6VkTdhy8EWcd5 FqgZWrdXyUD0LME0rLBPhg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:37 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:32 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:32 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 9976B11D3; Mon, 31 Jul 2023 16:57:32 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 8/9] ALSA: hda/cs35l56: Fail if .bin not found and firmware not patched Date: Mon, 31 Jul 2023 17:57:25 +0100 Message-ID: <20230731165726.7940-9-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: KD3mdf9fl-XadVx_X5Byy68JUQFon4mY X-Proofpoint-ORIG-GUID: KD3mdf9fl-XadVx_X5Byy68JUQFon4mY X-Proofpoint-Spam-Reason: safe Message-ID-Hash: MCVILGKPMSBDFBAPQS5JECJETDA2WFVJ X-Message-ID-Hash: MCVILGKPMSBDFBAPQS5JECJETDA2WFVJ X-MailFrom: prvs=3576b45159=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: A tuning patch is always needed to enable the ASP audio port. If the BIOS did not patch the firmware, then it is mandatory to have a .bin file. Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index 8f1665d38c92..004740509dbd 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -555,6 +555,16 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) &coeff_firmware, &coeff_filename); } + /* + * If the BIOS didn't patch the firmware a bin file is mandatory to + * enable the ASPĀ· + */ + if (!coeff_firmware && firmware_missing) { + dev_err(cs35l56->base.dev, ".bin file required but not found\n"); + ret = -ENOENT; + goto err_fw_release; + } + mutex_lock(&cs35l56->base.irq_lock); /* @@ -615,7 +625,7 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) cs_dsp_power_down(&cs35l56->cs_dsp); err: mutex_unlock(&cs35l56->base.irq_lock); - +err_fw_release: cs35l56_hda_release_firmware_files(wmfw_firmware, wmfw_filename, coeff_firmware, coeff_filename); err_pm_put: From patchwork Mon Jul 31 16:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13335077 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 5892BC001DC for ; Mon, 31 Jul 2023 17:00:24 +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 47F0D82B; Mon, 31 Jul 2023 18:59:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 47F0D82B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690822822; bh=F027/66LOSCyX4fIfF30zUjYwkx5bzh797Fkq4NM5Hc=; 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=sBUb3GqdpYuIJm+RvgOqExRKxz2B8gO6WVDCoS0P3rFLcS7+oRbxq/pWNFTDp5JY7 0TxaPCo6H9Er1WoxlLWvP7w/ObCLRCQbi3tlP3ke2Ej0QLTg3ffpAuPCQo+7gURqPV PZNRd2oz3vvUI7CC8i9vES2b0v4fs2Vb7ckjEgx4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 68E34F805BE; Mon, 31 Jul 2023 18:57:58 +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 D49EFF805BD; Mon, 31 Jul 2023 18:57:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 66F2BF80568; Mon, 31 Jul 2023 18:57:48 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 2669DF8015B for ; Mon, 31 Jul 2023 18:57:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2669DF8015B 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=U5vUnEnl Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 36V5lNJQ017071; Mon, 31 Jul 2023 11:57:38 -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=RHyGoQzk1u5genvtgwGtlQ8eSjyHd0Gs4TL3IEXqR+A=; b= U5vUnEnlzFelQxYvCphDPRU+MpWHHJHBUlJdiIZ2pV5SukOR1kJsHs7jFzettXd0 JSXzGjb69lZ1F4B8ry1mCQjUVDa1kOTJNYR/avSjGwbziEXkPxa3+Z8SHgJigucC WcMzCVjkINQ6bEYErJXVGoFgNLiNSfr4t2eUA5bC5meCxps3tXPGp7zjp0uAWhjX AdNvcJMxNu8UPe/cn7fKI9RAsywS0RNKIybfyytIq4xUFi5xtpkDYaCIilf7fKVj i8xknsPGQUF2p4CxxAsk9JRzTQHERSGvcJ72CqAV59TX3y682EPBqbYNL4/gKPPJ pZEHXXu/49KRpbEgZKvfWg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3s5gk1sg45-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 11:57:38 -0500 (CDT) 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.30; Mon, 31 Jul 2023 17:57:33 +0100 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.30 via Frontend Transport; Mon, 31 Jul 2023 17:57:33 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.107]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 07796475; Mon, 31 Jul 2023 16:57:32 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , , Richard Fitzgerald Subject: [PATCH 9/9] ALSA: hda/cs35l56: Reject I2C alias addresses Date: Mon, 31 Jul 2023 17:57:26 +0100 Message-ID: <20230731165726.7940-10-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230731165726.7940-1-rf@opensource.cirrus.com> References: <20230731165726.7940-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: aR0Fv-GAtzh-w4nrEOUP9pw2wCSgsztH X-Proofpoint-ORIG-GUID: aR0Fv-GAtzh-w4nrEOUP9pw2wCSgsztH X-Proofpoint-Spam-Reason: safe Message-ID-Hash: 5CDDMVHYIR5ICRXRQ7TBYVYH2ZUABMUM X-Message-ID-Hash: 5CDDMVHYIR5ICRXRQ7TBYVYH2ZUABMUM X-MailFrom: prvs=3576b45159=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: The ACPI nodes for CS35L56 can contain an extra I2CSerialBusV2 that is not a real device, it is an alias address. This alias address will not be in the cirrus,dev-index array, so reject any instantions with a device address not found in the array. Signed-off-by: Richard Fitzgerald --- sound/pci/hda/cs35l56_hda.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index 004740509dbd..76b9c685560b 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -852,8 +852,12 @@ static int cs35l56_hda_read_acpi(struct cs35l56_hda *cs35l56, int id) break; } } + /* + * It's not an error for the ID to be missing: for I2C there can be + * an alias address that is not a real device. So reject silently. + */ if (cs35l56->index == -1) { - dev_err(cs35l56->base.dev, "No index found in %s\n", property); + dev_dbg(cs35l56->base.dev, "No index found in %s\n", property); ret = -ENODEV; goto err; } @@ -891,7 +895,8 @@ static int cs35l56_hda_read_acpi(struct cs35l56_hda *cs35l56, int id) return 0; err: - dev_err(cs35l56->base.dev, "Failed property %s: %d\n", property, ret); + if (ret != -ENODEV) + dev_err(cs35l56->base.dev, "Failed property %s: %d\n", property, ret); return ret; } @@ -904,10 +909,8 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int id) dev_set_drvdata(cs35l56->base.dev, cs35l56); ret = cs35l56_hda_read_acpi(cs35l56, id); - if (ret) { - dev_err_probe(cs35l56->base.dev, ret, "Platform not supported\n"); + if (ret) goto err; - } cs35l56->amp_name = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL, "AMP%d", cs35l56->index + 1);