Skip to contentSkip to conversation

FAILED: patch "[PATCH] i2c: qcom-cci: fix autosuspend cleanup" failed to apply to 5.10-stable tree

PATCH New [email protected] 2 participants 5 messages Sep 9 – Sep 11

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x f98d4986482151a835b521a734722fe8dc5ca37d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090910-covenant-freestyle-77a9@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From f98d4986482151a835b521a734722fe8dc5ca37d Mon Sep 17 00:00:00 2001
From: Guangshuo Li <[email protected]>
Date: Wed, 12 Aug 2026 17:44:25 +0800
Subject: [PATCH] i2c: qcom-cci: fix autosuspend cleanup

cci_probe() calls pm_runtime_use_autosuspend(), but the remove path does not call the matching pm_runtime_dont_use_autosuspend() before disabling runtime PM.

If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without undoing the autosuspend setting during teardown, this reference is not dropped and usage_count remains unbalanced.

Use devm_pm_runtime_set_active_enabled() to manage the runtime PM state. Its managed cleanup disables autosuspend and runtime PM and restores the suspended state on probe failure and driver removal. Remove the now redundant manual runtime PM cleanup.

This issue was found by manual code inspection.

drivers/i2c/busses/i2c-qcom-cci.c +4 -7
index bdeda3979c48..25b6e4e9e3fa 100644
@@ -595,9 +595,11 @@ static int cci_probe(struct platform_device *pdev)
 		goto disable_clocks;
 
 	pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
+	ret = devm_pm_runtime_set_active_enabled(dev);
+	if (ret)
+		goto disable_clocks;
+
 	pm_runtime_use_autosuspend(dev);
-	pm_runtime_set_active(dev);
-	pm_runtime_enable(dev);
 
 	for (i = 0; i < cci->data->num_masters; i++) {
 		if (!cci->master[i].cci)
@@ -613,8 +615,6 @@ static int cci_probe(struct platform_device *pdev)
 	return 0;
 
 error_i2c:
-	pm_runtime_disable(dev);
-	pm_runtime_dont_use_autosuspend(dev);
 
 	for (--i ; i >= 0; i--) {
 		if (cci->master[i].cci) {
@@ -640,9 +640,6 @@ static void cci_remove(struct platform_device *pdev)
 			cci_halt(cci, i);
 		}
 	}
-
-	pm_runtime_disable(&pdev->dev);
-	pm_runtime_set_suspended(&pdev->dev);
 }
 
 static const struct cci_data cci_v1_data = {
maintainer
#1 lore raw

PATCH 1/4 i2c: omap: Improve error reporting for problems during .remove()

From: Uwe Kleine-König <[email protected]>

[ Upstream commit 9496fffcb28f39e0352779a0199b6e61861c9221 ]

If pm_runtime_get() fails in .remove() the driver used to return the error to the driver core. The only effect of this (compared to returning zero) is a generic warning that the error value is ignored.

So emit a better warning and return zero to suppress the generic (and little helpful) message. Also disable runtime PM in the error case.

This prepares changing platform device remove callbacks to return void.

Stable-dep-of: f98d49864821 ("i2c: qcom-cci: fix autosuspend cleanup")

---
 drivers/i2c/busses/i2c-omap.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-omap.c +6 -3
index 5c045c4da660b..1cd07faecd6c5 100644
@@ -1513,14 +1513,17 @@ static int omap_i2c_remove(struct platform_device *pdev)
 	int ret;
 
 	i2c_del_adapter(&omap->adapter);
-	ret = pm_runtime_resume_and_get(&pdev->dev);
+
+	ret = pm_runtime_get_sync(&pdev->dev);
 	if (ret < 0)
-		return ret;
+		dev_err(omap->dev, "Failed to resume hardware, skip disable\n");
+	else
+		omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0);
 
-	omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0);
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
+
 	return 0;
 }
 
Signature · 1 line
2.53.0
maintainer
#2 lore raw

PATCH 2/4 i2c: Convert to platform remove callback returning void

From: Uwe Kleine-König <[email protected]>

[ Upstream commit e190a0c389e60178fba3d532abf936dcae223e7d ]

The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.

Stable dependency adaptation for 5.10:

Limit the driver conversion to Qualcomm CCI, the only driver touched by f98d49864821. Drop the other 87 driver conversions, including drivers absent from this branch and drivers that still use ACPI or I2C callbacks.

