mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Saravana Kannan <saravanak@google.com>,
	Paul Cercueil <paul@crapouillou.net>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Android Kernel Team <kernel-team@android.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] clocksource: Avoid creating dead devices
Date: Tue, 17 Mar 2020 19:18:54 +0100	[thread overview]
Message-ID: <4b9752f6-1723-9c5f-03a5-005fe6182488@linaro.org> (raw)
In-Reply-To: <CAGETcx9-TB3XWFvU0ME+eCTyJVs7a_ExD-5Dvm9VVvB=UkkMWg@mail.gmail.com>

On 17/03/2020 19:08, Saravana Kannan wrote:
> On Tue, Mar 17, 2020 at 4:36 AM Paul Cercueil <paul@crapouillou.net> wrote:

[ ... ]

>>>>  >> Why not just set the OF_POPULATED if the probe succeeds?
>>>>  >>
>>>>  >> Like:
>>>>  >>
>>>>  >> diff --git a/drivers/clocksource/timer-probe.c
>>>>  >> b/drivers/clocksource/timer-probe.c
>>>>  >> index ee9574da53c0..f290639ff824 100644
>>>>  >> --- a/drivers/clocksource/timer-probe.c
>>>>  >> +++ b/drivers/clocksource/timer-probe.c
>>>>  >> @@ -35,6 +35,7 @@ void __init timer_probe(void)
>>>>  >>                         continue;
>>>>  >>                 }
>>>>  >>
>>>>  >> +               of_node_set_flag(np, OF_POPULATED);
>>>>  >>                 timers++;
>>>>  >>         }
>>>>  >>
>>>>  >> instead of setting the flag and clearing it in case of failure?
>>>>  >
>>>>  > Looking at IRQ framework which first did it the way you suggested
>>>> and
>>>>  > then changed it to the way I did it, it looks like it allows for
>>>>  > drivers that need to split the initialization between early init
>>>> (not
>>>>  > just error out, but init partly) and later driver probe. See [1].
>>>>  >
>>>>  > Also, most of the other frameworks that set OF_POPULATED, set it
>>>>  > before calling the initialization function for the device. Maybe
>>>> it's
>>>>  > to make sure the device node data "looks the same" whether a
>>>> device is
>>>>  > initialized during early init or during normal device probe
>>>> (since the
>>>>  > OF_POPULATED is set before the probe is called) -- i.e. have
>>>>  > OF_POPULATED  set before the device initialization code is
>>>> actually
>>>>  > run?
>>>>  >
>>>>  > Honestly I don't have a strong opinion either way, but I lean
>>>> towards
>>>>  > following what IRQ does.
>>>>
>>>>  Thanks for the pointer. Indeed it is to catch situation where the
>>>> driver
>>>>  is clearing the flag like:
>>>>
>>>>
>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/ingenic-timer.c#n245
>>>>
>>>>  But I'm not able to figure out why it is cleared here :/
>>>
>>> I think I know what's going on. He wants to implement PM support for
>>> this timer. But PM support is tied to devices. So, clearing out the
>>> flag allows creating the device which then hooks into PM ops.
>>
>> That's correct - the OF_POPULATED flag is cleared so that the driver
>> will probe as a platform_device. When I did write the driver this was
>> required or the platform_device would not probe.
> 
> Interesting. I went and looked at the kernel when your patch merged.
> As far as I can tell, you shouldn't have needed to clear OF_POPULATED
> because the timer framework never set OF_POPULATED even back then.
> 
> If this driver was based in drivers/irqchip/irq-ingenic-tcu.c and you
> were initially just trying to get it to create a device, then you'd
> have needed to clear OF_POPULATED because IRQ chip framework does set
> the flag.
> 
> In any case, it's good that you cleared it -- it'll continue to work
> with my patch.
> 
> Daniel,
> 
> Looks like this answers all the concerns you had. I also checked every
> driver in drivers/clocksource that had the word "probe" in it to make
> sure it won't need any updates to ingenic-timer.c. Can we merge this?

Applied [1], thanks

 -- Daniel

[1]
https://git.linaro.org/people/daniel.lezcano/linux.git/commit/?h=timers/drivers/next&id=4f41fe386a94639cd9a1831298d4f85db5662f1e


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2020-03-17 18:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-11  5:21 Saravana Kannan
2020-02-19  2:20 ` Saravana Kannan
2020-02-27  9:06 ` Daniel Lezcano
2020-02-27 21:22   ` Saravana Kannan
2020-03-04 19:30     ` Saravana Kannan
2020-03-04 19:56       ` Daniel Lezcano
2020-03-08  5:53         ` Saravana Kannan
2020-03-16 14:57           ` Daniel Lezcano
2020-03-16 17:49             ` Saravana Kannan
2020-03-16 18:07               ` Daniel Lezcano
2020-03-16 18:15                 ` Saravana Kannan
     [not found]                   ` <5e70b653.1c69fb81.b03d8.d2bbSMTPIN_ADDED_MISSING@mx.google.com>
2020-03-17 18:08                     ` Saravana Kannan
2020-03-17 18:18                       ` Daniel Lezcano [this message]
2020-03-19  8:47 ` [tip: timers/core] clocksource/drivers/timer-probe: " tip-bot2 for Saravana Kannan
2020-03-24 17:59   ` Ionela Voinescu
2020-03-24 18:34     ` Saravana Kannan
2020-03-24 19:56       ` Saravana Kannan
2020-03-25 21:47         ` Thomas Gleixner
2020-03-25 22:56           ` Saravana Kannan
2020-03-25 23:06             ` Saravana Kannan
2020-03-26 10:17             ` Daniel Lezcano
2020-03-26 17:35               ` Saravana Kannan
2020-03-26 10:33             ` Thomas Gleixner
2020-03-26 15:02               ` Rob Herring
2020-03-26 18:08                 ` Saravana Kannan
2020-03-28  2:23                   ` Rob Herring
2020-03-25 21:29     ` Jon Hunter
2020-03-26  1:21       ` Dmitry Osipenko
2020-03-28 10:30     ` [tip: timers/core] Revert "clocksource/drivers/timer-probe: Avoid creating dead devices" tip-bot2 for Thomas Gleixner

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=4b9752f6-1723-9c5f-03a5-005fe6182488@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --cc=saravanak@google.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®