summaryrefslogtreecommitdiff
path: root/drivers/firmware/arm_scmi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-11-25 11:33:12 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-11-25 11:33:12 -0800
commitebb7a8dc1e74c705daffe11c2faf38ec2628f838 (patch)
tree23df29183aa5d67fe3289e3f0d6b3bd8eca00bbf /drivers/firmware/arm_scmi
parentf441d24349a3fb7f0b0f8f76f05686e448fd0b10 (diff)
parent30275e284469c6f8bb2e1bf7a666b065a81b46c9 (diff)
Merge tag 'soc-fixes-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/socHEADmaster
Pull SoC fixes from Arnd Bergmann: "There are once more lots of individual device driver fixes across several subsystems, and most of them look like they were found with the help of LLM services looking more closely at corner cases that had been missed before: - Multiple SCMI firmware fixes for probing device nodes and mailboxes - Notifications on Arm FFA firmware with hash conflicts - Out-of-bounds access to i.MX SCMI firmware data from userspace - Several error handling and probe fixes for reset controllers, along with a circular locking problem and one NULL pointer dereference - Multiple error handling fixes for memory controller drivers - A probe order fix for Raspberry Pi firmware For the devicetree source files, there are relatively few fixes so far, mainly for Samsung and ST SoC based machines, and mainly covering broken functionality: - Suspend issues across ST SoCs - Boot time panic on one ST based board from accessing firmware memory - One revert for a regression caused by enabling IOMMU for USB on an i.MX8 based board - Corrections for harmless mismatches to the actual boards from Arm and ST - Broken Bluetooth and/or Wi-Fi on older Samsung Exynos based products" * tag 'soc-fixes-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (40 commits) ARM: dts: stm32: Fix STM32MP15xx DHCOM SoM PicoITX overlay application arm64: dts: st: mark STM32MP23 timer as stopping in suspend arm64: dts: st: add PSCI idle state to STM32MP23 CPU domains arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains arm64: dts: st: Update gpio-line-names on STM32MP23xx DHCOS SoM arm64: dts: st: Move Bluetooth to USART2 on STM32MP23xx DHCOS SoM arm64: dts: st: add firmware reserved memory to Engicam MicroGEA-STM32MP257 reset: core: honour optional resets when the GPIO fallback returns -ENOENT platform/raspberrypi: vchiq: register bus at subsys_initcall MAINTAINERS: fix bouncing {sbranden,rjui}@broadcom.com Revert "arm64: dts: imx8qm-ss-conn: add usbotg3 iommu information" memory: fsl_ifc: Do not dereference the unset global pointer in probe reset: Fix circular locking dependency in reset_controller_unregister() reset: Fix reset_control leak when put after controller unregister reset: spacemit: Fix the RCPU2 PWM reset registers reset: scmi: Set the device for the reset controller memory: fsl_ifc: Clear fsl_ifc_ctrl_dev on probe failure and removal ARM: dts: samsung: exynos4210-trats: fix BCM4330 Bluetooth GPIOs ARM: dts: samsung: exynos4210-universal_c210: fix BCM4330 Bluetooth GPIOs ARM: dts: samsung: exynos4412-p4note: allow powering off the wifi card ...
Diffstat (limited to 'drivers/firmware/arm_scmi')
-rw-r--r--drivers/firmware/arm_scmi/Kconfig2
-rw-r--r--drivers/firmware/arm_scmi/bus.c110
-rw-r--r--drivers/firmware/arm_scmi/driver.c4
-rw-r--r--drivers/firmware/arm_scmi/notify.c4
-rw-r--r--drivers/firmware/arm_scmi/transports/Kconfig2
-rw-r--r--drivers/firmware/arm_scmi/transports/mailbox.c7
-rw-r--r--drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c18
7 files changed, 89 insertions, 58 deletions
diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
index 783c24a20e29..9f6241efd592 100644
--- a/drivers/firmware/arm_scmi/Kconfig
+++ b/drivers/firmware/arm_scmi/Kconfig
@@ -52,7 +52,7 @@ config ARM_SCMI_RAW_MODE_SUPPORT_COEX
Allow SCMI Raw transmission mode to coexist with normal SCMI stack.
This will allow regular SCMI drivers to register with the core and
- operate normally, thing which could make an SCMI test suite using the
+ operate normally, things which could make an SCMI test suite using the
SCMI Raw mode support unreliable. If unsure, say N.
config ARM_SCMI_DEBUG_COUNTERS
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 25197197db8e..7613ea2893ef 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -36,6 +36,12 @@ struct scmi_requested_dev {
/* Track globally the SCMI SystemPower protocol device. */
static struct scmi_device *scmi_syspower_registered;
+static bool scmi_raw_mode_only(void)
+{
+ return IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT) &&
+ !IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX);
+}
+
/**
* scmi_protocol_device_request - Helper to request a device
*
@@ -60,8 +66,7 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
pr_debug("Requesting SCMI device (%s) for protocol %x\n",
id_table->name, id_table->protocol_id);
- if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT) &&
- !IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX)) {
+ if (scmi_raw_mode_only()) {
pr_warn("SCMI Raw mode active. Rejecting '%s'/0x%02X\n",
id_table->name, id_table->protocol_id);
return -EINVAL;
@@ -181,12 +186,43 @@ static void scmi_protocol_device_unrequest(const struct scmi_device_id *id_table
}
}
+/* Standard protocols table */
+static const struct scmi_device_id scmi_std_id_table[] = {
+ { SCMI_PROTOCOL_POWER, "genpd" },
+ { SCMI_PROTOCOL_SYSTEM, "syspower" },
+ { SCMI_PROTOCOL_PERF, "perf" },
+ { SCMI_PROTOCOL_PERF, "cpufreq" },
+ { SCMI_PROTOCOL_CLOCK, "clocks" },
+ { SCMI_PROTOCOL_SENSOR, "hwmon" },
+ { SCMI_PROTOCOL_SENSOR, "iiodev" },
+ { SCMI_PROTOCOL_RESET, "reset" },
+ { SCMI_PROTOCOL_VOLTAGE, "regulator" },
+ { SCMI_PROTOCOL_POWERCAP, "powercap" },
+ { SCMI_PROTOCOL_PINCTRL, "pinctrl" },
+ { },
+};
+
+static bool scmi_device_id_in_std_id_table(const struct scmi_device_id *id)
+{
+ for (int i = 0; scmi_std_id_table[i].name[0]; i++) {
+ if (scmi_std_id_table[i].protocol_id == id->protocol_id &&
+ !strcmp(scmi_std_id_table[i].name, id->name))
+ return true;
+ }
+
+ return false;
+}
+
static int scmi_protocol_table_register(const struct scmi_device_id *id_table)
{
const struct scmi_device_id *entry;
int ret;
for (entry = id_table; entry->name[0]; entry++) {
+ /* Skip standard devices as they are created unconditionally */
+ if (scmi_device_id_in_std_id_table(entry))
+ continue;
+
ret = scmi_protocol_device_request(entry);
if (ret)
goto err_unrequest;
@@ -195,8 +231,11 @@ static int scmi_protocol_table_register(const struct scmi_device_id *id_table)
return 0;
err_unrequest:
- while (entry != id_table)
- scmi_protocol_device_unrequest(--entry);
+ while (entry != id_table) {
+ --entry;
+ if (!scmi_device_id_in_std_id_table(entry))
+ scmi_protocol_device_unrequest(entry);
+ }
return ret;
}
@@ -206,16 +245,23 @@ scmi_protocol_table_unregister(const struct scmi_device_id *id_table)
{
const struct scmi_device_id *entry;
- for (entry = id_table; entry->name[0]; entry++)
- scmi_protocol_device_unrequest(entry);
+ for (entry = id_table; entry->name[0]; entry++) {
+ if (!scmi_device_id_in_std_id_table(entry))
+ scmi_protocol_device_unrequest(entry);
+ }
}
-static bool scmi_device_is_transport(const struct scmi_device *scmi_dev)
+static bool scmi_device_name_is_transport(const char *name)
{
- return !strncmp(scmi_dev->name, SCMI_TRANSPORT_DEVNAME_PREFIX,
+ return !strncmp(name, SCMI_TRANSPORT_DEVNAME_PREFIX,
strlen(SCMI_TRANSPORT_DEVNAME_PREFIX));
}
+static bool scmi_device_is_transport(const struct scmi_device *scmi_dev)
+{
+ return scmi_device_name_is_transport(scmi_dev->name);
+}
+
static int __scmi_dev_match_by_id_table(struct scmi_device *scmi_dev,
const struct scmi_device_id *id_table,
bool skip_transport)
@@ -524,6 +570,11 @@ _scmi_device_create(struct fwnode_handle *fwnode, struct device *parent,
{
struct scmi_device *sdev;
+ /* The perf device is only needed when it provides power domains. */
+ if (protocol == SCMI_PROTOCOL_PERF && !strcmp(name, "perf") &&
+ !fwnode_property_present(fwnode, "#power-domain-cells"))
+ return NULL;
+
sdev = __scmi_device_create(fwnode, parent, protocol, name);
if (!sdev)
pr_err("(%pfwf) Failed to create device - protocol 0x%x (%s)\n",
@@ -532,34 +583,6 @@ _scmi_device_create(struct fwnode_handle *fwnode, struct device *parent,
return sdev;
}
-/* Standard protocols table */
-static const struct scmi_device_id scmi_std_id_table[] = {
- { SCMI_PROTOCOL_POWER, "genpd" },
- { SCMI_PROTOCOL_SYSTEM, "syspower" },
- { SCMI_PROTOCOL_PERF, "perf" },
- { SCMI_PROTOCOL_PERF, "cpufreq" },
- { SCMI_PROTOCOL_CLOCK, "clocks" },
- { SCMI_PROTOCOL_SENSOR, "hwmon" },
- { SCMI_PROTOCOL_SENSOR, "iiodev" },
- { SCMI_PROTOCOL_RESET, "reset" },
- { SCMI_PROTOCOL_VOLTAGE, "regulator" },
- { SCMI_PROTOCOL_POWERCAP, "powercap" },
- { SCMI_PROTOCOL_PINCTRL, "pinctrl" },
- { SCMI_PROTOCOL_PINCTRL, "pinctrl-imx" },
- { },
-};
-
-static bool scmi_device_id_in_std_id_table(const struct scmi_device_id *id)
-{
- for (int i = 0; scmi_std_id_table[i].name[0]; i++) {
- if (scmi_std_id_table[i].protocol_id == id->protocol_id &&
- !strcmp(scmi_std_id_table[i].name, id->name))
- return true;
- }
-
- return false;
-}
-
/**
* scmi_device_create - A method to create one or more SCMI devices
*
@@ -578,10 +601,8 @@ static bool scmi_device_id_in_std_id_table(const struct scmi_device_id *id)
*
* Return: The created device (or one of them if @name was NOT provided and
* multiple devices were created) or NULL if no device was created;
- * note that NULL indicates an error ONLY in case a specific @name
- * was provided: when @name param was not provided, a number of devices
- * could have been potentially created for a whole protocol, unless no
- * device was found to have been requested for that specific protocol.
+ * note that NULL can also indicate that a named device is not needed
+ * for this fwnode, or that no device was requested when @name is NULL.
*/
struct scmi_device *scmi_device_create(struct fwnode_handle *fwnode,
struct device *parent, int protocol,
@@ -591,6 +612,11 @@ struct scmi_device *scmi_device_create(struct fwnode_handle *fwnode,
struct scmi_requested_dev *rdev;
struct scmi_device *sdev, *scmi_dev = NULL;
+ /* Exclusive raw mode still needs transport devices for its channels. */
+ if (scmi_raw_mode_only() &&
+ (!name || !scmi_device_name_is_transport(name)))
+ return NULL;
+
if (name)
return _scmi_device_create(fwnode, parent, protocol, name);
@@ -619,10 +645,6 @@ struct scmi_device *scmi_device_create(struct fwnode_handle *fwnode,
/* Walk the list of requested devices for protocol and create them */
list_for_each_entry(rdev, phead, node) {
- /* Standard proto matches already have their dev created above */
- if (scmi_device_id_in_std_id_table(rdev->id_table))
- continue;
-
sdev = _scmi_device_create(fwnode, parent,
rdev->id_table->protocol_id,
rdev->id_table->name);
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 05092301db29..b753a02f1358 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -3107,11 +3107,7 @@ static void scmi_debugfs_common_cleanup(void *d)
static const char *scmi_acpi_device_hid(struct acpi_device *adev)
{
-#ifdef CONFIG_ACPI
return adev ? acpi_device_hid(adev) : "unknown";
-#else
- return "unknown";
-#endif
}
static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
index bc046f2f83a6..7be01952500d 100644
--- a/drivers/firmware/arm_scmi/notify.c
+++ b/drivers/firmware/arm_scmi/notify.c
@@ -1393,8 +1393,10 @@ static int scmi_notifier_register(const struct scmi_handle *handle,
/* Enable events for not pending handlers */
if (!IS_HNDL_PENDING(hndl)) {
ret = scmi_event_handler_enable_events(hndl);
- if (ret)
+ if (ret) {
+ blocking_notifier_chain_unregister(&hndl->chain, nb);
scmi_put_handler(ni, hndl);
+ }
}
return ret;
diff --git a/drivers/firmware/arm_scmi/transports/Kconfig b/drivers/firmware/arm_scmi/transports/Kconfig
index 0e34fbf25053..6ba0dcb86204 100644
--- a/drivers/firmware/arm_scmi/transports/Kconfig
+++ b/drivers/firmware/arm_scmi/transports/Kconfig
@@ -5,7 +5,7 @@ config ARM_SCMI_HAVE_TRANSPORT
bool
help
This declares whether at least one SCMI transport has been configured.
- Used to trigger a build bug when trying to build SCMI without any
+ Used to trigger a runtime warning when enabling SCMI without any
configured transport.
config ARM_SCMI_HAVE_SHMEM
diff --git a/drivers/firmware/arm_scmi/transports/mailbox.c b/drivers/firmware/arm_scmi/transports/mailbox.c
index 0677005dc6d3..b12bd07c2867 100644
--- a/drivers/firmware/arm_scmi/transports/mailbox.c
+++ b/drivers/firmware/arm_scmi/transports/mailbox.c
@@ -206,8 +206,11 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
smbox->shmem = core->shmem->setup_iomap(cinfo, dev, tx, NULL,
&smbox->io_ops);
- if (IS_ERR(smbox->shmem))
- return PTR_ERR(smbox->shmem);
+ if (IS_ERR(smbox->shmem)) {
+ ret = PTR_ERR(smbox->shmem);
+ devm_kfree(dev, smbox);
+ return ret;
+ }
cl = &smbox->cl;
cl->dev = cdev;
diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
index 2cec3dbb56ad..ed7499d72f19 100644
--- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
+++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
@@ -273,10 +273,16 @@ static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph,
{
struct scmi_imx_misc_ctrl_get_out *out;
struct scmi_xfer *t;
+ u32 num_values, max_values;
int ret, i;
int max_msg_size = ph->hops->get_max_msg_size(ph);
int max_num = (max_msg_size - sizeof(*out)) / sizeof(__le32);
+ if (!num || !val || !*num)
+ return -EINVAL;
+
+ max_values = *num;
+
ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id);
if (ret)
return ret;
@@ -290,16 +296,18 @@ static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph,
ret = ph->xops->do_xfer(ph, t);
if (!ret) {
out = t->rx.buf;
- *num = le32_to_cpu(out->num);
+ num_values = le32_to_cpu(out->num);
- if (*num >= max_num ||
- *num * sizeof(__le32) > t->rx.len - sizeof(__le32)) {
+ if (num_values > max_values || num_values >= max_num ||
+ num_values * sizeof(__le32) > t->rx.len - sizeof(__le32)) {
ph->xops->xfer_put(ph, t);
return -EINVAL;
}
- for (i = 0; i < *num; i++)
+ for (i = 0; i < num_values; i++)
val[i] = le32_to_cpu(out->val[i]);
+
+ *num = num_values;
}
ph->xops->xfer_put(ph, t);
@@ -438,7 +446,7 @@ static int iter_misc_syslog_update_state(struct scmi_iterator_state *st,
st->num_returned = RETURNED(r->numlogflags);
st->num_remaining = REMAINING(r->numlogflags);
- *p->size = st->num_returned + st->num_remaining;
+ *p->size = st->desc_index + st->num_returned;
return 0;
}