Skip to content

i3c: Support IBI-based system wakeup

Adrian Hunter linux-i3c linux-pci linux-pm lkml 5 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest14 patches 3 repliesApplied
  2. v414 patches 17 repliesSuperseded
  3. v314 patches 14 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v28 patches10 repliesSuperseded
v1 RFC7 patches2 repliesSuperseded

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/14i3c: master: Fix recursive locking during device registrationdrivers/i3c/master.c include/linux/i3c/master.h+36 -120 replies
2/14i3c: Fix unlocked dereference of dev->desc in i3c_device_get_supported_xfer_mode()drivers/i3c/device.c drivers/i3c/internals.h drivers/i3c/master.c+6 -70 replies
3/14i3c: master: Do not treat master device as a duplicate targetdrivers/i3c/master.c+2 -10 replies
4/14i3c: master: Fix use-after-free of master->thisdrivers/i3c/master.c+11 -60 replies
5/14i3c: Make dev->desc locking assumptions explicitdrivers/i3c/device.c+1 -20 replies
6/14i3c: master: Fix potential UAF in i3c_device_uevent()drivers/i3c/master.c+1 -20 replies
7/14i3c: master: Fix potential UAF in i3c_device_match()drivers/i3c/master.c+3 -12 replies
8/14i3c: master: Support IBI-based wakeup capabilitydrivers/i3c/master.c include/linux/i3c/master.h+6 -00 replies
9/14i3c: master: Report wakeup events for IBIsdrivers/i3c/master.c+6 -00 replies
10/14i3c: master: Add helper to query bus wakeup requirementsdrivers/i3c/master.c include/linux/i3c/master.h+36 -00 replies
11/14i3c: master: Reject IBI requests from non-IBI-capable devicesdrivers/i3c/device.c+5 -30 replies
12/14i3c: mipi-i3c-hci-pci: Propagate I3C wakeup requirements to PCIdrivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c+21 -20 replies
13/14i3c: mipi-i3c-hci: Factor out i3c_hci_sysdev()drivers/i3c/master/mipi-i3c-hci/core.c drivers/i3c/master/mipi-i3c-hci/dma.c drivers/i3c/master/mipi-i3c-hci/hci.h+19 -140 replies
14/14i3c: mipi-i3c-hci: Advertise IBI wakeup capabilitydrivers/i3c/master/mipi-i3c-hci/core.c+6 -20 replies

Reviews trailers per patch

All 14 patches have a Reviewed-by or Acked-by.

PatchFrank LiMukesh Savaliya
1/14R-b
2/14R-b
3/14R-b A-b
4/14R-b
5/14R-b A-b
6/14R-b A-b
7/14R-b
8/14R-b A-b
9/14R-b
10/14R-b A-b
11/14R-b
12/14R-b
13/14R-b A-b
14/14R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH V5 00/14] i3c: Support IBI-based system wakeup

Hi

Note: all patches except patch 7 now have Frank's Rev'd-by

Intel LPSS I3C controllers support up to two I3C busses and can wake the system from an In-Band Interrupt (IBI) via a PCI PME. Today that wakeup capability lives only at the PCI function, with no way to express which I3C device is actually responsible for waking the system, and no way for user space to enable or disable wakeup on a per-device basis.

This series pushes the wakeup capability down to the individual I3C devices and then aggregates the resulting wakeup state back up to the PCI device.

An IBI-capable I3C device on a bus whose controller can wake the system is marked as wakeup capable, so it can be managed through the standard device wakeup framework (e.g. via power/wakeup in sysfs). When such a device is enabled for wakeup, a wakeup event is reported each time it queues an IBI.

At suspend time, the mipi-i3c-hci PCI driver aggregates the wakeup configuration of the I3C devices across its HCI instances (up to two I3C busses) and enables PCI wakeup (PME) only when at least one attached I3C device is enabled as a wakeup source and has IBI enabled. This keeps the PCI wakeup state in sync with the actual requirements of the devices on the busses.

The series is organised as follows:

- Patch 1 fixes a pre-existing recursive acquisition of the bus rwsem in i3c_master_register_new_i3c_devs(). The remaining patches add work to that same function, so the locking is corrected first.

- Patches 2-7 fix use-after-free and unlocked accesses of the i3c_device desc pointer. Moving device registration out from under the bus lock in patch 1 is what makes it possible to take the bus lock in the helpers that run during registration.

- Patches 8-11 add the generic I3C core support: an ibi_wakeup flag for controllers, marking IBI-capable devices as wakeup capable, reporting wakeup events on IBIs, a helper to query whether any device on a bus has both wakeup and IBI enabled, and a fix to reject IBI requests from devices that do not advertise IBI capability.

