From: Stephen Boyd <sboyd@kernel.org>
To: Doug Anderson <dianders@chromium.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <swboyd@chromium.org>,
John Stultz <john.stultz@linaro.org>,
Ravi Chandra Sadineni <ravisadineni@chromium.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/4] alarmtimer: Make alarmtimer platform device child of RTC device
Date: Thu, 16 Jan 2020 17:25:19 -0800 [thread overview]
Message-ID: <20200117012520.1234720728@mail.kernel.org> (raw)
In-Reply-To: <CAD=FV=XDPyJJEzjQTd8=6Om0i0HYRfin1+X5Feqcdu5oM0Ro+g@mail.gmail.com>
Quoting Doug Anderson (2020-01-15 11:22:26)
> Hi,
>
> On Wed, Jan 15, 2020 at 2:07 AM Thomas Gleixner <tglx@linutronix.de> wrote:
> >
> > Doug Anderson <dianders@chromium.org> writes:
> > > On Thu, Jan 9, 2020 at 7:59 AM Stephen Boyd <swboyd@chromium.org> wrote:
> > >> diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
> > >> index 4b11f0309eee..ccb6aea4f1d4 100644
> > >> --- a/kernel/time/alarmtimer.c
> > >> +++ b/kernel/time/alarmtimer.c
> > >> @@ -88,6 +88,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
> > >> unsigned long flags;
> > >> struct rtc_device *rtc = to_rtc_device(dev);
> > >> struct wakeup_source *__ws;
> > >> + struct platform_device *pdev;
> > >> int ret = 0;
> > >>
> > >> if (rtcdev)
> > >> @@ -99,6 +100,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
> > >> return -1;
> > >>
> > >> __ws = wakeup_source_register(dev, "alarmtimer");
> > >> + pdev = platform_device_register_data(dev, "alarmtimer", -1, NULL, 0);
> > >
> > > Don't you need to check for an error here? If pdev is an error you'll
> > > continue on your merry way. Before your patch if you got an error
> > > registering the device it would have caused probe to fail.
> >
> > Yes, that return value should be checked
> >
> > > I guess you'd only want it to be an error if "rtcdev" is NULL?
> >
> > If rtcdev is not NULL then this code is not reached. See the begin of
> > this function :)
>
> Wow, not sure how I missed that. I guess the one at the top of the
> function is an optimization, though? It's being accessed without the
> spinlock which means that it's not necessarily reliable, right? I
> guess once the rtcdev has been set then it is never unset, but it does
> seem like if two threads could call alarmtimer_rtc_add_device() at the
> same time then it's possible that we could end up calling
> wakeup_source_register() for both of them. Did I understand that
> correctly? If I did then maybe it deserves a comment?
It also looks like we call wakeup_source_register() and get lucky that
they're both called alarmtimer but they don't conflict with each other
in sysfs. Once we try to add a device named "alarmtimer" to the platform
bus it is the only one that can be added. I'll have to make this
autogenerate some number for the device instead of using -1 as the id so
that we don't see device name conflicts on the same bus.
next prev parent reply other threads:[~2020-01-17 1:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-09 15:59 [PATCH 0/4] Fix alarmtimer suspend failure Stephen Boyd
2020-01-09 15:59 ` [PATCH 1/4] alarmtimer: Unregister wakeup source when module get fails Stephen Boyd
2020-01-15 3:40 ` Doug Anderson
2020-01-15 10:24 ` [tip: timers/core] " tip-bot2 for Stephen Boyd
2020-01-09 15:59 ` [PATCH 2/4] alarmtimer: Make alarmtimer platform device child of RTC device Stephen Boyd
2020-01-15 3:40 ` Doug Anderson
2020-01-15 10:07 ` Thomas Gleixner
2020-01-15 16:47 ` Stephen Boyd
2020-01-15 19:32 ` Doug Anderson
2020-01-15 19:22 ` Doug Anderson
2020-01-17 1:25 ` Stephen Boyd [this message]
2020-01-09 15:59 ` [PATCH 3/4] alarmtimer: Use wakeup source from alarmtimer platform device Stephen Boyd
2020-01-15 19:47 ` Doug Anderson
2020-01-09 15:59 ` [PATCH 4/4] alarmtimer: Always export alarmtimer_get_rtcdev() and update docs Stephen Boyd
2020-01-15 20:31 ` Doug Anderson
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=20200117012520.1234720728@mail.kernel.org \
--to=sboyd@kernel.org \
--cc=dianders@chromium.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ravisadineni@chromium.org \
--cc=swboyd@chromium.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.