summaryrefslogtreecommitdiff
path: root/drivers/firmware
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2024-04-29 23:23:11 +0300
committerArnd Bergmann <arnd@arndb.de>2024-04-29 23:23:14 +0300
commit02c2c1900feb12363892a983bf04aa5d9d65934b (patch)
treebf2651360167c45ba905ecd37e3b86379cd1584e /drivers/firmware
parentcc0739fe2e55e59c7c983c00e22390b79a46ddc2 (diff)
parent166db01007ea802ff9933ac73ec8f140ca0cf5d5 (diff)
downloadlinux-02c2c1900feb12363892a983bf04aa5d9d65934b.tar.xz
Merge tag 'qcom-drivers-for-6.10' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into soc/drivers
Qualcomm driver updates for v6.10 The Qualcomm SCM driver initialization order is improved, to avoid any potential for a client to find a half-initialized SCM instance. The handling of download mode bits is updated to not attempt QCOM_SCM_BOOT_SET_DLOAD_MODE if a io-address for the update is specified, and that path is changed to perform a read-modify-write to avoid updating unrelated bits. Error handling is corrected in the peripheral authentication service (PAS) functions, to release interconnect bandwidth votes in the case of an error. An unwanted error print on allocation error is also removed from this code path. The QSEECOM allow list is marked __maybe_unused to avoid build warnings when built with !OF. The error handling related to the interconnect API is cleaned up to avoid handling the impossible IS_ERR() condition. initcall level is bumped to "core" for cmd-db and rpmh-rsc, as dependent drivers like regulators, interconnects and clocks are registered at this level. Another attempt is made to remove the strncpy() usage in cmd-db, this time with strtomem_pad() which has the correct characteristics. The bwmon regmap cache is changed to maple tree. After an attempt to add missing MODULE_DEVICE_TABLEs to debug drivers, the intention of not having them automatically load is documented. Operations on the pmic_glink client list is put under mutual exclusion, to avoid races when clients are being registered. pmic_glink client registered after the firmware notification arrived was not informed that the firmware was up, this is resolved. More DSPs and the apss subsystem is added to the Qualcomm sleep stats driver. Checks for in-flight regulator requests in the RPMh RSC driver is improved to deal with the fact that these occupy multiple registers, so it's insufficient to just to direct address comparison. The socinfo drivers learns about X1 Elite and SMB2360 PMIC. The maintainers entry is split between the linux-arm-msm list and subset that is maintained in the qcom-soc tree, to avoid some confusion about maintainership. * tag 'qcom-drivers-for-6.10' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux: (21 commits) soc: qcom: cmd-db: replace deprecated strncpy with strtomem soc: qcom: rpmh-rsc: Enhance check for VRM in-flight request firmware: qcom: scm: Modify only the download bits in TCSR register firmware: qcom: scm: Fix __scm and waitq completion variable initialization firmware: qcom: scm: Rework dload mode availability check firmware: qcom: scm: Remove redundant scm argument from qcom_scm_waitq_wakeup() firmware: qcom: scm: Remove log reporting memory allocation failure soc: qcom: pmic_glink: notify clients about the current state soc: qcom: pmic_glink: don't traverse clients list without a lock soc: qcom: mention intentionally broken module autoloading firmware: qcom: qcm: fix unused qcom_scm_qseecom_allowlist MAINTAINERS: Split Qualcomm SoC and linux-arm-msm entries soc: qcom: qcom_stats: Add DSPs and apss subsystem stats dt-bindings: soc: qcom: qcom,pmic-glink: document QCM6490 compatible soc: qcom: socinfo: Add SMB2360 PMIC soc: qcom: socinfo: Add X1E80100 SoC ID table entry dt-bindings: arm: qcom,ids: Add SoC ID for X1E80100 soc: qcom: Update init level to core_initcall() for cmd-db and rpmh-rsc soc: qcom: icc-bwmon: Convert to use maple tree register cache firmware: qcom_scm: remove IS_ERR() checks from qcom_scm_bw_{en,dis}able() ... Link: https://lore.kernel.org/r/20240427160917.1431354-1-andersson@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/qcom/qcom_scm.c79
1 files changed, 50 insertions, 29 deletions
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 520de9b5633a..5ff62f57aa55 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -4,6 +4,8 @@
*/
#include <linux/arm-smccc.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/cpumask.h>
@@ -114,6 +116,10 @@ static const u8 qcom_scm_cpu_warm_bits[QCOM_SCM_BOOT_MAX_CPUS] = {
#define QCOM_SMC_WAITQ_FLAG_WAKE_ONE BIT(0)
#define QCOM_SMC_WAITQ_FLAG_WAKE_ALL BIT(1)
+#define QCOM_DLOAD_MASK GENMASK(5, 4)
+#define QCOM_DLOAD_NODUMP 0
+#define QCOM_DLOAD_FULLDUMP 1
+
static const char * const qcom_scm_convention_names[] = {
[SMC_CONVENTION_UNKNOWN] = "unknown",
[SMC_CONVENTION_ARM_32] = "smc arm 32",
@@ -163,9 +169,6 @@ static int qcom_scm_bw_enable(void)
if (!__scm->path)
return 0;
- if (IS_ERR(__scm->path))
- return -EINVAL;
-
mutex_lock(&__scm->scm_bw_lock);
if (!__scm->scm_vote_count) {
ret = icc_set_bw(__scm->path, 0, UINT_MAX);
@@ -183,7 +186,7 @@ err_bw:
static void qcom_scm_bw_disable(void)
{
- if (IS_ERR_OR_NULL(__scm->path))
+ if (!__scm->path)
return;
mutex_lock(&__scm->scm_bw_lock);
@@ -496,19 +499,32 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
return qcom_scm_call_atomic(__scm->dev, &desc, NULL);
}
+static int qcom_scm_io_rmw(phys_addr_t addr, unsigned int mask, unsigned int val)
+{
+ unsigned int old;
+ unsigned int new;
+ int ret;
+
+ ret = qcom_scm_io_readl(addr, &old);
+ if (ret)
+ return ret;
+
+ new = (old & ~mask) | (val & mask);
+
+ return qcom_scm_io_writel(addr, new);
+}
+
static void qcom_scm_set_download_mode(bool enable)
{
- bool avail;
+ u32 val = enable ? QCOM_DLOAD_FULLDUMP : QCOM_DLOAD_NODUMP;
int ret = 0;
- avail = __qcom_scm_is_call_available(__scm->dev,
- QCOM_SCM_SVC_BOOT,
- QCOM_SCM_BOOT_SET_DLOAD_MODE);
- if (avail) {
+ if (__scm->dload_mode_addr) {
+ ret = qcom_scm_io_rmw(__scm->dload_mode_addr, QCOM_DLOAD_MASK,
+ FIELD_PREP(QCOM_DLOAD_MASK, val));
+ } else if (__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_BOOT,
+ QCOM_SCM_BOOT_SET_DLOAD_MODE)) {
ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
- } else if (__scm->dload_mode_addr) {
- ret = qcom_scm_io_writel(__scm->dload_mode_addr,
- enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0);
} else {
dev_err(__scm->dev,
"No available mechanism for setting download mode\n");
@@ -557,10 +573,9 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size,
*/
mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys,
GFP_KERNEL);
- if (!mdata_buf) {
- dev_err(__scm->dev, "Allocation of metadata buffer failed.\n");
+ if (!mdata_buf)
return -ENOMEM;
- }
+
memcpy(mdata_buf, metadata, size);
ret = qcom_scm_clk_enable();
@@ -569,13 +584,14 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size,
ret = qcom_scm_bw_enable();
if (ret)
- return ret;
+ goto disable_clk;
desc.args[1] = mdata_phys;
ret = qcom_scm_call(__scm->dev, &desc, &res);
-
qcom_scm_bw_disable();
+
+disable_clk:
qcom_scm_clk_disable();
out:
@@ -637,10 +653,12 @@ int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size)
ret = qcom_scm_bw_enable();
if (ret)
- return ret;
+ goto disable_clk;
ret = qcom_scm_call(__scm->dev, &desc, &res);
qcom_scm_bw_disable();
+
+disable_clk:
qcom_scm_clk_disable();
return ret ? : res.result[0];
@@ -672,10 +690,12 @@ int qcom_scm_pas_auth_and_reset(u32 peripheral)
ret = qcom_scm_bw_enable();
if (ret)
- return ret;
+ goto disable_clk;
ret = qcom_scm_call(__scm->dev, &desc, &res);
qcom_scm_bw_disable();
+
+disable_clk:
qcom_scm_clk_disable();
return ret ? : res.result[0];
@@ -706,11 +726,12 @@ int qcom_scm_pas_shutdown(u32 peripheral)
ret = qcom_scm_bw_enable();
if (ret)
- return ret;
+ goto disable_clk;
ret = qcom_scm_call(__scm->dev, &desc, &res);
-
qcom_scm_bw_disable();
+
+disable_clk:
qcom_scm_clk_disable();
return ret ? : res.result[0];
@@ -1649,7 +1670,7 @@ EXPORT_SYMBOL_GPL(qcom_scm_qseecom_app_send);
* We do not yet support re-entrant calls via the qseecom interface. To prevent
+ any potential issues with this, only allow validated machines for now.
*/
-static const struct of_device_id qcom_scm_qseecom_allowlist[] = {
+static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
{ .compatible = "lenovo,thinkpad-x13s", },
{ }
};
@@ -1738,7 +1759,7 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm)
*/
bool qcom_scm_is_available(void)
{
- return !!__scm;
+ return !!READ_ONCE(__scm);
}
EXPORT_SYMBOL_GPL(qcom_scm_is_available);
@@ -1769,7 +1790,7 @@ int qcom_scm_wait_for_wq_completion(u32 wq_ctx)
return 0;
}
-static int qcom_scm_waitq_wakeup(struct qcom_scm *scm, unsigned int wq_ctx)
+static int qcom_scm_waitq_wakeup(unsigned int wq_ctx)
{
int ret;
@@ -1801,7 +1822,7 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
goto out;
}
- ret = qcom_scm_waitq_wakeup(scm, wq_ctx);
+ ret = qcom_scm_waitq_wakeup(wq_ctx);
if (ret)
goto out;
} while (more_pending);
@@ -1819,10 +1840,12 @@ static int qcom_scm_probe(struct platform_device *pdev)
if (!scm)
return -ENOMEM;
+ scm->dev = &pdev->dev;
ret = qcom_scm_find_dload_address(&pdev->dev, &scm->dload_mode_addr);
if (ret < 0)
return ret;
+ init_completion(&scm->waitq_comp);
mutex_init(&scm->scm_bw_lock);
scm->path = devm_of_icc_get(&pdev->dev, NULL);
@@ -1854,10 +1877,8 @@ static int qcom_scm_probe(struct platform_device *pdev)
if (ret)
return ret;
- __scm = scm;
- __scm->dev = &pdev->dev;
-
- init_completion(&__scm->waitq_comp);
+ /* Let all above stores be available after this */
+ smp_store_release(&__scm, scm);
irq = platform_get_irq_optional(pdev, 0);
if (irq < 0) {