MIPS: Loongson-3: Add NUMA and Loongson-3B support
Subsystems (3)
cover MIPS: Loongson-3: Add NUMA and Loongson-3B support
This patchset is prepared for the next 3.16 release for Linux/MIPS. In this series we add NUMA and Loongson-3B support. Multiple Loongson-3A chips can be interconnected with HT0-bus. This is a CC-NUMA system that every chip (node) has its own local memory and cache coherency is maintained by hardware. Loongson-3B is a 8-cores processor which looks like there are two Loongson-3A integrated in one chip: 8 cores are separated into two groups (two NUMA node).
Huacai Chen(9):
MIPS: Support hard limit of cpu count (nr_cpu_ids).
MIPS: Support CPU topology files in sysfs.
MIPS: Loongson: Modify ChipConfig register definition.
MIPS: Add NUMA support for Loongson-3.
MIPS: Add numa api support.
MIPS: Add Loongson-3B support.
MIPS: Loongson: Make CPU name more clear.
MIPS: Loongson-3: Enable the COP2 usage.
MIPS: Loongson: Rename CONFIG_LEMOTE_MACH3A to CONFIG_LOONGSON_MACH3X.
--- arch/mips/Kconfig | 7 +- arch/mips/configs/loongson3_defconfig | 2 +- arch/mips/include/asm/addrspace.h | 6 + arch/mips/include/asm/cop2.h | 8 + arch/mips/include/asm/cpu-info.h | 1 + arch/mips/include/asm/cpu.h | 2 + arch/mips/include/asm/mach-loongson/boot_param.h | 4 + .../include/asm/mach-loongson/kernel-entry-init.h | 51 +++ arch/mips/include/asm/mach-loongson/loongson.h | 11 +- arch/mips/include/asm/mach-loongson/machine.h | 4 +- arch/mips/include/asm/mach-loongson/mmzone.h | 51 +++ arch/mips/include/asm/mach-loongson/topology.h | 23 ++ arch/mips/include/asm/smp.h | 6 + arch/mips/include/asm/sparsemem.h | 5 + arch/mips/kernel/cpu-probe.c | 12 +- arch/mips/kernel/proc.c | 1 + arch/mips/kernel/scall32-o32.S | 4 +- arch/mips/kernel/scall64-64.S | 4 +- arch/mips/kernel/scall64-n32.S | 6 +- arch/mips/kernel/scall64-o32.S | 6 +- arch/mips/kernel/setup.c | 20 +- arch/mips/kernel/smp.c | 26 ++- arch/mips/loongson/Kconfig | 9 +- arch/mips/loongson/Platform | 2 +- arch/mips/loongson/common/env.c | 49 +++- arch/mips/loongson/common/init.c | 4 + arch/mips/loongson/common/pm.c | 8 +- arch/mips/loongson/lemote-2f/clock.c | 4 +- arch/mips/loongson/lemote-2f/reset.c | 2 +- arch/mips/loongson/loongson-3/Makefile | 4 +- arch/mips/loongson/loongson-3/cop2-ex.c | 63 ++++ arch/mips/loongson/loongson-3/irq.c | 26 +- arch/mips/loongson/loongson-3/numa.c | 290 +++++++++++++++ arch/mips/loongson/loongson-3/smp.c | 387 +++++++++++++++----- arch/mips/loongson/loongson-3/smp.h | 37 +- arch/mips/pci/Makefile | 2 +- drivers/cpufreq/loongson2_cpufreq.c | 6 +- 37 files changed, 995 insertions(+), 158 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/kernel-entry-init.h create mode 100644 arch/mips/include/asm/mach-loongson/mmzone.h create mode 100644 arch/mips/include/asm/mach-loongson/topology.h create mode 100644 arch/mips/loongson/loongson-3/cop2-ex.c create mode 100644 arch/mips/loongson/loongson-3/numa.c
--
1.7.7.3
PATCH 1/9 MIPS: Support hard limit of cpu count (nr_cpu_ids)
On MIPS currently, only the soft limit of cpu count (maxcpus) has its effect, this patch enable the hard limit (nr_cpus) as well. Processor cores which greater than maxcpus and less than nr_cpus can be taken up via cpu hotplug. The code is borrowed from X86.
--- arch/mips/kernel/setup.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
arch/mips/kernel/setup.c +18 -0
@@ -729,6 +729,23 @@ static void __init resource_init(void) } } +static void __init prefill_possible_map (void ) +{ +#ifdef CONFIG_SMP +int i, possible =num_possible_cpus (); + +if (possible > nr_cpu_ids) + possible = nr_cpu_ids; + +for (i =0 ; i < possible; i++) +set_cpu_possible (i, true); +for (; i <NR_CPUS ; i++) +set_cpu_possible (i, false); + + nr_cpu_ids = possible; +#endif +} +void __init setup_arch (char **cmdline_p) {cpu_probe ();
@@ -752,6 +769,7 @@ void __init setup_arch(char **cmdline_p)resource_init ();plat_smp_setup (); +prefill_possible_map ();cpu_cache_init (); }
Signature · 1 line
1.7.7.3
Re: [PATCH 1/9] MIPS: Support hard limit of cpu count (nr_cpu_ids)
Hello.
Quoted 25 lines · Huacai Chen
On MIPS currently, only the soft limit of cpu count (maxcpus) has its effect, this patch enable the hard limit (
nr_cpus) as well. Processor cores which greater than maxcpus and less thannr_cpuscan be taken up via cpu hotplug. The code is borrowed from X86.Signed-off-by Huacai Chen <[email protected]>--- arch/mips/kernel/setup.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)arch/mips/kernel/setup.c +7
-0@@ -729,6 +729,23 @@ static void __init resource_init(void) } } +static void __init prefill_possible_map (void ) +{ +#ifdef CONFIG_SMP +int i, possible =num_possible_cpus (); + +if (possible > nr_cpu_ids) + possible = nr_cpu_ids;
arch/mips/kernel/setup.c static void __init resource_init(void) · line 748
Quoted 10 lines
arch/mips/kernel/setup.c +10
-0+ +for (i =0 ; i < possible; i++) +set_cpu_possible (i, true); +for (; i <NR_CPUS ; i++) +set_cpu_possible (i, false); + + nr_cpu_ids = possible; +#endif +} +
#ifdef's in the function body are ugly. Instead I'm suggesting:
#ifdef CONFIG_SMP
static void __init prefill_possible_map(void)
{
[...]
}
#else
static inline void prefill_possible_map(void) {}
#endif
WBR, Sergei
PATCH 2/9 MIPS: Support CPU topology files in sysfs
In reply to Huacai ChenThis patch is prepared for Loongson's NUMA support, it offer meaningful sysfs files such as physical_package_id, core_id, core_siblings and thread_siblings in /sys/devices/system/cpu/cpu?/topology.
--- arch/mips/include/asm/cpu-info.h | 1 + arch/mips/include/asm/smp.h | 6 ++++++ arch/mips/kernel/proc.c | 1 + arch/mips/kernel/smp.c | 26 +++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 1 deletions(-)
arch/mips/include/asm/cpu-info.h +1 -0
@@ -61,6 +61,7 @@ struct cpuinfo_mips {struct cache_desc scache;/* Secondary cache */ struct cache_desc tcache;/* Tertiary/split secondary cache */ int srsets;/* Shadow register sets */ +int package;/* physical package number */ int core;/* physical core number */ #ifdef CONFIG_64BIT int vmbits;/* Virtual memory size in bits */
arch/mips/include/asm/smp.h +6 -0
@@ -22,6 +22,7 @@extern int smp_num_siblings;extern cpumask_t cpu_sibling_map[]; +extern cpumask_t cpu_core_map[];#define raw_smp_processor_id () (current_thread_info()->cpu)
@@ -36,6 +37,11 @@ extern int __cpu_logical_map[NR_CPUS];#define NO_PROC_ID (-1) +#define topology_physical_package_id (cpu) (cpu_data[cpu].package) +#define topology_core_id (cpu) (cpu_data[cpu].core) +#define topology_core_cpumask (cpu) (&cpu_core_map[cpu]) +#define topology_thread_cpumask (cpu) (&cpu_sibling_map[cpu]) +#define SMP_RESCHEDULE_YOURSELF 0x1/* XXX braindead */ #define SMP_CALL_FUNCTION 0x2/* Octeon - Tell another core to flush its icache */
arch/mips/kernel/proc.c +1 -0
@@ -123,6 +123,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) cpu_data[n].srsets);seq_printf (m,"kscratch registers\t: %d\n" ,hweight8 (cpu_data[n].kscratch_mask)); +seq_printf (m,"package\t\t\t: %d\n" , cpu_data[n].package);seq_printf (m,"core\t\t\t: %d\n" , cpu_data[n].core);#if defined(CONFIG_MIPS_MT_SMP ) || defined(CONFIG_MIPS_MT_SMTC )if (cpu_has_mipsmt) {
arch/mips/kernel/smp.c +25 -1
@@ -63,9 +63,16 @@ EXPORT_SYMBOL(smp_num_siblings);cpumask_t cpu_sibling_map[NR_CPUS ]__read_mostly ;EXPORT_SYMBOL (cpu_sibling_map); +/* representing the core map of multi-core chips of each logical CPU */ +cpumask_t cpu_core_map[NR_CPUS ]__read_mostly ; +EXPORT_SYMBOL (cpu_core_map); +/* representing cpus for which sibling maps can be computed */ static cpumask_t cpu_sibling_setup_map; +/* representing cpus for which core maps can be computed */ +static cpumask_t cpu_core_setup_map; +static inline void set_cpu_sibling_map (int cpu) {int i;
@@ -74,7 +81,8 @@ static inline void set_cpu_sibling_map(int cpu)if (smp_num_siblings >1 ) {for_each_cpu_mask (i, cpu_sibling_setup_map) { -if (cpu_data[cpu].core == cpu_data[i].core) { +if (cpu_data[cpu].package == cpu_data[i].package && + cpu_data[cpu].core == cpu_data[i].core) {cpu_set (i, cpu_sibling_map[cpu]);cpu_set (cpu, cpu_sibling_map[i]); }
@@ -83,6 +91,20 @@ static inline void set_cpu_sibling_map(int cpu)cpu_set (cpu, cpu_sibling_map[cpu]); } +static inline void set_cpu_core_map (int cpu) +{ +int i; + +cpu_set (cpu, cpu_core_setup_map); + +for_each_cpu_mask (i, cpu_core_setup_map) { +if (cpu_data[cpu].package == cpu_data[i].package) { +cpu_set (i, cpu_core_map[cpu]); +cpu_set (cpu, cpu_core_map[i]); + } + } +} +struct plat_smp_ops *mp_ops;EXPORT_SYMBOL (mp_ops);
@@ -129,6 +151,7 @@ asmlinkage void start_secondary(void)set_cpu_online (cpu, true);set_cpu_sibling_map (cpu); +set_cpu_core_map (cpu);cpu_set (cpu, cpu_callin_map);
@@ -183,6 +206,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)current_thread_info ()->cpu =0 ; mp_ops->prepare_cpus (max_cpus);set_cpu_sibling_map (0 ); +set_cpu_core_map (0 );#ifndef CONFIG_HOTPLUG_CPU init_cpu_present (cpu_possible_mask);#endif
Signature · 1 line
1.7.7.3
PATCH 3/9 MIPS: Loongson: Modify ChipConfig register definition
In reply to Huacai ChenThis patch is prepared for Multi-chip interconnection. Since each chip has a ChipConfig register, LOONGSON_CHIPCFG should be an array.
--- arch/mips/include/asm/mach-loongson/loongson.h | 7 +++++-- arch/mips/loongson/common/env.c | 11 +++++++++++ arch/mips/loongson/common/pm.c | 8 ++++---- arch/mips/loongson/lemote-2f/clock.c | 4 ++-- arch/mips/loongson/lemote-2f/reset.c | 2 +- arch/mips/loongson/loongson-3/smp.c | 4 ++-- drivers/cpufreq/loongson2_cpufreq.c | 6 +++--- 7 files changed, 28 insertions(+), 14 deletions(-)
arch/mips/include/asm/mach-loongson/loongson.h +5 -2
@@ -249,8 +249,11 @@ static inline void do_perfcnt_IRQ(void)#define LOONGSON_PXARB_CFG LOONGSON_REG(LOONGSON_REGBASE + 0x68)#define LOONGSON_PXARB_STATUS LOONGSON_REG(LOONGSON_REGBASE + 0x6c) -/* Chip Config */ -#define LOONGSON_CHIPCFG0 LOONGSON_REG(LOONGSON_REGBASE + 0x80) +#define MAX_PACKAGES 4 + +/* Chip Config registor of each physical cpu package, PRid >= Loongson-2F */ +extern u64 loongson_chipcfg[MAX_PACKAGES ]; +#define LOONGSON_CHIPCFG (id) (*(volatile u32 *)(loongson_chipcfg[id]))/* pcimap */
arch/mips/loongson/common/env.c +11 -0
@@ -27,6 +27,8 @@ EXPORT_SYMBOL(cpu_clock_freq);struct efi_memory_map_loongson *loongson_memmap;struct loongson_system_configuration loongson_sysconf; +u64 loongson_chipcfg[MAX_PACKAGES ] = {0xffffffffbfc00180 }; +#define parse_even_earlier (res, option, p) \ do { \ unsigned int tmp __maybe_unused; \
@@ -77,6 +79,15 @@ void __init prom_init_env(void) cpu_clock_freq = ecpu->cpu_clock_freq; loongson_sysconf.cputype = ecpu->cputype; +if (ecpu->cputype == Loongson_3A) { + loongson_chipcfg[0 ] =0x900000001fe00180 ; + loongson_chipcfg[1 ] =0x900010001fe00180 ; + loongson_chipcfg[2 ] =0x900020001fe00180 ; + loongson_chipcfg[3 ] =0x900030001fe00180 ; + }else { + loongson_chipcfg[0 ] =0x900000001fe00180 ; + } + loongson_sysconf.nr_cpus = ecpu->nr_cpus;if (ecpu->nr_cpus >NR_CPUS || ecpu->nr_cpus ==0 ) loongson_sysconf.nr_cpus =NR_CPUS ;
arch/mips/loongson/common/pm.c +4 -4
@@ -79,7 +79,7 @@ int __weak wakeup_loongson(void)static void wait_for_wakeup_events (void ) {while (!wakeup_loongson ()) -LOONGSON_CHIPCFG0 &= ~0x7 ; +LOONGSON_CHIPCFG (0 ) &= ~0x7 ; }/*
@@ -102,15 +102,15 @@ static void loongson_suspend_enter(void)stop_perf_counters (); - cached_cpu_freq =LOONGSON_CHIPCFG0 ; + cached_cpu_freq =LOONGSON_CHIPCFG (0 );/* Put CPU into wait mode */ -LOONGSON_CHIPCFG0 &= ~0x7 ; +LOONGSON_CHIPCFG (0 ) &= ~0x7 ;/* wait for the given events to wakeup cpu from wait mode */ wait_for_wakeup_events (); -LOONGSON_CHIPCFG0 = cached_cpu_freq; +LOONGSON_CHIPCFG (0 ) = cached_cpu_freq;mmiowb (); }
arch/mips/loongson/lemote-2f/clock.c +2 -2
@@ -119,10 +119,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate) clk->rate = rate; - regval =LOONGSON_CHIPCFG0 ; + regval =LOONGSON_CHIPCFG (0 ); regval = (regval & ~0x7 ) | (loongson2_clockmod_table[i].driver_data -1 ); -LOONGSON_CHIPCFG0 = regval; +LOONGSON_CHIPCFG (0 ) = regval;return ret; }
arch/mips/loongson/lemote-2f/reset.c +1 -1
@@ -28,7 +28,7 @@ static void reset_cpu(void)* reset cpu to full speed, this is needed when enabling cpu frequency * scalling */ -LOONGSON_CHIPCFG0 |=0x7 ; +LOONGSON_CHIPCFG (0 ) |=0x7 ; }/* reset support for fuloong2f */
arch/mips/loongson/loongson-3/smp.c +2 -2
@@ -406,12 +406,12 @@ static int loongson3_cpu_callback(struct notifier_block *nfb,case CPU_POST_DEAD :case CPU_POST_DEAD_FROZEN :pr_info ("Disable clock for CPU#%d\n" , cpu); -LOONGSON_CHIPCFG0 &= ~(1 << (12 + cpu)); +LOONGSON_CHIPCFG (0 ) &= ~(1 << (12 + cpu));break ;case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN :pr_info ("Enable clock for CPU#%d\n" , cpu); -LOONGSON_CHIPCFG0 |=1 << (12 + cpu); +LOONGSON_CHIPCFG (0 ) |=1 << (12 + cpu);break ; }
drivers/cpufreq/loongson2_cpufreq.c +3 -3
@@ -148,9 +148,9 @@ static void loongson2_cpu_wait(void)u32 cpu_freq;spin_lock_irqsave (&loongson2_wait_lock, flags); - cpu_freq =LOONGSON_CHIPCFG0 ; -LOONGSON_CHIPCFG0 &= ~0x7 ;/* Put CPU into wait mode */ -LOONGSON_CHIPCFG0 = cpu_freq;/* Restore CPU state */ + cpu_freq =LOONGSON_CHIPCFG (0 ); +LOONGSON_CHIPCFG (0 ) &= ~0x7 ;/* Put CPU into wait mode */ +LOONGSON_CHIPCFG (0 ) = cpu_freq;/* Restore CPU state */ spin_unlock_irqrestore (&loongson2_wait_lock, flags);local_irq_enable (); }
Signature · 1 line
1.7.7.3
PATCH 4/9 MIPS: Add NUMA support for Loongson-3
In reply to Huacai ChenMultiple Loongson-3A chips can be interconnected with HT0-bus. This is a CC-NUMA system that every chip (node) has its own local memory and cache coherency is maintained by hardware. The 64-bit physical memory address format is as follows:
0x-0000-YZZZ-ZZZZ-ZZZZ
The high 16 bits should be 0, which means the real physical address supported by Loongson-3 is 48-bit. The "Y" bits is the base address of each node, which can be also considered as the node-id. The "Z" bits is the address offset within a node, which means every node has a 44 bits address space.
--- arch/mips/Kconfig | 7 +- arch/mips/include/asm/addrspace.h | 6 + arch/mips/include/asm/mach-loongson/boot_param.h | 3 + .../include/asm/mach-loongson/kernel-entry-init.h | 51 ++++ arch/mips/include/asm/mach-loongson/mmzone.h | 51 ++++ arch/mips/include/asm/mach-loongson/topology.h | 23 ++ arch/mips/include/asm/sparsemem.h | 5 + arch/mips/kernel/setup.c | 2 +- arch/mips/loongson/Kconfig | 1 + arch/mips/loongson/common/env.c | 7 + arch/mips/loongson/common/init.c | 4 + arch/mips/loongson/loongson-3/Makefile | 2 + arch/mips/loongson/loongson-3/numa.c | 290 ++++++++++++++++++++ arch/mips/loongson/loongson-3/smp.c | 8 +- 14 files changed, 456 insertions(+), 4 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/kernel-entry-init.h create mode 100644 arch/mips/include/asm/mach-loongson/mmzone.h create mode 100644 arch/mips/include/asm/mach-loongson/topology.h create mode 100644 arch/mips/loongson/loongson-3/numa.c
arch/mips/Kconfig +6 -1
@@ -2233,9 +2233,14 @@ config SYS_SUPPORTS_NUMA bool config NODES_SHIFT - int + int "Maximum Number of NUMA Nodes Shift" + range 1 10 default "6" depends on NEED_MULTIPLE_NODES + help + This option specifies the maximum number of available NUMA nodes + on the target system. MAX_NUMNODES will be 2^(This value). + If in doubt, use the default. config HW_PERF_EVENTS bool "Enable hardware performance counter support for perf events"
arch/mips/include/asm/addrspace.h +6 -0
@@ -51,8 +51,14 @@* Returns the physical address of a CKSEGx / XKPHYS address */ #define CPHYSADDR (a) ((_ACAST32_(a)) & 0x1fffffff) + +#ifndef CONFIG_NUMA #define XPHYSADDR (a) ((_ACAST64_(a)) & \ _CONST64_(0x000000ffffffffff)) +#else +#define XPHYSADDR (a) ((_ACAST64_(a)) & \ + _CONST64_(0x0000ffffffffffff)) +#endif #ifdef CONFIG_64BIT
arch/mips/include/asm/mach-loongson/boot_param.h +3 -0
@@ -146,6 +146,9 @@ struct boot_params {struct loongson_system_configuration {u32 nr_cpus; +u32 nr_nodes; +int cores_per_node; +int cores_per_package;enum loongson_cpu_type cputype;u64 ht_control_base;u64 pci_mem_start_addr;
arch/mips/include/asm/mach-loongson/kernel-entry-init.h new file +51 -0
51 lines not on this page · raw message
arch/mips/include/asm/mach-loongson/mmzone.h new file +51 -0
51 lines not on this page · raw message
arch/mips/include/asm/mach-loongson/topology.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef _ASM_MACH_TOPOLOGY_H +#define _ASM_MACH_TOPOLOGY_H + +#ifdef CONFIG_NUMA + +#define cpu_to_node (cpu) ((cpu) >> 2) +#define parent_node (node) (node) +#define cpumask_of_node (node) (&__node_data[(node)]->cpumask) + +struct pci_bus ; +extern int pcibus_to_node (struct pci_bus *); + +#define cpumask_of_pcibus (bus) (cpu_online_mask) + +extern unsigned char __node_distances[MAX_NUMNODES ][MAX_NUMNODES ]; + +#define node_distance (from, to) (__node_distances[(from)][(to)]) + +#endif + +#include <asm-generic/topology.h> + +#endif /* _ASM_MACH_TOPOLOGY_H */
arch/mips/include/asm/sparsemem.h +5 -0
@@ -11,7 +11,12 @@#else # define SECTION_SIZE_BITS 28#endif + +#ifdef CONFIG_NUMA +#define MAX_PHYSMEM_BITS 48 +#else #define MAX_PHYSMEM_BITS 35 +#endif #endif /* CONFIG_SPARSEMEM */ #endif /* _MIPS_SPARSEMEM_H */
arch/mips/kernel/setup.c +1 -1
@@ -282,7 +282,7 @@ static unsigned long __init init_initrd(void)* Initialize the bootmem allocator. It also setup initrd related data * if needed. */ -#ifdef CONFIG_SGI_IP27 +#if defined(CONFIG_SGI_IP27 ) || (defined(CONFIG_CPU_LOONGSON3 ) && defined(CONFIG_NUMA ))static void __init bootmem_init (void ) {
arch/mips/loongson/Kconfig +1 -0
@@ -80,6 +80,7 @@ config LEMOTE_MACH3A select SYS_HAS_EARLY_PRINTK select SYS_SUPPORTS_SMP select SYS_SUPPORTS_HOTPLUG_CPU + select SYS_SUPPORTS_NUMA select SYS_SUPPORTS_64BIT_KERNEL select SYS_SUPPORTS_HIGHMEM select SYS_SUPPORTS_LITTLE_ENDIAN
arch/mips/loongson/common/env.c +7 -0
@@ -80,17 +80,24 @@ void __init prom_init_env(void) cpu_clock_freq = ecpu->cpu_clock_freq; loongson_sysconf.cputype = ecpu->cputype;if (ecpu->cputype == Loongson_3A) { + loongson_sysconf.cores_per_node =4 ; + loongson_sysconf.cores_per_package =4 ; loongson_chipcfg[0 ] =0x900000001fe00180 ; loongson_chipcfg[1 ] =0x900010001fe00180 ; loongson_chipcfg[2 ] =0x900020001fe00180 ; loongson_chipcfg[3 ] =0x900030001fe00180 ; }else { + loongson_sysconf.cores_per_node =1 ; + loongson_sysconf.cores_per_package =1 ; loongson_chipcfg[0 ] =0x900000001fe00180 ; } loongson_sysconf.nr_cpus = ecpu->nr_cpus;if (ecpu->nr_cpus >NR_CPUS || ecpu->nr_cpus ==0 ) loongson_sysconf.nr_cpus =NR_CPUS ; + loongson_sysconf.nr_nodes = (loongson_sysconf.nr_cpus + + loongson_sysconf.cores_per_node -1 ) / + loongson_sysconf.cores_per_node; loongson_sysconf.pci_mem_start_addr = eirq_source->pci_mem_start_addr; loongson_sysconf.pci_mem_end_addr = eirq_source->pci_mem_end_addr;
arch/mips/loongson/common/init.c +4 -0
@@ -30,7 +30,11 @@ void __init prom_init(void)set_io_port_base ((unsigned long )ioremap (LOONGSON_PCIIO_BASE ,LOONGSON_PCIIO_SIZE )); +#ifdef CONFIG_NUMA +prom_init_numa_memory (); +#else prom_init_memory (); +#endif /*init the uart base address */ prom_init_uart_base ();
arch/mips/loongson/loongson-3/Makefile +2 -0
@@ -4,3 +4,5 @@ obj-y += irq.o obj-$(CONFIG_SMP) += smp.o + +obj-$(CONFIG_NUMA) += numa.o
arch/mips/loongson/loongson-3/numa.c new file +290 -0
290 lines not on this page · raw message
arch/mips/loongson/loongson-3/smp.c +6 -2
@@ -203,6 +203,8 @@ static void loongson3_init_secondary(void)for (i =0 ; i < loongson_sysconf.nr_cpus; i++)loongson3_ipi_write32 (0xffffffff , ipi_en0_regs[i]); + cpu_data[cpu].package = cpu / loongson_sysconf.cores_per_package; + cpu_data[cpu].core = cpu % loongson_sysconf.cores_per_package;per_cpu (cpu_state, cpu) =CPU_ONLINE ; i =0 ;
@@ -401,17 +403,19 @@ static int loongson3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) {unsigned int cpu = (unsigned long )hcpu; +uint64_t core_id = cpu_data[cpu].core; +uint64_t package_id = cpu_data[cpu].package;switch (action) {case CPU_POST_DEAD :case CPU_POST_DEAD_FROZEN :pr_info ("Disable clock for CPU#%d\n" , cpu); -LOONGSON_CHIPCFG (0 ) &= ~(1 << (12 + cpu)); +LOONGSON_CHIPCFG (package_id) &= ~(1 << (12 + core_id));break ;case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN :pr_info ("Enable clock for CPU#%d\n" , cpu); -LOONGSON_CHIPCFG (0 ) |=1 << (12 + cpu); +LOONGSON_CHIPCFG (package_id) |=1 << (12 + core_id);break ; }
Signature · 1 line
1.7.7.3
PATCH 5/9 MIPS: Add numa api support
In reply to Huacai ChenEnable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32, and N64 ABIs.
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)
arch/mips/kernel/scall32-o32.S +2 -2
@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlink PTR sys_mq_timedsend
arch/mips/kernel/scall64-64.S +2 -2
@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsend
arch/mips/kernel/scall64-n32.S +3 -3
@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsend
arch/mips/kernel/scall64-o32.S +3 -3
@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR compat_sys_mq_open PTR sys_mq_unlink PTR compat_sys_mq_timedsend
Signature · 1 line
1.7.7.3
David Daney
NAKRe: [PATCH 5/9] MIPS: Add numa api support
Quoted 4 lines · Huacai Chen
Enable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32, and N64 ABIs.
Signed-off-by Huacai Chen <[email protected]>
NACK.
You need compat versions of the syscalls...
Also current migrate_pages and move_pages syscalls need to use the compat wrappers for 32-bit ABIs.
David Daney
Quoted 42 lines
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)arch/mips/kernel/scall32-o32.S +2
-2@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-64.S +2
-2@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-n32.S +0
-0
arch/mips/kernel/scall64-n32.S EXPORT(sysn32_call_table) · line 344
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +3
-3@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy
Here
Quoted 8 lines
arch/mips/kernel/scall64-n32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsendarch/mips/kernel/scall64-o32.S +0
-0
arch/mips/kernel/scall64-o32.S EXPORT(sys32_call_table) · line 478
Quoted 9 lines
arch/mips/kernel/scall64-o32.S +3
-3@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */
And Here.
Quoted 4 lines
arch/mips/kernel/scall64-o32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink PTR compat_sys_mq_timedsend
Re: [PATCH 5/9] MIPS: Add numa api support
Excuse me, what's the compat version exactly means? Or how to produce a problem without a compat version? It seems everything works fine just with this patch.
Huacai
Quoted 102 lines · Huacai Chen
Quoted 4 lines
Enable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32, and N64 ABIs.
Signed-off-by Huacai Chen <[email protected]>NACK.
You need compat versions of the syscalls...
Also current
migrate_pagesandmove_pagessyscalls need to use the compat wrappers for 32-bit ABIs.David Daney
Quoted 45 lines
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)arch/mips/kernel/scall32-o32.S +2
-2@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-64.S +2
-2@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-n32.S +0
-0arch/mips/kernel/scall64-n32.S EXPORT(sysn32_call_table) · line 344
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +3
-3@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicyHere
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsendarch/mips/kernel/scall64-o32.S +0
-0arch/mips/kernel/scall64-o32.S EXPORT(sys32_call_table) · line 478
Quoted 9 lines
arch/mips/kernel/scall64-o32.S +3
-3@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */And Here.
Quoted 4 lines
arch/mips/kernel/scall64-o32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink PTR compat_sys_mq_timedsend
Re: [PATCH 5/9] MIPS: Add numa api support
Hi, David,
After some code reading, I have some understanding about compat syscall, please tell me whether I'm correct.
1, compat syscall is only needed by n32/o32 userspace on 64-bit kernel. 2, compat syscall is only needed when there are arguments in pointer type. 3, compat syscall is only needed when pointer arguments are array/struct/union for reading (reading means get_user or copy_from_user), or pointer arguments are array/struct/union/long integer for writing (writing means put_user or copy_to_user).
If my understanding is correct, then in this patch, get_mempolicy() need to use the compat version for n32/o32 on 64-bit kernel, mbind() and set_mempolicy() can use the normal version in all cases. But when I reading the X86 code, it seems like only o32 on 64-bit kernel need a compat version (I assume i386/X32/X64 on X86 is the same as o32/n32/n64 on MIPS).
Please give some information, thanks.
Huacai
Quoted 111 lines · 陈华才
Excuse me, what's the compat version exactly means? Or how to produce a problem without a compat version? It seems everything works fine just with this patch.
Huacai
Quoted 102 lines · Huacai Chen
Quoted 4 lines
Enable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32, and N64 ABIs.
Signed-off-by Huacai Chen <[email protected]>NACK.
You need compat versions of the syscalls...
Also current
migrate_pagesandmove_pagessyscalls need to use the compat wrappers for 32-bit ABIs.David Daney
Quoted 45 lines
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)arch/mips/kernel/scall32-o32.S +2
-2@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-64.S +2
-2@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-n32.S +0
-0arch/mips/kernel/scall64-n32.S EXPORT(sysn32_call_table) · line 344
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +3
-3@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicyHere
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsendarch/mips/kernel/scall64-o32.S +0
-0arch/mips/kernel/scall64-o32.S EXPORT(sys32_call_table) · line 478
Quoted 9 lines
arch/mips/kernel/scall64-o32.S +3
-3@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */And Here.
Quoted 4 lines
arch/mips/kernel/scall64-o32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink PTR compat_sys_mq_timedsend
Re: [PATCH 5/9] MIPS: Add numa api support
Hi, MIPS hackers,
Could anyone help me?
Huacai
Quoted 134 lines · Huacai Chen
Hi, David,
After some code reading, I have some understanding about compat syscall, please tell me whether I'm correct.
1, compat syscall is only needed by n32/o32 userspace on 64-bit kernel. 2, compat syscall is only needed when there are arguments in pointer type. 3, compat syscall is only needed when pointer arguments are array/struct/union for reading (reading meansget_userorcopy_from_user), or pointer arguments are array/struct/union/long integer for writing (writing meansput_userorcopy_to_user).If my understanding is correct, then in this patch,
get_mempolicy()need to use the compat version for n32/o32 on 64-bit kernel,mbind()andset_mempolicy()can use the normal version in all cases. But when I reading the X86 code, it seems like only o32 on 64-bit kernel need a compat version (I assume i386/X32/X64 on X86 is the same as o32/n32/n64 on MIPS).Please give some information, thanks.
Huacai
Quoted 111 lines · 陈华才
Excuse me, what's the compat version exactly means? Or how to produce a problem without a compat version? It seems everything works fine just with this patch.
Huacai
Quoted 102 lines · Huacai Chen
Quoted 4 lines
Enable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32, and N64 ABIs.
Signed-off-by Huacai Chen <[email protected]>NACK.
You need compat versions of the syscalls...
Also current
migrate_pagesandmove_pagessyscalls need to use the compat wrappers for 32-bit ABIs.David Daney
Quoted 45 lines
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)arch/mips/kernel/scall32-o32.S +2
-2@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-64.S +2
-2@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-n32.S +0
-0arch/mips/kernel/scall64-n32.S EXPORT(sysn32_call_table) · line 344
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +3
-3@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicyHere
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsendarch/mips/kernel/scall64-o32.S +0
-0arch/mips/kernel/scall64-o32.S EXPORT(sys32_call_table) · line 478
Quoted 9 lines
arch/mips/kernel/scall64-o32.S +3
-3@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */And Here.
Quoted 4 lines
arch/mips/kernel/scall64-o32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink PTR compat_sys_mq_timedsend
Re: [PATCH 5/9] MIPS: Add numa api support
Hi Huacai,
The compat wrappers are needed for all of them for O32/N32 on a 64-bit kernel. {get,set}mempolicy, mbind and migrate_pages all copy bitmaps to/from user memory. The non-compat versions would behave fine on little endian, but the compat versions are needed to convert the 32-bit bitmaps to 64-bit on big endian.
move_pages takes an array of pointers, the compat version is needed to convert that to 64-bit.
Alex
Quoted 142 lines · Huacai Chen
Hi, MIPS hackers,
Could anyone help me?
Huacai
Quoted 134 lines · Huacai Chen
Hi, David,
After some code reading, I have some understanding about compat syscall, please tell me whether I'm correct.
1, compat syscall is only needed by n32/o32 userspace on 64-bit kernel. 2, compat syscall is only needed when there are arguments in pointer type. 3, compat syscall is only needed when pointer arguments are array/struct/union for reading (reading meansget_userorcopy_from_user), or pointer arguments are array/struct/union/long integer for writing (writing meansput_userorcopy_to_user).If my understanding is correct, then in this patch,
get_mempolicy()need to use the compat version for n32/o32 on 64-bit kernel,mbind()andset_mempolicy()can use the normal version in all cases. But when I reading the X86 code, it seems like only o32 on 64-bit kernel need a compat version (I assume i386/X32/X64 on X86 is the same as o32/n32/n64 on MIPS).Please give some information, thanks.
Huacai
Quoted 111 lines · 陈华才
Excuse me, what's the compat version exactly means? Or how to produce a problem without a compat version? It seems everything works fine just with this patch.
Huacai
Quoted 102 lines · Huacai Chen
Quoted 4 lines
Enable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32, and N64 ABIs.
Signed-off-by Huacai Chen <[email protected]>NACK.
You need compat versions of the syscalls...
Also current
migrate_pagesandmove_pagessyscalls need to use the compat wrappers for 32-bit ABIs.David Daney
Quoted 45 lines
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)arch/mips/kernel/scall32-o32.S +2
-2@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-64.S +2
-2@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-n32.S +0
-0arch/mips/kernel/scall64-n32.S EXPORT(sysn32_call_table) · line 344
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +3
-3@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicyHere
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsendarch/mips/kernel/scall64-o32.S +0
-0arch/mips/kernel/scall64-o32.S EXPORT(sys32_call_table) · line 478
Quoted 9 lines
arch/mips/kernel/scall64-o32.S +3
-3@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */And Here.
Quoted 4 lines
arch/mips/kernel/scall64-o32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink PTR compat_sys_mq_timedsend
Re: [PATCH 5/9] MIPS: Add numa api support
Hi, Alex,
I found that only o32 use the compat version of move_pages(), n32 use the normal one. And both o32/n32 doesn't use the compat version of migrate_pages(). That means they are all need to be fixed in this patch?
Huacai
Quoted 169 lines · Alex Smith
Hi Huacai,
The compat wrappers are needed for all of them for O32/N32 on a 64-bit kernel. {get,set}mempolicy, mbind and
migrate_pagesall copy bitmaps to/from user memory. The non-compat versions would behave fine on little endian, but the compat versions are needed to convert the 32-bit bitmaps to 64-bit on big endian.
move_pagestakes an array of pointers, the compat version is needed to convert that to 64-bit.Alex
Quoted 153 lines · Huacai Chen
Hi, MIPS hackers,
Could anyone help me?
Huacai
Quoted 144 lines · Huacai Chen
Hi, David,
After some code reading, I have some understanding about compat syscall, please tell me whether I'm correct.
1, compat syscall is only needed by n32/o32 userspace on 64-bit kernel. 2, compat syscall is only needed when there are arguments in pointer type.
3, compat syscall is only needed when pointer arguments are array/struct/union for reading (reading meansget_userorcopy_from_user), or pointer arguments are array/struct/union/long integer for writing (writing meansput_userorcopy_to_user).If my understanding is correct, then in this patch,
get_mempolicy()need to use the compat version for n32/o32 on 64-bit kernel,mbind()andset_mempolicy()can use the normal version in all cases. But when I reading the X86 code, it seems like only o32 on 64-bit kernel need a compat version (I assume i386/X32/X64 on X86 is the same as o32/n32/n64 on MIPS).Please give some information, thanks.
Huacai
Quoted 119 lines · 陈华才
Excuse me, what's the compat version exactly means? Or how to produce a problem without a compat version? It seems everything works fine just with this patch.
Huacai
Quoted 109 lines · Huacai Chen
Quoted 6 lines
Enable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32,
and N64 ABIs.Signed-off-by Huacai Chen <[email protected]>NACK.
You need compat versions of the syscalls...
Also current
migrate_pagesandmove_pagessyscalls need to use the compat wrappers for 32-bit ABIs.David Daney
Quoted 46 lines
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)arch/mips/kernel/scall32-o32.S +2
-2@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlinkPTR
sys_mq_timedsendarch/mips/kernel/scall64-64.S +2
-2@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-n32.S +0
-0arch/mips/kernel/scall64-n32.S EXPORT(sysn32_call_table) · line 344
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +3
-3@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicyHere
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsendarch/mips/kernel/scall64-o32.S +0
-0arch/mips/kernel/scall64-o32.S EXPORT(sys32_call_table) · line 479
Quoted 10 lines
arch/mips/kernel/scall64-o32.S +3
-3@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */And Here.
Quoted 4 lines
arch/mips/kernel/scall64-o32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlinkPTR
compat_sys_mq_timedsend
Re: [PATCH 5/9] MIPS: Add numa api support
Quoted 6 lines · Huacai Chen
Hi, Alex,
I found that only o32 use the compat version of
move_pages(), n32 use the normal one. And both o32/n32 doesn't use the compat version ofmigrate_pages(). That means they are all need to be fixed in this patch?
Yes, both o32/n32 on 64-bit should be using the compat versions.
Alex
Quoted 173 lines
Huacai
Quoted 169 lines · Alex Smith
Hi Huacai,
The compat wrappers are needed for all of them for O32/N32 on a 64-bit kernel. {get,set}mempolicy, mbind and
migrate_pagesall copy bitmaps to/from user memory. The non-compat versions would behave fine on little endian, but the compat versions are needed to convert the 32-bit bitmaps to 64-bit on big endian.
move_pagestakes an array of pointers, the compat version is needed to convert that to 64-bit.Alex
Quoted 153 lines · Huacai Chen
Hi, MIPS hackers,
Could anyone help me?
Huacai
Quoted 144 lines · Huacai Chen
Hi, David,
After some code reading, I have some understanding about compat syscall, please tell me whether I'm correct.
1, compat syscall is only needed by n32/o32 userspace on 64-bit kernel. 2, compat syscall is only needed when there are arguments in pointer type.
3, compat syscall is only needed when pointer arguments are array/struct/union for reading (reading meansget_userorcopy_from_user), or pointer arguments are array/struct/union/long integer for writing (writing meansput_userorcopy_to_user).If my understanding is correct, then in this patch,
get_mempolicy()need to use the compat version for n32/o32 on 64-bit kernel,mbind()andset_mempolicy()can use the normal version in all cases. But when I reading the X86 code, it seems like only o32 on 64-bit kernel need a compat version (I assume i386/X32/X64 on X86 is the same as o32/n32/n64 on MIPS).Please give some information, thanks.
Huacai
Quoted 119 lines · 陈华才
Excuse me, what's the compat version exactly means? Or how to produce a problem without a compat version? It seems everything works fine just with this patch.
Huacai
Quoted 109 lines · Huacai Chen
Quoted 6 lines
Enable sys_mbind()/sys_get_mempolicy()/sys_set_mempolicy() for O32, N32,
and N64 ABIs.Signed-off-by Huacai Chen <[email protected]>NACK.
You need compat versions of the syscalls...
Also current
migrate_pagesandmove_pagessyscalls need to use the compat wrappers for 32-bit ABIs.David Daney
Quoted 46 lines
--- arch/mips/kernel/scall32-o32.S | 4 ++-- arch/mips/kernel/scall64-64.S | 4 ++-- arch/mips/kernel/scall64-n32.S | 6 +++--- arch/mips/kernel/scall64-o32.S | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)arch/mips/kernel/scall32-o32.S +2
-2@@ -495,8 +495,8 @@ EXPORT(sys_call_table) PTR sys_tgkill PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */ PTR sys_mq_open PTR sys_mq_unlinkPTR
sys_mq_timedsendarch/mips/kernel/scall64-64.S +2
-2@@ -347,8 +347,8 @@ EXPORT(sys_call_table) PTR sys_tgkill /* 5225 */ PTR sys_utimes PTR sys_mbind - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_get_mempolicy + PTR sys_set_mempolicy PTR sys_mq_open /* 5230 */ PTR sys_mq_unlink PTR sys_mq_timedsendarch/mips/kernel/scall64-n32.S +0
-0arch/mips/kernel/scall64-n32.S EXPORT(sysn32_call_table) · line 344
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +3
-3@@ -339,9 +339,9 @@ EXPORT(sysn32_call_table) PTR compat_sys_clock_nanosleep PTR sys_tgkill PTR compat_sys_utimes /* 6230 */ - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicyHere
Quoted 9 lines
arch/mips/kernel/scall64-n32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlink /* 6235 */ PTR compat_sys_mq_timedsendarch/mips/kernel/scall64-o32.S +0
-0arch/mips/kernel/scall64-o32.S EXPORT(sys32_call_table) · line 479
Quoted 10 lines
arch/mips/kernel/scall64-o32.S +3
-3@@ -473,9 +473,9 @@ EXPORT(sys32_call_table) PTR compat_sys_clock_nanosleep /* 4265 */ PTR sys_tgkill PTR compat_sys_utimes - PTR sys_ni_syscall /* sys_mbind */ - PTR sys_ni_syscall /* sys_get_mempolicy */ - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ + PTR sys_mbind + PTR sys_get_mempolicy + PTR sys_set_mempolicy /* 4270 */And Here.
Quoted 4 lines
arch/mips/kernel/scall64-o32.S +0
-0PTR compat_sys_mq_open PTR sys_mq_unlinkPTR
compat_sys_mq_timedsend
PATCH 6/9 MIPS: Add Loongson-3B support
In reply to Huacai ChenLoongson-3B is a 8-cores processor. In general it looks like there are two Loongson-3A integrated in one chip: 8 cores are separated into two groups (two NUMA node), each node has its own local memory.
Of course there are some differences between one Loongson-3B and two Loongson-3A. E.g., the base addresses of IPI registers of each node are not the same; Loongson-3A use ChipConfig register to enable/disable clock, but Loongson-3B use FreqControl register instead.
There are two revision of Loongson-3B, the first revision is called as Loongson-3B1000, whose frequency is 1GHz and has a PRid 0x6306, the second revision is called as Loongson-3B1500, whose frequency is 1.5GHz and has a PRid 0x6307. Both revisions has a bug that clock cannot be disabled at runtime, but this will be fixed in future.
--- arch/mips/include/asm/cpu.h | 2 + arch/mips/include/asm/mach-loongson/boot_param.h | 1 + arch/mips/include/asm/mach-loongson/loongson.h | 4 + arch/mips/kernel/cpu-probe.c | 6 + arch/mips/loongson/common/env.c | 31 ++- arch/mips/loongson/loongson-3/irq.c | 26 ++- arch/mips/loongson/loongson-3/smp.c | 387 ++++++++++++++++------ arch/mips/loongson/loongson-3/smp.h | 37 +- 8 files changed, 372 insertions(+), 122 deletions(-)
arch/mips/include/asm/cpu.h +2 -0
@@ -232,6 +232,8 @@#define PRID_REV_LOONGSON2E 0x0002#define PRID_REV_LOONGSON2F 0x0003#define PRID_REV_LOONGSON3A 0x0005 +#define PRID_REV_LOONGSON3B_R1 0x0006 +#define PRID_REV_LOONGSON3B_R2 0x0007/* * Older processors used to encode processor version and revision in two
arch/mips/include/asm/mach-loongson/boot_param.h +1 -0
@@ -163,4 +163,5 @@ struct loongson_system_configuration {extern struct efi_memory_map_loongson *loongson_memmap;extern struct loongson_system_configuration loongson_sysconf; +extern int cpuhotplug_workaround;#endif
arch/mips/include/asm/mach-loongson/loongson.h +4 -0
@@ -255,6 +255,10 @@ static inline void do_perfcnt_IRQ(void)extern u64 loongson_chipcfg[MAX_PACKAGES ];#define LOONGSON_CHIPCFG (id) (*(volatile u32 *)(loongson_chipcfg[id])) +/* Freq Control register of each physical cpu package, PRid >= Loongson-3B */ +extern u64 loongson_freqctrl[MAX_PACKAGES ]; +#define LOONGSON_FREQCTRL (id) (*(volatile u32 *)(loongson_freqctrl[id])) +/* pcimap */ #define LOONGSON_PCIMAP_PCIMAP_LO0 0x0000003f
arch/mips/kernel/cpu-probe.c +6 -0
@@ -755,6 +755,12 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) __cpu_name[cpu] ="ICT Loongson-3" ;set_elf_platform (cpu,"loongson3a" );break ; +case PRID_REV_LOONGSON3B_R1 : +case PRID_REV_LOONGSON3B_R2 : + c->cputype =CPU_LOONGSON3 ; + __cpu_name[cpu] ="ICT Loongson-3" ; +set_elf_platform (cpu,"loongson3b" ); +break ; }set_isa (c,MIPS_CPU_ISA_III );
arch/mips/loongson/common/env.c +30 -1
@@ -28,6 +28,10 @@ struct efi_memory_map_loongson *loongson_memmap;struct loongson_system_configuration loongson_sysconf;u64 loongson_chipcfg[MAX_PACKAGES ] = {0xffffffffbfc00180 }; +u64 loongson_freqctrl[MAX_PACKAGES ]; + +unsigned long long smp_group[4 ]; +int cpuhotplug_workaround =0 ;#define parse_even_earlier (res, option, p) \ do { \
@@ -82,10 +86,32 @@ void __init prom_init_env(void)if (ecpu->cputype == Loongson_3A) { loongson_sysconf.cores_per_node =4 ; loongson_sysconf.cores_per_package =4 ; + smp_group[0 ] =0x900000003ff01000 ; + smp_group[1 ] =0x900010003ff01000 ; + smp_group[2 ] =0x900020003ff01000 ; + smp_group[3 ] =0x900030003ff01000 ; loongson_chipcfg[0 ] =0x900000001fe00180 ; loongson_chipcfg[1 ] =0x900010001fe00180 ; loongson_chipcfg[2 ] =0x900020001fe00180 ; loongson_chipcfg[3 ] =0x900030001fe00180 ; + loongson_sysconf.ht_control_base =0x90000EFDFB000000 ; + }else if (ecpu->cputype == Loongson_3B) { + loongson_sysconf.cores_per_node =4 ;/* One chip has 2 nodes */ + loongson_sysconf.cores_per_package =8 ; + smp_group[0 ] =0x900000003ff01000 ; + smp_group[1 ] =0x900010003ff05000 ; + smp_group[2 ] =0x900020003ff09000 ; + smp_group[3 ] =0x900030003ff0d000 ; + loongson_chipcfg[0 ] =0x900000001fe00180 ; + loongson_chipcfg[1 ] =0x900020001fe00180 ; + loongson_chipcfg[2 ] =0x900040001fe00180 ; + loongson_chipcfg[3 ] =0x900060001fe00180 ; + loongson_freqctrl[0 ] =0x900000001fe001d0 ; + loongson_freqctrl[1 ] =0x900020001fe001d0 ; + loongson_freqctrl[2 ] =0x900040001fe001d0 ; + loongson_freqctrl[3 ] =0x900060001fe001d0 ; + loongson_sysconf.ht_control_base =0x90001EFDFB000000 ; + cpuhotplug_workaround =1 ; }else { loongson_sysconf.cores_per_node =1 ; loongson_sysconf.cores_per_package =1 ;
@@ -111,7 +137,6 @@ void __init prom_init_env(void) loongson_sysconf.poweroff_addr = boot_p->reset_system.Shutdown; loongson_sysconf.suspend_addr = boot_p->reset_system.DoSuspend; - loongson_sysconf.ht_control_base =0x90000EFDFB000000 ; loongson_sysconf.vgabios_addr = boot_p->efi.smbios.vga_bios; pr_debug("Shutdown Addr: %llx, Restart Addr: %llx, VBIOS Addr: %llx\n", loongson_sysconf.poweroff_addr, loongson_sysconf.restart_addr,
@@ -129,6 +154,10 @@ void __init prom_init_env(void)case PRID_REV_LOONGSON3A : cpu_clock_freq =900000000 ;break ; +case PRID_REV_LOONGSON3B_R1 : +case PRID_REV_LOONGSON3B_R2 : + cpu_clock_freq =1000000000 ; +break ;default : cpu_clock_freq =100000000 ;break ;
arch/mips/loongson/loongson-3/irq.c +20 -6
@@ -7,6 +7,8 @@#include <asm/i8259.h> #include <asm/mipsregs.h> +#include "smp.h" +unsigned int ht_irq[] = {1 ,3 ,4 ,5 ,6 ,7 ,8 ,12 ,14 ,15 };static void ht_irqdispatch (void )
@@ -53,9 +55,15 @@ static inline void mask_loongson_irq(struct irq_data *d)/* Workaround: UART IRQ may deliver to any core */ if (d->irq ==LOONGSON_UART_IRQ ) {int cpu =smp_processor_id (); - -LOONGSON_INT_ROUTER_INTENCLR =1 <<10 ; -LOONGSON_INT_ROUTER_LPC =0x10 + (1 <<cpu); +int node_id = cpu / loongson_sysconf.cores_per_node; +int core_id = cpu % loongson_sysconf.cores_per_node; +u64 intenclr_addr = smp_group[node_id] | + (u64)(&LOONGSON_INT_ROUTER_INTENCLR ); +u64 introuter_lpc_addr = smp_group[node_id] | + (u64)(&LOONGSON_INT_ROUTER_LPC ); + + *(volatile u32 *)intenclr_addr =1 <<10 ; + *(volatile u8 *)introuter_lpc_addr =0x10 + (1 <<core_id); } }
@@ -64,9 +72,15 @@ static inline void unmask_loongson_irq(struct irq_data *d)/* Workaround: UART IRQ may deliver to any core */ if (d->irq ==LOONGSON_UART_IRQ ) {int cpu =smp_processor_id (); - -LOONGSON_INT_ROUTER_INTENSET =1 <<10 ; -LOONGSON_INT_ROUTER_LPC =0x10 + (1 <<cpu); +int node_id = cpu / loongson_sysconf.cores_per_node; +int core_id = cpu % loongson_sysconf.cores_per_node; +u64 intenset_addr = smp_group[node_id] | + (u64)(&LOONGSON_INT_ROUTER_INTENSET ); +u64 introuter_lpc_addr = smp_group[node_id] | + (u64)(&LOONGSON_INT_ROUTER_LPC ); + + *(volatile u32 *)intenset_addr =1 <<10 ; + *(volatile u8 *)introuter_lpc_addr =0x10 + (1 <<core_id); }set_c0_status (0x100 << (d->irq -MIPS_CPU_IRQ_BASE ));
arch/mips/loongson/loongson-3/smp.c +290 -97
446 lines not on this page · raw message
arch/mips/loongson/loongson-3/smp.h +19 -18
@@ -1,29 +1,30 @@#ifndef __LOONGSON_SMP_H_#define __LOONGSON_SMP_H_ -/* for Loongson-3A smp support */ +/* for Loongson-3 smp support */ +extern unsigned long long smp_group[4 ];/* 4 groups(nodes) in maximum in numa case */ -#define SMP_CORE_GROUP0_BASE 0x900000003ff01000 -#define SMP_CORE_GROUP1_BASE 0x900010003ff01000 -#define SMP_CORE_GROUP2_BASE 0x900020003ff01000 -#define SMP_CORE_GROUP3_BASE 0x900030003ff01000 +#define SMP_CORE_GROUP0_BASE (smp_group[0]) +#define SMP_CORE_GROUP1_BASE (smp_group[1]) +#define SMP_CORE_GROUP2_BASE (smp_group[2]) +#define SMP_CORE_GROUP3_BASE (smp_group[3])/* 4 cores in each group(node) */ -#define SMP_CORE0_OFFSET 0x000 -#define SMP_CORE1_OFFSET 0x100 -#define SMP_CORE2_OFFSET 0x200 -#define SMP_CORE3_OFFSET 0x300 +#define SMP_CORE0_OFFSET 0x000 +#define SMP_CORE1_OFFSET 0x100 +#define SMP_CORE2_OFFSET 0x200 +#define SMP_CORE3_OFFSET 0x300/* ipi registers offsets */ -#define STATUS0 0x00 -#define EN0 0x04 -#define SET0 0x08 -#define CLEAR0 0x0c -#define STATUS1 0x10 -#define MASK1 0x14 -#define SET1 0x18 -#define CLEAR1 0x1c -#define BUF 0x20 +#define STATUS0 0x00 +#define EN0 0x04 +#define SET0 0x08 +#define CLEAR0 0x0c +#define STATUS1 0x10 +#define MASK1 0x14 +#define SET1 0x18 +#define CLEAR1 0x1c +#define BUF 0x20#endif
Signature · 1 line
1.7.7.3
PATCH 7/9 MIPS: Loongson: Make CPU name more clear
In reply to Huacai ChenMake names in /proc/cpuinfo more human-readable, Since GCC support the new-style names for a long time, this may not break -march=native any more.
--- arch/mips/kernel/cpu-probe.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
arch/mips/kernel/cpu-probe.c +4 -4
@@ -742,23 +742,23 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)switch (c->processor_id &PRID_REV_MASK ) {case PRID_REV_LOONGSON2E : c->cputype =CPU_LOONGSON2 ; - __cpu_name[cpu] ="ICT Loongson-2" ; + __cpu_name[cpu] ="ICT Loongson-2E" ;set_elf_platform (cpu,"loongson2e" );break ;case PRID_REV_LOONGSON2F : c->cputype =CPU_LOONGSON2 ; - __cpu_name[cpu] ="ICT Loongson-2" ; + __cpu_name[cpu] ="ICT Loongson-2F" ;set_elf_platform (cpu,"loongson2f" );break ;case PRID_REV_LOONGSON3A : c->cputype =CPU_LOONGSON3 ; - __cpu_name[cpu] ="ICT Loongson-3" ; + __cpu_name[cpu] ="ICT Loongson-3A" ;set_elf_platform (cpu,"loongson3a" );break ;case PRID_REV_LOONGSON3B_R1 :case PRID_REV_LOONGSON3B_R2 : c->cputype =CPU_LOONGSON3 ; - __cpu_name[cpu] ="ICT Loongson-3" ; + __cpu_name[cpu] ="ICT Loongson-3B" ;set_elf_platform (cpu,"loongson3b" );break ; }
Signature · 1 line
1.7.7.3
Re: [PATCH 7/9] MIPS: Loongson: Make CPU name more clear
Quoted 3 lines · Huacai Chen
Make names in
/proc/cpuinfomore human-readable, Since GCC support the new-style names for a long time, this may not break -march=native any more.
NACK. There isn't a GCC release available yet that supports new Loongson 2 names. You need to wait until such release is made and everyone starts using it. That will take maybe 5-10 years.
A.
Quoted 41 lines
Signed-off-by Huacai Chen <[email protected]>--- arch/mips/kernel/cpu-probe.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)arch/mips/kernel/cpu-probe.c +4
-4@@ -742,23 +742,23 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)switch (c->processor_id &PRID_REV_MASK ) {case PRID_REV_LOONGSON2E : c->cputype =CPU_LOONGSON2 ; - __cpu_name[cpu] ="ICT Loongson-2" ; + __cpu_name[cpu] ="ICT Loongson-2E" ;set_elf_platform (cpu,"loongson2e" );break ;case PRID_REV_LOONGSON2F : c->cputype =CPU_LOONGSON2 ; - __cpu_name[cpu] ="ICT Loongson-2" ; + __cpu_name[cpu] ="ICT Loongson-2F" ;set_elf_platform (cpu,"loongson2f" );break ;case PRID_REV_LOONGSON3A : c->cputype =CPU_LOONGSON3 ; - __cpu_name[cpu] ="ICT Loongson-3" ; + __cpu_name[cpu] ="ICT Loongson-3A" ;set_elf_platform (cpu,"loongson3a" );break ;case PRID_REV_LOONGSON3B_R1 :case PRID_REV_LOONGSON3B_R2 : c->cputype =CPU_LOONGSON3 ; - __cpu_name[cpu] ="ICT Loongson-3" ; + __cpu_name[cpu] ="ICT Loongson-3B" ;set_elf_platform (cpu,"loongson3b" );break ; }Signature · 1 line
1.7.7.3
Re: [PATCH 7/9] MIPS: Loongson: Make CPU name more clear
Quoted 8 lines · Aaro Koskinen
Quoted 3 lines · Huacai Chen
Make names in
/proc/cpuinfomore human-readable, Since GCC support the new-style names for a long time, this may not break -march=native any more.NACK. There isn't a GCC release available yet that supports new Loongson 2 names. You need to wait until such release is made and everyone starts using it. That will take maybe 5-10 years.
It seems like he could, however, modify the names such that they allowed new gcc to differentiate between them if old gcc could still recognize them.
PATCH 8/9 MIPS: Loongson-3: Enable the COP2 usage
In reply to Huacai ChenLoongson-3 has some specific instructions (MMI/SIMD) in coprocessor 2. COP2 isn't independent because it share COP1 (FPU)'s registers. This patch enable the COP2 usage so user-space programs can use the MMI/SIMD instructions. When COP2 exception happens, we enable both COP1 (FPU) and COP2, only in this way the fp context can be saved and restored correctly.
--- arch/mips/include/asm/cop2.h | 8 ++++ arch/mips/loongson/loongson-3/Makefile | 2 +- arch/mips/loongson/loongson-3/cop2-ex.c | 63 +++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletions(-) create mode 100644 arch/mips/loongson/loongson-3/cop2-ex.c
arch/mips/include/asm/cop2.h +8 -0
@@ -32,6 +32,14 @@ extern void nlm_cop2_restore(struct nlm_cop2_state *);#define cop2_present 1#define cop2_lazy_restore 0 +#elif defined(CONFIG_CPU_LOONGSON3 ) + +#define cop2_save (r) +#define cop2_restore (r) + +#define cop2_present 1 +#define cop2_lazy_restore 1 +#else #define cop2_present 0
arch/mips/loongson/loongson-3/Makefile +1 -1
@@ -1,7 +1,7 @@ # # Makefile for Loongson-3 family machines # -obj-y += irq.o +obj-y += irq.o cop2-ex.o obj-$(CONFIG_SMP) += smp.o
arch/mips/loongson/loongson-3/cop2-ex.c new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
1.7.7.3
Re: [PATCH 8/9] MIPS: Loongson-3: Enable the COP2 usage
Quoted 6 lines · Huacai Chen
Loongson-3 has some specific instructions (MMI/SIMD) in coprocessor 2. COP2 isn't independent because it share COP1 (FPU)'s registers. This patch enable the COP2 usage so user-space programs can use the MMI/SIMD instructions. When COP2 exception happens, we enable both COP1 (FPU) and COP2, only in this way the fp context can be saved and restored correctly.
Is there a Loongson 3 programmers manual somewhere, similar to Loongson2FUserGuide.pdf?
I optimized pixman for Loongson 2E/2F using their SIMD instructions. I've compiled pixman for Loongson 3A and I see some new instructions being used in the disassembly, but I have no Loongson 3 system to test on. At minimum, having a manual would be nice.
Thanks,
Matt
Re: [PATCH 8/9] MIPS: Loongson-3: Enable the COP2 usage
To Matt,
At first thank you very much for your pixman work. In my opinion, Loongson-3 has the same MMI/SIMD instructions as Loongson-2. The only difference is that Loongson-2's MMI/SIMD trigger COP1 exception, and Loongson-3's MMI/SIMD trigger COP2 exception, so we need this patch to make pixman work fine.
To Xiuzhi,
Do you have an English version of Loongson-3's user mannual? I think that will be very useful for Matt.
Huacai
Quoted 19 lines · Huacai Chen
Quoted 6 lines
Loongson-3 has some specific instructions (MMI/SIMD) in coprocessor 2. COP2 isn't independent because it share COP1 (FPU)'s registers. This patch enable the COP2 usage so user-space programs can use the MMI/SIMD instructions. When COP2 exception happens, we enable both COP1 (FPU) and COP2, only in this way the fp context can be saved and restored correctly.
Is there a Loongson 3 programmers manual somewhere, similar to Loongson2FUserGuide.pdf?
I optimized pixman for Loongson 2E/2F using their SIMD instructions. I've compiled pixman for Loongson 3A and I see some new instructions being used in the disassembly, but I have no Loongson 3 system to test on. At minimum, having a manual would be nice.
Thanks,
Matt
Re: Re: [PATCH 8/9] MIPS: Loongson-3: Enable the COP2 usage
Hi Matt,
The different instructions between 2F and 3A is:
madd instruction: 2F has two operands , 3A has three ones
The English version of Loongson3A usermanualis not available now, I will translating part of it and email you ASAP. Regards,
xiuzhi
Quoted 36 lines
To Matt,
At first thank you very much for your pixman work. In my opinion, Loongson-3 has the same MMI/SIMD instructions as Loongson-2. The only difference is that Loongson-2's MMI/SIMD trigger COP1 exception, and Loongson-3's MMI/SIMD trigger COP2 exception, so we need this patch to make pixman work fine.
To Xiuzhi,
Do you have an English version of Loongson-3's user mannual? I think that will be very useful for Matt.
Huacai
Quoted 19 lines · Huacai Chen
Quoted 6 lines
Loongson-3 has some specific instructions (MMI/SIMD) in coprocessor 2. COP2 isn't independent because it share COP1 (FPU)'s registers. This patch enable the COP2 usage so user-space programs can use the MMI/SIMD instructions. When COP2 exception happens, we enable both COP1 (FPU) and COP2, only in this way the fp context can be saved and restored correctly.
Is there a Loongson 3 programmers manual somewhere, similar to Loongson2FUserGuide.pdf?
I optimized pixman for Loongson 2E/2F using their SIMD instructions. I've compiled pixman for Loongson 3A and I see some new instructions being used in the disassembly, but I have no Loongson 3 system to test on. At minimum, having a manual would be nice.
Thanks,
Matt
PATCH 9/9 MIPS: Loongson: Rename CONFIG_LEMOTE_MACH3A to CONFIG_LOONGSON_MACH3X
In reply to Huacai ChenSince this CONFIG option will be used for both Loongson-3A/3B machines, and not all Loongson-3 machines are produced by Lemote, we rename CONFIG_LEMOTE_MACH3A to CONFIG_LOONGSON_MACH3X.
--- arch/mips/configs/loongson3_defconfig | 2 +- arch/mips/include/asm/mach-loongson/machine.h | 4 ++-- arch/mips/loongson/Kconfig | 8 ++++---- arch/mips/loongson/Platform | 2 +- arch/mips/pci/Makefile | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
arch/mips/configs/loongson3_defconfig +1 -1
@@ -1,6 +1,6 @@ CONFIG_MACH_LOONGSON=y CONFIG_SWIOTLB=y -CONFIG_LEMOTE_MACH3A=y +CONFIG_LOONGSON_MACH3X=y CONFIG_CPU_LOONGSON3=y CONFIG_64BIT=y CONFIG_PAGE_SIZE_16KB=y
arch/mips/include/asm/mach-loongson/machine.h +2 -2
@@ -24,10 +24,10 @@#endif -#ifdef CONFIG_LEMOTE_MACH3A +#ifdef CONFIG_LOONGSON_MACH3X #define LOONGSON_MACHTYPE MACH_LEMOTE_A1101 -#endif /* CONFIG_LEMOTE_MACH3A */ +#endif /* CONFIG_LOONGSON_MACH3X */ #endif /* __ASM_MACH_LOONGSON_MACHINE_H */
arch/mips/loongson/Kconfig +4 -4
@@ -60,8 +60,8 @@ config LEMOTE_MACH2F These family machines include fuloong2f mini PC, yeeloong2f notebook, LingLoong allinone PC and so forth. -config LEMOTE_MACH3A - bool "Lemote Loongson 3A family machines" +config LOONGSON_MACH3X + bool "Generic Loongson 3 family machines" select ARCH_SPARSEMEM_ENABLE select GENERIC_ISA_DMA_SUPPORT_BROKEN select GENERIC_HARDIRQS_NO__DO_IRQ
@@ -88,8 +88,8 @@ config LEMOTE_MACH3A select ZONE_DMA32 select LEFI_FIRMWARE_INTERFACE help - Lemote Loongson 3A family machines utilize the 3A revision of - Loongson processor and RS780/SBX00 chipset. + Generic Loongson 3 family machines utilize the 3A/3B revision + of Loongson processor and RS780/SBX00 chipset. endchoice config CS5536
arch/mips/loongson/Platform +1 -1
@@ -30,4 +30,4 @@ platform-$(CONFIG_MACH_LOONGSON) += loongson/ cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-loongson -mno-branch-likely load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000 -load-$(CONFIG_CPU_LOONGSON3) += 0xffffffff80200000 +load-$(CONFIG_LOONGSON_MACH3X) += 0xffffffff80200000
arch/mips/pci/Makefile +1 -1
@@ -29,7 +29,7 @@ obj-$(CONFIG_LASAT) += pci-lasat.o obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o obj-$(CONFIG_LEMOTE_MACH2F) += fixup-lemote2f.o ops-loongson2.o -obj-$(CONFIG_LEMOTE_MACH3A) += fixup-loongson3.o ops-loongson3.o +obj-$(CONFIG_LOONGSON_MACH3X) += fixup-loongson3.o ops-loongson3.o obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o pci-malta.o obj-$(CONFIG_PMC_MSP7120_GW) += fixup-pmcmsp.o ops-pmcmsp.o obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o
Signature · 1 line
1.7.7.3