Re: [RFC/RFT 08/10] i2c: exynos5: use core helper to mark adapter suspended
From: Marek Szyprowski
Date: Tue Dec 18 2018 - 06:23:56 EST
Hi,
On 2018-12-10 22:03, Wolfram Sang wrote:
> Rejecting transfers should be handled by the core. Also, this will
> ensure proper locking which was forgotten in this open coded version.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
Tested-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Works fine on TM2e and OdroidXU3. The only minor issue is the following
warning:
WARNING: CPU: 4 PID: 28 at drivers/i2c/i2c-core-base.c:1869
__i2c_transfer+0x428/0x5e0
Modules linked in:
CPU: 4 PID: 28 Comm: cpuhp/4 Tainted: GÂÂÂÂÂÂÂ WÂÂÂÂÂÂÂÂ
4.20.0-rc1-00031-ga1c77790d03f #5130
Hardware name: Samsung TM2E board (DT)
pstate: 20000005 (nzCv daif -PAN -UAO)
pc : __i2c_transfer+0x428/0x5e0
lr : i2c_transfer+0x64/0xb8
...
Call trace:
Â__i2c_transfer+0x428/0x5e0
Âi2c_transfer+0x64/0xb8
Âregmap_i2c_read+0x5c/0xa0
Â_regmap_raw_read+0xac/0x2a8
Â_regmap_bus_read+0x3c/0x70
Â_regmap_read+0x64/0x1a0
Âregmap_read+0x48/0x70
Âregulator_is_enabled_regmap+0x38/0xb8
Â_regulator_is_enabled.part.1+0x1c/0x30
Âcreate_regulator+0x264/0x270
Â_regulator_get+0x90/0x2b0
Âregulator_get_optional+0x10/0x18
Âdev_pm_opp_set_regulators+0xb8/0x1e8
Âcpufreq_init+0xd0/0x2f8
Âcpufreq_online+0xc0/0x660
Âcpuhp_cpufreq_online+0xc/0x18
Âcpuhp_invoke_callback+0xac/0x7b0
Âcpuhp_thread_fun+0xec/0x180
Âsmpboot_thread_fn+0x1f0/0x290
Âkthread+0xfc/0x128
Âret_from_fork+0x10/0x1c
---[ end trace bea5412bc21deb81 ]---
Similar warning was already there ('HS-I2C is not initialized' message,
without backtrace) during system suspend/resume. It looks that cpu freq
is resumed too early, before any device drivers, but this is not an
issue for this patchset.
> ---
> drivers/i2c/busses/i2c-exynos5.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
> index c1ce2299a76e..fe2f2031ea36 100644
> --- a/drivers/i2c/busses/i2c-exynos5.c
> +++ b/drivers/i2c/busses/i2c-exynos5.c
> @@ -183,7 +183,6 @@ enum i2c_type_exynos {
>
> struct exynos5_i2c {
> struct i2c_adapter adap;
> - unsigned int suspended:1;
>
> struct i2c_msg *msg;
> struct completion msg_complete;
> @@ -715,11 +714,6 @@ static int exynos5_i2c_xfer(struct i2c_adapter *adap,
> struct exynos5_i2c *i2c = adap->algo_data;
> int i, ret;
>
> - if (i2c->suspended) {
> - dev_err(i2c->dev, "HS-I2C is not initialized.\n");
> - return -EIO;
> - }
> -
> ret = clk_enable(i2c->clk);
> if (ret)
> return ret;
> @@ -847,8 +841,7 @@ static int exynos5_i2c_suspend_noirq(struct device *dev)
> {
> struct exynos5_i2c *i2c = dev_get_drvdata(dev);
>
> - i2c->suspended = 1;
> -
> + i2c_mark_adapter_suspended(&i2c->adap, true);
> clk_unprepare(i2c->clk);
>
> return 0;
> @@ -871,7 +864,7 @@ static int exynos5_i2c_resume_noirq(struct device *dev)
>
> exynos5_i2c_init(i2c);
> clk_disable(i2c->clk);
> - i2c->suspended = 0;
> + i2c_mark_adapter_suspended(&i2c->adap, false);
>
> return 0;
> }
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland