| Message ID | 20261026152027.1417178-1-hsyysy@163.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-26904-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id 690971C2001 for <noreply@patchwork.local>; Mon, 26 Oct 2026 16:23:29 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=163.com; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-26904-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-26904-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 2B99129471 for <noreply@patchwork.local>; Mon, 26 Oct 2026 15:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1793028081; b=UfPuDdoVcYjvwcd1ruajFUkvjxHkexP6Qj4PwQ0c+UaE4R2AFwf6G3FZu0Gk9RUr1DuA PQPS7PtK2jlAOf53AWEXvaeC78CQ6VaGar2NcSlbYhLiqqw39Yy0j5ZYK6Qg4Rv/LaNx/ grtHXaoxRbCgVlhTxNc/IHjBlnvkgwp4tLOY7AUhmWV0nlMMtVwsloMz0RuaNp3Ju0/Sl CGva0kLj/G34njR/xXiDlehtO25dvkAxNcI6vIgA9CBThWmpsFuCWCOqRKVpu8ZZtYdTQ 8JuQDACYy1m2cpOe+FEEmG2OHfLs+ixnT/ReouqkR66s7jxTJyUOWLIVNFmT1hYXxfA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793028081; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=NgUZou+QAUenodbqqsNTHG+MAZHRcJXPTQZv1JbHVys=; b=Mlsqj2FDRlT3jtXLXYvgdg5YvtS2ZyxIM/e9SpxD0m5cmQqzWhNRG8D3JAC99FYK4e/P U0zDKwZw1s4tMwD8OWTdJLOpWq8KUQjqznDVYRNoi1h9NGjRP6jSmmDG3vzFu+wmnsPHj CV7d5iVj57UDcvKJCYSx3CLiEVNL9rs6izJhaWIZKGZuSIunY2/iLUqRsWOYl9cxNPyLH mmcrSZN8zFVgYkNC7wAS2xw3kNAAKfMCJ1duMxm3Q1c20bTNt1kvJFYSk8/Hos0s4f4Ph Aj3VwYEMu9N+2wK348lKsfAEJSgDYoWDh6zYcA2Pc+HHLUl9xr5JJa5o0rkt/MnOgaA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Zdp1usVO; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=fail smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AAC8606A31B; Mon, 26 Oct 2026 15:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Zdp1usVO X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793028081; b=zeeUwNgUZ+fFetau51nrLvoz/a9Wy9BRsB317M/mxN/m2UxS0eqthxU1jZNMDz/O2Aaq 1VRzw+0CcZG7LAbLfHypLO6+McVzfDOkaJaT0iahCi9KqpBu30xVWizV6ou8ZfdZzHmXB wkrMpdg5a8LvpjBEpe9qGrOoAKRwX+LHJ5qGoDyCREE5VxYpR+HtPNi7aRdhZgP3VYewo qR91ckU+eser6RiVvnBwXMgkzduysNkGPdoPWRp7uxc2r0VB7cLZrcB7IKZLVVts9J2Dk thwLGcuZZFPOgFPTvKH5EsthPhUTkEo6Spo7sfj/b460oYnIGKcS+OYwKhyBWKHpe4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793028081; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-Originating-IP:X-CM-SenderInfo; bh=NgUZou+QAUenodbqqsNTHG+MAZHRcJXPTQZv1JbHVys=; b=J/4Of8IWVoL7c/PdxpKF22RoOJ9QMcO7cjiXegRn0+DDnt+6hvZU4Tm6JSgja0vm0f0j V+76dCNnUfLj/fKHNnj+biVLKUr4j80ACAXyNutUL+PcfWdPf90/0CuU2FKJX7D3qPMi6 o+RGCkGQlXgzDM3o+Kffh+4YtWpiq+GIHmTCEBLtHUdBU/4zgQD3tcH9W+h1UG/j4wsSN QO4+lCzCjK5oSUBBe5ig78n/WCREHrAvrZT5qhnMOVxaXWxCdeatzlDU7tcrmheziGM4P JNElUlPagrjKCyW8SxXqh2307omPtapHxmd9Sw5ceDobj7hNfauzhK0L/qc0Pyq+W4A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Zdp1usVO; arc=none smtp.remote-ip=117.135.210.4 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F22AC606A31A for <linux-sunxi@lists.linux.dev>; Mon, 26 Oct 2026 15:21:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F22AC606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Ng UZou+QAUenodbqqsNTHG+MAZHRcJXPTQZv1JbHVys=; b=Zdp1usVO+wA1HyRZky ELohWUrb/FJ+Wz0rd8BNcMAJLR2AJTCopWLgYZjKLUQrhK2qtFJIp8OBGc82TKSJ XJDf45LKpo/wjE6WreuMLkMg14/R/8xSMf45Cc6Vrixj9BJddKRvmlWXk86cUPr7 iHtijdSLB3Vlf6BkvdfoVPlxU= Received: from SYPC (unknown []) by gzga-smtp-mtada-g0-3 (Coremail) with SMTP id _____wDXXx3Ub99q1qL2Cw--.8607S2; Mon, 26 Oct 2026 23:20:52 +0800 (CST) From: Yang Siyuan <hsyysy@163.com> To: Linus Walleij <linusw@kernel.org> Cc: Chen-Yu Tsai <wens@kernel.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2] pinctrl: sunxi: request the per-bank supply optionally Date: Mon, 26 Oct 2026 23:20:27 +0800 Message-ID: <20261026152027.1417178-1-hsyysy@163.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261026144751.1392715-1-hsyysy@163.com> References: <20261026144751.1392715-1-hsyysy@163.com> X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Post: <mailto:linux-sunxi@lists.linux.dev> List-Help: <mailto:linux-sunxi+help@lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> List-Owner: <mailto:linux-sunxi+owner@lists.linux.dev> Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wDXXx3Ub99q1qL2Cw--.8607S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFW7AF43XF4fAr4UAFyftFb_yoW5Xr4kpr sxXr1akr4kAFyfKw47uw1xtr1fuan7Ja43CFy0g34rXFs8AFs3Xw1akF4YkFWkGr4kXr4Y yryDZFyxGF45Z3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UH7K3UUUUU= X-CM-SenderInfo: 5kv152r16rljoofrz/xtbC7RWj12rfb9XufgAA3T X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [0.31 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; SUSPICIOUS_RECIPS(1.50)[]; ARC_REJECT(1.00)[cv is fail on i=2]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.18)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; TAGGED_RCPT(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,117.135.210.4:received]; FREEMAIL_CC(0.00)[kernel.org,gmail.com,sholland.org,vger.kernel.org,lists.infradead.org,lists.linux.dev]; DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:helo,tor.lore.kernel.org:rdns]; FORGED_SENDER_MAILLIST(0.00)[]; R_DKIM_ALLOW(0.00)[163.com:s=s110527]; FROM_NEQ_ENVFROM(0.00)[hsyysy@163.com,linux-sunxi@lists.linux.dev]; TAGGED_FROM(0.00)[bounces-26904-noreply=patchwork.local]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; DKIM_TRACE(0.00)[163.com:+]; FREEMAIL_FROM(0.00)[163.com]; TO_DN_SOME(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; DMARC_POLICY_ALLOW(0.00)[163.com,none]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.105.105.114:from] X-Rspamd-Queue-Id: 690971C2001 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
[v2] pinctrl: sunxi: request the per-bank supply optionally
|
|
Commit Message
Yang Siyuan
Oct. 26, 2026, 3:20 p.m. UTC
The per-bank "vcc-pX" supplies are optional in the device tree: the binding documents them, but notes that many boards do not describe them. sunxi_pmx_request() uses regulator_get() anyway, so the regulator core falls back to a dummy regulator and warns for every bank that has no supply: sun50i-h616-r-pinctrl 7022000.pinctrl: supply vcc-pl not found, using dummy regulator The H616 R_PIO is such a controller, and its PL0/PL1 pins drive the R_I2C bus, so every H616 board hits the warning during boot. Use regulator_get_optional() instead. A bank supply that is described in the device tree is still acquired and enabled, as it powers the physical VCC-Px rail, but one that is absent is skipped without a warning. Signed-off-by: Yang Siyuan <hsyysy@163.com> --- Changes in v2: - Do not skip the supply on controllers without IO bias configuration: the per-bank regulator also powers the physical VCC-Px rail, so a supply described in the device tree must still be requested and enabled. Use regulator_get_optional() so only banks that have no supply are skipped, which silences the warning without changing the power management behaviour. - Link to v1: https://lore.kernel.org/linux-gpio/20261026144751.1392715-1-hsyysy@163.com/ --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) base-commit: 091b06388b117fefdcb63336ac09956a4914b961
Comments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] pinctrl: sunxi: unbalanced bank regulator refcount in sunxi_pmx_request() -- commit 387a0217944495d51d6191636af797bf5c7e5da5 Author: Yang Siyuan <hsyysy@163.com> pinctrl: sunxi: request the per-bank supply optionally This commit switches sunxi_pmx_request() from regulator_get() to regulator_get_optional() so that banks without a per-bank supply in the device tree do not trigger a dummy regulator warning. When regulator_get_optional() returns -ENODEV, sunxi_pmx_request() returns 0 with s_reg->regulator left as NULL, and sunxi_pmx_free() skips cleanup when s_reg->regulator is NULL. > diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > index 31cd142ce0f79..f6c48a287a0e4 100644 > --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c > +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > @@ -925,11 +925,19 @@ static int sunxi_pmx_request(struct pinctrl_dev *pctldev, unsigned offset) > } > > snprintf(supply, sizeof(supply), "vcc-p%c", 'a' + bank); > - reg = regulator_get(pctl->dev, supply); > - if (IS_ERR(reg)) > + reg = regulator_get_optional(pctl->dev, supply); > + if (IS_ERR(reg)) { > + /* > + * The per-bank supply is optional: boards that do not > + * describe it simply have no regulator to manage. > + */ > + if (PTR_ERR(reg) == -ENODEV) > + return 0; > + > return dev_err_probe(pctl->dev, PTR_ERR(reg), > "Couldn't get bank P%c regulator\n", > 'A' + bank); > + } > > ret = regulator_enable(reg); > if (ret) { > @@ -959,6 +967,10 @@ static int sunxi_pmx_free(struct pinctrl_dev *pctldev, unsigned offset) > PINS_PER_BANK; > struct sunxi_pinctrl_regulator *s_reg = &pctl->regulators[bank_offset]; > > + /* The per-bank supply is optional, so this bank may not have one. */ > + if (!s_reg->regulator) > + return 0; [Severity: High] Can leaving s_reg->regulator as NULL on -ENODEV cause s_reg->refcount to become unbalanced and disable the bank regulator while other pins in the same bank are still active? In sunxi_pmx_request(), returning 0 on -ENODEV without recording that the bank has no supply or incrementing s_reg->refcount means every subsequent pin request in the same bank will call regulator_get_optional() again. Inside regulator_get_optional() -> _regulator_get() -> regulator_dev_lookup(), when the pinctrl device tree node does not have a vcc-pX-supply property, regulator_dt_lookup() returns NULL and regulator_dev_lookup() falls back to a global name lookup: drivers/regulator/core.c:regulator_dev_lookup() { /* first do a dt based lookup */ r = regulator_dt_lookup(dev, supply); if (r) return r; ... r = regulator_lookup_by_name(supply); if (r) return r; return ERR_PTR(-ENODEV); } On several Allwinner boards (for example, arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi and sun50i-a64-pine64.dts), vcc-pl-supply is omitted from r_pio to avoid a circular dependency with the PMIC bus on PL0/PL1, while the PMIC regulator node defines regulator-name = "vcc-pl": &r_pio { /* * FIXME: We can't add that supply for now since it would * create a circular dependency between pinctrl, the regulator * and the RSB Bus. * * vcc-pl-supply = <®_aldo2>; */ }; ... ®_aldo2 { regulator-always-on; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-name = "vcc-pl"; }; When the PMIC bus driver probes before the PMIC and requests PL0/PL1, regulator_get_optional(pctl->dev, "vcc-pl") returns -ENODEV, leaving s_reg->regulator as NULL and s_reg->refcount at 0 for those active pins. Once the PMIC registers the regulator named "vcc-pl", a later request for another pin in bank PL sees s_reg->regulator == NULL, calls regulator_get_optional(pctl->dev, "vcc-pl") again, matches the regulator via regulator_lookup_by_name("vcc-pl"), and initializes s_reg->refcount to 1: drivers/pinctrl/sunxi/pinctrl-sunxi.c:sunxi_pmx_request() { ... s_reg->regulator = reg; refcount_set(&s_reg->refcount, 1); } If that later pin (or one of the earlier pins requested before the PMIC probed) is subsequently freed in sunxi_pmx_free(), s_reg->regulator is now non-NULL, so refcount_dec_and_test(&s_reg->refcount) drops the refcount to 0 and calls regulator_disable() and regulator_put() while other pins in the bank remain requested.
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 70099052d..23c1fbd46 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -925,11 +925,19 @@ static int sunxi_pmx_request(struct pinctrl_dev *pctldev, unsigned offset) } snprintf(supply, sizeof(supply), "vcc-p%c", 'a' + bank); - reg = regulator_get(pctl->dev, supply); - if (IS_ERR(reg)) + reg = regulator_get_optional(pctl->dev, supply); + if (IS_ERR(reg)) { + /* + * The per-bank supply is optional: boards that do not + * describe it simply have no regulator to manage. + */ + if (PTR_ERR(reg) == -ENODEV) + return 0; + return dev_err_probe(pctl->dev, PTR_ERR(reg), "Couldn't get bank P%c regulator\n", 'A' + bank); + } ret = regulator_enable(reg); if (ret) { @@ -959,6 +967,10 @@ static int sunxi_pmx_free(struct pinctrl_dev *pctldev, unsigned offset) PINS_PER_BANK; struct sunxi_pinctrl_regulator *s_reg = &pctl->regulators[bank_offset]; + /* The per-bank supply is optional, so this bank may not have one. */ + if (!s_reg->regulator) + return 0; + if (!refcount_dec_and_test(&s_reg->refcount)) return 0;