Re: [PATCH v2 3/4] i2c: s3c2410: enable RuntimePM before registering to the core

2015-10-10 Thread Wolfram Sang
On Sat, Oct 10, 2015 at 03:08:52PM +0900, Krzysztof Kozlowski wrote:
> W dniu 09.10.2015 o 18:39, Wolfram Sang pisze:
> > From: Wolfram Sang 
> > 
> > The core may register clients attached to this master which may use
> > funtionality from the master. So, RuntimePM must be enabled before, 
> > otherwise
> > this will fail. While here, move drvdata, too.
> > 
> > Signed-off-by: Wolfram Sang 
> > ---
> >  drivers/i2c/busses/i2c-s3c2410.c | 12 +++-
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
> > b/drivers/i2c/busses/i2c-s3c2410.c
> > index 50bfd8cef5f224..336e34e1ca597d 100644
> > --- a/drivers/i2c/busses/i2c-s3c2410.c
> > +++ b/drivers/i2c/busses/i2c-s3c2410.c
> > @@ -1243,19 +1243,21 @@ static int s3c24xx_i2c_probe(struct platform_device 
> > *pdev)
> > i2c->adap.nr = i2c->pdata->bus_num;
> > i2c->adap.dev.of_node = pdev->dev.of_node;
> >  
> > +   platform_set_drvdata(pdev, i2c);
> > +
> > +   pm_runtime_enable(&pdev->dev);
> > +   pm_runtime_enable(&i2c->adap.dev);
> > +
> > ret = i2c_add_numbered_adapter(&i2c->adap);
> > if (ret < 0) {
> > dev_err(&pdev->dev, "failed to add bus to i2c core\n");
> > +   pm_runtime_disable(&i2c->adap.dev);
> > +   pm_runtime_disable(&pdev->dev);
> > s3c24xx_i2c_deregister_cpufreq(i2c);
> > clk_unprepare(i2c->clk);
> > return ret;
> > }
> >  
> > -   platform_set_drvdata(pdev, i2c);
> > -
> > -   pm_runtime_enable(&pdev->dev);
> > -   pm_runtime_enable(&i2c->adap.dev);
> > -
> > dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
> > return 0;
> >  }
> > 
> 
> Hi,
> 
> Unfortunately on Odroid XU3, Exynos5420, samsung,s3c2440-i2c,
> next-20151009-1-ga93b1a6f5055:

Thanks for testing! Will send v3 in a minute.



signature.asc
Description: Digital signature


Re: [PATCH v2 3/4] i2c: s3c2410: enable RuntimePM before registering to the core

2015-10-09 Thread Krzysztof Kozlowski
W dniu 09.10.2015 o 18:39, Wolfram Sang pisze:
> From: Wolfram Sang 
> 
> The core may register clients attached to this master which may use
> funtionality from the master. So, RuntimePM must be enabled before, otherwise
> this will fail. While here, move drvdata, too.
> 
> Signed-off-by: Wolfram Sang 
> ---
>  drivers/i2c/busses/i2c-s3c2410.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
> b/drivers/i2c/busses/i2c-s3c2410.c
> index 50bfd8cef5f224..336e34e1ca597d 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -1243,19 +1243,21 @@ static int s3c24xx_i2c_probe(struct platform_device 
> *pdev)
>   i2c->adap.nr = i2c->pdata->bus_num;
>   i2c->adap.dev.of_node = pdev->dev.of_node;
>  
> + platform_set_drvdata(pdev, i2c);
> +
> + pm_runtime_enable(&pdev->dev);
> + pm_runtime_enable(&i2c->adap.dev);
> +
>   ret = i2c_add_numbered_adapter(&i2c->adap);
>   if (ret < 0) {
>   dev_err(&pdev->dev, "failed to add bus to i2c core\n");
> + pm_runtime_disable(&i2c->adap.dev);
> + pm_runtime_disable(&pdev->dev);
>   s3c24xx_i2c_deregister_cpufreq(i2c);
>   clk_unprepare(i2c->clk);
>   return ret;
>   }
>  
> - platform_set_drvdata(pdev, i2c);
> -
> - pm_runtime_enable(&pdev->dev);
> - pm_runtime_enable(&i2c->adap.dev);
> -
>   dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
>   return 0;
>  }
> 

Hi,

Unfortunately on Odroid XU3, Exynos5420, samsung,s3c2440-i2c,
next-20151009-1-ga93b1a6f5055:

[0.437678] s3c-i2c 12c8.i2c: slave address 0x00
[0.437748] s3c-i2c 12c8.i2c: bus frequency set to 65 KHz
[0.438136] INFO: trying to register non-static key.
[0.438180] the code is fine but needs lockdep annotation.
[0.438225] turning off the locking correctness validator.
[0.438277] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 
4.3.0-rc4-next-20151009-1-ga93b1a6f5055-dirty #237
[0.438353] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[0.438427] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[0.438512] [] (show_stack) from [] 
(dump_stack+0x70/0xbc)
[0.438590] [] (dump_stack) from [] 
(__lock_acquire+0xa84/0xb18)
[0.438667] [] (__lock_acquire) from [] 
(lock_acquire+0x70/0x90)
[0.438746] [] (lock_acquire) from [] 
(_raw_spin_lock_irqsave+0x48/0x5c)
[0.438830] [] (_raw_spin_lock_irqsave) from [] 
(pm_runtime_enable+0x14/0x5c)
[0.438921] [] (pm_runtime_enable) from [] 
(s3c24xx_i2c_probe+0x450/0x5f0)
[0.439006] [] (s3c24xx_i2c_probe) from [] 
(platform_drv_probe+0x50/0xac)
[0.439086] [] (platform_drv_probe) from [] 
(driver_probe_device+0x1e0/0x418)
[0.439165] [] (driver_probe_device) from [] 
(__driver_attach+0x94/0x98)
[0.439250] [] (__driver_attach) from [] 
(bus_for_each_dev+0x54/0x88)
[0.439332] [] (bus_for_each_dev) from [] 
(bus_add_driver+0x178/0x254)
[0.439411] [] (bus_add_driver) from [] 
(driver_register+0x78/0xf4)
[0.439488] [] (driver_register) from [] 
(do_one_initcall+0xb0/0x1f4)
[0.439571] [] (do_one_initcall) from [] 
(kernel_init_freeable+0x11c/0x1e8)
[0.439660] [] (kernel_init_freeable) from [] 
(kernel_init+0x8/0xec)
[0.439740] [] (kernel_init) from [] 
(ret_from_fork+0x14/0x24)
[0.439810]  (null): Unbalanced pm_runtime_enable!
[0.440965] s3c-i2c 12c8.i2c: i2c-2: S3C I2C adapter

The message appears after second pm_runtime_enable().

Next without the patch works.

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html