lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 Oct 2023 09:59:31 +0200
From:   Oleksij Rempel <o.rempel@...gutronix.de>
To:     Mark Brown <broonie@...nel.org>
Cc:     Liam Girdwood <lgirdwood@...il.com>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Conor Dooley <conor+dt@...nel.org>, kernel@...gutronix.de,
        linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
        Naresh Solanki <naresh.solanki@...ements.com>,
        zev@...ilderbeest.net, Sebastian Reichel <sre@...nel.org>,
        linux-pm@...r.kernel.org
Subject: Re: [PATCH v1 3/3] regulator: fixed: forward under-voltage events

On Tue, Oct 10, 2023 at 06:19:59PM +0100, Mark Brown wrote:
> On Tue, Oct 10, 2023 at 02:55:31PM +0200, Oleksij Rempel wrote:
> 
> > The hardware I am working with has an under-voltage sensor on the 24V
> > supply regulator and some backup capacitors to run SoC for 100ms. I want
> > to forward under-voltage events across a chain of different regulators
> > to a designated consumer. For instance, to the mmc driver, enabling it
> > to initiate shutdown before power loss occurs.  Additionally, a bit can
> > be set in the volatile memory of a scratch pad in an RTC clock to record
> > sudden power loss, which can be checked on the next system start.
> 
> So it sounds like the underlying need is to flag the notifications from
> one of the regulators as being system wide and then take action based on
> those notifications somewhere basically disconnected?  That does seem
> like a good use case.
> 
> The MMC doesn't specifically care that it is handling a regulator
> notification, it more wants to know that the system is dying and doesn't
> really care how we figured that out so if we can hook it into a system
> level notificaiton it'd be happy and would also be able to handle other
> critical faults.  I would have thought that we should have some
> mechanisms for this already for RAS type stuff but I'm drawing a blank
> on what it actually is if there is an existing abstraction.  It could
> potentially go through userspace though there's latency concerns there
> which might not be ideal, there should at least be some policy for
> userspace.

The project I'm working prefers reducing user space daemons to configure and
enforce RAS policies due to time and financial budget constraints. The customer
is inclined to invest only in essential infrastructure.

Configuration through the device tree and kernel defaults is preferable.
For instance, having a default kernel governor that doesn’t require user
space configuration aligns with the project’s objectives.

While a proper UAPI might not be implemented in the first run, the
design will allow for it to be added and extended by other projects in
the future.

> For the regulator itself we probably want a way to identify regulators
> as being system critical so they start notifying.  It would be tempting
> to just do that by default but that would likely cause some issues for
> example with regulators for things like SD cards which are more likely
> to get hardware problems that don't comprimise the entire system.  We
> could do that with DT, either a property or some sort of runtime
> consumer, but it might be better to have a control in sysfs that
> userspace can turn on?  OTOH the ability do something about this depends
> on specific hardware design...
> 
> I've copied in Sebastian since this sounds like the sort of thing that
> power supplies might have some kind of handling for, or at least if we
> need to add something we should make it so that the power supplies can
> be joined up to it.  I do see temperature and capacity alerts in the
> sysfs ABI for power supplies, but nothing for voltage.

Thank you for pointing towards the power supply framework. Given the hardware
design of my project, I can envision mapping the following states and
properties within this framework:

1. States:
   - POWER_SUPPLY_STATUS_FULL: When the capacitor is fully charged.
   - POWER_SUPPLY_STATUS_DISCHARGING: Triggered when an under-voltage event is
                                      detected.

2. Technology:
   - POWER_SUPPLY_TECHNOLOGY_CAPACITOR

3. Capacity Level:
   - Post under-voltage detection, the system would immediately transition to
     POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL state.

4. Properties:
   - POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: 100ms, representing the time until
                                          complete power loss.
   - POWER_SUPPLY_TYPE_MAINS: Under normal operation.
   - POWER_SUPPLY_TYPE_BATTERY: Triggered when under-voltage is detected.

Considering the above mapping, my initial step would be to create a simple
regulator coupled (if regulator is still needed in this casr) with a Device
Tree (DT) based power supply driver.  This setup would align with the existing
power supply framework, with a notable extension being the system-wide
notification for emergency shutdown upon under-voltage detection.

> I've also coped in Naresh and Zev who've been discussing something
> vaugely similar with userspace notifications for the userspace consumer
> - it's not the same thing given that you don't specifically need
> userspace to be involved here but it feels like it might have something
> of a similar shape, or at least there might be some shared interest.

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