devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Cernekee <cernekee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org
Cc: f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	jfraser-dY08KVG/lbpWk0Htik3J/w@public.gmane.org,
	dtor-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
	jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org,
	linux-mips-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH V2 09/22] MIPS: BMIPS: Introduce helper function to change the reset vector
Date: Sat, 15 Nov 2014 16:17:33 -0800	[thread overview]
Message-ID: <1416097066-20452-10-git-send-email-cernekee@gmail.com> (raw)
In-Reply-To: <1416097066-20452-1-git-send-email-cernekee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This will need to be called from a few different places, and the logic
is starting to get a bit hairy (with the need for IPIs, CPU bug
workarounds, and hazards).

Signed-off-by: Kevin Cernekee <cernekee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 arch/mips/kernel/smp-bmips.c | 65 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 58 insertions(+), 7 deletions(-)

diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index 4e56911..8383fa4 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -35,6 +35,7 @@
 #include <asm/bmips.h>
 #include <asm/traps.h>
 #include <asm/barrier.h>
+#include <asm/cpu-features.h>
 
 static int __maybe_unused max_cpus = 1;
 
@@ -43,6 +44,9 @@ int bmips_smp_enabled = 1;
 int bmips_cpu_offset;
 cpumask_t bmips_booted_mask;
 
+#define RESET_FROM_KSEG0		0x80080800
+#define RESET_FROM_KSEG1		0xa0080800
+
 #ifdef CONFIG_SMP
 
 /* initial $sp, $gp - used by arch/mips/kernel/bmips_vec.S */
@@ -463,10 +467,61 @@ static inline void bmips_nmi_handler_setup(void)
 		&bmips_smp_int_vec_end);
 }
 
+struct reset_vec_info {
+	int cpu;
+	u32 val;
+};
+
+static void bmips_set_reset_vec_remote(void *vinfo)
+{
+	struct reset_vec_info *info = vinfo;
+	int shift = info->cpu & 0x01 ? 16 : 0;
+	u32 mask = ~(0xffff << shift), val = info->val >> 16;
+
+	preempt_disable();
+	if (smp_processor_id() > 0) {
+		smp_call_function_single(0, &bmips_set_reset_vec_remote,
+					 info, 1);
+	} else {
+		if (info->cpu & 0x02) {
+			/* BMIPS5200 "should" use mask/shift, but it's buggy */
+			bmips_write_zscm_reg(0xa0, (val << 16) | val);
+			bmips_read_zscm_reg(0xa0);
+		} else {
+			write_c0_brcm_bootvec((read_c0_brcm_bootvec() & mask) |
+					      (val << shift));
+		}
+	}
+	preempt_enable();
+}
+
+static void bmips_set_reset_vec(int cpu, u32 val)
+{
+	struct reset_vec_info info;
+
+	if (current_cpu_type() == CPU_BMIPS5000) {
+		/* this needs to run from CPU0 (which is always online) */
+		info.cpu = cpu;
+		info.val = val;
+		bmips_set_reset_vec_remote(&info);
+	} else {
+		void __iomem *cbr = BMIPS_GET_CBR();
+
+		if (cpu == 0)
+			__raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_0);
+		else {
+			if (current_cpu_type() != CPU_BMIPS4380)
+				return;
+			__raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_1);
+		}
+	}
+	__sync();
+	back_to_back_c0_hazard();
+}
+
 void bmips_ebase_setup(void)
 {
 	unsigned long new_ebase = ebase;
-	void __iomem __maybe_unused *cbr;
 
 	BUG_ON(ebase != CKSEG0);
 
@@ -492,9 +547,7 @@ void bmips_ebase_setup(void)
 		 * 0x8000_0400: normal vectors
 		 */
 		new_ebase = 0x80000400;
-		cbr = BMIPS_GET_CBR();
-		__raw_writel(0x80080800, cbr + BMIPS_RELO_VECTOR_CONTROL_0);
-		__raw_writel(0xa0080800, cbr + BMIPS_RELO_VECTOR_CONTROL_1);
+		bmips_set_reset_vec(0, RESET_FROM_KSEG0);
 		break;
 	case CPU_BMIPS5000:
 		/*
@@ -502,10 +555,8 @@ void bmips_ebase_setup(void)
 		 * 0x8000_1000: normal vectors
 		 */
 		new_ebase = 0x80001000;
-		write_c0_brcm_bootvec(0xa0088008);
+		bmips_set_reset_vec(0, RESET_FROM_KSEG0);
 		write_c0_ebase(new_ebase);
-		if (max_cpus > 2)
-			bmips_write_zscm_reg(0xa0, 0xa008a008);
 		break;
 	default:
 		return;
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-11-16  0:17 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-16  0:17 [PATCH V2 00/22] Multiplatform BMIPS kernel Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 01/22] irqchip: Update docs regarding irq_domain_add_tree() Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 02/22] irqchip: brcmstb-l2: fix error handling of irq_of_parse_and_map Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 04/22] irqchip: bcm7120-l2: Refactor driver for arbitrary IRQEN/IRQSTAT offsets Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 05/22] irqchip: bcm7120-l2: Change DT binding to allow non-contiguous IRQEN/IRQSTAT Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 06/22] irqchip: Add new driver for BCM7038-style level 1 interrupt controllers Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 07/22] MIPS: BMIPS: Fix ".previous without corresponding .section" warnings Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 08/22] MIPS: BMIPS: Align secondary boot sequence with latest firmware releases Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 10/22] MIPS: BMIPS: Allow BMIPS3300 to utilize SMP ebase relocation code Kevin Cernekee
2014-11-20 23:40   ` Ralf Baechle
2014-11-16  0:17 ` [PATCH V2 11/22] MIPS: BMIPS: Mask off timer IRQs when hot-unplugging a CPU Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 12/22] MIPS: BMIPS: Explicitly configure reset vectors prior to secondary boot Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 13/22] MIPS: Allow MIPS_CPU_SCACHE to be used with different line sizes Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 14/22] MIPS: BMIPS: Fix L1_CACHE_SHIFT when BMIPS5000 is selected Kevin Cernekee
     [not found] ` <1416097066-20452-1-git-send-email-cernekee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-16  0:17   ` [PATCH V2 03/22] irqchip: bcm7120-l2: fix error handling of irq_of_parse_and_map Kevin Cernekee
