Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1385715rdb; Wed, 20 Sep 2023 07:49:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPGnFoJ0dFLObdWLmOSi8Am2yRZR2uIzipSFl6DuO1zzhn3WZh2mxHlFRjNy56tKC8MMP1 X-Received: by 2002:a05:6a20:561b:b0:133:b3a9:90d with SMTP id ir27-20020a056a20561b00b00133b3a9090dmr2384086pzc.36.1695221396668; Wed, 20 Sep 2023 07:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695221396; cv=none; d=google.com; s=arc-20160816; b=pQ5qimI7Bu5zgP7aHTIB2VAeorQjsQiD8rIc3FhEd4ne6OQJrcqyisMNMhNpprzT65 U38bEsooPkcSVywrnSoFrfqws3tmSpMhYVgGnR52sIn54P4cxGLjjdi2hCVgM+bOhX2I slyzub5/CYNGjn8iIbO2corNBo7mAL5Zmu/TTADagoYjbEgfn4Tr2pzTML/PmDV+Y2zZ yjKcYSgusfoJIpWFY1jhuxQWRlnyNw+tElnyzdB0axZdT6OlET8fFWyj5zHm8CicphZL eUkzBgDvycKwh67GeQwgZKxfz8WtUMPBQigzx5whsvug+t80jD8OkhAjQc8LS/CMNowz eplQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IPx7Jmkoig2dFPoaQnl9oODzj/zMV0LMvfVPjxIECtc=; fh=rC3T8EcV8Vn/EKlN5HUiXxuyWVOP4yBhK+Qde+ZuI/Q=; b=RmV9L0YwSuL3ZDg7YRPvUierk7TkxAA1orjDQwcrBC/G3ctfylgh7adA9anrjNYb3P boJTldgB/K5RreBKZYmq+gsTAvi+XsTNsbUAcY3OoAH6mw3Y7Nyt9eIapGGi28fWjmML DllEuJ+0XLS/FuXHBdyw+HabnSkXGQBSuBN420w2BpH0vH/WC7fXvTimrWvvXhO62plb 99B8Wzcttg+4np98610HLowlrEtzpoOAmegCi0+wQz2y6Q2PeuzLzbeykUEoProWR00N Wm8F9J0HzgnrO1o6WarEfmP4kovtk0BWE0zye+iOnBuC+dLgHUuGvYJgdE5ywveeyet1 Ysdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=C8epKASf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id bq10-20020a056a000e0a00b00686b62a6dc4si11850951pfb.145.2023.09.20.07.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 07:49:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=C8epKASf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4698E831F258; Wed, 20 Sep 2023 06:27:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235291AbjITN1E (ORCPT + 99 others); Wed, 20 Sep 2023 09:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233952AbjITN1D (ORCPT ); Wed, 20 Sep 2023 09:27:03 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2C5CA9; Wed, 20 Sep 2023 06:26:56 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5278A4000B; Wed, 20 Sep 2023 13:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1695216415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IPx7Jmkoig2dFPoaQnl9oODzj/zMV0LMvfVPjxIECtc=; b=C8epKASfmcu4PmIHh2QuitaDTSH8j988DZ3QnPpNAYU4pZp1RPtIwaFDNE2aIhwJywqkCz 79yz97vnpeQ9oIkv0S7CJeh4F5junoCUN1whaepE//w3z5gUZYHGmwQouTfqIr5DIXGAM6 /Mi5EMRhR90w1WvE2zxHiTRBc2aNM9DUxgoUa5tOMSliSWpSrZMu/fn8lLEeowSJOYnN8H uNbT+ftnKX+hPiO3FMKh2RvJqQ8NCZSM38a6MjjHncLB1otyvmUWXPvE8fAxRX1fZ5zOoa LOCIZEdTjTyss70FVesOknhO26XijSm4XthbTynJmotWDnwJnGgQUGXucmSOKw== Date: Wed, 20 Sep 2023 15:26:53 +0200 From: Alexandre Belloni To: Biju Das Cc: Thomas Gleixner , Alessandro Zummo , John Stultz , Stephen Boyd , Geert Uytterhoeven , Biju Das , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH] alarmtimer: Fix rebind failure Message-ID: <2023092013265355e7a02a@mail.local> References: <20230920115935.144391-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230920115935.144391-1-biju.das.jz@bp.renesas.com> X-GND-Sasl: alexandre.belloni@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 20 Sep 2023 06:27:06 -0700 (PDT) On 20/09/2023 12:59:35+0100, Biju Das wrote: > The resources allocated in alarmtimer_rtc_add_device() are not freed > leading to re-bind failure for the endpoint driver. Fix this issue > by adding alarmtimer_rtc_remove_device(). > > Signed-off-by: Biju Das > --- > This issue is found while adding irq support for built in RTC > found on Renesas PMIC RAA215300 device. This issue should present > on all RTC drivers which calls device_init_wakeup() in probe(). > --- > kernel/time/alarmtimer.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c > index 8d9f13d847f0..592668136bb5 100644 > --- a/kernel/time/alarmtimer.c > +++ b/kernel/time/alarmtimer.c > @@ -61,6 +61,7 @@ static DEFINE_SPINLOCK(freezer_delta_lock); > /* rtc timer and device for setting alarm wakeups at suspend */ > static struct rtc_timer rtctimer; > static struct rtc_device *rtcdev; > +static struct platform_device *rtc_pdev; This is the alarmtimer pdev, not the RTC one, right? > static DEFINE_SPINLOCK(rtcdev_lock); > > /** > @@ -109,6 +110,7 @@ static int alarmtimer_rtc_add_device(struct device *dev) > } > > rtcdev = rtc; > + rtc_pdev = pdev; > /* hold a reference so it doesn't go away */ > get_device(dev); > pdev = NULL; > @@ -123,6 +125,23 @@ static int alarmtimer_rtc_add_device(struct device *dev) > return ret; > } > > +static void alarmtimer_rtc_remove_device(struct device *dev) > +{ > + struct rtc_device *rtc = to_rtc_device(dev); > + > + if (rtc_pdev) { > + module_put(rtc->owner); > + if (device_may_wakeup(rtc->dev.parent)) > + device_init_wakeup(&rtc_pdev->dev, false); > + > + platform_device_unregister(rtc_pdev); > + put_device(dev); > + } > + > + rtcdev = NULL; > + rtc_pdev = NULL; > +} > + > static inline void alarmtimer_rtc_timer_init(void) > { > rtc_timer_init(&rtctimer, NULL, NULL); > @@ -130,6 +149,7 @@ static inline void alarmtimer_rtc_timer_init(void) > > static struct class_interface alarmtimer_rtc_interface = { > .add_dev = &alarmtimer_rtc_add_device, > + .remove_dev = &alarmtimer_rtc_remove_device, > }; > > static int alarmtimer_rtc_interface_setup(void) > -- > 2.25.1 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com