Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1383354 > unrolled thread

Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable and prepare

Started byJarkko Nikula <jarkko.nikula@linux.intel.com>
First post2016-04-20 15:00 +0200
Last post2016-04-21 10:30 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable  and prepare Jarkko Nikula <jarkko.nikula@linux.intel.com> - 2016-04-20 15:00 +0200
    Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable  and prepare Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-20 16:20 +0200
      Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable  and prepare Jisheng Zhang <jszhang@marvell.com> - 2016-04-21 04:50 +0200
        Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable  and prepare Jarkko Nikula <jarkko.nikula@linux.intel.com> - 2016-04-21 09:50 +0200
          Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable  and prepare Jisheng Zhang <jszhang@marvell.com> - 2016-04-21 10:30 +0200

#1383354 — Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable and prepare

FromJarkko Nikula <jarkko.nikula@linux.intel.com>
Date2016-04-20 15:00 +0200
SubjectRe: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable and prepare
Message-ID<rpZTz-834-13@gated-at.bofh.it>
On 04/14/2016 03:53 PM, Jisheng Zhang wrote:
> If i2c_dw_probe() fail, we should call i2c_dw_plat_prepare_clk() to
> disable and unprepare the clk, otherwise the clk enable and prepare
> is left unbalanced.
>
> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> ---
>   drivers/i2c/busses/i2c-designware-platdrv.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index 00f9e99..1488cea 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -268,6 +268,8 @@ rpm_disable:
>   		pm_runtime_put_noidle(&pdev->dev);
>   	}
>
> +	i2c_dw_plat_prepare_clk(dev, false);
> +
>   	return r;
>   }
>
This is a bit unclear to me does devm_clk_get take care of clk disabling 
in case of probe error or driver removal?

I see Andy's 1cb715ca4694 ("i2c-designware: move to managed functions 
(devm_*)") removed it but at quick look drivers/clk/clk-devres.c: 
devm_clk_release() calls only clk_put and I don't see disable is done 
down the path.

-- 
Jarkko

[toc] | [next] | [standalone]


#1383430

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2016-04-20 16:20 +0200
Message-ID<rq18Z-K6-7@gated-at.bofh.it>
In reply to#1383354
On Wed, 2016-04-20 at 15:55 +0300, Jarkko Nikula wrote:
> On 04/14/2016 03:53 PM, Jisheng Zhang wrote:
> > 
> > If i2c_dw_probe() fail, we should call i2c_dw_plat_prepare_clk() to
> > disable and unprepare the clk, otherwise the clk enable and prepare
> > is left unbalanced.
> > 
> > Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> > ---
> >   drivers/i2c/busses/i2c-designware-platdrv.c | 2 ++
> >   1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c
> > b/drivers/i2c/busses/i2c-designware-platdrv.c
> > index 00f9e99..1488cea 100644
> > --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> > @@ -268,6 +268,8 @@ rpm_disable:
> >   		pm_runtime_put_noidle(&pdev->dev);
> >   	}
> > 
> > +	i2c_dw_plat_prepare_clk(dev, false);
> > +
> >   	return r;
> >   }
> > 
> This is a bit unclear to me does devm_clk_get take care of clk
> disabling 
> in case of probe error or driver removal?
> 
> I see Andy's 1cb715ca4694 ("i2c-designware: move to managed functions 
> (devm_*)") removed it but at quick look drivers/clk/clk-devres.c: 
> devm_clk_release() calls only clk_put and I don't see disable is done 
> down the path.

The following is a mistake of the mentioned patch.
-       clk_disable_unprepare(dev->clk);

