All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robherring2@gmail.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Olof Johansson <olof@lixom.net>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Russell King <linux@arm.linux.org.uk>,
	Christian Daudt <bcm@fixthebug.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Matt Porter <mporter@linaro.org>,
	Marc Carino <marc.ceeeee@gmail.com>,
	Gregory Fong <gregory.0xf0@gmail.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v8 01/11] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs
Date: Fri, 1 Aug 2014 09:33:44 -0500	[thread overview]
Message-ID: <CAL_Jsq+47YtqWwOkxYDzaEOG-+oouvpXvmGaX+Wh3wQ+BNAx_w@mail.gmail.com> (raw)
In-Reply-To: <20140731022320.GM3711@ld-irv-0074>

On Wed, Jul 30, 2014 at 9:23 PM, Brian Norris
<computersforpeace@gmail.com> wrote:
> Hi Rob,
>
> I appreciate your comments, but where were many of these 5 months ago on
> the first 7 revisions? :)

Sorry, but that is the nature of upstreaming. But given some of the
issues, it is obvious the reviews were not sufficient.

> On a practical note: v9 is already queued for 3.17. Should I send
> patches for the 3.17 cycle (or later) to fixup some of these issues? Or
> would you recommend pulling the patches out of Matt Porter's tree now,
> and reintroducing for 3.18? (I would be much happier with the first.)

Things can always be un-queued. I guess that's Matt's and arm-soc's decision.

>> > +static const char *brcmstb_match[] __initconst = {
>> > +       "brcm,bcm7445",
>> > +       "brcm,brcmstb",
>> > +       NULL
>> > +};
>> > +
>> > +DT_MACHINE_START(BRCMSTB, "Broadcom STB (Flattened Device Tree)")
>> > +       .dt_compat      = brcmstb_match,
>> > +MACHINE_END
>>
>> Do you plan to add more here? Otherwise you don't need this file.
>
> Probably eventually, but not yet (there's out-of-tree stuff that hasn't
> been integrated); should we drop the file until it's needed?

I would say yes if you re-spin the patches.

>> > +ENTRY(brcmstb_secondary_startup)
>> > +        /*
>> > +         * Ensure CPU is in a sane state by disabling all IRQs and switching
>> > +         * into SVC mode.
>> > +         */
>> > +        setmode        PSR_I_BIT | PSR_F_BIT | SVC_MODE, r0
>> > +
>> > +        bl      v7_invalidate_l1
>>
>> This should be in your boot code. That is part of the documented entry
>> requirements.
>
> By "documented" are you referring to the ARM TRM? Wouldn't any "boot
> code" requirements only apply to CPU0? Linux prepares the non-boot CPUs
> for SMP, as you see here.
>
>> Also, if you are coming straight from reset, there is
>> other setup probably missing.
>
> Like what?

Errata work-arounds, performance bits, etc. I don't recall exactly
which ones are per core vs. global. I assume this is an A9, but cores
with virt extensions would also need to drop to non-secure mode.

Also, your entry (and many of the custom entry points) would not work
for big endian kernels. You may not care, but there's really no reason
why it should not work.

>> > +       per_cpu(per_cpu_sw_state, cpu) = val;
>> > +       dmb();
>> > +       sync_cache_w(SHIFT_PERCPU_PTR(&per_cpu_sw_state, per_cpu_offset(cpu)));
>> > +       dsb_sev();
>>
>> Barriers need to be documented why they are needed.
>
> (NB: I see approximately 3 total existing cases where there is a comment
> near a dsb()/dsb_sev().)
>
> This was actually adapted from the mcpm code, and

Why? Blindly copying other implementations seems to be a common issue here...

> (1) I think the dmb() is in the wrong place (it should be the first
>     thing in this function);
> (2) the SEV is unnecessary (we don't use WFE; just a cache-invalidated
>     polling loop); and
> (3) the DSB is also unnecessary, since sync_cache_w() handles its own
>     barriers.
>
> Plus, we should probably add some comments to describe what's going on
> here. (Follow-up patch?)

I'm not sure you need the state variable at all. You appear to be able
to fully control power on and off of the cores, so you should not need
any spin loops or synchronization.

