From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Rany Hany <rany_hany@riseup.net>
Cc: linux-mips@vger.kernel.org
Subject: Re: [PATCH 3/3] MIPS: SMP: Properly stop secondary CPUs for restart
Date: Tue, 5 May 2026 08:48:04 +0200 [thread overview]
Message-ID: <afmSpLBEb2OemYRY@alpha.franken.de> (raw)
In-Reply-To: <20260405235956.79535-4-rany_hany@riseup.net>
On Mon, Apr 06, 2026 at 02:59:55AM +0300, Rany Hany wrote:
> @@ -422,13 +425,66 @@ static void stop_this_cpu(void *dummy)
> set_cpu_online(smp_processor_id(), false);
> calculate_cpu_foreign_map();
> local_irq_disable();
> - while (1);
> +
> + if (mips_cm_present() && r4k_blast_dcache) {
> + unsigned int core = cpu_core(¤t_cpu_data);
> +
> + if (atomic_dec_and_test(&core_stop_count[core])) {
> + /* Flush data cache */
> + r4k_blast_dcache();
> + __sync();
> +
> + if (mips_cm_revision() < CM_REV_CM3) {
> + /* Restrict coherence to own core first */
> + write_gcr_cl_coherence(1 << core);
> + read_gcr_cl_coherence();
> + __sync();
> + }
> +
> + /* Disable coherence */
> + write_gcr_cl_coherence(0);
> + read_gcr_cl_coherence();
> +
> + /* Gate the core clock */
> + if (mips_cpc_present())
> + write_cpc_cl_cmd(CPC_Cx_CMD_CLOCKOFF);
> + }
> + }
> +
> + if (cpu_has_mipsmt) {
> + /* The last active VPE on the core will gate the core clock
> + * and all other remaining VPEs will halt this TC instead.
> + *
> + * Note that on systems without CPC, this will be the
> + * only way to shutdown the CPU.
> + */
> + write_c0_tchalt(TCHALT_H);
> + instruction_hazard();
> + }
> +
> + while (1)
> + cpu_relax();
> }
is this whole dance safe for _all_ SOCs with CM and MIPSMT ? if not,
this should be moved to a not so generic place...
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
next prev parent reply other threads:[~2026-05-05 6:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 23:59 [PATCH 0/3] Fix MT7621 restart deadlock Rany Hany
2026-04-05 23:59 ` [PATCH 1/3] MIPS: Stop secondary CPUs before platform restart/halt/poweroff Rany Hany
2026-04-05 23:59 ` [PATCH 2/3] MIPS: SMP: Wait for secondary CPUs to stop in smp_send_stop() Rany Hany
2026-04-05 23:59 ` [PATCH 3/3] MIPS: SMP: Properly stop secondary CPUs for restart Rany Hany
2026-05-05 6:48 ` Thomas Bogendoerfer [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-04-05 23:23 Rany Hany
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=afmSpLBEb2OemYRY@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=linux-mips@vger.kernel.org \
--cc=rany_hany@riseup.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox