All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support
@ 2022-05-11  8:30 Qing Zhang
  2022-05-11  8:30 ` [PATCH 2/3] MIPS: Loongson64: DTS: Add Loongson-2K1000 DTS related smp support Qing Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Qing Zhang @ 2022-05-11  8:30 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Thomas Bogendoerfer, Jiaxun Yang
  Cc: devicetree, linux-mips, linux-kernel, yangtiezhu, zhangqing

Add SMP part of dt parsing about Loongson-2K1000 to multiplex
loongson3_smp_ops, CONFIG_NUMA is not currently supported,
so of_numa is not used to parse relevant information.

Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
---
 arch/mips/loongson64/env.c |   3 +
 arch/mips/loongson64/smp.c | 130 +++++++++++++++++++++++++++++++++++--
 2 files changed, 129 insertions(+), 4 deletions(-)

diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c
index c961e2999f15..90552f6b00ca 100644
--- a/arch/mips/loongson64/env.c
+++ b/arch/mips/loongson64/env.c
@@ -52,6 +52,9 @@ void __init prom_dtb_init_env(void)
 		loongson_fdt_blob = __dtb_loongson64_2core_2k1000_begin;
 	else
 		loongson_fdt_blob = (void *)fw_arg2;
+
+	loongson_sysconf.dma_mask_bits = 32;
+	loongson_sysconf.workarounds = WORKAROUND_CPUHOTPLUG;
 }
 
 void __init prom_lefi_init_env(void)
diff --git a/arch/mips/loongson64/smp.c b/arch/mips/loongson64/smp.c
index 660e1de4412a..a7d2ad87bae0 100644
--- a/arch/mips/loongson64/smp.c
+++ b/arch/mips/loongson64/smp.c
@@ -13,6 +13,7 @@
 #include <linux/smp.h>
 #include <linux/cpufreq.h>
 #include <linux/kexec.h>
+#include <linux/of_address.h>
 #include <asm/processor.h>
 #include <asm/time.h>
 #include <asm/tlbflush.h>
@@ -476,10 +477,59 @@ static void loongson3_smp_finish(void)
 			smp_processor_id(), read_c0_status());
 }
 
+#define INVALID_HWID	ULONG_MAX
+static void parse_dt_cpus_init(void)
+{
+	struct device_node *dn, *np;
+	int i, hwids[NR_CPUS];
+	u64 hwid;
+
+	for_each_of_cpu_node(dn) {
+		hwid = of_get_cpu_hwid(dn, 0);
+		if (hwid >= INVALID_HWID)
+			continue;
+
+		for (i = 0; i < loongson_sysconf.nr_cpus; i++) {
+			if (hwids[i] == hwid) {
+				pr_err("%pOF: duplicate cpu reg properties in the DT\n", dn);
+				continue;
+			}
+		}
+
+		if (loongson_sysconf.nr_cpus >= NR_CPUS)
+			break;
+
+		hwids[loongson_sysconf.nr_cpus] = hwid;
+		loongson_sysconf.nr_cpus++;
+
+		np = of_find_compatible_node(NULL, NULL, "loongson, mmio-ipi");
+		if (!np) {
+			pr_info("Failed to get ipi node\n");
+			return;
+		}
+
+		smp_group[0] = (unsigned long long)of_iomap(np, 0);
+		if (!smp_group[0]) {
+			pr_info("Failed to map ipi register base address\n");
+			return;
+		}
+	}
+
+	of_node_put(np);
+	loongson_sysconf.reserved_cpus_mask = 0;
+	loongson_sysconf.boot_cpu_id = 0;
+	loongson_sysconf.nr_nodes = 1;
+	loongson_sysconf.cores_per_node = loongson_sysconf.nr_cpus;
+	loongson_sysconf.cores_per_package = loongson_sysconf.nr_cpus;
+}
+
 static void __init loongson3_smp_setup(void)
 {
 	int i = 0, num = 0; /* i: physical id, num: logical id */
 
+	if (loongson_sysconf.fw_interface == LOONGSON_DTB)
+		parse_dt_cpus_init();
+
 	init_cpu_possible(cpu_none_mask);
 
 	/* For unified kernel, NR_CPUS is the maximum possible value,
@@ -781,6 +831,68 @@ static void loongson3_type3_play_dead(int *state_addr)
 		: "a1");
 }
 
+static void loongson3_type4_play_dead(int *state_addr)
+{
+	register int val;
+	register long cpuid, core, node, count;
+	register void *addr, *base, *initfunc;
+
+	__asm__ __volatile__(
+		"   .set push                     \n"
+		"   .set noreorder                \n"
+		"   li %[addr], 0x80000000        \n" /* KSEG0 */
+		"1: cache 0, 0(%[addr])           \n" /* flush L1 ICache */
+		"   cache 0, 1(%[addr])           \n"
+		"   cache 0, 2(%[addr])           \n"
+		"   cache 0, 3(%[addr])           \n"
+		"   cache 1, 0(%[addr])           \n" /* flush L1 DCache */
+		"   cache 1, 1(%[addr])           \n"
+		"   cache 1, 2(%[addr])           \n"
+		"   cache 1, 3(%[addr])           \n"
+		"   addiu %[sets], %[sets], -1    \n"
+		"   bnez  %[sets], 1b             \n"
+		"   addiu %[addr], %[addr], 0x40  \n"
+		"   li    %[val], 0x7             \n" /* *state_addr = CPU_DEAD; */
+		"   sw    %[val], (%[state_addr]) \n"
+		"   sync                          \n"
+		"   cache 21, (%[state_addr])     \n" /* flush entry of *state_addr */
+		"   .set pop                      \n"
+		: [addr] "=&r" (addr), [val] "=&r" (val)
+		: [state_addr] "r" (state_addr),
+		  [sets] "r" (cpu_data[smp_processor_id()].dcache.sets));
+
+	__asm__ __volatile__(
+		"   .set push                         \n"
+		"   .set noreorder                    \n"
+		"   .set mips64                       \n"
+		"   mfc0  %[cpuid], $15, 1            \n"
+		"   andi  %[cpuid], 0x3ff             \n"
+		"   dli   %[base], 0x900000001fe11000 \n"
+		"   andi  %[core], %[cpuid], 0x3      \n"
+		"   sll   %[core], 8                  \n" /* get core id */
+		"   or    %[base], %[base], %[core]   \n"
+		"   andi  %[node], %[cpuid], 0xc      \n"
+		"   dsll  %[node], 42                 \n" /* get node id */
+		"   or    %[base], %[base], %[node]   \n"
+		"1: li    %[count], 0x100             \n" /* wait for init loop */
+		"2: bnez  %[count], 2b                \n" /* limit mailbox access */
+		"   addiu %[count], -1                \n"
+		"   ld    %[initfunc], 0x20(%[base])  \n" /* get PC via mailbox */
+		"   beqz  %[initfunc], 1b             \n"
+		"   nop                               \n"
+		"   ld    $sp, 0x28(%[base])          \n" /* get SP via mailbox */
+		"   ld    $gp, 0x30(%[base])          \n" /* get GP via mailbox */
+		"   ld    $a1, 0x38(%[base])          \n"
+		"   jr    %[initfunc]                 \n" /* jump to initial PC */
+		"   nop                               \n"
+		"   .set pop                          \n"
+		: [core] "=&r" (core), [node] "=&r" (node),
+		  [base] "=&r" (base), [cpuid] "=&r" (cpuid),
+		  [count] "=&r" (count), [initfunc] "=&r" (initfunc)
+		: /* No Input */
+		: "a1");
+}
+
 void play_dead(void)
 {
 	int prid_imp, prid_rev, *state_addr;
@@ -816,6 +928,13 @@ void play_dead(void)
 		play_dead_at_ckseg1 =
 			(void *)CKSEG1ADDR((unsigned long)loongson3_type3_play_dead);
 		break;
+	case PRID_REV_LOONGSON2K_R1_0:
+	case PRID_REV_LOONGSON2K_R1_1:
+	case PRID_REV_LOONGSON2K_R1_2:
+	case PRID_REV_LOONGSON2K_R1_3:
+		play_dead_at_ckseg1 =
+			(void *)CKSEG1ADDR((unsigned long)loongson3_type4_play_dead);
+		break;
 	}
 
 out:
@@ -854,10 +973,13 @@ static int loongson3_enable_clock(unsigned int cpu)
 
 static int register_loongson3_notifier(void)
 {
-	return cpuhp_setup_state_nocalls(CPUHP_MIPS_SOC_PREPARE,
-					 "mips/loongson:prepare",
-					 loongson3_enable_clock,
-					 loongson3_disable_clock);
+	if (loongson_sysconf.fw_interface != LOONGSON_DTB)
+		return cpuhp_setup_state_nocalls(CPUHP_MIPS_SOC_PREPARE,
+						 "mips/loongson:prepare",
+						 loongson3_enable_clock,
+						 loongson3_disable_clock);
+	else
+		return 0;
 }
 early_initcall(register_loongson3_notifier);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] MIPS: Loongson64: DTS: Add Loongson-2K1000 DTS related smp support
  2022-05-11  8:30 [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support Qing Zhang
@ 2022-05-11  8:30 ` Qing Zhang
  2022-05-11 16:04   ` Krzysztof Kozlowski
  2022-05-11  8:30 ` [PATCH 3/3] MIPS: Loongson64: Enable CONFIG_SMP and set default NR_CPUS to 2 Qing Zhang
  2022-05-11 16:04 ` [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support Krzysztof Kozlowski
  2 siblings, 1 reply; 5+ messages in thread
From: Qing Zhang @ 2022-05-11  8:30 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Thomas Bogendoerfer, Jiaxun Yang
  Cc: devicetree, linux-mips, linux-kernel, yangtiezhu, zhangqing

Add the device tree node and connect it to the CPU nodes.

Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
---
 .../mips/boot/dts/loongson/loongson64-2k1000.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi b/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
index 8143a61111e3..3b765c063d7a 100644
--- a/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
+++ b/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
@@ -20,6 +20,16 @@
 			reg = <0x0>;
 			#clock-cells = <1>;
 			clocks = <&cpu_clk>;
+			enable-method = "mmio-ipi";
+		};
+
+		cpu1: cpu@1 {
+			device_type = "cpu";
+			compatible = "loongson,gs264";
+			reg = <0x1>;
+			#clock-cells = <1>;
+			clocks = <&cpu_clk>;
+			enable-method = "mmio-ipi";
 		};
 	};
 
@@ -44,6 +54,11 @@
 		compatible = "mti,cpu-interrupt-controller";
 	};
 
+	ipi: interrupt-controller@1fe11000 {
+		compatible = "loongson, mmio-ipi";
+		reg = <0 0x1fe11000 0 0x40>;
+	};
+
 	package0: bus@10000000 {
 		compatible = "simple-bus";
 		#address-cells = <2>;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] MIPS: Loongson64: Enable CONFIG_SMP and set default NR_CPUS to 2
  2022-05-11  8:30 [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support Qing Zhang
  2022-05-11  8:30 ` [PATCH 2/3] MIPS: Loongson64: DTS: Add Loongson-2K1000 DTS related smp support Qing Zhang
