From: Greg Kroah-Hartman Date: Mon, 5 Dec 2022 08:21:44 +0000 (+0100) Subject: 6.0-stable patches X-Git-Tag: v4.9.335~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d22949b30499c2757aa0eabada940661dbf50539;p=thirdparty%2Fkernel%2Fstable-queue.git 6.0-stable patches added patches: i2c-restore-initial-power-state-if-probe-fails.patch --- diff --git a/queue-6.0/i2c-restore-initial-power-state-if-probe-fails.patch b/queue-6.0/i2c-restore-initial-power-state-if-probe-fails.patch new file mode 100644 index 00000000000..c1237a51115 --- /dev/null +++ b/queue-6.0/i2c-restore-initial-power-state-if-probe-fails.patch @@ -0,0 +1,72 @@ +From 79ece9b292af6b0edcfb4d67a00711d25507640b Mon Sep 17 00:00:00 2001 +From: Ricardo Ribalda +Date: Mon, 14 Nov 2022 13:20:34 +0100 +Subject: i2c: Restore initial power state if probe fails + +From: Ricardo Ribalda + +commit 79ece9b292af6b0edcfb4d67a00711d25507640b upstream. + +A driver that supports I2C_DRV_ACPI_WAIVE_D0_PROBE is not expected to +power off a device that it has not powered on previously. + +For devices operating in "full_power" mode, the first call to +`i2c_acpi_waive_d0_probe` will return 0, which means that the device +will be turned on with `dev_pm_domain_attach`. + +If probe fails the second call to `i2c_acpi_waive_d0_probe` will +return 1, which means that the device will not be turned off. +This is, it will be left in a different power state. Lets fix it. + +Reviewed-by: Hidenori Kobayashi +Reviewed-by: Sergey Senozhatsky +Reviewed-by: Sakari Ailus +Cc: stable@vger.kernel.org +Fixes: b18c1ad685d9 ("i2c: Allow an ACPI driver to manage the device's power state during probe") +Signed-off-by: Ricardo Ribalda +Reviewed-by: Mika Westerberg +Signed-off-by: Wolfram Sang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/i2c/i2c-core-base.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/drivers/i2c/i2c-core-base.c ++++ b/drivers/i2c/i2c-core-base.c +@@ -467,6 +467,7 @@ static int i2c_device_probe(struct devic + { + struct i2c_client *client = i2c_verify_client(dev); + struct i2c_driver *driver; ++ bool do_power_on; + int status; + + if (!client) +@@ -541,8 +542,8 @@ static int i2c_device_probe(struct devic + if (status < 0) + goto err_clear_wakeup_irq; + +- status = dev_pm_domain_attach(&client->dev, +- !i2c_acpi_waive_d0_probe(dev)); ++ do_power_on = !i2c_acpi_waive_d0_probe(dev); ++ status = dev_pm_domain_attach(&client->dev, do_power_on); + if (status) + goto err_clear_wakeup_irq; + +@@ -581,7 +582,7 @@ static int i2c_device_probe(struct devic + err_release_driver_resources: + devres_release_group(&client->dev, client->devres_group_id); + err_detach_pm_domain: +- dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev)); ++ dev_pm_domain_detach(&client->dev, do_power_on); + err_clear_wakeup_irq: + dev_pm_clear_wake_irq(&client->dev); + device_init_wakeup(&client->dev, false); +@@ -610,7 +611,7 @@ static void i2c_device_remove(struct dev + + devres_release_group(&client->dev, client->devres_group_id); + +- dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev)); ++ dev_pm_domain_detach(&client->dev, true); + + dev_pm_clear_wake_irq(&client->dev); + device_init_wakeup(&client->dev, false); diff --git a/queue-6.0/series b/queue-6.0/series index 2bbe3e5c535..f73c5ecce48 100644 --- a/queue-6.0/series +++ b/queue-6.0/series @@ -112,3 +112,4 @@ ipv4-handle-attempt-to-delete-multipath-route-when-f.patch ipv4-fix-route-deletion-when-nexthop-info-is-not-spe.patch mm-damon-introduce-struct-damos_access_pattern.patch mm-damon-sysfs-fix-wrong-empty-schemes-assumption-un.patch +i2c-restore-initial-power-state-if-probe-fails.patch