From: Michael Ellerman <mpe@ellerman.id.au>
To: Paul Mackerras <paulus@ozlabs.org>, Nicholas Piggin <npiggin@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 5/5] powerpc/microwatt: Add SMP support
Date: Wed, 29 Jan 2025 23:50:44 +1100 [thread overview]
Message-ID: <874j1hss0r.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <Z5nRYn11vxVuGU7J@thinks.paulus.ozlabs.org>
Paul Mackerras <paulus@ozlabs.org> writes:
> On Wed, Jan 29, 2025 at 04:21:26PM +1000, Nicholas Piggin wrote:
>> On Wed Jan 29, 2025 at 8:55 AM AEST, Paul Mackerras wrote:
>> > This adds support for Microwatt systems with more than one core, and
>> > updates the device tree for a 2-core version. (This does not prevent
>> > the kernel from running on a single-core system.)
>> >
>> > Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
>>
>> Well, I'm impressed you added SMP :)
>>
>> What happens with a 1 CPU system? Do we time out waiting for secondaries
>> and continue, or is there something more graceful?
>
> There's a field in the SYSCON register which tells you how many cores
> there are. microwatt_init_smp() looks at that field and only starts
> the CPUs that are there.
>
> Oops, sorry, I see that I forgot to do 'git add' on
> arch/powerpc/platforms/microwatt/smp.c. Here it is (I'll include it
> properly in v2, of course):
>
> // SPDX-License-Identifier: GPL-2.0-or-later
>
> /*
> * SMP support functions for Microwatt
> * Copyright 2025 Paul Mackerras <paulus@ozlabs.org>
> */
>
> #include <linux/kernel.h>
> #include <linux/smp.h>
> #include <linux/io.h>
> #include <asm/early_ioremap.h>
> #include <asm/xics.h>
>
> #include "microwatt.h"
>
> static void __init microwatt_smp_probe(void)
> {
> xics_smp_probe();
> }
>
> static void microwatt_smp_setup_cpu(int cpu)
> {
> if (cpu != 0)
> xics_setup_cpu();
> }
>
> static struct smp_ops_t microwatt_smp_ops = {
> .probe = microwatt_smp_probe,
> .message_pass = NULL, /* Use smp_muxed_ipi_message_pass */
> .kick_cpu = smp_generic_kick_cpu,
> .setup_cpu = microwatt_smp_setup_cpu,
> };
>
> /* XXX get from device tree */
> #define SYSCON_BASE 0xc0000000
>
> #define SYSCON_CPU_CTRL 0x58
>
> void __init microwatt_init_smp(void)
> {
> volatile unsigned char __iomem *syscon;
> int ncpus;
> int timeout;
>
> syscon = early_ioremap(SYSCON_BASE, 0x100);
> if (syscon == NULL) {
> pr_err("Failed to map SYSCON\n");
> return;
> }
> ncpus = (readl(syscon + SYSCON_CPU_CTRL) >> 8) & 0xff;
> if (ncpus < 2)
> goto out;
>
> smp_ops = µwatt_smp_ops;
>
> /*
> * Write two instructions at location 0:
> * mfspr r3, PIR
> * b __secondary_hold
> */
> *(unsigned int *)KERNELBASE = 0x7c7ffaa6;
> *(unsigned int *)(KERNELBASE+4) = 0x4800005c;
There's macros that would make these a little nicer, ie. PPC_RAW_MFSPR()
and PPC_RAW_BRANCH().
> /* enable the other CPUs, they start at location 0 */
> writel((1ul << ncpus) - 1, syscon + SYSCON_CPU_CTRL);
>
> timeout = 10000;
> while (!__secondary_hold_acknowledge) {
> if (--timeout == 0)
> break;
> barrier();
> }
I assume CPU 0 always boots first?
Is the loop actually necessary? It only waits for a single non-zero CPU
to come up after all, not all of them.
cheers
next prev parent reply other threads:[~2025-01-29 12:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 22:49 [PATCH 0/5] Microwatt updates Paul Mackerras
2025-01-28 22:51 ` [PATCH 1/5] powerpc/microwatt: Select COMMON_CLK in order to get the clock framework Paul Mackerras
2025-01-29 5:57 ` Nicholas Piggin
2025-01-28 22:52 ` [PATCH 2/5] powerpc/microwatt: Device-tree updates Paul Mackerras
2025-01-29 6:36 ` Nicholas Piggin
2025-01-29 7:18 ` Paul Mackerras
2025-01-29 8:20 ` Nicholas Piggin
2025-01-31 17:03 ` Segher Boessenkool
2025-01-31 16:55 ` Segher Boessenkool
2025-01-31 16:53 ` Segher Boessenkool
2025-01-31 16:48 ` Segher Boessenkool
2025-01-28 22:52 ` [PATCH 3/5] powerpc/microwatt: Define an idle power-save function Paul Mackerras
2025-01-29 6:06 ` Nicholas Piggin
2025-01-29 6:49 ` Paul Mackerras
2025-01-31 16:32 ` Segher Boessenkool
2025-02-01 1:41 ` Paul Mackerras
2025-01-31 16:25 ` Segher Boessenkool
2025-01-28 22:53 ` [PATCH 4/5] powerpc: Define config option for processors without broadcast TLBIE Paul Mackerras
2025-01-29 6:14 ` Nicholas Piggin
2025-01-29 7:10 ` Paul Mackerras
2025-01-29 8:17 ` Nicholas Piggin
2025-01-31 17:30 ` Segher Boessenkool
2025-01-31 17:26 ` Segher Boessenkool
2025-01-28 22:55 ` [PATCH 5/5] powerpc/microwatt: Add SMP support Paul Mackerras
2025-01-29 6:21 ` Nicholas Piggin
2025-01-29 6:57 ` Paul Mackerras
2025-01-29 8:12 ` Nicholas Piggin
2025-01-31 1:27 ` Paul Mackerras
2025-01-29 12:50 ` Michael Ellerman [this message]
2025-01-31 1:34 ` Paul Mackerras
2025-01-31 16:13 ` [PATCH 0/5] Microwatt updates Segher Boessenkool
2025-02-01 1:22 ` Paul Mackerras
2025-03-02 10:13 ` Gabriel Paubert
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=874j1hss0r.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=paulus@ozlabs.org \
/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;
as well as URLs for NNTP newsgroup(s).