This branch lacks platform_driver.remove_new. Include the minimal support from 5c5a7680e67b ("platform: Provide a remove callback that returns no value"): add the callback member and dispatch it in the existing platform_drv_remove(), preserving the legacy int-returning remove path.

Also adapt the CCI IRQ cleanup from f0285c286bca ("i2c: qcom-cci: Remove overcautious disable_irq() calls"). The IRQ is already devres-managed; remove its explicit disable calls and route both reset and initialization failures to clock cleanup. Retain the 5.10-specific cci_init() call. This provides the probe and remove context required for the target to apply without conflicts. The managed runtime-PM helper used by the target is already available in this branch.

No functions are added. The autosuspend fix remains in the target commit.

[ sashal: Reduced backport -- upstream e190a0c389e60 touches 88 file(s), this
backport carries 3. Not backported here:
drivers/i2c/busses/i2c-altera.c drivers/i2c/busses/i2c-amd-mp2-plat.c drivers/i2c/busses/i2c-aspeed.c drivers/i2c/busses/i2c-at91-core.c drivers/i2c/busses/i2c-au1550.c
drivers/i2c/busses/i2c-axxia.c
drivers/i2c/busses/i2c-bcm2835.c drivers/i2c/busses/i2c-bcm-iproc.c
... and 79 more
This note is generated from the file lists only; see the resolution record for the reasoning. ]

Stable-dep-of: f98d49864821 ("i2c: qcom-cci: fix autosuspend cleanup")

---
 drivers/base/platform.c           |  4 +++-
 drivers/i2c/busses/i2c-qcom-cci.c | 13 ++++---------
 include/linux/platform_device.h   |  2 ++
 3 files changed, 9 insertions(+), 10 deletions(-)
drivers/base/platform.c +3 -1
index 647066229fec3..94a4c8184cc91 100644
@@ -783,7 +783,9 @@ static int platform_drv_remove(struct device *_dev)
 	struct platform_device *dev = to_platform_device(_dev);
 	int ret = 0;
 
-	if (drv->remove)
+	if (drv->remove_new)
+		drv->remove_new(dev);
+	else if (drv->remove)
 		ret = drv->remove(dev);
 	dev_pm_domain_detach(_dev, true);
 
drivers/i2c/busses/i2c-qcom-cci.c +4 -9
index 7e3e1514416d8..c13cc1509b166 100644
@@ -632,11 +632,11 @@ static int cci_probe(struct platform_device *pdev)
 
 	ret = cci_reset(cci);
 	if (ret < 0)
-		goto error;
+		goto disable_clocks;
 
 	ret = cci_init(cci);
 	if (ret < 0)
-		goto error;
+		goto disable_clocks;
 
 	pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
 	pm_runtime_use_autosuspend(dev);
@@ -666,15 +666,13 @@ static int cci_probe(struct platform_device *pdev)
 			of_node_put(cci->master[i].adap.dev.of_node);
 		}
 	}
-error:
-	disable_irq(cci->irq);
 disable_clocks:
 	cci_disable_clocks(cci);
 
 	return ret;
 }
 
-static int cci_remove(struct platform_device *pdev)
+static void cci_remove(struct platform_device *pdev)
 {
 	struct cci *cci = platform_get_drvdata(pdev);
 	int i;
@@ -687,11 +685,8 @@ static int cci_remove(struct platform_device *pdev)
 		}
 	}
 
