From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Alessandro Zummo <a.zummo@towertech.it>,
John Stultz <jstultz@google.com>, Stephen Boyd <sboyd@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Biju Das <biju.das.au@gmail.com>,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] alarmtimer: Fix rebind failure
Date: Wed, 20 Sep 2023 15:26:53 +0200 [thread overview]
Message-ID: <2023092013265355e7a02a@mail.local> (raw)
In-Reply-To: <20230920115935.144391-1-biju.das.jz@bp.renesas.com>
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 <biju.das.jz@bp.renesas.com>
> ---
> 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
next prev parent reply other threads:[~2023-09-20 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 11:59 [PATCH] alarmtimer: Fix rebind failure Biju Das
2023-09-20 12:24 ` Geert Uytterhoeven
2023-09-20 12:47 ` Biju Das
2023-09-22 7:14 ` Biju Das
2023-09-20 13:26 ` Alexandre Belloni [this message]
2023-09-20 13:31 ` Biju Das
2023-09-20 13:33 ` Biju Das
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2023092013265355e7a02a@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=biju.das.au@gmail.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=geert+renesas@glider.be \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.