2014-11-16  0:17   ` Kevin Cernekee [this message]
2014-11-16  0:17   ` [PATCH V2 15/22] MIPS: BMIPS: Let each platform customize the CPU1 IRQ mask Kevin Cernekee
2014-11-16  0:17   ` [PATCH V2 16/22] MIPS: BMIPS: Add special cache handling in c-r4k.c Kevin Cernekee
2014-11-16  0:17   ` [PATCH V2 19/22] Documentation: DT: Add "mti" vendor prefix Kevin Cernekee
2014-11-20  3:04   ` [PATCH V2 00/22] Multiplatform BMIPS kernel Brian Norris
2014-11-20  3:55     ` Kevin Cernekee
     [not found]       ` <CAJiQ=7C8h-MAuRdgzZqx2=bg8bvy7v9pv7e7tGXWmA9ghYJiqQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-20 18:09         ` Florian Fainelli
     [not found]           ` <546E2E3E.5040305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-20 20:13             ` Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 17/22] MIPS: BMIPS: Add PRId for BMIPS5200 (Whirlwind) Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 18/22] MIPS: Create a helper function for DT setup Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 20/22] MAINTAINERS: Add entry for bcm63xx/bcm33xx UDC gadget driver Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 21/22] MAINTAINERS: Add entry for BMIPS multiplatform kernel Kevin Cernekee
2014-11-16  0:17 ` [PATCH V2 22/22] MIPS: Add multiplatform BMIPS target Kevin Cernekee
2014-11-16 21:24   ` Arnd Bergmann
2014-11-16 22:12     ` Kevin Cernekee
     [not found]       ` <CAJiQ=7C-HniwXiVrqQg3cnFNNYGwoxHJf8JP-XYOqM1yWoyXaw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-17 12:16         ` Arnd Bergmann
2014-11-17 14:52           ` Jonas Gorski
     [not found]             ` <CAOiHx=ky5T7z3T3gX382d=3sw+gGUEfnwXwpcLGa_Oi5YyBwgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-17 16:13               ` Arnd Bergmann
2014-11-17 17:19                 ` Kevin Cernekee
     [not found]                   ` <CAJiQ=7An5eZ3j2+Zkx1crV9pBSVodkEQ+6ESGcFk5z0tDV7cHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-17 18:55                     ` Arnd Bergmann
2014-11-17 19:47                       ` Kevin Cernekee
2014-11-17 20:33                         ` Arnd Bergmann
2014-11-17 21:57                           ` Kevin Cernekee
     [not found]                             ` <CAJiQ=7AhyAyN6Hnvtdowdh6oPknbPFMe-_PrPdzyCGe5H7eE1g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-18 10:15                               ` Arnd Bergmann
2014-11-17 17:01           ` Kevin Cernekee
     [not found]             ` <CAJiQ=7A29-v5mo1ybvE2UodOZx-FoGeBTHYcTZuX-LaqRaF1Lw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-17 18:46               ` Arnd Bergmann
2014-11-17 19:39                 ` Kevin Cernekee
2014-11-17 20:40                   ` Arnd Bergmann
2014-11-17 21:21                     ` Kevin Cernekee
     [not found]                       ` <CAJiQ=7B6Xwz2iqqH4vEG8WzPOzHj7NHsuGWqq49uy-E34RHp4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-17 23:06                         ` Jonas Gorski
2014-11-18 10:19                         ` Arnd Bergmann
     [not found]   ` <1416097066-20452-23-git-send-email-cernekee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-17 14:44     ` Jonas Gorski
     [not found]       ` <CAOiHx=mGzPKO4N7KR+5FM1RfFDF+-wncdBz6PavR0q47Gtd2Jg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-17 20:35         ` Kevin Cernekee
     [not found]           ` <CAJiQ=7AMiRq8rbLmsKe0s9+vr91BRrL4s3mZWcsVgyS0bLgThw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-17 23:00             ` Jonas Gorski

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=1416097066-20452-10-git-send-email-cernekee@gmail.com \
    --to=cernekee-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dtor-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=jfraser-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mips-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org \
    --cc=ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.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).