Linux Power Management development
 help / color / mirror / Atom feed
From: Joshua Yeong <joshua.yeong@starfivetech.com>
To: rahul@summations.net, anup@brainfault.org, lftan.linux@gmail.com,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	ulfh@kernel.org, pjw@kernel.org, palmer@dabbelt.com,
	aou@eecs.berkeley.edu
Cc: alex@ghiti.fr, joshua.yeong@starfivetech.com,
	linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 0/3] Add RISC-V RPMI device power service support
Date: Thu,  3 Sep 2026 17:23:44 +0800	[thread overview]
Message-ID: <20260903092347.620060-1-joshua.yeong@starfivetech.com> (raw)

The RISC-V Platform Management Interface (RPMI) specification defines a
modular and extensible messaging protocol between the supervisor software
and a platform microcontroller (PuC). Among the service groups it defines
is the device power service group (service group ID 0x00009), which allows
the supervisor to enumerate the power domains of platform devices managed
by the PuC, query their attributes, and get/set their power state.

This series adds supervisor-side support for that service group:

 - DT bindings for the power domain controller exposed to the supervisor
   ("riscv,rpmi-device-power") and for the SBI MPXY channel that the SBI
   implementation uses to expose the service group to the supervisor
   ("riscv,rpmi-mpxy-device-power").

 - A generic power domain (genpd) provider driver under
   drivers/pmdomain/riscv/ which talks to the PuC over an SBI MPXY
   mailbox channel. At probe it queries GET_NUM_DOMAINS, then for each
   domain queries GET_ATTRS for the name and transition latency and
   GET_STATE for the initial state, and registers the whole set as a
   onecell genpd provider. Domain power on/off is driven through
   SET_STATE with the generic ON/OFF power state parameters, so devices
   can simply reference a domain through the "power-domains" property.

The series is based on the existing RISC-V RPMI/MPXY infrastructure
already present in the tree (drivers/mailbox/riscv-sbi-mpxy-mbox.c and
include/linux/mailbox/riscv-rpmi-message.h), and only adds the device
power service group definitions on top of it.

Changes in v3:
 - Move the MAINTAINERS change into its own patch, and add a new
   "RISC-V RPMI DEVICE POWER DRIVER" section scoped to this driver and
   its bindings instead of adding an M: entry to the existing "RISC-V
   RPMI AND MPXY DRIVERS" section, which covers drivers maintained by
   others.
 - Drop the redundant trailing "bindings" from the dt-bindings subject.
 - Compare only the value field of the RPMI power state word. The word
   also carries a context bit, so a full word comparison would report
   -EIO after a successful transition, and would drop a domain at probe,
   whenever the PuC reports context as lost.
 - Check the pm_genpd_init() return value and leave a failed domain out
   of the onecell array. Every failure path in pm_genpd_init() returns
   before the genpd is linked into gpd_list, so the previous code could
   hand a half initialised genpd to of_genpd_add_provider_onecell() and
   then list_del() an uninitialised list head in the unwind loop.
 - Set GENPD_FLAG_DEV_NAME_FW. The domain names come from the PuC and
   are not guaranteed to be unique or non-empty, and were used verbatim
   as the sysfs and debugfs names, where a duplicate fails device_add()
   with -EEXIST and takes down the whole provider.

v1: https://lore.kernel.org/r/20260829205520.1691-1-joshua.yeong@starfivetech.com
v2: https://lore.kernel.org/r/20260830152812.312663-1-joshua.yeong@starfivetech.com

Testing
=======

The series was tested under QEMU with the RPMI device power service
implemented in firmware.

Components:

 - OpenSBI: latest master branch
   https://github.com/riscv-software-src/opensbi

 - QEMU: the RPMI-enabled tree at
   https://github.com/yeongjoshua/qemu/tree/rpmi-v11.1.0

Kernel config: enable CONFIG_RISCV_RPMI_DEVICE_POWER (default y on RISC-V
when MAILBOX is enabled) along with the SBI MPXY mailbox driver.

Run with:

  qemu-system-riscv64 \
      -M virt -m 2G -smp 4 \
      -bios fw_dynamic.bin \
      -kernel Image \
      -M rpmi=true \
      -nographic \
      -initrd rootfs-busybox.cpio \
      -append "root=/dev/ram rw console=ttyS0,115200 no_console_suspend mem=2048M earlycon=uart8250,mmio,0x10000000"

The RPMI device power domains advertised by the emulated platform
microcontroller show up as generic power domains and can be inspected
through /sys/kernel/debug/pm_genpd/. The series was additionally booted
with CONFIG_PROVE_LOCKING, CONFIG_DEBUG_MUTEXES and
CONFIG_DEBUG_ATOMIC_SLEEP enabled, with no lockdep reports.

Joshua Yeong (3):
  dt-bindings: power: Add RPMI device power service
  pmdomain: riscv: Add RPMI device power service
  MAINTAINERS: Add RISC-V RPMI device power driver

 .../power/riscv,rpmi-device-power.yaml        |  65 +++
 .../power/riscv,rpmi-mpxy-device-power.yaml   |  65 +++
 MAINTAINERS                                   |   8 +
 drivers/pmdomain/Kconfig                      |   1 +
 drivers/pmdomain/Makefile                     |   1 +
 drivers/pmdomain/riscv/Kconfig                |  15 +
 drivers/pmdomain/riscv/Makefile               |   3 +
 .../pmdomain/riscv/riscv-rpmi-device-power.c  | 485 ++++++++++++++++++
 include/linux/mailbox/riscv-rpmi-message.h    |  11 +
 9 files changed, 654 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-device-power.yaml
 create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-mpxy-device-power.yaml
 create mode 100644 drivers/pmdomain/riscv/Kconfig
 create mode 100644 drivers/pmdomain/riscv/Makefile
 create mode 100644 drivers/pmdomain/riscv/riscv-rpmi-device-power.c


base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
--
2.43.0

             reply	other threads:[~2026-09-03  9:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  9:23 Joshua Yeong [this message]
2026-09-03  9:23 ` [PATCH v3 1/3] dt-bindings: power: Add RPMI device power service Joshua Yeong
2026-09-03 17:22   ` Conor Dooley
2026-09-03  9:23 ` [PATCH v3 2/3] pmdomain: riscv: " Joshua Yeong
2026-09-03  9:23 ` [PATCH v3 3/3] MAINTAINERS: Add RISC-V RPMI device power driver Joshua Yeong

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=20260903092347.620060-1-joshua.yeong@starfivetech.com \
    --to=joshua.yeong@starfivetech.com \
    --cc=alex@ghiti.fr \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lftan.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=rahul@summations.net \
    --cc=robh@kernel.org \
    --cc=ulfh@kernel.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