I did at the same mistake in dw_dmac driver which had been fixed later
in the commit 8be4f523b480 ("dmaengine: dw: fix regression in dw_probe()
function").

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

[toc] | [prev] | [next] | [standalone]


#1383840

FromJisheng Zhang <jszhang@marvell.com>
Date2016-04-21 04:50 +0200
Message-ID<rqcQN-1Dq-1@gated-at.bofh.it>
In reply to#1383430
Dear Jarkko, Andy,

On Wed, 20 Apr 2016 17:16:00 +0300 Andy Shevchenko wrote:

> On Wed, 2016-04-20 at 15:55 +0300, Jarkko Nikula wrote:
> > On 04/14/2016 03:53 PM, Jisheng Zhang wrote:  
> > > 
> > > If i2c_dw_probe() fail, we should call i2c_dw_plat_prepare_clk() to
> > > disable and unprepare the clk, otherwise the clk enable and prepare
> > > is left unbalanced.
> > > 
> > > Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
> > > ---
> > >   drivers/i2c/busses/i2c-designware-platdrv.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c
> > > b/drivers/i2c/busses/i2c-designware-platdrv.c
> > > index 00f9e99..1488cea 100644
> > > --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> > > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> > > @@ -268,6 +268,8 @@ rpm_disable:
> > >   		pm_runtime_put_noidle(&pdev->dev);
> > >   	}
> > > 
> > > +	i2c_dw_plat_prepare_clk(dev, false);
> > > +
> > >   	return r;
> > >   }
> > >   
> > This is a bit unclear to me does devm_clk_get take care of clk
> > disabling 
> > in case of probe error or driver removal?
> > 
> > I see Andy's 1cb715ca4694 ("i2c-designware: move to managed functions 
> > (devm_*)") removed it but at quick look drivers/clk/clk-devres.c: 
> > devm_clk_release() calls only clk_put and I don't see disable is done 
> > down the path.  
> 
> The following is a mistake of the mentioned patch.
> -       clk_disable_unprepare(dev->clk);
> 
> I did at the same mistake in dw_dmac driver which had been fixed later
> in the commit 8be4f523b480 ("dmaengine: dw: fix regression in dw_probe()
> function").
> 

As Andy pointed out, managed devm_clk_get can only automatically put clk
but doesn't unprepare and disable the clk

Thanks,
Jisheng

[toc] | [prev] | [next] | [standalone]


#1383916

FromJarkko Nikula <jarkko.nikula@linux.intel.com>
Date2016-04-21 09:50 +0200
Message-ID<rqhx8-5x3-19@gated-at.bofh.it>
In reply to#1383840
On 04/21/2016 05:40 AM, Jisheng Zhang wrote:
> Dear Jarkko, Andy,
>
> On Wed, 20 Apr 2016 17:16:00 +0300 Andy Shevchenko wrote:
>
>> On Wed, 2016-04-20 at 15:55 +0300, Jarkko Nikula wrote:
>>> I see Andy's 1cb715ca4694 ("i2c-designware: move to managed functions
>>> (devm_*)") removed it but at quick look drivers/clk/clk-devres.c:
>>> devm_clk_release() calls only clk_put and I don't see disable is done
>>> down the path.
>>
>> The following is a mistake of the mentioned patch.
>> -       clk_disable_unprepare(dev->clk);
>>
>> I did at the same mistake in dw_dmac driver which had been fixed later
>> in the commit 8be4f523b480 ("dmaengine: dw: fix regression in dw_probe()
>> function").
>>
>
> As Andy pointed out, managed devm_clk_get can only automatically put clk
> but doesn't unprepare and disable the clk
>
Ok, then it makes sense to move this fix first in the series and queue 
for stable v4.5+. Then another from you, Andy or me for kernels before 
b33af11de236 ("i2c: designware: Do not require clock when SSCN and FFCN 
are provided") that introduced the i2c_dw_plat_prepare_clk().

-- 
Jarkko

[toc] | [prev] | [next] | [standalone]


#1383926

FromJisheng Zhang <jszhang@marvell.com>
Date2016-04-21 10:30 +0200
Message-ID<rqi9Q-69w-9@gated-at.bofh.it>
In reply to#1383916
Dear Jarkko,

On Thu, 21 Apr 2016 10:39:50 +0300 Jarkko Nikula wrote:

> On 04/21/2016 05:40 AM, Jisheng Zhang wrote:
> > Dear Jarkko, Andy,
> >
> > On Wed, 20 Apr 2016 17:16:00 +0300 Andy Shevchenko wrote:
> >  
> >> On Wed, 2016-04-20 at 15:55 +0300, Jarkko Nikula wrote:  
> >>> I see Andy's 1cb715ca4694 ("i2c-designware: move to managed functions
> >>> (devm_*)") removed it but at quick look drivers/clk/clk-devres.c:
> >>> devm_clk_release() calls only clk_put and I don't see disable is done
> >>> down the path.  
> >>
> >> The following is a mistake of the mentioned patch.
> >> -       clk_disable_unprepare(dev->clk);
> >>
> >> I did at the same mistake in dw_dmac driver which had been fixed later
> >> in the commit 8be4f523b480 ("dmaengine: dw: fix regression in dw_probe()
> >> function").
> >>  
> >
> > As Andy pointed out, managed devm_clk_get can only automatically put clk
> > but doesn't unprepare and disable the clk
> >  
> Ok, then it makes sense to move this fix first in the series and queue 
> for stable v4.5+. Then another from you, Andy or me for kernels before 
> b33af11de236 ("i2c: designware: Do not require clock when SSCN and FFCN 
> are provided") that introduced the i2c_dw_plat_prepare_clk().

Sounds a good idea. Will send a separate fix for this purpose soon.

Thanks,
Jisheng

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web