Re: [PATCH V3 1/2] i2c-designware: Add i2c bus locking support

From: David E. Box
Date: Thu Dec 04 2014 - 13:45:56 EST


On Thu, Dec 04, 2014 at 09:59:11AM +0200, Jarkko Nikula wrote:
> Hi
>
> On 12/02/2014 02:09 AM, David E. Box wrote:
> >Adds support for acquiring and releasing a hardware bus lock in the i2c
> >designware core transfer function. This is needed for i2c bus controllers
> >that are shared with but not controlled by the kernel.
> >
> >Signed-off-by: David E. Box <david.e.box@xxxxxxxxxxxxxxx>
> >---
> > drivers/i2c/busses/i2c-designware-core.c | 11 +++++++++++
> > drivers/i2c/busses/i2c-designware-core.h | 6 ++++++
> > drivers/i2c/busses/i2c-designware-platdrv.c | 18 +++++++++++++-----
> > 3 files changed, 30 insertions(+), 5 deletions(-)
> >
> ...
> >diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> >index a743115..afdff3b 100644
> >--- a/drivers/i2c/busses/i2c-designware-platdrv.c
> >+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> >@@ -261,10 +261,16 @@ static int dw_i2c_probe(struct platform_device *pdev)
> > return r;
> > }
> >- pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
> >- pm_runtime_use_autosuspend(&pdev->dev);
> >- pm_runtime_set_active(&pdev->dev);
> >- pm_runtime_enable(&pdev->dev);
> >+ i2c_dw_eval_lock_support(dev);
> i2c_dw_eval_lock_support() is added in the next patch.
> >+
> >+ if (dev->pm_runtime_disabled) {
> >+ pm_runtime_forbid(&pdev->dev);
> >+ } else {
> >+ pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
> >+ pm_runtime_use_autosuspend(&pdev);
> >+ pm_runtime_set_active(&pdev->dev);
> >+ pm_runtime_enable(&pdev->dev);
> >+ }
> > return 0;
> > }
> >@@ -314,7 +320,9 @@ static int dw_i2c_resume(struct device *dev)
> > struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
> > clk_prepare_enable(i_dev->clk);
> >- i2c_dw_init(i_dev);
> >+
> >+ if (!i_dev->pm_runtime_disabled)
> >+ i2c_dw_init(i_dev);
> Should there be similar conditional call or locking around
> i2c_dw_init() and i2c_dw_disable_int() also in dw_i2c_probe()?
>

Timely reply. Around i2c_dw_init(), yes. I just discovered this as the source
of a recent hang that's occuring in the loop in __i2c_dw_enable().
The hange occurs very infrequently and only, so far, when not built in. A
block around i2c_dw_disable_int() would make sense as well as a precaution.

Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/