Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2381654lqp; Sun, 24 Mar 2024 16:56:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXN1pNahsR0sZjDbeo957sqrkV2UorJ273n3gO74Dq/C9dqm9+h2VQODNfoXIgpqikgQszaRhlMBslwuZK9Jd5uVVOFtUT5+Jv1S4jgKg== X-Google-Smtp-Source: AGHT+IH1gCoWZ/+5khAddxSt9GTb8o6t0l+0s4Xn4lWMUCmzNCqBJa1len9cocRFBUUmLF9O2PX5 X-Received: by 2002:a19:4312:0:b0:513:ed17:af03 with SMTP id q18-20020a194312000000b00513ed17af03mr4056575lfa.59.1711324570106; Sun, 24 Mar 2024 16:56:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324570; cv=pass; d=google.com; s=arc-20160816; b=PmqeUrI5JkQAPTkS+vYRoVztU4xnvhX27fRddny4Zfjz11yzykn7XANqOr8UcdxnRh fSDLK+c5wCCVNH3SP5QEvkcG9Bmy825Bk2zA8Xazvr6K0WT9ljYrIMCbt3gJxdKgZE18 tgLw0RgILeaPp4I7PrKVaTFncQhFQKRGnZxDm8MZVQ97OSj9bCxQeEQ2dq1QBrBM/wGN RxCPJpd4KbNikTC3rUP3wKQM/67OhGC0hcA6wHoklX0x4pEvdKy3ClEjthYzxq/QaQ26 YDIdqe/meoYPYB42XwbcRiCHGa64hUBX7LczogEJhYMA/q6Hce6YIQlWg9eWTew7LfKZ vrHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bhMHBjJjziCBxi06LlwQn7LNOrj2fB9EGAEqUaQxdrY=; fh=xyO+CIbliXzkv7pjU3CTq5wABV/8CvRtuix89WvW5bY=; b=Z/wqfnGo/4tjLvSJDlMvw3QY2fVFcBPqO6Pws4KvmW+q7eCjeo7rqxD+Fdccw6yn/0 /Ak41zoLwSR3e86FffUf7ut81bW33bL6aIyZRUtAjwGOc2XU+TotZKj6kjI096pnMPue 9c7AHYHxdnlbYwYafTzXG8x3fgptDqSnQtMsrjn5YHGA4JeO7mIhANT7+NkRS212NIZi 9cUkXDLda82x9nNeBeCCUvzEs/Ww0G05oXGkxhaHgzK7MZbyBZ+cR/OyLwJ9xp6x7x9L r4vnOp55jTcNEk7qTDv9OMGUvirXGFf0MddiUpOSxBDRiHuUUWuaFCNcVyFRxw+Kr9eo /wfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c5GsmeH6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113260-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113260-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p16-20020a1709060e9000b00a46cd89f0c2si2012184ejf.780.2024.03.24.16.56.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:56:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113260-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c5GsmeH6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113260-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113260-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 60F2B1F2244C for ; Sun, 24 Mar 2024 23:56:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2535F188A89; Sun, 24 Mar 2024 22:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c5GsmeH6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F801188A69; Sun, 24 Mar 2024 22:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320060; cv=none; b=jjewyt0pwt2hcNjrSVwv4JARGZ7qalrIttJJnXSUAy7yCrAbFu3mAP/rdxEZc+dGEugbXh9TKkpA1J0+UnGAvhDxUhgg50JFf5RUdOHu1zFfL5SOKjM/2ToNoIYsjs33Z+J9hakD3BRM04LTmkSkq74P94WGlgMTAACRbochAFs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320060; c=relaxed/simple; bh=7Kh9WBTrHZpZpHd+8mqm62KvN/Rtbc1InbRLgxFXGC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JzIXhLeJrGyCE/ofNHk8hq95kCjYq9G37JWTQMwRhAl7FYmhevY01qDmyLN4WCzfGj2Fk8VHylimrmIq+y0tW9SNPUt4HJhhKd+7tVMV+COIRw6IRdh44/GwAauy+bVfmx1yXjwi0OBiY75rqA8w6mPzUyeyHuQ0hV0oCUZ0O3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c5GsmeH6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0355BC433C7; Sun, 24 Mar 2024 22:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320059; bh=7Kh9WBTrHZpZpHd+8mqm62KvN/Rtbc1InbRLgxFXGC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c5GsmeH6JKFiGxr/OU4dJEvhmwVn631cYAesK3rcRjLWH14pZb7oWbdSu5WiRTkVd 18cJIlY3wdPVCQKxKSrvtYUwzWz2+oWJJOoSt7TLcN+o0jKSOFlbDwv8tNE1/rMH7v VtK8yQb7UezHYlZPhhDL4K0Jx7SSxlDZoVOIvh1XZCmasjmeibHWYD0l12qH5wpjVV WR9GMdwwgLfk/RZkG6/9IElnqZj+lvse0hPmO0dRFF9XePZxeAfrwZX9+cyXYcKta6 mVjRQavXfSuhU2UV8JdO1sL1OSi9rjLYEtb9T68TT4B1UMxMjchvLJkVO11xrRbXvt VaVrffUkfytHA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Cristian Ciocaltea , Emil Velikov , Mark Brown , Sasha Levin Subject: [PATCH 6.8 369/715] ASoC: SOF: amd: Compute file paths on firmware load Date: Sun, 24 Mar 2024 18:29:08 -0400 Message-ID: <20240324223455.1342824-370-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Cristian Ciocaltea [ Upstream commit d9cacc1a2af2e1cd781b5cd2a3e57fbde64f5a2d ] Commit 6c393ebbd74a ("ASoC: SOF: core: Implement IPC version fallback if firmware files are missing") changed the order of some operations and the firmware paths are not available anymore at snd_sof_probe() time. Precisely, fw_filename_prefix is set by sof_select_ipc_and_paths() via plat_data->fw_filename_prefix = out_profile.fw_path; but sof_init_environment() which calls this function was moved from snd_sof_device_probe() to sof_probe_continue(). Moreover, snd_sof_probe() was moved from sof_probe_continue() to sof_init_environment(), but before the call to sof_select_ipc_and_paths(). The problem here is that amd_sof_acp_probe() uses fw_filename_prefix to compute fw_code_bin and fw_data_bin paths, and because the field is not yet initialized, the paths end up containing (null): snd_sof_amd_vangogh 0000:04:00.5: Direct firmware load for (null)/sof-vangogh-code.bin failed with error -2 snd_sof_amd_vangogh 0000:04:00.5: sof signed firmware code bin is missing snd_sof_amd_vangogh 0000:04:00.5: error: failed to load DSP firmware -2 snd_sof_amd_vangogh: probe of 0000:04:00.5 failed with error -2 Move usage of fw_filename_prefix right before request_firmware() calls in acp_sof_load_signed_firmware(). Fixes: 6c393ebbd74a ("ASoC: SOF: core: Implement IPC version fallback if firmware files are missing") Signed-off-by: Cristian Ciocaltea Reviewed-by: Emil Velikov Link: https://msgid.link/r/20231219030728.2431640-9-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/amd/acp-loader.c | 32 ++++++++++++++++++++++++++------ sound/soc/sof/amd/acp.c | 7 ++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/sound/soc/sof/amd/acp-loader.c b/sound/soc/sof/amd/acp-loader.c index e05eb7a86dd44..d2d21478399e0 100644 --- a/sound/soc/sof/amd/acp-loader.c +++ b/sound/soc/sof/amd/acp-loader.c @@ -267,29 +267,49 @@ int acp_sof_load_signed_firmware(struct snd_sof_dev *sdev) { struct snd_sof_pdata *plat_data = sdev->pdata; struct acp_dev_data *adata = plat_data->hw_pdata; + const char *fw_filename; int ret; - ret = request_firmware(&sdev->basefw.fw, adata->fw_code_bin, sdev->dev); + fw_filename = kasprintf(GFP_KERNEL, "%s/%s", + plat_data->fw_filename_prefix, + adata->fw_code_bin); + if (!fw_filename) + return -ENOMEM; + + ret = request_firmware(&sdev->basefw.fw, fw_filename, sdev->dev); if (ret < 0) { + kfree(fw_filename); dev_err(sdev->dev, "sof signed firmware code bin is missing\n"); return ret; } else { - dev_dbg(sdev->dev, "request_firmware %s successful\n", adata->fw_code_bin); + dev_dbg(sdev->dev, "request_firmware %s successful\n", fw_filename); } + kfree(fw_filename); + ret = snd_sof_dsp_block_write(sdev, SOF_FW_BLK_TYPE_IRAM, 0, - (void *)sdev->basefw.fw->data, sdev->basefw.fw->size); + (void *)sdev->basefw.fw->data, + sdev->basefw.fw->size); + + fw_filename = kasprintf(GFP_KERNEL, "%s/%s", + plat_data->fw_filename_prefix, + adata->fw_data_bin); + if (!fw_filename) + return -ENOMEM; - ret = request_firmware(&adata->fw_dbin, adata->fw_data_bin, sdev->dev); + ret = request_firmware(&adata->fw_dbin, fw_filename, sdev->dev); if (ret < 0) { + kfree(fw_filename); dev_err(sdev->dev, "sof signed firmware data bin is missing\n"); return ret; } else { - dev_dbg(sdev->dev, "request_firmware %s successful\n", adata->fw_data_bin); + dev_dbg(sdev->dev, "request_firmware %s successful\n", fw_filename); } + kfree(fw_filename); ret = snd_sof_dsp_block_write(sdev, SOF_FW_BLK_TYPE_DRAM, 0, - (void *)adata->fw_dbin->data, adata->fw_dbin->size); + (void *)adata->fw_dbin->data, + adata->fw_dbin->size); return ret; } EXPORT_SYMBOL_NS(acp_sof_load_signed_firmware, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index 9aa9600c05d61..9794d64a110fd 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -493,7 +493,6 @@ EXPORT_SYMBOL_NS(amd_sof_acp_resume, SND_SOC_SOF_AMD_COMMON); int amd_sof_acp_probe(struct snd_sof_dev *sdev) { struct pci_dev *pci = to_pci_dev(sdev->dev); - struct snd_sof_pdata *plat_data = sdev->pdata; struct acp_dev_data *adata; const struct sof_amd_acp_desc *chip; const struct dmi_system_id *dmi_id; @@ -561,8 +560,7 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) dmi_id = dmi_first_match(acp_sof_quirk_table); if (dmi_id && dmi_id->driver_data) { adata->fw_code_bin = devm_kasprintf(sdev->dev, GFP_KERNEL, - "%s/sof-%s-code.bin", - plat_data->fw_filename_prefix, + "sof-%s-code.bin", chip->name); if (!adata->fw_code_bin) { ret = -ENOMEM; @@ -570,8 +568,7 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) } adata->fw_data_bin = devm_kasprintf(sdev->dev, GFP_KERNEL, - "%s/sof-%s-data.bin", - plat_data->fw_filename_prefix, + "sof-%s-data.bin", chip->name); if (!adata->fw_data_bin) { ret = -ENOMEM; -- 2.43.0