All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: qcom: lpass-lpi: Don't touch reserved pins
@ 2026-12-05 12:39 Andrey Derkach
  2026-12-05 12:59 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Derkach @ 2026-12-05 12:39 UTC (permalink / raw)
  To: Bjorn Andersson, Bartosz Golaszewski, Linus Walleij
  Cc: Richard Acayan, linux-arm-msm, linux-gpio

Since commit a22d2598a563 ("dt-bindings: qcom: lpass-lpi-common: add
reserved GPIOs property") an LPI pin controller can have
gpio-reserved-ranges. On SDM670 phones such as the Pixel 3a these are
the sensor pins, which the firmware protects: reading their registers
hangs the bus and freezes the SoC. gpiolib leaves reserved lines alone,
but the LPI driver still reads them from the GPIO debugfs dump and from
the pinconf-groups debugfs file, and pinmux does not refuse to mux
them.

Do what pinctrl-msm does since commit 691bf5d5a7bf ("pinctrl: qcom:
Don't allow protected pins to be requested") and
commit 27030ff78772 ("pinctrl: qcom: fail to retrieve configuration
from invalid pin groups"): refuse pinmux requests for reserved pins,
fail pinconf reads of them and leave them out of the GPIO debugfs dump.

Tested on the Xiaomi Mi 9 SE (SDM712), which reserves <0 18>, <26 6>:
without this change reading /sys/kernel/debug/gpio freezes the SoC;
with it the dump lists only GPIOs 18-25, and pinconf-groups shows the
reserved groups without configs.

Signed-off-by: Andrey Derkach <gabin278@gmail.com>
---
Writing the pinctrl "pinmux-select" debugfs file calls .set_mux without
.request, so it can still mux a reserved group. pinctrl-msm has the same
gap; this patch leaves it alone.

 drivers/pinctrl/qcom/pinctrl-lpass-lpi.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
index f693e5101a7b..de5bab0d28ec 100644
--- a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
+++ b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
@@ -171,7 +171,15 @@ static int lpi_gpio_set_mux(struct pinctrl_dev *pctldev, unsigned int function,
 	return 0;
 }
 
+static int lpi_gpio_request(struct pinctrl_dev *pctldev, unsigned int offset)
+{
+	struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
+
+	return gpiochip_line_is_valid(&pctrl->chip, offset) ? 0 : -EINVAL;
+}
+
 static const struct pinmux_ops lpi_gpio_pinmux_ops = {
+	.request		= lpi_gpio_request,
 	.get_functions_count	= lpi_gpio_get_functions_count,
 	.get_function_name	= lpi_gpio_get_function_name,
 	.get_function_groups	= lpi_gpio_get_function_groups,
@@ -189,6 +197,10 @@ static int lpi_config_get(struct pinctrl_dev *pctldev,
 	int pull;
 	int ret;
 
+	/* Reserved pins may be protected, reading them can hang the bus */
+	if (!gpiochip_line_is_valid(&state->chip, pin))
+		return -EINVAL;
+
 	ret = lpi_gpio_read(state, pin, LPI_GPIO_CFG_REG, &ctl_reg);
 	if (ret)
 		return ret;
@@ -466,6 +478,9 @@ static void lpi_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 	unsigned int i;
 
 	for (i = 0; i < chip->ngpio; i++, gpio++) {
+		if (!gpiochip_line_is_valid(chip, i))
+			continue;
+
 		lpi_gpio_dbg_show_one(s, NULL, chip, i, gpio);
 		seq_puts(s, "\n");
 	}

base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-05 12:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 12:39 [PATCH] pinctrl: qcom: lpass-lpi: Don't touch reserved pins Andrey Derkach
2026-12-05 12:59 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.