- Patches 12-14 wire this up for the mipi-i3c-hci driver: propagate the aggregated I3C wakeup requirements to the PCI function, factor out i3c_hci_sysdev() for the shared device lookup, and advertise IBI wakeup capability when the underlying system device can wake the system.

Note, since the PCI wakeup state is now derived from the wakeup configuration of the attached I3C devices, the PCI device's power/wakeup sysfs attribute no longer provides independent wakeup control.

Changes in V5:

Added Frank Li's Reviewed-by and Mukesh Savaliya's Acked-by tags.

Changes in V4:

i3c: master: Fix recursive locking during device registration
Expanded the kernel-doc for the new struct i3c_device @node member to note that it is only for use by i3c_master_register_new_i3c_devs() and is not protected by a lock.

i3c: master: Fix use-after-free of master->this
Also reset master->this and bus.cur_master to NULL on the i3c_master_set_info() error path before freeing the allocated device. Tidied up the commit message wording.

i3c: master: Support IBI-based wakeup capability
Shortened the comment about IBI-capable devices being wakeup capable.

i3c: master: Add helper to query bus wakeup requirements
Renamed i3c_master_any_wakeup_enabled() to i3c_master_has_wakeup_enabled_devs().

i3c: mipi-i3c-hci-pci: Propagate I3C wakeup requirements to PCI
Updated for the rename of i3c_master_any_wakeup_enabled() to i3c_master_has_wakeup_enabled_devs().

i3c: mipi-i3c-hci: Factor out i3c_hci_sysdev()
Reworked the comment that moves with the code into kernel-doc, and mentioned that in the commit message.

i3c: mipi-i3c-hci: Advertise IBI wakeup capability
Updated the i3c_hci_sysdev() kernel-doc to mention system PM and wakeup, in place of the old comment tweak.

Added Frank Li's Reviewed-by and Mukesh Savaliya's Acked-by tags.

Changes in V3:

Added 6 patches (2-7) that fix use-after-free and unlocked accesses of the i3c_device desc pointer. Moving device registration out from under the bus lock in patch 1 is what allows that pointer to be protected in the helpers that run during registration.

i3c: master: Fix recursive locking during device registration
Added Cc: [email protected]

i3c: master: Add helper to query bus wakeup requirements
Skip the master device explicitly. Noted in the kernel-doc that wakeup enablement is user space policy, so the helper is meant to be called from a system suspend callback.

Added Frank Li's Reviewed-by tags.

Rebased onto i3c/next.

Changes in V2:

Dropped the RFC tag.

i3c: master: Fix recursive locking during device registration
New patch

i3c: master: Support IBI-based wakeup capability
Dropped the redundant #include <linux/pm_wakeup.h>. That header must not be included directly, and linux/device.h, which is already included, provides device_set_wakeup_capable().

i3c: master: Add helper to query bus wakeup requirements
i3c_master_any_wakeup_enabled() now also requires the device to have IBI enabled, not just system wakeup enabled, so that a device with no active IBI request does not keep PCI PME enabled. desc->ibi_lock is taken while checking. The commit message and kernel-doc are updated to match.

Rebased onto i3c/next.

Adrian Hunter (14):
i3c: master: Fix recursive locking during device registration
i3c: Fix unlocked dereference of dev->desc in i3c_device_get_supported_xfer_mode()
i3c: master: Do not treat master device as a duplicate target
i3c: master: Fix use-after-free of master->this
i3c: Make dev->desc locking assumptions explicit
i3c: master: Fix potential UAF in i3c_device_uevent()
i3c: master: Fix potential UAF in i3c_device_match()
i3c: master: Support IBI-based wakeup capability
i3c: master: Report wakeup events for IBIs
i3c: master: Add helper to query bus wakeup requirements
i3c: master: Reject IBI requests from non-IBI-capable devices
i3c: mipi-i3c-hci-pci: Propagate I3C wakeup requirements to PCI
i3c: mipi-i3c-hci: Factor out i3c_hci_sysdev()
i3c: mipi-i3c-hci: Advertise IBI wakeup capability

 drivers/i3c/device.c                               |  13 +--
 drivers/i3c/internals.h                            |   5 +
 drivers/i3c/master.c                               | 119 ++++++++++++++++-----
 drivers/i3c/master/mipi-i3c-hci/core.c             |  20 ++++
 drivers/i3c/master/mipi-i3c-hci/dma.c              |  15 +--
 drivers/i3c/master/mipi-i3c-hci/hci.h              |   2 +
 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c |  23 +++-
 include/linux/i3c/master.h                         |   6 ++
 8 files changed, 155 insertions(+), 48 deletions(-)

Regards
Adrian