-	disable_irq(cci->irq);
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_set_suspended(&pdev->dev);
-
-	return 0;
 }
 
 static const struct cci_data cci_v1_data = {
@@ -784,7 +779,7 @@ MODULE_DEVICE_TABLE(of, cci_dt_match);
 
 static struct platform_driver qcom_cci_driver = {
 	.probe  = cci_probe,
-	.remove = cci_remove,
+	.remove_new = cci_remove,
 	.driver = {
 		.name = "i2c-qcom-cci",
 		.of_match_table = cci_dt_match,
include/linux/platform_device.h +2 -0
index e7a83b0218077..37b5161d61fcf 100644
@@ -203,7 +203,9 @@ extern void platform_device_put(struct platform_device *pdev);
 
 struct platform_driver {
 	int (*probe)(struct platform_device *);
+	/* Use remove_new for callbacks that return no value. */
 	int (*remove)(struct platform_device *);
+	void (*remove_new)(struct platform_device *);
 	void (*shutdown)(struct platform_device *);
 	int (*suspend)(struct platform_device *, pm_message_t state);
 	int (*resume)(struct platform_device *);
Signature · 1 line
2.53.0
maintainer
#3 lore raw

PATCH 3/4 i2c: qcom-cci: Do not check return value of cci_init()

In reply to Sasha Levin

From: Vladimir Zapolskiy <[email protected]>

[ Upstream commit 17c5d247e3e4708cac05ff087c8013c0dda383a2 ]

The cci_init() function is not supposed to fail, and it never returns a non-zero, so it'd make sense to convert its signature to void.

Stable dependency adaptation for 5.10:

Resolve the probe conflict against the earlier dependency's IRQ cleanup, which renamed the failure destination from error to disable_clocks. cci_init() only writes registers and always returned zero in this tree, so retain the void conversion and replace its checked probe call with an unconditional call. Keep the real cci_reset() failure path unchanged.

Retain the separate cci_init() calls in probe, queue timeout recovery, and runtime resume because this branch does not have the later upstream refactor moving initialization into cci_reset(). No functions are added. The target f98d49864821 applies cleanly with Git's three-way merge; its runtime PM cleanup changes remain in the target.

Stable-dep-of: f98d49864821 ("i2c: qcom-cci: fix autosuspend cleanup")

---
 drivers/i2c/busses/i2c-qcom-cci.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-qcom-cci.c +2 -6
index c13cc1509b166..e11aa8e495020 100644
@@ -247,7 +247,7 @@ static int cci_reset(struct cci *cci)
 	return 0;
 }
 
-static int cci_init(struct cci *cci)
+static void cci_init(struct cci *cci)
 {
 	u32 val = CCI_IRQ_MASK_0_I2C_M0_RD_DONE |
 			CCI_IRQ_MASK_0_I2C_M0_Q0_REPORT |
@@ -288,8 +288,6 @@ static int cci_init(struct cci *cci)
 		val = hw->scl_stretch_en << 8 | hw->trdhld << 4 | hw->tsp;
 		writel(val, cci->base + CCI_I2C_Mm_MISC_CTL(i));
 	}
-
-	return 0;
 }
 
 static int cci_run_queue(struct cci *cci, u8 master, u8 queue)
@@ -634,9 +632,7 @@ static int cci_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto disable_clocks;
 
-	ret = cci_init(cci);
-	if (ret < 0)
-		goto disable_clocks;
+	cci_init(cci);
 
 	pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
 	pm_runtime_use_autosuspend(dev);
Signature · 1 line
2.53.0
maintainer
#4 lore raw

PATCH 4/4 i2c: qcom-cci: fix autosuspend cleanup

In reply to Sasha Levin

From: Guangshuo Li <[email protected]>

[ Upstream commit f98d4986482151a835b521a734722fe8dc5ca37d ]

cci_probe() calls pm_runtime_use_autosuspend(), but the remove path does not call the matching pm_runtime_dont_use_autosuspend() before disabling runtime PM.

If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without undoing the autosuspend setting during teardown, this reference is not dropped and usage_count remains unbalanced.

Use devm_pm_runtime_set_active_enabled() to manage the runtime PM state. Its managed cleanup disables autosuspend and runtime PM and restores the suspended state on probe failure and driver removal. Remove the now redundant manual runtime PM cleanup.

This issue was found by manual code inspection.

---
 drivers/i2c/busses/i2c-qcom-cci.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-qcom-cci.c +4 -7
index e11aa8e495020..31d37deaa026f 100644
@@ -635,9 +635,11 @@ static int cci_probe(struct platform_device *pdev)
 	cci_init(cci);
 
 	pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
+	ret = devm_pm_runtime_set_active_enabled(dev);
+	if (ret)
+		goto disable_clocks;
+
 	pm_runtime_use_autosuspend(dev);
-	pm_runtime_set_active(dev);
-	pm_runtime_enable(dev);
 
 	for (i = 0; i < cci->data->num_masters; i++) {
 		if (!cci->master[i].cci)
@@ -653,8 +655,6 @@ static int cci_probe(struct platform_device *pdev)
 	return 0;
 
 error_i2c:
-	pm_runtime_disable(dev);
-	pm_runtime_dont_use_autosuspend(dev);
 
 	for (--i ; i >= 0; i--) {
 		if (cci->master[i].cci) {
@@ -680,9 +680,6 @@ static void cci_remove(struct platform_device *pdev)
 			cci_halt(cci, i);
 		}
 	}
-
-	pm_runtime_disable(&pdev->dev);
-	pm_runtime_set_suspended(&pdev->dev);
 }
 
 static const struct cci_data cci_v1_data = {
Signature · 1 line
2.53.0