Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@kernel.org>
To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Cristian Marussi <cristian.marussi@arm.com>
Subject: [PATCH v2 00/14] firmware: arm_scmi: Fix SCMI core cleanup paths
Date: Wed, 01 Jul 2026 17:52:21 +0100	[thread overview]
Message-ID: <20260701-scmi_core_fixes-v2-0-1f5e85553f73@kernel.org> (raw)

This series fixes a set of SCMI core and mailbox transport lifetime issues
found around device creation, channel setup failure, notification teardown
and malformed firmware descriptions.

Most of these issues were found by Sashiko[1][2] while reviewing the ACPI SCMI
PCC work[3]. They are posted separately because the problems are independent
SCMI core and mailbox transport cleanup bugs, and do not depend on the ACPI
PCC series.

Here is the attempt to fix them, some of them can be dropped if it is too
theoretical. I have addressed all the issues that made sense to me at the
time of reading the report.

The fixes tighten ownership and teardown rules for generated SCMI devices,
transport devices and transport channels. They make internal transport
devices reachable by explicit teardown without exposing them to normal SCMI
driver binding, ensure partially initialized channels are unwound on setup
failures, and avoid IDR/device lifetime races during probe failure and device
unbind.

The series also fixes notifier and notification teardown ordering. Requested
device notifiers are unregistered before protocol IDRs are destroyed, RCU is
used around requested-device protocol lookups, and transport callbacks are
stopped before notification state is released.

The mailbox transport fixes cover both setup failure unwinding and an early
interrupt window: mailbox callbacks can run as soon as mbox_request_channel()
binds the client and starts the controller, so the SCMI mailbox transport now
publishes its cinfo before requesting channels.

Fixes tags need to be checked again or even dropped if it is not a stable
material. Just some placeholders that I thought are appropriated are in place.

Summary:

- Fix OF node reference ownership for generated SCMI devices.
- Allow explicit teardown lookup of internal transport devices.
- Clean up TX/RX channels when SCMI channel setup fails midway.
- Fix SCMI device lifetime handling around child lookup and bus ID reuse.
- Free transport resources when IDR insertion fails after channel setup.
- Unregister requested-device notifier before active protocol IDR teardown.
- Unwind mailbox channels on TX receiver and P2A receiver setup failures.
- Protect requested-device protocol lookup with RCU.
- Avoid modifying an IDR while iterating it during channel cleanup.
- Clear the SystemPower singleton flag on SCMI device creation failure.
- Reject out-of-range DT protocol IDs instead of allowing u8 truncation.
- Stop transport callbacks before releasing notification state.
- Publish mailbox cinfo before requesting mailbox channels.

Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>

[1] https://sashiko.dev/#/patchset/20260525-acpi_scmi_pcc-v2-0-4f38938d08d8@arm.com
[2] https://sashiko.dev/#/patchset/20260630-scmi_core_fixes-v1-0-f932c1e51992@kernel.org
[3] https://patch.msgid.link/20260525-acpi_scmi_pcc-v2-0-4f38938d08d8@arm.com

---
Changes in v2:
(Mostly addressing the additional issues found by Sashiko)
- Added fixes for IDR mutation during channel cleanup.
- Added SystemPower singleton flag unwind on device creation failure.
- Added validation to skip out-of-range DT protocol IDs.
- Moved notification teardown after transport channel cleanup.
- Published mailbox cinfo before mbox_request_channel() can enable callbacks.
- Link to v1: https://patch.msgid.link/20260630-scmi_core_fixes-v1-0-f932c1e51992@kernel.org

---
Sudeep Holla (14):
      firmware: arm_scmi: Fix OF node reference handling
      firmware: arm_scmi: Fix transport device teardown lookup
      firmware: arm_scmi: Clean up channels on setup failure
      firmware: arm_scmi: Fix SCMI device destroy lifetimes
      firmware: arm_scmi: Free transport channel on IDR failure
      firmware: arm_scmi: Unregister device notifier before IDR teardown
      firmware: arm_scmi: Unwind TX receiver mailbox setup failure
      firmware: arm_scmi: Unwind P2A receiver mailbox setup failure
      firmware: arm_scmi: Protect device request lookup with RCU
      firmware: arm_scmi: Avoid IDR updates while cleaning channels
      firmware: arm_scmi: Clear SystemPower flag on create failure
      firmware: arm_scmi: Reject out of range DT protocol IDs
      firmware: arm_scmi: Stop channels before notification teardown
      firmware: arm_scmi: Publish mailbox cinfo before channel request

 drivers/firmware/arm_scmi/bus.c                | 72 ++++++++++++++++----------
 drivers/firmware/arm_scmi/common.h             |  2 +
 drivers/firmware/arm_scmi/driver.c             | 44 +++++++++-------
 drivers/firmware/arm_scmi/transports/mailbox.c | 26 +++++++---
 4 files changed, 90 insertions(+), 54 deletions(-)
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260629-scmi_core_fixes-da3cd753b4ea


-- 
Regards,
Sudeep



             reply	other threads:[~2026-07-01 16:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 16:52 Sudeep Holla [this message]
2026-07-01 16:52 ` [PATCH v2 01/14] firmware: arm_scmi: Fix OF node reference handling Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 02/14] firmware: arm_scmi: Fix transport device teardown lookup Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 03/14] firmware: arm_scmi: Clean up channels on setup failure Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 04/14] firmware: arm_scmi: Fix SCMI device destroy lifetimes Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 05/14] firmware: arm_scmi: Free transport channel on IDR failure Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 06/14] firmware: arm_scmi: Unregister device notifier before IDR teardown Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 07/14] firmware: arm_scmi: Unwind TX receiver mailbox setup failure Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 08/14] firmware: arm_scmi: Unwind P2A " Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 09/14] firmware: arm_scmi: Protect device request lookup with RCU Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 10/14] firmware: arm_scmi: Avoid IDR updates while cleaning channels Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 11/14] firmware: arm_scmi: Clear SystemPower flag on create failure Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 12/14] firmware: arm_scmi: Reject out of range DT protocol IDs Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 13/14] firmware: arm_scmi: Stop channels before notification teardown Sudeep Holla
2026-07-01 16:52 ` [PATCH v2 14/14] firmware: arm_scmi: Publish mailbox cinfo before channel request Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260701-scmi_core_fixes-v2-0-1f5e85553f73@kernel.org \
    --to=sudeep.holla@kernel.org \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox