Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp644439rdg; Wed, 11 Oct 2023 01:00:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG09TulqO2dj0dYjuYUGVuyrFq83PCkSN8EJ5+B04pdohLpLKjxjcUAxDuWKPDXKyvSCaVb X-Received: by 2002:a17:902:c411:b0:1c3:e2eb:f79d with SMTP id k17-20020a170902c41100b001c3e2ebf79dmr28729953plk.8.1697011205421; Wed, 11 Oct 2023 01:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697011205; cv=none; d=google.com; s=arc-20160816; b=rsA2cWxaHkKhbkHWu2eoqAGv4UNzfIaAdLm/DR6UGnMfVfgY9qGfPg5EMN9GMI6vvC i3LdkS8ZbK2bljAKzJPnHr9KqQkRGAFRt6g6U8anHlokhh/IheQ2lbER731+RILYLdZ6 j0hjeSFSJxuxLyd6vHnJXduxM6IUHfA5wOUByAfW4OWa94O38DKpcVw4XkXq7RGL4lgu J8r0Cfl845jNGrhA8Du5gM5zfXqPCeCHqzab7gtzyVo4g+hZzL9U2+j/ZByf9kuYv7Of m9+0TaprsZ2Be3jLhOnzhfP7/BSh9edzxEi8s/FnIduF5BXbi/yjBJVbc4a/4PqGGRb9 qtlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JLq14XnncjKyfavYmzV3/W9S2tVjGtSTham7dWJMMpM=; fh=rpUgunYLxjbKSPE+ytwMGvmiie/34RHqDOPJyb8RUWQ=; b=gM8l9N9LDwzDOx/GPA7GtqHttrqfUnbYJXO/qFx3O3XdTrgwLTcrhykCdQMKJ6srT+ ui2T+V0qPLnyJsd/G8lqJ7QAl7icKjWV9/QLzOG1GM/RqxxqbUPlEIxojBqpnrtB4edL 4OkjULiYmh2j0UZ7iLBQxS3CETFDv7zAv4ZkuWbqxs9uQLL/t699k6+Y/q3lZ339lhK/ KxuQU/o2SPOwQcgNVOfhij57oczlVT8uoRiOqae9nUtHd2M6GOupbQ794Z8wpeCgb8gy YAXbFNdj/xJwxFdfv8SnKEZE/ZSFQFP4EptTF/JOFfUJWwUS/5s5oTYAEkuM7XTCTZ6N KydA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id c9-20020a170903234900b001bf1973eafcsi15130911plh.571.2023.10.11.01.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 01:00:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B60C7802587E; Wed, 11 Oct 2023 00:59:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbjJKH7t (ORCPT + 99 others); Wed, 11 Oct 2023 03:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230031AbjJKH7r (ORCPT ); Wed, 11 Oct 2023 03:59:47 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF19591 for ; Wed, 11 Oct 2023 00:59:44 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qqU7w-0006Ab-CQ; Wed, 11 Oct 2023 09:59:32 +0200 Received: from [2a0a:edc0:2:b01:1d::c0] (helo=ptx.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqU7v-000qiI-HM; Wed, 11 Oct 2023 09:59:31 +0200 Received: from ore by ptx.whiteo.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qqU7v-00Ds9z-EG; Wed, 11 Oct 2023 09:59:31 +0200 Date: Wed, 11 Oct 2023 09:59:31 +0200 From: Oleksij Rempel To: Mark Brown Cc: Liam Girdwood , Rob Herring , Krzysztof Kozlowski , Conor Dooley , kernel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Naresh Solanki , zev@bewilderbeest.net, Sebastian Reichel , linux-pm@vger.kernel.org Subject: Re: [PATCH v1 3/3] regulator: fixed: forward under-voltage events Message-ID: <20231011075931.GA3305420@pengutronix.de> References: <20231010085906.3440452-1-o.rempel@pengutronix.de> <20231010085906.3440452-3-o.rempel@pengutronix.de> <5e51792a-cc93-4364-a51b-c2b116d89369@sirena.org.uk> <20231010125531.GA3268051@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 00:59:59 -0700 (PDT) X-Spam-Level: ** 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 |