linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/16] arm_mpam: Add MPAM-Fb firmware support
@ 2026-07-10 14:45 Andre Przywara
  2026-07-10 14:45 ` [PATCH v3 01/16] arm_mpam: let low level MSC read accessors return an error Andre Przywara
                   ` (15 more replies)
  0 siblings, 16 replies; 32+ messages in thread
From: Andre Przywara @ 2026-07-10 14:45 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Catalin Marinas,
	Will Deacon, Rafael J . Wysocki, Len Brown, James Morse,
	Ben Horgan, Reinette Chatre, Fenghua Yu
  Cc: Jonathan Cameron, Srivathsa L Rao, Ganapatrao Kulkarni,
	Trilok Soni, Srinivas Ramana, Niyas Sait, linux-acpi,
	linux-arm-kernel, linux-kernel

Hi,

meet version 3 of the MPAM-Fb code, for firmware based MSC accesses.
Compared to last week's drop, this fixes many bugs that Ben's diligent
review revealed, many thanks for that!
No real major changes this time, though the revised mon_sel locking has
changed to a simpler scheme, and the MPAM-Fb protocol version is now checked
for compatibility at probe time. For the remaining smaller changes, find a
changelog below. Based on v7.2-rc1.

=======================
The Arm MPAM specification defines Memory System Components (MSCs),
which are devices that are programmed through an MMIO register frame. In
some occasions this turned out to be too limiting: the MSC might be
located behind a separate bus system (for instance inside an on-board
controller), it might be mapped secure-only, or in a different processor
socket without direct MMIO mapping. Also the MMIO access might be too slow
or it would need to be filtered or otherwise access controlled. Finally
there might be bugs in the MSC integration, which require a mediating
firmware to be accessible.

To accommodate all those different use cases, the MPAM-Fb specification
[1] describes an alternative way to access MSCs. Accesses to an MSC
would be wrapped in a message and communicated to the system using a
shared-memory/mailbox system mostly mimicking the Arm SCMI spec.
For ACPI systems, this would be abstracted through an ACPI PCC channel,
which provides the shared-memory region and the mailbox trigger. We can
lean on existing ACPI parsing code to register with these two
subsystems, but cannot rely on the existing SCMI code in the kernel.
This means we somewhat need to open code a very simplified SCMI handler,
which just provides enough functionality for the very basic subset of
SCMI that the MPAM-Fb spec requires.

The first 12 patches rework all MSC access wrappers to propagate error
information. Pure MMIO based MSC accesses would never fail, but the
MPAM-Fb access can go wrong in multiple ways. The patches have been split
up purely for reviewing reasons, if the number is a problem, we could as
well squash them.
Patch 13/16 solves a nasty problem: At the moment we protect stateful MSC
register accesses (mon_sel) through a spinlock. Unfortunately the mailbox
subsystem and the slow nature of the communication through this channel
forbid MPAM-Fb access in atomic context. So this patch uses a mutex when
using MPAM-Fb, and the locking fails when trying to grab that mutex in
atomic context, for instance when programming MSCs inside an interrupt
handler. We just deny the latter when using MPAM-Fb, ideally we wouldn't
need that (no need to IPI another core when the MSC access does not need
to be local to one particular core), or we simply deny that part of the
functionality (access through perf).
Patch 14/16 adds the code to redirect MSC accesses through the
PCC shmem/mailbox system.
Patch 15/16 avoids the error IRQ handler to do an MSC access when using
MPAM_Fb, since those accesses cannot run in atomic context.
The final patch 16/16 then adds the code to detect and store the PCC
channel information from the ACPI tables, and eventually enables
MPAM-Fb accesses.

This would enable systems where some MSCs are not accessible via MMIO to
use those components anyway.

Please have a look and test!

Cheers,
Andre

[1] https://developer.arm.com/documentation/den0144/latest

Changes in v3:
- drop inner/outer mon_sel lock patch, replace with simpler version
- harmonise code patterns in error propagation changes
- drop mon_sel lock before erroring out in mpam_ris_hw_probe_csu_nrdy()
- refactor mpam_msc_read_mbwu_l() to return an error
- drop special NRDY handling in __ris_msmon_read()
- add IRQ numbers in error interrupt handler to help pinpoint failure
- refactor MPAM-Fb message generation to accommodate more than read/write
- check MPAM-Fb protocol version at probe time
- drop mpam_fb.h header, merge into mpam_internal.h
- translate MPAM-Fb error code in Linux codes where needed
- clear IRQ flag bit in MPAM-Fb protocol header
- drop unneeded endianness conversions when crafting MPAM-Fb message
- use C struct to model MPAM-Fb message payload

Changes in v2:
- add patches to add error propagation to MSC access wrappers
- drop former patch 1/5 (not needed)
- drop lock in mpam_reprogram_msc(), to avoid double lock
- add support for multiple MSCs per PCC channel
- adjust SCMI protocol code to use a PCC subtype 3 channel
- let PCC code handle the PCC channel negotiation (due to subtype 3)
- drop SCMI names in shmem offsets, and use existing PCC type 3 struct
- adjust shmem field offsets to match MPAM-Fb spec, not pure SCMI
- prevent MPAM-Fb calls inside atomic smp_call_function_any() payload
- skip all MSC accesses inside the IRQ handler when using MPAM-Fb

Andre Przywara (16):
  arm_mpam: let low level MSC read accessors return an error
  arm_mpam: propagate MSC read errors for wrapper functions
  arm_mpam: propagate MSC read errors for hw_probe functions
  arm_mpam: propagate MSC read errors for mpam_msc_read_mbwu_l()
  arm_mpam: propagate MSC read errors for msmon helpers
  arm_mpam: propagate MSC read errors for __ris_msmon_read()
  arm_mpam: __ris_msmon_read(): get rid of nrdy special handling
  arm_mpam: propagate MSC read errors for state saving functions
  arm_mpam: let low level MSC write accessors return an error
  arm_mpam: propagate MSC write errors for ESR and part_sel wrappers
  arm_mpam: propagate MSC write errors for hardware probe functions
  arm_mpam: propagate MSC write errors for remaining MSC write users
  arm_mpam: prepare mon_sel locking for MPAM-Fb
  arm_mpam: add MPAM-Fb MSC firmware access support
  arm_mpam: prevent MPAM-Fb accesses inside IRQ handler
  arm_mpam: detect and enable MPAM-Fb PCC support

 drivers/acpi/arm64/mpam.c       |   2 +
 drivers/resctrl/Makefile        |   2 +-
 drivers/resctrl/mpam_devices.c  | 651 ++++++++++++++++++++++++--------
 drivers/resctrl/mpam_fb.c       | 208 ++++++++++
 drivers/resctrl/mpam_internal.h |  48 ++-
 include/linux/arm_mpam.h        |   2 +-
 6 files changed, 740 insertions(+), 173 deletions(-)
 create mode 100644 drivers/resctrl/mpam_fb.c

-- 
2.43.0



^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2026-07-10 21:40 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 14:45 [PATCH v3 00/16] arm_mpam: Add MPAM-Fb firmware support Andre Przywara
2026-07-10 14:45 ` [PATCH v3 01/16] arm_mpam: let low level MSC read accessors return an error Andre Przywara
2026-07-10 18:11   ` Jonathan Cameron
2026-07-10 21:40     ` Andre Przywara
2026-07-10 14:45 ` [PATCH v3 02/16] arm_mpam: propagate MSC read errors for wrapper functions Andre Przywara
2026-07-10 18:21   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 03/16] arm_mpam: propagate MSC read errors for hw_probe functions Andre Przywara
2026-07-10 18:31   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 04/16] arm_mpam: propagate MSC read errors for mpam_msc_read_mbwu_l() Andre Przywara
2026-07-10 18:40   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 05/16] arm_mpam: propagate MSC read errors for msmon helpers Andre Przywara
2026-07-10 18:44   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 06/16] arm_mpam: propagate MSC read errors for __ris_msmon_read() Andre Przywara
2026-07-10 18:48   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 07/16] arm_mpam: __ris_msmon_read(): get rid of nrdy special handling Andre Przywara
2026-07-10 18:56   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 08/16] arm_mpam: propagate MSC read errors for state saving functions Andre Przywara
2026-07-10 19:00   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 09/16] arm_mpam: let low level MSC write accessors return an error Andre Przywara
2026-07-10 19:02   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 10/16] arm_mpam: propagate MSC write errors for ESR and part_sel wrappers Andre Przywara
2026-07-10 14:45 ` [PATCH v3 11/16] arm_mpam: propagate MSC write errors for hardware probe functions Andre Przywara
2026-07-10 19:04   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 12/16] arm_mpam: propagate MSC write errors for remaining MSC write users Andre Przywara
2026-07-10 19:10   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 13/16] arm_mpam: prepare mon_sel locking for MPAM-Fb Andre Przywara
2026-07-10 19:14   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 14/16] arm_mpam: add MPAM-Fb MSC firmware access support Andre Przywara
2026-07-10 19:58   ` Jonathan Cameron
2026-07-10 14:45 ` [PATCH v3 15/16] arm_mpam: prevent MPAM-Fb accesses inside IRQ handler Andre Przywara
2026-07-10 14:45 ` [PATCH v3 16/16] arm_mpam: detect and enable MPAM-Fb PCC support Andre Przywara
2026-07-10 20:10   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).