...ysfs-platform-regulator-userspace-consumer | 23 +++++ .../regulator/userspace-consumer.rst | 92 +++++++++++++++++++ drivers/regulator/userspace-consumer.c | 74 ++++++++++++++- 3 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-regulator-userspace-consumer create mode 100644 Documentation/driver-api/regulator/userspace-consumer.rst
This series adds support for regulator event reporting via uevents to the
userspace-consumer regulator driver. The goal is to provide userspace with
a straightforward mechanism to monitor and respond to important regulator
events such as overcurrent conditions, voltage changes, and enable/disable
transitions.
Signed-off-by: Johann Neuhauser <jneuhauser@dh-electronics.com>
---
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
---
Johann Neuhauser (3):
regulator: userspace-consumer: Add uevent reporting for regulator
events
ABI: sysfs-platform: Document uevent ABI for reg-userspace-consumer
docs: regulator: userspace-consumer: Add uevent-based regulator event
reporting
...ysfs-platform-regulator-userspace-consumer | 23 +++++
.../regulator/userspace-consumer.rst | 92 +++++++++++++++++++
drivers/regulator/userspace-consumer.c | 74 ++++++++++++++-
3 files changed, 188 insertions(+), 1 deletion(-)
create mode 100644 Documentation/ABI/testing/sysfs-platform-regulator-userspace-consumer
create mode 100644 Documentation/driver-api/regulator/userspace-consumer.rst
--
2.39.5
On Fri, Apr 04, 2025 at 03:40:06PM +0200, Johann Neuhauser wrote: > This series adds support for regulator event reporting via uevents to the > userspace-consumer regulator driver. The goal is to provide userspace with > a straightforward mechanism to monitor and respond to important regulator > events such as overcurrent conditions, voltage changes, and enable/disable > transitions. This sounds like you're trying to use userspace-consumer in production rather than as a test bodge... what's the actual use case here?
From: Mark Brown <broonie@kernel.org> Sent: Friday, April 4, 2025 7:03 PM > >On Fri, Apr 04, 2025 at 03:40:06PM +0200, Johann Neuhauser wrote: >> This series adds support for regulator event reporting via uevents to the >> userspace-consumer regulator driver. The goal is to provide userspace with >> a straightforward mechanism to monitor and respond to important regulator >> events such as overcurrent conditions, voltage changes, and enable/disable >> transitions. > >This sounds like you're trying to use userspace-consumer in production >rather than as a test bodge... what's the actual use case here? Hi Mark, Thank you for your feedback and question. We have a hardware setup where the USB-A port is directly connected (D+/D- lines) to the SoC, while its VBUS line is driven by an external I²C-based PMIC. If a connected USB device attempts to draw more than approximately 800mA, the PMIC detects an overcurrent condition, automatically disables the output, and communicates an overcurrent event via the regulator framework. Currently, the generic USB HCD drivers lack a built-in mechanism for handling or recovering from such regulator-related events, particularly for reporting or re-enabling regulator outputs after an OC condition occurs. The DA8xx OHCI driver is one exception, as it indeed provides such functionality, but integrating similar support into the generic USB HCD drivers seemed unlikely to be accepted upstream. I came across the userspace-consumer driver and believed it could help manage this specific scenario. With this driver, I was able to manually toggle the regulator off and back on, successfully clearing the error state. However, the driver lacked proper event reporting, making it difficult to identify when the regulator had entered an error state. Therefore, I proposed adding regulator event reporting to enable userspace to detect these regulator events via udev rules and subsequently restore regular USB power operation. While I was aware that using the userspace-consumer driver might be seen as somewhat of a workaround for special cases, I did not fully consider that it was intended primarily as a temporary testing solution and perhaps not suitable for this kind of production usage. I'd be grateful for any suggestions or advice you might have on the appropriate approach or alternative solutions you could recommend for upstream integration. Thanks for again your input and guidance! Best regards, Johann
On Mon, Apr 07, 2025 at 02:17:10PM +0000, Johann Neuhauser wrote: > From: Mark Brown <broonie@kernel.org> > >On Fri, Apr 04, 2025 at 03:40:06PM +0200, Johann Neuhauser wrote: > >> This series adds support for regulator event reporting via uevents to the > >> userspace-consumer regulator driver. The goal is to provide userspace with > >> a straightforward mechanism to monitor and respond to important regulator > >> events such as overcurrent conditions, voltage changes, and enable/disable > >> transitions. > >This sounds like you're trying to use userspace-consumer in production > >rather than as a test bodge... what's the actual use case here? > We have a hardware setup where the USB-A port is directly connected (D+/D- > lines) to the SoC, while its VBUS line is driven by an external I²C-based PMIC. > If a connected USB device attempts to draw more than approximately 800mA, > the PMIC detects an overcurrent condition, automatically disables the output, > and communicates an overcurrent event via the regulator framework. You absolutely should not be using the userspace consumer for this. > Currently, the generic USB HCD drivers lack a built-in mechanism for handling > or recovering from such regulator-related events, particularly for reporting or > re-enabling regulator outputs after an OC condition occurs. The DA8xx OHCI > driver is one exception, as it indeed provides such functionality, but > integrating similar support into the generic USB HCD drivers seemed unlikely to > be accepted upstream. Why not? This seems like a perfectly reasonable thing to want to do, if only as far as generating notifications to userspace. > While I was aware that using the userspace-consumer driver might be seen as > somewhat of a workaround for special cases, I did not fully consider that it > was intended primarily as a temporary testing solution and perhaps not suitable > for this kind of production usage. I'd be grateful for any suggestions or advice you > might have on the appropriate approach or alternative solutions you could > recommend for upstream integration. I'd expect the consumer driver to be listening for events and offering some sort of handling and/or interface for this that's joined up with whatever the consumer is doing. That basically means that your initial thought above sounds about right to me.
© 2016 - 2026 Red Hat, Inc.