@ 2022-05-11  8:30 ` Qing Zhang
  2022-05-11 16:04 ` [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support Krzysztof Kozlowski
  2 siblings, 0 replies; 5+ messages in thread
From: Qing Zhang @ 2022-05-11  8:30 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Thomas Bogendoerfer, Jiaxun Yang
  Cc: devicetree, linux-mips, linux-kernel, yangtiezhu, zhangqing

Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
---
 arch/mips/configs/loongson2k_defconfig | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/mips/configs/loongson2k_defconfig b/arch/mips/configs/loongson2k_defconfig
index e948ca487e2d..74353a4254eb 100644
--- a/arch/mips/configs/loongson2k_defconfig
+++ b/arch/mips/configs/loongson2k_defconfig
@@ -20,7 +20,10 @@ CONFIG_RELAY=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_EMBEDDED=y
 CONFIG_MACH_LOONGSON64=y
+# CONFIG_CPU_LOONGSON3_WORKAROUNDS is not set
 # CONFIG_CPU_LOONGSON3_CPUCFG_EMULATION is not set
+CONFIG_SMP=y
+CONFIG_NR_CPUS=2
 CONFIG_HZ_256=y
 CONFIG_MIPS32_O32=y
 CONFIG_MIPS32_N32=y
@@ -95,7 +98,6 @@ CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_MTD=m
 CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_CRYPTOLOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_RAID_ATTRS=m
@@ -144,7 +146,6 @@ CONFIG_TUN=m
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_CHELSIO is not set
 # CONFIG_NET_VENDOR_CIRRUS is not set
 # CONFIG_NET_VENDOR_CISCO is not set
@@ -163,15 +164,16 @@ CONFIG_IXGBE=y
 # CONFIG_NET_VENDOR_MICROCHIP is not set
 # CONFIG_NET_VENDOR_MICROSEMI is not set
 # CONFIG_NET_VENDOR_MYRI is not set
+# CONFIG_NET_VENDOR_NI is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
 # CONFIG_NET_VENDOR_NETERION is not set
 # CONFIG_NET_VENDOR_NETRONOME is not set
-# CONFIG_NET_VENDOR_NI is not set
 # CONFIG_NET_VENDOR_NVIDIA is not set
 # CONFIG_NET_VENDOR_OKI is not set
 # CONFIG_NET_VENDOR_PACKET_ENGINES is not set
 # CONFIG_NET_VENDOR_PENSANDO is not set
 # CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RDC is not set
 CONFIG_8139CP=y
@@ -182,9 +184,9 @@ CONFIG_R8169=y
 # CONFIG_NET_VENDOR_ROCKER is not set
 # CONFIG_NET_VENDOR_SAMSUNG is not set
 # CONFIG_NET_VENDOR_SEEQ is not set
-# CONFIG_NET_VENDOR_SOLARFLARE is not set
 # CONFIG_NET_VENDOR_SILAN is not set
 # CONFIG_NET_VENDOR_SIS is not set
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
 # CONFIG_NET_VENDOR_SMSC is not set
 CONFIG_STMMAC_ETH=y
 # CONFIG_NET_VENDOR_SUN is not set
@@ -229,7 +231,6 @@ CONFIG_SERIAL_8250_RSA=y
 CONFIG_SERIAL_OF_PLATFORM=y
 CONFIG_SERIAL_NONSTANDARD=y
 CONFIG_HW_RANDOM=y
-CONFIG_RAW_DRIVER=m
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_PIIX4=y
 CONFIG_GPIO_LOONGSON=y
@@ -243,13 +244,9 @@ CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
 CONFIG_DRM=y
 CONFIG_DRM_RADEON=y
-CONFIG_FB_RADEON=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_PLATFORM=m
 # CONFIG_VGA_CONSOLE is not set
-CONFIG_FRAMEBUFFER_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
-CONFIG_LOGO=y
 CONFIG_SOUND=y
 CONFIG_SND=y
 CONFIG_SND_VERBOSE_PRINTK=y
@@ -336,7 +333,6 @@ CONFIG_DEFAULT_SECURITY_DAC=y
 CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_MD5=y
-CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_BLOWFISH=m
 CONFIG_CRYPTO_CAST5=m
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] MIPS: Loongson64: DTS: Add Loongson-2K1000 DTS related smp support
  2022-05-11  8:30 ` [PATCH 2/3] MIPS: Loongson64: DTS: Add Loongson-2K1000 DTS related smp support Qing Zhang
@ 2022-05-11 16:04   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2022-05-11 16:04 UTC (permalink / raw)
  To: Qing Zhang, Rob Herring, Krzysztof Kozlowski,
	Thomas Bogendoerfer, Jiaxun Yang
  Cc: devicetree, linux-mips, linux-kernel, yangtiezhu

On 11/05/2022 10:30, Qing Zhang wrote:
> Add the device tree node and connect it to the CPU nodes.

>  
> +	ipi: interrupt-controller@1fe11000 {
> +		compatible = "loongson, mmio-ipi";

No spaces in compatibles. The compatible needs bindings.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support
  2022-05-11  8:30 [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support Qing Zhang
  2022-05-11  8:30 ` [PATCH 2/3] MIPS: Loongson64: DTS: Add Loongson-2K1000 DTS related smp support Qing Zhang
  2022-05-11  8:30 ` [PATCH 3/3] MIPS: Loongson64: Enable CONFIG_SMP and set default NR_CPUS to 2 Qing Zhang
@ 2022-05-11 16:04 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2022-05-11 16:04 UTC (permalink / raw)
  To: Qing Zhang, Rob Herring, Krzysztof Kozlowski,
	Thomas Bogendoerfer, Jiaxun Yang
  Cc: devicetree, linux-mips, linux-kernel, yangtiezhu

On 11/05/2022 10:30, Qing Zhang wrote:
> +		if (loongson_sysconf.nr_cpus >= NR_CPUS)
> +			break;
> +
> +		hwids[loongson_sysconf.nr_cpus] = hwid;
> +		loongson_sysconf.nr_cpus++;
> +
> +		np = of_find_compatible_node(NULL, NULL, "loongson, mmio-ipi");

Please document compatibles in the bindings.



Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-11 16:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  8:30 [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support Qing Zhang
2022-05-11  8:30 ` [PATCH 2/3] MIPS: Loongson64: DTS: Add Loongson-2K1000 DTS related smp support Qing Zhang
2022-05-11 16:04   ` Krzysztof Kozlowski
2022-05-11  8:30 ` [PATCH 3/3] MIPS: Loongson64: Enable CONFIG_SMP and set default NR_CPUS to 2 Qing Zhang
2022-05-11 16:04 ` [PATCH 1/3] MIPS: Loongson64: Add Loongson-2K1000 SMP support Krzysztof Kozlowski

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.