Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3702024pxj; Mon, 7 Jun 2021 18:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnJv6oCicjodxVp6FSE4oZ3jjXiIcnkehJCnaBl7reUGR8zLOW2zUHFLTOALieBA6QbkCi X-Received: by 2002:a50:fc9a:: with SMTP id f26mr20426594edq.216.1623115619093; Mon, 07 Jun 2021 18:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623115619; cv=none; d=google.com; s=arc-20160816; b=0Ef0e6QQW+45v+uJld0WcvrBUu9ALur/uHPhrNdGcwWwYVXR+5m79jYt50OAm752FH pcAe0ethvAvpIyHVujRMqfBXMze26TSiIa3pNn8p7SRfqL3y9DFCldAAjJ11+SxsibsT cBHKuzuMGMcP+LIxgPWdARk75i697RDCDo0pHmRuVn6otpYUaFeDL4TzbjNmoLo0nM3p XoYYE1pWPTEWl7sRjHQNtUgvWpiDN2ulp5ILOVF0BdnqOoUlvAHgph0ahVI9/EYyolCo xVRy9D226KXoP2mGHOy8mZA+bhvY1fYrKY9KDKSvWrtD85YDEFWFPmzc3SqLfngGINbn Fr8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=y763XzHC2KtVYY8WpGzotgg8OceQbCjZ0tVGUQhBJ28=; b=LwbV4g53PPg2P8pOpjn6+kTiy9NhUnftIIEGGYyysLF7BSn2lRn0r/e9gxvqGHS0cX 2gVRd8cE/WGSnzl5wlOXXyBa+086qXBbJzW+UKgQrhT1STZjRzSQ+HGySZu2AUqqCYwA UWYOJkyuix6PR8XUZtQ4q9ZKbaBCDJvRMWmOlsxwIoEtUNc/pZcf0WDEuo2MdjN6MMpn fPpFJjuRpeVW/JEztnugY93rFYaJNn0ACubt8yMkrkosP9GW5fpUzdnaUbATziqi5wfj QWsxSDIHCcA5YQTsNFgGAaIwMcBPvyw7e09RLEOqc6Syd+mamqDkWNwDcDwXmWsNSRmQ qHnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nigauri-org.20150623.gappssmtp.com header.s=20150623 header.b=sRrq9ET0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p21si13163746ejn.49.2021.06.07.18.26.34; Mon, 07 Jun 2021 18:26:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nigauri-org.20150623.gappssmtp.com header.s=20150623 header.b=sRrq9ET0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbhFHB0x (ORCPT + 99 others); Mon, 7 Jun 2021 21:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbhFHB0x (ORCPT ); Mon, 7 Jun 2021 21:26:53 -0400 Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8F7FC061787 for ; Mon, 7 Jun 2021 18:25:00 -0700 (PDT) Received: by mail-vs1-xe36.google.com with SMTP id z206so9998085vsz.6 for ; Mon, 07 Jun 2021 18:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nigauri-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=y763XzHC2KtVYY8WpGzotgg8OceQbCjZ0tVGUQhBJ28=; b=sRrq9ET0FtypyPl7+UwR4e2TXdbQLyON0oQb4uwj/SrithueBRZPmdK0chncX6h5SS uZyjdwhS8UaPL5Zz/JEJeegNkebWHHh/HQjNChsDKl87EsU8Qzdry1XWb8VUOyyevHgQ n6pcN7uSTWUjxbUN8w8siKmB+h+fC1RHQMPrQ6AR95Dfd277ahOHLQkAGV5MuPMonUyC E/8Ctt+W1qhUrfOxRXVQmbGdZ9NKILhxo0uM1hfjpsRITL9QUt9UIPu0SXQ3R1pYAY48 DdHEW5WOQ375SNjkfuznHLDM6lCuUCvKLg+fyuTLthBCLCdCQJZYBVu5J16DyCUIi54u F+0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=y763XzHC2KtVYY8WpGzotgg8OceQbCjZ0tVGUQhBJ28=; b=f1cqLt7wjtijuKfBQH0eiv/majhyxuyjRSixpZRXi8A/sWjeurN6oSCkTQUauijn9S t8Juz8b1pKd1j2Spf7Gv/Q41rKw4hbEYOAC3c9kin6kgtGexl+7M9i7z0/6rPk/2xqH9 xnkBLDJmKM5bQd4kckCdpEu9nyduzE56X3FBbJ8B/TbQO+UikPMD7M8KNcEr2wmh1cuT EmR9ygyWjcrTCoVah7+wy0a0PUqghtfgQs7+6GDr9kaqEjlWyAXCXJ8YQ59hSInBZVLg bZsKsEmNiGSikmz9Ydgs1evPrQaYsr2iHzqeVm1RLfzQP08sATenRFMId0aWaoAZqIvV zlIw== X-Gm-Message-State: AOAM5323gAerrzqxIdPkekUUJ8NTVvCCUgwiPhWwhIZLFGAcQhL+lMsO ackqi3JnURulPI02OQQabckQjIRAcCz6xL4Pbt5m X-Received: by 2002:a05:6102:c49:: with SMTP id y9mr11102041vss.24.1623115495802; Mon, 07 Jun 2021 18:24:55 -0700 (PDT) MIME-Version: 1.0 References: <1623087421-19722-1-git-send-email-martin.fuzzey@flowbird.group> In-Reply-To: <1623087421-19722-1-git-send-email-martin.fuzzey@flowbird.group> From: Nobuhiro Iwamatsu Date: Tue, 8 Jun 2021 10:24:29 +0900 Message-ID: Subject: Re: [PATCH] rtc: stm32: Fix unbalanced clk_disable_unprepare() on probe error path To: Martin Fuzzey Cc: Alessandro Zummo , Alexandre Belloni , Alexandre Torgue , Amelie Delaunay , linux-rtc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, 2021=E5=B9=B46=E6=9C=888=E6=97=A5(=E7=81=AB) 2:38 Martin Fuzzey : > > The STM32MP1 RTC may have 2 clocks, the pclk and the rtc_ck. > > If clk_prepare_enable() fails for the second clock (rtc_ck) we must only > call clk_disable_unprepare() for the first clock (pclk) but currently we > call it on both leading to a WARN: > > [ 15.629568] WARNING: CPU: 0 PID: 146 at drivers/clk/clk.c:958 clk_core= _disable+0xb0/0xc8 > [ 15.637620] ck_rtc already disabled > [ 15.663322] CPU: 0 PID: 146 Comm: systemd-udevd Not tainted 5.4.77-pkn= bsp-svn5759-atag-v5.4.77-204-gea4235203137-dirty #2413 > [ 15.674510] Hardware name: STM32 (Device Tree Support) > [ 15.679658] [] (unwind_backtrace) from [] (show_st= ack+0x10/0x14) > [ 15.687371] [] (show_stack) from [] (dump_stack+0x= c0/0xe0) > [ 15.694574] [] (dump_stack) from [] (__warn+0xc8/0= xf0) > [ 15.701428] [] (__warn) from [] (warn_slowpath_fmt= +0x60/0x94) > [ 15.708894] [] (warn_slowpath_fmt) from [] (clk_co= re_disable+0xb0/0xc8) > [ 15.717230] [] (clk_core_disable) from [] (clk_cor= e_disable_lock+0x18/0x24) > [ 15.725924] [] (clk_core_disable_lock) from [] (st= m32_rtc_probe+0x124/0x5e4 [rtc_stm32]) > [ 15.735739] [] (stm32_rtc_probe [rtc_stm32]) from [] (platform_drv_probe+0x48/0x98) > [ 15.745095] [] (platform_drv_probe) from [] (reall= y_probe+0x1f0/0x458) > [ 15.753338] [] (really_probe) from [] (driver_prob= e_device+0x70/0x1c4) > [ 15.761584] [] (driver_probe_device) from [] (devi= ce_driver_attach+0x58/0x60) > [ 15.770439] [] (device_driver_attach) from [] (__d= river_attach+0xcc/0x170) > [ 15.779032] [] (__driver_attach) from [] (bus_for_= each_dev+0x58/0x7c) > [ 15.787191] [] (bus_for_each_dev) from [] (bus_add= _driver+0xdc/0x1f8) > [ 15.795352] [] (bus_add_driver) from [] (driver_re= gister+0x7c/0x110) > [ 15.803425] [] (driver_register) from [] (do_one_i= nitcall+0x70/0x1b8) > [ 15.811588] [] (do_one_initcall) from [] (do_init_= module+0x58/0x1f8) > [ 15.819660] [] (do_init_module) from [] (load_modu= le+0x1e58/0x23c8) > [ 15.827646] [] (load_module) from [] (sys_finit_mo= dule+0xa0/0xd4) > [ 15.835459] [] (sys_finit_module) from [] (__sys_t= race_return+0x0/0x20) > > Signed-off-by: Martin Fuzzey > Fixes: 4e64350f42e2 ("rtc: add STM32 RTC driver") > Cc: stable@vger.kernel.org > --- > drivers/rtc/rtc-stm32.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c > index 75a8924..ac9e228 100644 > --- a/drivers/rtc/rtc-stm32.c > +++ b/drivers/rtc/rtc-stm32.c > @@ -754,7 +754,7 @@ static int stm32_rtc_probe(struct platform_device *pd= ev) > > ret =3D clk_prepare_enable(rtc->rtc_ck); > if (ret) > - goto err; > + goto err_no_rtc_ck; > > if (rtc->data->need_dbp) > regmap_update_bits(rtc->dbp, rtc->dbp_reg, > @@ -830,10 +830,12 @@ static int stm32_rtc_probe(struct platform_device *= pdev) > } > > return 0; > + > err: > + clk_disable_unprepare(rtc->rtc_ck); > +err_no_rtc_ck: > if (rtc->data->has_pclk) > clk_disable_unprepare(rtc->pclk); > - clk_disable_unprepare(rtc->rtc_ck); > > if (rtc->data->need_dbp) > regmap_update_bits(rtc->dbp, rtc->dbp_reg, rtc->dbp_mask,= 0); > -- > 1.9.1 > Looks good to me. Reviewed-by: Nobuhiro Iwamatsu Best regards, Nobuhiro --=20 Nobuhiro Iwamatsu iwamatsu at {nigauri.org / debian.org / kernel.org} GPG ID: 40AD1FA6