Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2973300lqo; Tue, 21 May 2024 03:02:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW6BqJdl9e1W6KF06RL3gfixDKmSR9gi8FF/I6qY7JMijFPDkkVEWt+414hS8prX2hPkOOjqKluu7p+EYM1Hktn+yPDTRZMP0TmeqpZlg== X-Google-Smtp-Source: AGHT+IELrPICsOKjcaKIaGtjEI/TWUrnGbPdiB+IQzoC/3LDiL6mjTsCYOxUBQsVnHibol1ECsyT X-Received: by 2002:a05:6a20:9191:b0:1af:ad23:3d7b with SMTP id adf61e73a8af0-1afde197906mr47307807637.44.1716285728970; Tue, 21 May 2024 03:02:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716285728; cv=pass; d=google.com; s=arc-20160816; b=YXJm61fa7BlPkLiOyWuY8KEEpZRYPTVjoiHpf2KCv7h2v7esYDsao5nSlKMcxduHNP bWJF1jllr4e+AFmNRSJZGaiiPRJjsResKll0aqlNVV2v7K3w0wmJ0tiC//h95MwiOY1A QaXqXm7EJsYMJ+Nl+q7RbfVY0R3s8XAvoyiw5YkDwCy9XUJoGktFNDexai1pvhgAU979 znTDCD9+pRwKaqL3m0C/drLg34WZ+11jLPuttjrtC+AKtmPGtkk7T2LgOy5iTnaYL4t1 D1WJ1LGOHLHR5lx1vN0fzM0jg6ePOiaXKLuRy8DLivEFhC56nCHK+5++nu6XJFFtPsH2 UqoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=AP264UOFD4ja8oEQ5wju53drQLAuhDOSUhP1BJZIxXs=; fh=9uLEIXp3x/8DecpjLxwdA3GocXDWFibBSts9tL/W5VA=; b=JhGBnA8SuObKW49zkF3y5K2Wi4jNFpGenFAsfa6pi6+12Dd/j9rz6i6ZO1Y2D2zOhn zijVBUSdrzgMhcnQpLJE2nbx4Nonaum05DdK4TgHJ5cPlIK+NPHKVp367dXvGTWh+Up0 WHgGwKZMuXyoPn/WfzYG3kK38F3Ztej2PpVMvMHvNVUPUD64Mbm2ztIFTtehMzLyuo4c 2cKv1P7FBAUFnY6jWlHg1ltr1gU7dBtKECoY58L67jk4y12q8lNEjUcuZRjbOjrm6/HL w9t9NsS8HC2oZYcLw56ZNzbKtP5k+wBpmAXN86UcMgrT09ioo3pvkyqh8fVwttjUQjeq DUOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UF3u+hhL; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-wireless+bounces-7896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7896-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f2e0b33e9asi74344035ad.181.2024.05.21.03.02.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 03:02:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UF3u+hhL; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-wireless+bounces-7896-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7896-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8DD8C281B42 for ; Tue, 21 May 2024 10:02:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F5D54206E; Tue, 21 May 2024 10:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UF3u+hhL" X-Original-To: linux-wireless@vger.kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0249256B7B for ; Tue, 21 May 2024 10:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716285721; cv=none; b=YhZJmsbjmKLyPor8YL/U8W73t0KrKBsGaS2ouHHbzt2o2NUpxFwHV29Lhc/158BDEnrxbhZN91nryHOaD4Ss9YhNjLu0O6XB5Wl6ncUhgqayICTL7jyvKGq0qLVMmD/0fRVg2WvFe+IJNjxlSMBR80x0Ny/RWU2ts5OdoOIl9PM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716285721; c=relaxed/simple; bh=cMDoLL6QBfIieTZE2r7W+c1QqtEbw5d3Use77tBA+tM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lwYNjGl8RR7Juwg7a6QyQlR1XWF0T+ocW4Ko1fh52ytdwZPH0yPVwTtjYAwSWvHA5gKMjhbabVGJQoNAMXzsuojXPOcmP8bDQJ6zu28fjuUfvSLizE+KMTTLcxkqJBcJhfbPezFBfojc7yTtJkPoZJLRpZTpGW0u6f86zeqcrWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=UF3u+hhL; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1ecddf96313so89844615ad.2 for ; Tue, 21 May 2024 03:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716285718; x=1716890518; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=AP264UOFD4ja8oEQ5wju53drQLAuhDOSUhP1BJZIxXs=; b=UF3u+hhLYRikE89tsXCmfKVgV/hKvSb8hwCXq0grcsG0sgAujFCfu94H29niT/ygO3 wkRt0WCcu/jln1Ji0dcLXbsfeDn4gdutOOPsCusAF+X2C+VdBAo4bc5uBjRAHLuSbSEa YuT+D6lqebZUYxjjWq/y2+G6hPnr5ru3VxTYpovuDJK4KK7ZoDRBzH05Hfe+YM/H4/g1 np53kRXndtk9hCHSINkRKYOnWjDKWPuJBT/We0lpWY4VPT8beGOQsJPZhuVDZQ59nlnp fIT6q+xS6/SAxk0sHmYwhw2uMcKkpaLT0rbvPYPACNLxUPgSASp5LsxBTv/qw2V9grHB spRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716285718; x=1716890518; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AP264UOFD4ja8oEQ5wju53drQLAuhDOSUhP1BJZIxXs=; b=J9j8Scb7lU9PowxPbOE2KhXzdN2oOZUCWCZXS62ZbXmP9R1FQE0oBhwjZHRBeqDR4a RWns6LvmwksV6iQ9DeE157JHQuPFQjdMCUMVpjF/+KTKkx8vl1zUGFnEfjpYxGBPIJqk wufYqhxdFw8iWS+OsE32y3ikCxg4WKhMu1nTKbbAros8d5AfIOWrj6eSfy8vzMUmDjXx 63z6ZQ7Yqd4tsuZaib/2cW8Eh84tyMsuq2gyfKrJ0j/xOiTG7Y/0qI7ZwroKySIcNGov 7LqFx3rbi8LZmNBLKpKrFR1sQDGu5zjgIK/aXyFCa1FVerS40QtU6eNnI2x6ucDznoKP eWVg== X-Forwarded-Encrypted: i=1; AJvYcCWcypfTfRKz73+Cvlq9TnUm04yWinBrLt0uSfQ5CvFiDJnom0Guu1uWV6x3KXas+AwEEA6t62O2uvH9Xa81pyC14TjiIhDIAdq8xqIf0KY= X-Gm-Message-State: AOJu0YyzAA5g/l/BeY8SyqdDiCHdnHMou/7nt3uf4IsnER9/pYsGZuIr vgCaHRym5RyNsdhrj1HZBNEMcKKJ1e65swEtgKkGRufBIjaGmg77axNqgCHs0f3ct+ZVv3svrnL aGN6nzsSMkugcXdZW6Pphx2JCEbvliC+Wh4TpmQ== X-Received: by 2002:a17:90a:d58c:b0:2bb:b23e:14cc with SMTP id 98e67ed59e1d1-2bbb23e4f03mr15657587a91.42.1716285718303; Tue, 21 May 2024 03:01:58 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240521-qcom-firmware-name-v1-0-99a6d32b1e5e@linaro.org> <20240521-qcom-firmware-name-v1-1-99a6d32b1e5e@linaro.org> In-Reply-To: From: Dmitry Baryshkov Date: Tue, 21 May 2024 13:01:45 +0300 Message-ID: Subject: Re: [PATCH 01/12] soc: qcom: add firmware name helper To: neil.armstrong@linaro.org Cc: Bjorn Andersson , Konrad Dybcio , Loic Poulain , Kalle Valo , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, Arnd Bergmann Content-Type: text/plain; charset="UTF-8" On Tue, 21 May 2024 at 12:52, wrote: > > On 21/05/2024 11:45, Dmitry Baryshkov wrote: > > Qualcomm platforms have different sets of the firmware files, which > > differ from platform to platform (and from board to board, due to the > > embedded signatures). Rather than listing all the firmware files, > > including full paths, in the DT, provide a way to determine firmware > > path based on the root DT node compatible. > > Ok this looks quite over-engineered but necessary to handle the legacy, > but I really think we should add a way to look for a board-specific path > first and fallback to those SoC specific paths. Again, CONFIG_FW_LOADER_USER_HELPER => delays. > > Neil > > > > > Suggested-by: Arnd Bergmann > > Signed-off-by: Dmitry Baryshkov > > --- > > drivers/soc/qcom/Kconfig | 5 +++ > > drivers/soc/qcom/Makefile | 1 + > > drivers/soc/qcom/qcom_fw_helper.c | 86 ++++++++++++++++++++++++++++++++++++++ > > include/linux/soc/qcom/fw_helper.h | 10 +++++ > > 4 files changed, 102 insertions(+) > > > > diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig > > index 5af33b0e3470..b663774d65f8 100644 > > --- a/drivers/soc/qcom/Kconfig > > +++ b/drivers/soc/qcom/Kconfig > > @@ -62,6 +62,11 @@ config QCOM_MDT_LOADER > > tristate > > select QCOM_SCM > > > > +config QCOM_FW_HELPER > > + tristate "NONE FW HELPER" > > + help > > + Helpers to return platform-specific location for the firmware files. > > + > > config QCOM_OCMEM > > tristate "Qualcomm On Chip Memory (OCMEM) driver" > > depends on ARCH_QCOM > > diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile > > index ca0bece0dfff..e612bee5b955 100644 > > --- a/drivers/soc/qcom/Makefile > > +++ b/drivers/soc/qcom/Makefile > > @@ -6,6 +6,7 @@ obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o > > obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o > > obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o > > obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o > > +obj-$(CONFIG_QCOM_FW_HELPER) += qcom_fw_helper.o > > obj-$(CONFIG_QCOM_OCMEM) += ocmem.o > > obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o > > obj-$(CONFIG_QCOM_PMIC_GLINK) += pmic_glink.o > > diff --git a/drivers/soc/qcom/qcom_fw_helper.c b/drivers/soc/qcom/qcom_fw_helper.c > > new file mode 100644 > > index 000000000000..13123c2514b8 > > --- /dev/null > > +++ b/drivers/soc/qcom/qcom_fw_helper.c > > @@ -0,0 +1,86 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > +/* > > + * Qualcomm Firmware loading data > > + * > > + * Copyright (C) 2024 Linaro Ltd > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +static DEFINE_MUTEX(qcom_fw_mutex); > > +static const char *fw_path; > > + > > +static const struct of_device_id qcom_fw_paths[] = { > > + /* device-specific entries */ > > + { .compatible = "thundercomm,db845c", .data = "qcom/sdm845/Thundercomm/db845c", }, > > + { .compatible = "qcom,qrb5165-rb5", .data = "qcom/sm8250/Thundercomm/RB5", }, > > + /* SoC default entries */ > > + { .compatible = "qcom,apq8016", .data = "qcom/apq8016", }, > > + { .compatible = "qcom,apq8096", .data = "qcom/apq8096", }, > > + { .compatible = "qcom,sdm845", .data = "qcom/sdm845", }, > > + { .compatible = "qcom,sm8250", .data = "qcom/sm8250", }, > > + { .compatible = "qcom,sm8350", .data = "qcom/sm8350", }, > > + { .compatible = "qcom,sm8450", .data = "qcom/sm8450", }, > > + { .compatible = "qcom,sm8550", .data = "qcom/sm8550", }, > > + { .compatible = "qcom,sm8650", .data = "qcom/sm8650", }, > > + {}, > > +}; > > + > > +static int qcom_fw_ensure_init(void) > > +{ > > + const struct of_device_id *match; > > + struct device_node *root; > > + > > + if (fw_path) > > + return 0; > > + > > + root = of_find_node_by_path("/"); > > + if (!root) > > + return -ENODEV; > > + > > + match = of_match_node(qcom_fw_paths, root); > > + of_node_put(root); > > + if (!match || !match->data) { > > + pr_notice("Platform not supported by qcom_fw_helper\n"); > > + return -ENODEV; > > + } > > + > > + fw_path = match->data; > > + > > + return 0; > > +} > > + > > +const char *qcom_get_board_fw(const char *firmware) > > +{ > > + if (strchr(firmware, '/')) > > + return kstrdup(firmware, GFP_KERNEL); > > + > > + scoped_guard(mutex, &qcom_fw_mutex) { > > + if (!qcom_fw_ensure_init()) > > + return kasprintf(GFP_KERNEL, "%s/%s", fw_path, firmware); > > + } > > + > > + return kstrdup(firmware, GFP_KERNEL); > > +} > > +EXPORT_SYMBOL_GPL(qcom_get_board_fw); > > + > > +const char *devm_qcom_get_board_fw(struct device *dev, const char *firmware) > > +{ > > + if (strchr(firmware, '/')) > > + return devm_kstrdup(dev, firmware, GFP_KERNEL); > > + > > + scoped_guard(mutex, &qcom_fw_mutex) { > > + if (!qcom_fw_ensure_init()) > > + return devm_kasprintf(dev, GFP_KERNEL, "%s/%s", fw_path, firmware); > > + } > > + > > + return devm_kstrdup(dev, firmware, GFP_KERNEL); > > +} > > +EXPORT_SYMBOL_GPL(devm_qcom_get_board_fw); > > + > > +MODULE_DESCRIPTION("Firmware helpers for Qualcomm devices"); > > +MODULE_LICENSE("GPL"); > > diff --git a/include/linux/soc/qcom/fw_helper.h b/include/linux/soc/qcom/fw_helper.h > > new file mode 100644 > > index 000000000000..755645386bba > > --- /dev/null > > +++ b/include/linux/soc/qcom/fw_helper.h > > @@ -0,0 +1,10 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +#ifndef __QCOM_FW_HELPER_H__ > > +#define __QCOM_FW_HELPER_H__ > > + > > +struct device; > > + > > +const char *qcom_get_board_fw(const char *firmware); > > +const char *devm_qcom_get_board_fw(struct device *dev, const char *firmware); > > + > > +#endif > > > -- With best wishes Dmitry