* [PATCH] i2c: sh_mobile: Mark adapter suspended during suspend
@ 2020-10-13 14:12 Geert Uytterhoeven
2020-12-09 20:30 ` Wolfram Sang
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2020-10-13 14:12 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c, linux-renesas-soc, Geert Uytterhoeven
When a driver tries to send an I2C message while the adapter is
suspended, this typically fails with:
i2c-sh_mobile e60b0000.i2c: Transfer request timed out
Avoid accessing the adapter while it is suspended by marking it
suspended during suspend. This allows the I2C core to catch this, and
print a warning:
WARNING: CPU: 1 PID: 13 at drivers/i2c/i2c-core.h:54
__i2c_transfer+0x4a4/0x4e4
i2c i2c-6: Transfer while suspended
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This follows the same approach as commit 18569fa89a4db9ed ("i2c: rcar:
add suspend/resume support").
Exposed by commit dc279ac6e5b4e06e ("cpufreq: dt: Refactor
initialization to handle probe deferral properly") in linux-next, which
tries to talk to the PMIC on r8a7791/koelsch while the I2C controller is
suspended.
---
drivers/i2c/busses/i2c-sh_mobile.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index bdd60770779ad523..3ae6ca21a02c6b9f 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -956,10 +956,38 @@ static int sh_mobile_i2c_remove(struct platform_device *dev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int sh_mobile_i2c_suspend(struct device *dev)
+{
+ struct sh_mobile_i2c_data *pd = dev_get_drvdata(dev);
+
+ i2c_mark_adapter_suspended(&pd->adap);
+ return 0;
+}
+
+static int sh_mobile_i2c_resume(struct device *dev)
+{
+ struct sh_mobile_i2c_data *pd = dev_get_drvdata(dev);
+
+ i2c_mark_adapter_resumed(&pd->adap);
+ return 0;
+}
+
+static const struct dev_pm_ops sh_mobile_i2c_pm_ops = {
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sh_mobile_i2c_suspend,
+ sh_mobile_i2c_resume)
+};
+
+#define DEV_PM_OPS (&sh_mobile_i2c_pm_ops)
+#else
+#define DEV_PM_OPS NULL
+#endif /* CONFIG_PM_SLEEP */
+
static struct platform_driver sh_mobile_i2c_driver = {
.driver = {
.name = "i2c-sh_mobile",
.of_match_table = sh_mobile_i2c_dt_ids,
+ .pm = DEV_PM_OPS,
},
.probe = sh_mobile_i2c_probe,
.remove = sh_mobile_i2c_remove,
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: sh_mobile: Mark adapter suspended during suspend
2020-10-13 14:12 [PATCH] i2c: sh_mobile: Mark adapter suspended during suspend Geert Uytterhoeven
@ 2020-12-09 20:30 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2020-12-09 20:30 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-i2c, linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
On Tue, Oct 13, 2020 at 04:12:01PM +0200, Geert Uytterhoeven wrote:
> When a driver tries to send an I2C message while the adapter is
> suspended, this typically fails with:
>
> i2c-sh_mobile e60b0000.i2c: Transfer request timed out
>
> Avoid accessing the adapter while it is suspended by marking it
> suspended during suspend. This allows the I2C core to catch this, and
> print a warning:
>
> WARNING: CPU: 1 PID: 13 at drivers/i2c/i2c-core.h:54
> __i2c_transfer+0x4a4/0x4e4
> i2c i2c-6: Transfer while suspended
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
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:[~2020-12-09 20:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 14:12 [PATCH] i2c: sh_mobile: Mark adapter suspended during suspend Geert Uytterhoeven
2020-12-09 20:30 ` 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).