Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751569AbcDUCqI (ORCPT ); Wed, 20 Apr 2016 22:46:08 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:37318 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbcDUCqH convert rfc822-to-8bit (ORCPT ); Wed, 20 Apr 2016 22:46:07 -0400 Date: Thu, 21 Apr 2016 10:40:22 +0800 From: Jisheng Zhang To: Andy Shevchenko CC: Jarkko Nikula , , , , , Subject: Re: [PATCH 2/4] i2c: designware-platdrv: fix unbalanced clk enable and prepare Message-ID: <20160421104022.2d6549a9@xhacker> In-Reply-To: <1461161760.6620.306.camel@linux.intel.com> References: <1460638414-5987-1-git-send-email-jszhang@marvell.com> <1460638414-5987-3-git-send-email-jszhang@marvell.com> <57177C32.4090000@linux.intel.com> <1461161760.6620.306.camel@linux.intel.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-04-21_01:,, signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1604210038 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1800 Lines: 52 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 > > > --- > > >   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