Skip to contentSkip to conversation

gpio: omap: Propagate runtime PM failures in probe and request

PATCH Applied Avi Weiss 2 participants 2 messages Oct 29 – Oct 30

Subsystems (2)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 gpio: omap: Propagate runtime PM failures in probe and request

pm_runtime_get_sync() can fail when the OMAP PM domain cannot resume a GPIO controller, but omap_gpio_probe() and omap_gpio_request() ignore its return value.

Consequently, probe can register a GPIO controller despite a failed resume, while a GPIO request can report success and modify GPIO state even though runtime-PM acquisition failed.

Use pm_runtime_resume_and_get() in both paths and propagate resume errors. On probe failure, disable runtime PM and unprepare the debounce clock when applicable.

Reproduced both failures on QEMU N800 by injecting -EIO from the OMAP PM-domain resume callback. The original driver continues probe and accepts the GPIO request - while the patched driver rejects both operations with -EIO. Normal GPIO controller registration continues to work without fault injection.

Fixes 77640aabd755 ("OMAP: GPIO: Implement GPIO as a platform device")
Fixes 55b93c32520d ("gpio/omap: use pm-runtime framework")

---

Related/similar upstream GPIO runtime-PM commits:

e9438ab5328a (gpio: zynq: fix runtime PM leak on request error path) ff82fc3a4a1d (gpio: xilinx: fix runtime PM leak on request error path)

Both use pm_runtime_resume_and_get() to avoid retaining a PM usage reference when acquisition fails.

 drivers/gpio/gpio-omap.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpio/gpio-omap.c +11 -2
index a9b9a3d9631e..31525a8eedf5 100644
@@ -813,8 +813,11 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_bank *bank = gpiochip_get_data(chip);
 	unsigned long flags;
+	int ret;
 
-	pm_runtime_get_sync(chip->parent);
+	ret = pm_runtime_resume_and_get(chip->parent);
+	if (ret < 0)
+		return ret;
 
 	raw_spin_lock_irqsave(&bank->lock, flags);
 	omap_enable_gpio_module(bank, offset);
@@ -1459,7 +1462,13 @@ static int omap_gpio_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, bank);
 
 	pm_runtime_enable(dev);
-	pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0) {
+		pm_runtime_disable(dev);
+		if (bank->dbck_flag)
+			clk_unprepare(bank->dbck);
+		return ret;
+	}
 
 	if (bank->is_mpuio)
 		omap_mpuio_init(bank);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Avi Weiss

pm_runtime_get_sync() can fail when the OMAP PM domain cannot resume a GPIO controller, but omap_gpio_probe() and omap_gpio_request() ignore its return value.

Consequently, probe can register a GPIO controller despite a failed resume, while a GPIO request can report success and modify GPIO state even though runtime-PM acquisition failed.

[...]

Applied, thanks!

[1/1] gpio: omap: Propagate runtime PM failures in probe and request

      https://git.kernel.org/brgl/c/05be1a99d6d68b24cbe24a191e1af67c70193ac3

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>