>> > +static int brcmstb_cpu_kill(u32 cpu)
>> > +{
>> > +       u32 tmp;
>> > +
>> > +       pr_info("SMP: Powering down CPU%d...\n", cpu);
>> > +
>> > +       while (per_cpu_sw_state_rd(cpu))
>> > +               ;
>>
>> I don't think this is necessary. You don't need to synchronize die and
>> kill. Look at other implementations that actually power down the core
>> (vs. just wfi).
>
> Hmm, I'm pretty sure the synchronization is required for our B15 core.
> If we yank the power before the core has properly quiesced, the whole
> CPU complex will lock up. (Similar story for the power-up while loop you
> complained about above.)

That is true for every SMP system which is why it is done in the core
code as Russell pointed out.

>> > +static void brcmstb_secondary_init(unsigned int cpu)
>> > +{
>> > +       /*
>> > +        * Synchronise with the boot thread.
>> > +        */
>> > +       spin_lock(&boot_lock);
>> > +       spin_unlock(&boot_lock);
>>
>> I suggest you read previous discussions on attempts to make this
>> common before replying to Russell.
>
> Can you point me to this discussion? linux-arm-kernel is a big and noisy
> world...

Here's a recent example:

http://www.spinics.net/lists/arm-kernel/msg318585.html

> BTW, I'm not sure the boot_lock is actually necessary at all for us; it
> was just borrowed from one of the other mach-*'s. The synchronization we
> need is done in the while loops above.

The blindly copying code without knowing what it does problem...

Rob

WARNING: multiple messages have this Message-ID (diff)
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 01/11] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs
Date: Fri, 1 Aug 2014 09:33:44 -0500	[thread overview]
Message-ID: <CAL_Jsq+47YtqWwOkxYDzaEOG-+oouvpXvmGaX+Wh3wQ+BNAx_w@mail.gmail.com> (raw)
In-Reply-To: <20140731022320.GM3711@ld-irv-0074>

On Wed, Jul 30, 2014 at 9:23 PM, Brian Norris
<computersforpeace@gmail.com> wrote:
> Hi Rob,
>
> I appreciate your comments, but where were many of these 5 months ago on
> the first 7 revisions? :)

Sorry, but that is the nature of upstreaming. But given some of the
issues, it is obvious the reviews were not sufficient.

> On a practical note: v9 is already queued for 3.17. Should I send
> patches for the 3.17 cycle (or later) to fixup some of these issues? Or
> would you recommend pulling the patches out of Matt Porter's tree now,
> and reintroducing for 3.18? (I would be much happier with the first.)

Things can always be un-queued. I guess that's Matt's and arm-soc's decision.

>> > +static const char *brcmstb_match[] __initconst = {
>> > +       "brcm,bcm7445",
>> > +       "brcm,brcmstb",
>> > +       NULL
>> > +};
>> > +
>> > +DT_MACHINE_START(BRCMSTB, "Broadcom STB (Flattened Device Tree)")
>> > +       .dt_compat      = brcmstb_match,
>> > +MACHINE_END
>>
>> Do you plan to add more here? Otherwise you don't need this file.
>
> Probably eventually, but not yet (there's out-of-tree stuff that hasn't
> been integrated); should we drop the file until it's needed?

I would say yes if you re-spin the patches.

>> > +ENTRY(brcmstb_secondary_startup)
>> > +        /*
>> > +         * Ensure CPU is in a sane state by disabling all IRQs and switching
>> > +         * into SVC mode.
>> > +         */
>> > +        setmode        PSR_I_BIT | PSR_F_BIT | SVC_MODE, r0
>> > +
>> > +        bl      v7_invalidate_l1
>>
>> This should be in your boot code. That is part of the documented entry
>> requirements.
>
> By "documented" are you referring to the ARM TRM? Wouldn't any "boot
> code" requirements only apply to CPU0? Linux prepares the non-boot CPUs
> for SMP, as you see here.
>
>> Also, if you are coming straight from reset, there is
>> other setup probably missing.
>
> Like what?

Errata work-arounds, performance bits, etc. I don't recall exactly
which ones are per core vs. global. I assume this is an A9, but cores
with virt extensions would also need to drop to non-secure mode.

Also, your entry (and many of the custom entry points) would not work
for big endian kernels. You may not care, but there's really no reason
why it should not work.

>> > +       per_cpu(per_cpu_sw_state, cpu) = val;
>> > +       dmb();
>> > +       sync_cache_w(SHIFT_PERCPU_PTR(&per_cpu_sw_state, per_cpu_offset(cpu)));
>> > +       dsb_sev();
>>
>> Barriers need to be documented why they are needed.
>
> (NB: I see approximately 3 total existing cases where there is a comment
> near a dsb()/dsb_sev().)
>
> This was actually adapted from the mcpm code, and

