[PATCH v2 0/2] rpmsg: glink: Offer wakeup capabilities

From: David Heidelberg via B4 Relay

Date: Sun Nov 22 2026 - 15:24:34 EST


LLM generated summary of the decision chosen here, feel free to skip to
the changelog.

Trade-offs made:
1. Sysfs power/wakeup switch vs per-socket EPOLLWAKEUP (from v1 review):
- Chosen: Device-level sysfs power/wakeup (disabled by default).
- Trade-off: Works immediately with existing userspace (ModemManager, sensor daemons, udev rules) without requiring application changes, at the
cost of channel/endpoint granularity instead of per-socket granularity.
2. Reporting wakeup only inside if (channel->ept.cb) under channel->recv_lock:
- Chosen: Gate wakeup on an active endpoint callback rather than adding extra synchronization around channel->rpdev.
- Trade-off: Keeps GLINK locking simple and avoids waking the system for packets that get dropped anyway (no consumer), while holding channel-
>recv_lock across pm_wakeup_hard_event() (a short spinlock path: dev->power.lock -> ws->lock).
3. Solving /dev/rpmsg_ctrlX wakeup in rpmsg_char.c (Patch 2) instead of falling back to channel->rpdev in GLINK:
- Chosen: Per-endpoint wakeup on /sys/class/rpmsg/rpmsgX/power/wakeup in rpmsg_char.
- Trade-off: Transport-independent (works for GLINK, SMD, virtio-rpmsg) and covers locally-initiated endpoints that never have a per-channel
channel->rpdev, without complicating GLINK's channel->rpdev lifetime. In return, userspace configures /sys/class/rpmsg/rpmsgX/power/wakeup
after endpoint creation rather than the GLINK bus device, and directly bound rpmsg_chrdev channels expose two independent power/wakeup knobs
(both off by default).
4. Immediate hard wakeup (pm_wakeup_hard_event(), msec = 0) vs timed wakeup (pm_wakeup_event(..., msec)):
- Chosen: Same as v1 (msec = 0, hard = true).
- Trade-off: Immediately aborts suspend / wakes s2idle and bumps wakeup_count without holding the system awake for an arbitrary hardcoded
timeout, relying on userspace/suspend managers (e.g. via /sys/power/wakeup_count) not to re-suspend before draining the queued message.
5. Setting wakeup capability after rpmsg_register_device() in GLINK:
- Chosen: Kept v1's placement in qcom_glink_rx_open().
- Trade-off: Works via wakeup_sysfs_add() + a KOBJ_CHANGE uevent, though udev rules matching only ACTION=="add" could race with power/wakeup
creation on the GLINK bus device (Patch 2 avoids this for /sys/class/rpmsg/rpmsgX by calling device_set_wakeup_capable() before
cdev_device_add()).

Changes in v2:
- Use pm_wakeup_hard_event(&channel->ept.rpdev->dev) inside channel->recv_lock
and the channel->ept.cb check to fix the NULL pointer dereference,
dev->power.wakeup/rpdev use-after-free races, and CONFIG_PM_SLEEP=n build.
- Fix subject prefix ("rpmsg: glink:") and comment typo.
- Add a follow-up patch enabling per-endpoint wakeup on /dev/rpmsgX in
rpmsg_char so dynamic /dev/rpmsg_ctrlX endpoints can also opt in to wakeup.
- Link to v1: https://lore.kernel.org/all/20230117142414.983946-1-caleb.connolly@xxxxxxxxxx/

Signed-off-by: David Heidelberg <david@xxxxxxx>
---
Casey Connolly (1):
rpmsg: glink: Support waking up on channel rx

David Heidelberg (1):
rpmsg: char: Support waking up on endpoint rx

drivers/rpmsg/qcom_glink_native.c | 12 ++++++++++++
drivers/rpmsg/rpmsg_char.c | 2 ++
2 files changed, 14 insertions(+)
---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20251118-rpmsg-qcom-glink-8aab10623ff5

Best regards,
--
David Heidelberg <david@xxxxxxx>