All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>, Olof Johansson <olof@lixom.net>,
	Matt Porter <mporter@linaro.org>,
	Christian Daudt <bcm@fixthebug.org>,
	linux-arm-kernel@lists.infradead.org,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	devicetree@vger.kernel.org, Gregory Fong <gregory.0xf0@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Marc Carino <marc.ceeeee@gmail.com>
Subject: Re: [PATCH v8 01/11] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs
Date: Mon, 4 Aug 2014 10:39:07 -0700	[thread overview]
Message-ID: <20140804173907.GU3711@ld-irv-0074> (raw)
In-Reply-To: <20140802081924.GW30282@n2100.arm.linux.org.uk>

On Sat, Aug 02, 2014 at 09:19:24AM +0100, Russell King wrote:
> Here's some more comments on this.
> 
> On Mon, Jul 21, 2014 at 02:07:56PM -0700, Brian Norris wrote:
> > +static void brcmstb_cpu_die(u32 cpu)
> > +{
> > +	v7_exit_coherency_flush(all);
> 
> This is ultimately what causes my builds to break:
> 
> /tmp/ccSPowmq.s:171: Error: selected processor does not support ARM mode `isb '
> /tmp/ccSPowmq.s:177: Error: selected processor does not support ARM mode `isb '
> /tmp/ccSPowmq.s:178: Error: selected processor does not support ARM mode `dsb '
> make[2]: *** [arch/arm/mach-bcm/platsmp-brcmstb.o] Error 1
> 
> It seems that v7_exit_coherency_flush() can only be used with code which
> is ARMv7 only.

Yes, I noticed this already, and I proposed a solution:

  http://article.gmane.org/gmane.linux.drivers.devicetree/84517

> > +	/* Prevent all interrupts from reaching this CPU. */
> > +	arch_local_irq_disable();
> 
> Why do you think it is necessary to disable interrupts here?  Where
> have they been re-enabled since this bit of generic code:
> 
> void __ref cpu_die(void)
> {
>         unsigned int cpu = smp_processor_id();
> 
>         idle_task_exit();
> 
>         local_irq_disable();
> 
> and why arch_local_irq_disable() at that?  Even if interrupts were
> enabled prior to your call to arch_local_irq_disable(), what do you
> think would be the effect of receiving an interrupt after you've
> exited coherency?

This mistake was already noted. No need for the extra IRQ disable.

(http://article.gmane.org/gmane.linux.drivers.devicetree/84516)

> > +
> > +	/*
> > +	 * Final full barrier to ensure everything before this instruction has
> > +	 * quiesced.
> > +	 */
> > +	isb();
> > +	dsb();
> 
> If the call to arch_local_irq_disable() is removed, and
> v7_exit_coherency_flush() is fixed, then this is not required, because
> v7_exit_coherency_flush() already does this at the very end.

Right. Will drop.

> > +
> > +	per_cpu_sw_state_wr(cpu, 0);
> > +
> > +	/* Sit and wait to die */
> > +	wfi();
> > +
> > +	/* We should never get here... */
> > +	panic("Spurious interrupt on CPU %d received!\n", cpu);
> 
> You really should /not/ be calling panic here, because that uses data
> shared with the CPUs which are still coherent.  This is akin to doing
> DMA into bits of the kernel space without dealing with the cache
> coherency issues.

OK.

> Moreover, if you read the comments on
> v7_exit_coherency_flush() about ldrex/strex, which are two instructions
> spinlocks use, you'll see that ldrex/strex must not be executed, which
> means you can't call any function which uses spinlocks.  That rules
> out printk() et.al.  printascii is fine, but that's only available when
> the low level debug stuff is enabled.

OK, so I'll drop the panic(). printascii doesn't look extremely useful,
but I suppose we could use it for debugging. Seems like a while (1) loop
might be a suitable replacement. If we get this far, we'll likely get
locked up trying to power this CPU off anyway, so it'll be apparent that
there was power-down failure.

Thanks,
Brian

WARNING: multiple messages have this Message-ID (diff)
From: computersforpeace@gmail.com (Brian Norris)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 01/11] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs
Date: Mon, 4 Aug 2014 10:39:07 -0700	[thread overview]
Message-ID: <20140804173907.GU3711@ld-irv-0074> (raw)
In-Reply-To: <20140802081924.GW30282@n2100.arm.linux.org.uk>

On Sat, Aug 02, 2014 at 09:19:24AM +0100, Russell King wrote:
> Here's some more comments on this.
> 
> On Mon, Jul 21, 2014 at 02:07:56PM -0700, Brian Norris wrote:
> > +static void brcmstb_cpu_die(u32 cpu)
> > +{
> > +	v7_exit_coherency_flush(all);
> 
> This is ultimately what causes my builds to break:
> 
> /tmp/ccSPowmq.s:171: Error: selected processor does not support ARM mode `isb '
> /tmp/ccSPowmq.s:177: Error: selected processor does not support ARM mode `isb '
> /tmp/ccSPowmq.s:178: Error: selected processor does not support ARM mode `dsb '
> make[2]: *** [arch/arm/mach-bcm/platsmp-brcmstb.o] Error 1
> 
> It seems that v7_exit_coherency_flush() can only be used with code which
> is ARMv7 only.

Yes, I noticed this already, and I proposed a solution:

  http://article.gmane.org/gmane.linux.drivers.devicetree/84517

> > +	/* Prevent all interrupts from reaching this CPU. */
> > +	arch_local_irq_disable();
> 
> Why do you think it is necessary to disable interrupts here?  Where
> have they been re-enabled since this bit of generic code:
> 
> void __ref cpu_die(void)
> {
>         unsigned int cpu = smp_processor_id();
> 
>         idle_task_exit();
> 
>         local_irq_disable();
> 
> and why arch_local_irq_disable() at that?  Even if interrupts were
> enabled prior to your call to arch_local_irq_disable(), what do you
> think would be the effect of receiving an interrupt after you've
> exited coherency?

This mistake was already noted. No need for the extra IRQ disable.

(http://article.gmane.org/gmane.linux.drivers.devicetree/84516)

> > +
> > +	/*
> > +	 * Final full barrier to ensure everything before this instruction has
> > +	 * quiesced.
> > +	 */
> > +	isb();
> > +	dsb();
> 
> If the call to arch_local_irq_disable() is removed, and
> v7_exit_coherency_flush() is fixed, then this is not required, because
> v7_exit_coherency_flush() already does this at the very end.

Right. Will drop.

> > +
> > +	per_cpu_sw_state_wr(cpu, 0);
> > +
> > +	/* Sit and wait to die */
> > +	wfi();
> > +
> > +	/* We should never get here... */
> > +	panic("Spurious interrupt on CPU %d received!\n", cpu);
> 
> You really should /not/ be calling panic here, because that uses data
> shared with the CPUs which are still coherent.  This is akin to doing
> DMA into bits of the kernel space without dealing with the cache
> coherency issues.

OK.

> Moreover, if you read the comments on
> v7_exit_coherency_flush() about ldrex/strex, which are two instructions
> spinlocks use, you'll see that ldrex/strex must not be executed, which
> means you can't call any function which uses spinlocks.  That rules
> out printk() et.al.  printascii is fine, but that's only available when
> the low level debug stuff is enabled.

OK, so I'll drop the panic(). printascii doesn't look extremely useful,
but I suppose we could use it for debugging. Seems like a while (1) loop
might be a suitable replacement. If we get this far, we'll likely get
locked up trying to power this CPU off anyway, so it'll be apparent that
there was power-down failure.

Thanks,
Brian

  reply	other threads:[~2014-08-04 17:39 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
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 [this message]
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=20140804173907.GU3711@ld-irv-0074 \
    --to=computersforpeace@gmail.com \
    --cc=arnd@arndb.de \
    --cc=bcm@fixthebug.org \
    --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.