Why? Blindly copying other implementations seems to be a common issue here...

> (1) I think the dmb() is in the wrong place (it should be the first
>     thing in this function);
> (2) the SEV is unnecessary (we don't use WFE; just a cache-invalidated
>     polling loop); and
> (3) the DSB is also unnecessary, since sync_cache_w() handles its own
>     barriers.
>
> Plus, we should probably add some comments to describe what's going on
> here. (Follow-up patch?)

I'm not sure you need the state variable at all. You appear to be able
to fully control power on and off of the cores, so you should not need
any spin loops or synchronization.

>> > +static int brcmstb_cpu_kill(u32 cpu)
>> > +{
>> > +       u32 tmp;
>> > +
>> > +       pr_info("SMP: Powering down CPU%d...\n", cpu);
>> > +
>> > +       while (per_cpu_sw_state_rd(cpu))
>> > +               ;
>>
>> I don't think this is necessary. You don't need to synchronize die and
>> kill. Look at other implementations that actually power down the core
>> (vs. just wfi).
>
> Hmm, I'm pretty sure the synchronization is required for our B15 core.
> If we yank the power before the core has properly quiesced, the whole
> CPU complex will lock up. (Similar story for the power-up while loop you
> complained about above.)

That is true for every SMP system which is why it is done in the core
code as Russell pointed out.

>> > +static void brcmstb_secondary_init(unsigned int cpu)
>> > +{
>> > +       /*
>> > +        * Synchronise with the boot thread.
>> > +        */
>> > +       spin_lock(&boot_lock);
>> > +       spin_unlock(&boot_lock);
>>
>> I suggest you read previous discussions on attempts to make this
>> common before replying to Russell.
>
> Can you point me to this discussion? linux-arm-kernel is a big and noisy
> world...

Here's a recent example:

http://www.spinics.net/lists/arm-kernel/msg318585.html

> BTW, I'm not sure the boot_lock is actually necessary at all for us; it
> was just borrowed from one of the other mach-*'s. The synchronization we
> need is done in the while loops above.

The blindly copying code without knowing what it does problem...

Rob

  parent reply	other threads:[~2014-08-01 14:34 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 21:07 [PATCH v8 00/11] ARM: brcmstb: Add Broadcom STB SoC support Brian Norris
2014-07-21 21:07 ` Brian Norris
2014-07-21 21:07 ` Brian Norris
2014-07-21 21:07 ` [PATCH v8 01/11] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-07-30  9:26   ` Russell King - ARM Linux
2014-07-30  9:26     ` Russell King - ARM Linux
2014-07-31  2:36     ` Brian Norris
2014-07-31  2:36       ` Brian Norris
2014-07-31  2:36       ` Brian Norris
2014-07-30 17:09   ` Rob Herring
2014-07-30 17:09     ` Rob Herring
2014-07-30 17:09     ` Rob Herring
2014-07-31  2:23     ` Brian Norris
2014-07-31  2:23       ` Brian Norris
2014-07-31  2:23       ` Brian Norris
2014-07-31  8:43       ` Russell King - ARM Linux
2014-07-31  8:43         ` Russell King - ARM Linux
2014-07-31  8:43         ` Russell King - ARM Linux
2014-07-31 22:06         ` Brian Norris
2014-07-31 22:06           ` Brian Norris
2014-07-31 22:06           ` Brian Norris
2014-08-02  9:27           ` Russell King - ARM Linux
2014-08-02  9:27             ` Russell King - ARM Linux
2014-08-02  9:27             ` Russell King - ARM Linux
2014-08-13 23:47             ` Brian Norris
2014-08-13 23:47               ` Brian Norris
2014-08-13 23:47               ` Brian Norris
2014-08-19  0:02               ` Brian Norris
2014-08-19  0:02                 ` Brian Norris
2014-08-19  0:02                 ` Brian Norris
2014-08-01 14:33       ` Rob Herring [this message]
2014-08-01 14:33         ` Rob Herring
2014-08-01 14:33         ` Rob Herring
2014-08-01 19:29         ` Florian Fainelli
2014-08-01 19:29           ` Florian Fainelli
2014-08-01 19:29           ` Florian Fainelli
2014-08-01 19:46           ` Matt Porter
2014-08-01 19:46             ` Matt Porter
2014-08-01 19:46             ` Matt Porter
2014-08-02  8:21         ` Russell King - ARM Linux
2014-08-02  8:21           ` Russell King - ARM Linux
2014-08-02  8:21           ` Russell King - ARM Linux
2014-08-02  8:19   ` Russell King - ARM Linux
2014-08-02  8:19     ` Russell King - ARM Linux
2014-08-04 17:39     ` Brian Norris
2014-08-04 17:39       ` Brian Norris
2014-07-21 21:07 ` [PATCH v8 02/11] power: reset: Add reboot driver for brcmstb Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-07-22  7:28   ` Arnd Bergmann
2014-07-22  7:28     ` Arnd Bergmann
2014-07-22  7:28     ` Arnd Bergmann
2014-07-22 20:02     ` Brian Norris
2014-07-22 20:02       ` Brian Norris
2014-07-22 20:02       ` Brian Norris
2014-07-22 21:02       ` Arnd Bergmann
2014-07-22 21:02         ` Arnd Bergmann
2014-07-22 21:02         ` Arnd Bergmann
2014-07-22 22:51         ` Brian Norris
2014-07-22 22:51           ` Brian Norris
2014-07-21 21:07 ` [PATCH v8 03/11] ARM: brcmstb: add debug UART for earlyprintk support Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-08-02  8:30   ` Russell King - ARM Linux
2014-08-02  8:30     ` Russell King - ARM Linux
2014-08-04 16:56     ` Brian Norris
2014-08-04 16:56       ` Brian Norris
2014-08-13 22:11       ` Brian Norris
2014-08-13 22:11         ` Brian Norris
2014-08-13 22:11         ` Brian Norris
2014-08-13 22:16         ` Olof Johansson
2014-08-13 22:16           ` Olof Johansson
2014-08-13 22:16           ` Olof Johansson
2014-09-02 22:22           ` Florian Fainelli
2014-09-02 22:22             ` Florian Fainelli
2014-09-02 22:22             ` Florian Fainelli
2014-09-02 22:44             ` Brian Norris
2014-09-02 22:44               ` Brian Norris
2014-09-02 22:44               ` Brian Norris
2014-07-21 21:07 ` [PATCH v8 04/11] ARM: do CPU-specific init for Broadcom Brahma15 cores Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-07-21 21:07   ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 05/11] ARM: Enable erratum 798181 for Broadcom Brahma-B15 Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 06/11] ARM: brcmstb: add CPU binding for Broadcom Brahma15 Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 07/11] ARM: brcmstb: add misc. DT bindings for brcmstb Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 08/11] ARM: brcmstb: gic: add compatible string for Broadcom Brahma15 Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 09/11] ARM: brcmstb: dts: add a reference DTS for Broadcom 7445 Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 10/11] ARM: brcmstb: select GISB arbiter and interrupt drivers Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08 ` [PATCH v8 11/11] MAINTAINERS: add entry for Broadcom ARM STB architecture Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-21 21:08   ` Brian Norris
2014-07-22  7:35 ` [PATCH v8 00/11] ARM: brcmstb: Add Broadcom STB SoC support Arnd Bergmann
2014-07-22  7:35   ` Arnd Bergmann
2014-07-22  7:35   ` Arnd Bergmann
2014-07-22 20:44   ` Brian Norris
2014-07-22 20:44     ` Brian Norris
2014-07-22 20:57     ` Arnd Bergmann
2014-07-22 20:57       ` Arnd Bergmann
2014-07-22 20:57       ` Arnd Bergmann
2014-07-22 21:33       ` Matt Porter
2014-07-22 21:33         ` Matt Porter
2014-07-22 21:33         ` Matt Porter
2014-07-22 22:24         ` Arnd Bergmann
2014-07-22 22:24           ` Arnd Bergmann
2014-07-22 22:24           ` Arnd Bergmann
2014-07-22 22:30           ` Brian Norris
2014-07-22 22:30             ` Brian Norris

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=CAL_Jsq+47YtqWwOkxYDzaEOG-+oouvpXvmGaX+Wh3wQ+BNAx_w@mail.gmail.com \
    --to=robherring2@gmail.com \
    --cc=arnd@arndb.de \
    --cc=bcm@fixthebug.org \
    --cc=computersforpeace@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=gregory.0xf0@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=marc.ceeeee@gmail.com \
    --cc=mporter@linaro.org \
    --cc=olof@lixom.net \
    /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.