linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] i2c: tegra: Ensure that device is suspended before driver is removed
@ 2021-10-19 23:29 Dmitry Osipenko
  2021-10-29 19:52 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Osipenko @ 2021-10-19 23:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Laxman Dewangan, Wolfram Sang
  Cc: linux-i2c, linux-tegra, linux-kernel

Tegra I2C device isn't guaranteed to be suspended after removal of
the driver since driver uses pm_runtime_put() that is asynchronous and
pm_runtime_disable() cancels pending power-change requests. This means
that potentially refcount of the clocks may become unbalanced after
removal of the driver. This a very minor problem which unlikely to
happen in practice and won't cause any visible problems, nevertheless
let's replace pm_runtime_disable() with pm_runtime_force_suspend() and
use pm_runtime_put_sync() which disables RPM of the device and puts it
into suspend before driver is removed.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/i2c/busses/i2c-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index c883044715f3..b3184c422826 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1700,7 +1700,7 @@ static int tegra_i2c_init_hardware(struct tegra_i2c_dev *i2c_dev)
 	else
 		ret = tegra_i2c_init(i2c_dev);
 
-	pm_runtime_put(i2c_dev->dev);
+	pm_runtime_put_sync(i2c_dev->dev);
 
 	return ret;
 }
@@ -1819,7 +1819,7 @@ static int tegra_i2c_remove(struct platform_device *pdev)
 	struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
 
 	i2c_del_adapter(&i2c_dev->adapter);
-	pm_runtime_disable(i2c_dev->dev);
+	pm_runtime_force_suspend(i2c_dev->dev);
 
 	tegra_i2c_release_dma(i2c_dev);
 	tegra_i2c_release_clocks(i2c_dev);
-- 
2.32.0


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

* Re: [PATCH v1] i2c: tegra: Ensure that device is suspended before driver is removed
  2021-10-19 23:29 [PATCH v1] i2c: tegra: Ensure that device is suspended before driver is removed Dmitry Osipenko
@ 2021-10-29 19:52 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2021-10-29 19:52 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan, linux-i2c,
	linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

On Wed, Oct 20, 2021 at 02:29:19AM +0300, Dmitry Osipenko wrote:
> Tegra I2C device isn't guaranteed to be suspended after removal of
> the driver since driver uses pm_runtime_put() that is asynchronous and
> pm_runtime_disable() cancels pending power-change requests. This means
> that potentially refcount of the clocks may become unbalanced after
> removal of the driver. This a very minor problem which unlikely to
> happen in practice and won't cause any visible problems, nevertheless
> let's replace pm_runtime_disable() with pm_runtime_force_suspend() and
> use pm_runtime_put_sync() which disables RPM of the device and puts it
> into suspend before driver is removed.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-10-29 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-19 23:29 [PATCH v1] i2c: tegra: Ensure that device is suspended before driver is removed Dmitry Osipenko
2021-10-29 19:52 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).