From patchwork Tue Nov 7 19:09:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 162696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp451446vqo; Tue, 7 Nov 2023 11:11:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFRawankng1fw6NkIOx3RWUdKBIdk5Lb/4MiOhRRhCAD517mofm3GciZ4+3Z1tUa7T6daJ X-Received: by 2002:a05:6a00:2345:b0:6be:4228:6970 with SMTP id j5-20020a056a00234500b006be42286970mr32138472pfj.21.1699384271385; Tue, 07 Nov 2023 11:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699384271; cv=none; d=google.com; s=arc-20160816; b=k4yBC2+9FxKmb0DY0pFqCfTRIhG4i4P5jnJWtVyeAfO1ckpa86ABdWGRqbkRhDSc8T 2zrU2VrljIG45EWJKe8ZGhja+O9ztMsbD74sP4fY22zid4C4VRN6g7C7t/Mgp0fP9uDb NfrrI5Epj/Va2YO5OkBW3RUWmmalzSrqdoKvSCW3vd/uS4FqNFk9QXXoXbkPQiEROCwQ B1iv8v6zxA6Pw3/4e0c0n8fUXWRk1TJbg9Rrx9jhuglIwuee3C0R+S8Kx7Kx43zcP4pK zWoswqOkoX4FpLdANurTTD1u3T6831dGwPFUFObKqZXsstQeBUhuT2aSsCqkbTWIoZRj 5OCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3J40+zQ/6dP9tvNGgIODUTJ9R+5seR+mVk01q9f45Uc=; fh=3oN2B+/HtpoCgLb5XsrOKJ4Np6tA9iGe9Ck5gbnlBw8=; b=HQtICzBGaOccG1G4aG/mY18jPcOhkhPqzwvGZr7cIoPNDHzuSujNlekqs5bcG8MXde 6Q5XmP3yH/UPwwnfTVPvIDIJ/2zqpeHSTqMaCaiReLcOYAuMDOm1LDBtvN8efJjirzKO NoXp5CHSAIUikVVchcA5Rqlg3pLCzC/FRNcBHXksHIElnzf40yFKgmkZVY/7jC9zx1Op TGXS0w5r9GQDY8xPe7LcBLKWH2ScOeacCWVhisnyf1pMe0vsY7S6f7BD2LgDZJnXg2o5 sx2LZ3GZWyBK9VtiyMhUL5zjuZbf2peeLXLHgoCRJKvVx7A6v8XILJAY38ATHDRXDaSR JmmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AkWCmIm4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u1-20020aa78481000000b006933c57195esi10213752pfn.399.2023.11.07.11.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 11:11:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AkWCmIm4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0EA70808EE70; Tue, 7 Nov 2023 11:11:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234038AbjKGTKU (ORCPT + 32 others); Tue, 7 Nov 2023 14:10:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjKGTKS (ORCPT ); Tue, 7 Nov 2023 14:10:18 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D20119 for ; Tue, 7 Nov 2023 11:09:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699384173; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3J40+zQ/6dP9tvNGgIODUTJ9R+5seR+mVk01q9f45Uc=; b=AkWCmIm4FGB+ozV4JCeS9eBvArUd0nSetKfVWjNj1yyTBrL1ibzOiPUXC6OhPuBMMLOGy9 TNSSuWdot26E0rHwjWxvob113D47e/f4xrCJfFDY1/fnpoUF4JbA8WPirQLfurW5eU2/Z6 bVfdbw3dwPFNK4iuUVxRwsWVc7F75iQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-kwqMoIXeNfuFAdziF3K6Og-1; Tue, 07 Nov 2023 14:09:32 -0500 X-MC-Unique: kwqMoIXeNfuFAdziF3K6Og-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4094e5664a3so40140235e9.0 for ; Tue, 07 Nov 2023 11:09:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699384170; x=1699988970; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3J40+zQ/6dP9tvNGgIODUTJ9R+5seR+mVk01q9f45Uc=; b=aCYhs2RsYynN248dgJjIcK/n23Ta8B8vUpzUwXGJT39c32zPZfxP32AsCTtNgwueNF KzxufQWDHs7dLplUHuv/xytDKsdlSVUlOl3NkXmCvE2cBGxOxhz+aENPo5uHclCtrgF8 SpPgg0NNxRRy+EXbGsUgqbhnyEefA45tEh1WEekZmwx2xFPHgfO48e3pr0QwhxyLrbZw 8xONYd4KECf+D80vMu7mvqSxtdFmon2qFqfy7ri2tlV7CgglGJCP2YOjLbkN8uZT4+TC m+WNnv8Z923JvfZbAFYj1AQ5WIhk7Poa2xoTg8+1y0cojezDXYsKL1bRZoqGnj03GlyW 6a2Q== X-Gm-Message-State: AOJu0YyPYrbRlrjX1a/PFcIn9gVqDyEQ1NFS3RqVw6MbJ9dL7BRXAAfd 5lJw7bwfJRcRKzIx27r0xAUlRu2xDOFAuZibkz6B32h46EXwq+eDcYAB+W2zwKB6Z9BQTlTr/nc eJiBtGXS9uhozpkh8bphNfU3EstooQ9RVsgVla5bUdVZuHVtiMEoc4W16tq7N/EmvvDij0iJOLX g0YzI/zmY= X-Received: by 2002:a05:600c:4448:b0:409:79cb:1df6 with SMTP id v8-20020a05600c444800b0040979cb1df6mr3032976wmn.14.1699384169634; Tue, 07 Nov 2023 11:09:29 -0800 (PST) X-Received: by 2002:a05:600c:4448:b0:409:79cb:1df6 with SMTP id v8-20020a05600c444800b0040979cb1df6mr3032941wmn.14.1699384169220; Tue, 07 Nov 2023 11:09:29 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id f20-20020a05600c43d400b003fbe4cecc3bsm16089746wmn.16.2023.11.07.11.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 11:09:28 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Manivannan Sadhasivam , Randy Dunlap , Manivannan Sadhasivam , Brian Masney , Javier Martinez Canillas , Jonathan Corbet , Liam Girdwood , Mark Brown , "Paul E. McKenney" , "Rafael J. Wysocki" , "Steven Rostedt (Google)" , Tejun Heo , linux-doc@vger.kernel.org Subject: [PATCH v2] regulator: core: Add option to prevent disabling unused regulators Date: Tue, 7 Nov 2023 20:09:18 +0100 Message-ID: <20231107190926.1185326-1-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 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 (fry.vger.email [0.0.0.0]); Tue, 07 Nov 2023 11:11:09 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781933561911889819 X-GMAIL-MSGID: 1781933561911889819 This may be useful for debugging and develompent purposes, when there are drivers that depend on regulators to be enabled but do not request them. It is inspired from the clk_ignore_unused and pd_ignore_unused parameters, that are used to keep firmware-enabled clocks and power domains on even if these are not used by drivers. The parameter is not expected to be used in normal cases and should not be needed on a platform with proper driver support. Signed-off-by: Javier Martinez Canillas Reviewed-by: Brian Masney Acked-by: Manivannan Sadhasivam --- Changes in v2: - Grammar changes suggested by Randy Dunlap. - Add collected tags from v1. Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ drivers/regulator/core.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0a1731a0f0ef..d7c83c8ae80d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5461,6 +5461,13 @@ print every Nth verbose statement, where N is the value specified. + regulator_ignore_unused + [REGULATOR] + Prevents regulator framework from disabling regulators + that are unused, due no driver claiming them. This may + be useful for debug and development, but should not be + needed on a platform with proper driver support. + relax_domain_level= [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/admin-guide/cgroup-v1/cpusets.rst. diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 3137e40fcd3e..79777495cc3a 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -6234,6 +6234,14 @@ static int regulator_late_cleanup(struct device *dev, void *data) return 0; } +static bool regulator_ignore_unused; +static int __init regulator_ignore_unused_setup(char *__unused) +{ + regulator_ignore_unused = true; + return 1; +} +__setup("regulator_ignore_unused", regulator_ignore_unused_setup); + static void regulator_init_complete_work_function(struct work_struct *work) { /* @@ -6246,6 +6254,15 @@ static void regulator_init_complete_work_function(struct work_struct *work) class_for_each_device(®ulator_class, NULL, NULL, regulator_register_resolve_supply); + /* + * For debugging purposes, it may be useful to prevent unused + * regulators from being disabled. + */ + if (regulator_ignore_unused) { + pr_warn("regulator: Not disabling unused regulators\n"); + return; + } + /* If we have a full configuration then disable any regulators * we have permission to change the status for and which are * not in use or always_on. This is effectively the default