From 8f74f52bb3d8596636614433faa067d73066a724 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Tue, 15 Jan 2013 15:27:45 +0000 Subject: [PATCH 01/24] metag: of_platform_populate from arch generic code If no init_machine callback is provided, call of_platform_populate() instead. This allows a board/SoC that only needs to call of_platform_populate to omit the callback altogether. Signed-off-by: James Hogan Cc: Grant Likely Cc: Rob Herring Cc: Arnd Bergmann Cc: devicetree-discuss@lists.ozlabs.org --- arch/metag/kernel/setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/metag/kernel/setup.c b/arch/metag/kernel/setup.c index 4f5726f1a55b..e18cebb076bf 100644 --- a/arch/metag/kernel/setup.c +++ b/arch/metag/kernel/setup.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -424,6 +425,9 @@ static int __init customize_machine(void) /* customizes platform devices, or adds new ones */ if (machine_desc->init_machine) machine_desc->init_machine(); + else + of_platform_populate(NULL, of_default_bus_match_table, NULL, + NULL); return 0; } arch_initcall(customize_machine); From c24d2976c7834aa948f9d8a48ad4285cfbaf1c3a Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 5 Dec 2012 16:32:10 +0000 Subject: [PATCH 02/24] metag: minimal TZ1090 (Comet) SoC infrastructure Add really minimal support for Toumaz Xenif TZ1090 SoC (A.K.A. Comet). This consists of minimal build infrastructure, device tree files, and a defconfig based on meta2_defconfig. This SoC contains a 2-threaded HTP (Meta 2) as the main application processor, and is found in a number of development boards and digital radios, such as the Minimorph Development Platform. Signed-off-by: James Hogan Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Cc: Arnd Bergmann Cc: linux-doc@vger.kernel.org Cc: devicetree-discuss@lists.ozlabs.org --- .../devicetree/bindings/vendor-prefixes.txt | 1 + arch/metag/Kconfig.soc | 9 ++++ arch/metag/Makefile | 2 +- arch/metag/boot/dts/Makefile | 2 + arch/metag/boot/dts/tz1090.dtsi | 29 +++++++++++++ arch/metag/boot/dts/tz1090_generic.dts | 10 +++++ arch/metag/configs/tz1090_defconfig | 42 +++++++++++++++++++ 7 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 arch/metag/boot/dts/tz1090.dtsi create mode 100644 arch/metag/boot/dts/tz1090_generic.dts create mode 100644 arch/metag/configs/tz1090_defconfig diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 6931c4348d24..be8099206d8d 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -57,6 +57,7 @@ snps Synopsys, Inc. st STMicroelectronics ste ST-Ericsson stericsson ST-Ericsson +toumaz Toumaz ti Texas Instruments toshiba Toshiba Corporation via VIA Technologies, Inc. diff --git a/arch/metag/Kconfig.soc b/arch/metag/Kconfig.soc index ec079cfb7c6a..653b47917caf 100644 --- a/arch/metag/Kconfig.soc +++ b/arch/metag/Kconfig.soc @@ -14,6 +14,15 @@ config META21_FPGA help This is a Meta 2.1 FPGA bitstream, just a bare CPU. +config SOC_TZ1090 + bool "Toumaz Xenif TZ1090 SoC (Comet)" + select METAG_LNKGET_AROUND_CACHE + select METAG_META21 + select METAG_SMP_WRITE_REORDERING + help + This is a Toumaz Technology Xenif TZ1090 (A.K.A. Comet) SoC containing + a 2-threaded HTP. + endchoice menu "SoC configuration" diff --git a/arch/metag/Makefile b/arch/metag/Makefile index b566116b171b..9739857bdedc 100644 --- a/arch/metag/Makefile +++ b/arch/metag/Makefile @@ -20,7 +20,7 @@ checkflags-$(CONFIG_METAG_META12) += -DMETAC_1_2 checkflags-$(CONFIG_METAG_META21) += -DMETAC_2_1 CHECKFLAGS += -D__metag__ $(checkflags-y) -KBUILD_DEFCONFIG := meta2_defconfig +KBUILD_DEFCONFIG := tz1090_defconfig sflags-$(CONFIG_METAG_META12) += -mmetac=1.2 ifeq ($(CONFIG_METAG_META12),y) diff --git a/arch/metag/boot/dts/Makefile b/arch/metag/boot/dts/Makefile index dbd95217733a..72c121879426 100644 --- a/arch/metag/boot/dts/Makefile +++ b/arch/metag/boot/dts/Makefile @@ -1,7 +1,9 @@ dtb-y += skeleton.dtb +dtb-y += tz1090_generic.dtb # Built-in dtb builtindtb-y := skeleton +builtindtb-$(CONFIG_SOC_TZ1090) := tz1090_generic ifneq ($(CONFIG_METAG_BUILTIN_DTB_NAME),"") builtindtb-y := $(patsubst "%",%,$(CONFIG_METAG_BUILTIN_DTB_NAME)) diff --git a/arch/metag/boot/dts/tz1090.dtsi b/arch/metag/boot/dts/tz1090.dtsi new file mode 100644 index 000000000000..ca057f07cac1 --- /dev/null +++ b/arch/metag/boot/dts/tz1090.dtsi @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2012 Imagination Technologies Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/include/ "skeleton.dtsi" + +/ { + compatible = "toumaz,tz1090", "img,meta"; + + interrupt-parent = <&intc>; + + intc: interrupt-controller { + compatible = "img,meta-intc"; + interrupt-controller; + #interrupt-cells = <2>; + num-banks = <2>; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + }; +}; diff --git a/arch/metag/boot/dts/tz1090_generic.dts b/arch/metag/boot/dts/tz1090_generic.dts new file mode 100644 index 000000000000..aa826cb842de --- /dev/null +++ b/arch/metag/boot/dts/tz1090_generic.dts @@ -0,0 +1,10 @@ +/* + * Copyright (C) 2012 Imagination Technologies Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +/dts-v1/; + +/include/ "tz1090.dtsi" diff --git a/arch/metag/configs/tz1090_defconfig b/arch/metag/configs/tz1090_defconfig new file mode 100644 index 000000000000..9f9316a6df27 --- /dev/null +++ b/arch/metag/configs/tz1090_defconfig @@ -0,0 +1,42 @@ +# CONFIG_LOCALVERSION_AUTO is not set +# CONFIG_SWAP is not set +CONFIG_SYSVIPC=y +CONFIG_SYSFS_DEPRECATED=y +CONFIG_SYSFS_DEPRECATED_V2=y +CONFIG_KALLSYMS_ALL=y +# CONFIG_ELF_CORE is not set +CONFIG_SLAB=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_MSDOS_PARTITION is not set +# CONFIG_IOSCHED_DEADLINE is not set +# CONFIG_IOSCHED_CFQ is not set +CONFIG_FLATMEM_MANUAL=y +CONFIG_SOC_TZ1090=y +CONFIG_METAG_HALT_ON_PANIC=y +# CONFIG_METAG_FPU is not set +CONFIG_METAG_DA=y +CONFIG_HZ_100=y +CONFIG_DEVTMPFS=y +# CONFIG_STANDALONE is not set +# CONFIG_PREVENT_FIRMWARE_BUILD is not set +# CONFIG_FW_LOADER is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=1 +CONFIG_BLK_DEV_RAM_SIZE=16384 +# CONFIG_INPUT is not set +# CONFIG_SERIO is not set +# CONFIG_VT is not set +# CONFIG_LEGACY_PTYS is not set +CONFIG_DA_TTY=y +CONFIG_DA_CONSOLE=y +# CONFIG_DEVKMEM is not set +# CONFIG_HW_RANDOM is not set +CONFIG_GPIOLIB=y +# CONFIG_HWMON is not set +# CONFIG_USB_SUPPORT is not set +# CONFIG_DNOTIFY is not set +CONFIG_TMPFS=y +# CONFIG_MISC_FILESYSTEMS is not set +# CONFIG_SCHED_DEBUG is not set +CONFIG_DEBUG_INFO=y From caa279dda4d9a442d824cd333e8b72078b83e855 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Tue, 15 Jan 2013 15:27:45 +0000 Subject: [PATCH 03/24] metag: init common clk and use "core" clk If the common clock framework is enabled, call of_clk_init(NULL) in time_init() to register device tree clocks with the clock framework. After this time_init() calls a new function init_metag_clocks(), which looks for a clock named "core" in the node compatible with "img,meta" (usually the root node). If found the get_core_freq machine callback is overridden to obtain the core clock frequency using that clock. Signed-off-by: James Hogan Cc: Mike Turquette Cc: Grant Likely Cc: Rob Herring Cc: devicetree-discuss@lists.ozlabs.org --- .../devicetree/bindings/metag/meta.txt | 30 ++++++++++ arch/metag/include/asm/clock.h | 8 +++ arch/metag/kernel/clock.c | 57 ++++++++++++++++++- arch/metag/kernel/time.c | 14 ++++- 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/metag/meta.txt diff --git a/Documentation/devicetree/bindings/metag/meta.txt b/Documentation/devicetree/bindings/metag/meta.txt new file mode 100644 index 000000000000..f4457f57ab08 --- /dev/null +++ b/Documentation/devicetree/bindings/metag/meta.txt @@ -0,0 +1,30 @@ +* Meta Processor Binding + +This binding specifies what properties must be available in the device tree +representation of a Meta Processor Core, which is the root node in the tree. + +Required properties: + + - compatible: Specifies the compatibility list for the Meta processor. + The type shall be and the value shall include "img,meta". + +Optional properties: + + - clocks: Clock consumer specifiers as described in + Documentation/devicetree/bindings/clock/clock-bindings.txt + + - clock-names: Clock consumer names as described in + Documentation/devicetree/bindings/clock/clock-bindings.txt. + +Clocks are identified by name. Valid clocks are: + + - "core": The Meta core clock from which the Meta timers are derived. + +* Examples + +/ { + compatible = "toumaz,tz1090", "img,meta"; + + clocks = <&meta_core_clk>; + clock-names = "core"; +}; diff --git a/arch/metag/include/asm/clock.h b/arch/metag/include/asm/clock.h index 3e2915a280c7..ded4ab2e1fd0 100644 --- a/arch/metag/include/asm/clock.h +++ b/arch/metag/include/asm/clock.h @@ -19,6 +19,8 @@ * core frequency will be determined like this: * Meta 1: based on loops_per_jiffy. * Meta 2: (EXPAND_TIMER_DIV + 1) MHz. + * If a "core" clock is provided by the device tree, it + * will override this function. */ struct meta_clock_desc { unsigned long (*get_core_freq)(void); @@ -26,6 +28,12 @@ struct meta_clock_desc { extern struct meta_clock_desc _meta_clock; +/* + * Perform platform clock initialisation, reading clocks from device tree etc. + * Only accessible during boot. + */ +void init_metag_clocks(void); + /* * Set up the default clock, ensuring all callbacks are valid - only accessible * during boot. diff --git a/arch/metag/kernel/clock.c b/arch/metag/kernel/clock.c index defc84056f18..8bfd6a5deac9 100644 --- a/arch/metag/kernel/clock.c +++ b/arch/metag/kernel/clock.c @@ -8,8 +8,10 @@ * published by the Free Software Foundation. */ +#include #include #include +#include #include #include @@ -34,8 +36,61 @@ static unsigned long get_core_freq_default(void) #endif } +static struct clk *clk_core; + +/* Clk based get_core_freq callback. */ +static unsigned long get_core_freq_clk(void) +{ + return clk_get_rate(clk_core); +} + /** - * setup_meta_clocks() - Set up the Meta clock. + * init_metag_core_clock() - Set up core clock from devicetree. + * + * Checks to see if a "core" clock is provided in the device tree, and overrides + * the get_core_freq callback to use it. + */ +static void __init init_metag_core_clock(void) +{ + /* + * See if a core clock is provided by the devicetree (and + * registered by the init callback above). + */ + struct device_node *node; + node = of_find_compatible_node(NULL, NULL, "img,meta"); + if (!node) { + pr_warn("%s: no compatible img,meta DT node found\n", + __func__); + return; + } + + clk_core = of_clk_get_by_name(node, "core"); + if (IS_ERR(clk_core)) { + pr_warn("%s: no core clock found in DT\n", + __func__); + return; + } + + /* + * Override the core frequency callback to use + * this clk. + */ + _meta_clock.get_core_freq = get_core_freq_clk; +} + +/** + * init_metag_clocks() - Set up clocks from devicetree. + * + * Set up important clocks from device tree. In particular any needed for clock + * sources. + */ +void __init init_metag_clocks(void) +{ + init_metag_core_clock(); +} + +/** + * setup_meta_clocks() - Early set up of the Meta clock. * @desc: Clock descriptor usually provided by machine description * * Ensures all callbacks are valid. diff --git a/arch/metag/kernel/time.c b/arch/metag/kernel/time.c index 17dc10733b2f..f1c8c53dace7 100644 --- a/arch/metag/kernel/time.c +++ b/arch/metag/kernel/time.c @@ -5,11 +5,21 @@ * */ -#include - #include +#include +#include +#include void __init time_init(void) { +#ifdef CONFIG_COMMON_CLK + /* Init clocks from device tree */ + of_clk_init(NULL); +#endif + + /* Init meta clocks, particularly the core clock */ + init_metag_clocks(); + + /* Set up the timer clock sources */ metag_generic_timer_init(); } From cf07053214efccc80eed429dcd8f95583af75e7b Mon Sep 17 00:00:00 2001 From: James Hogan Date: Tue, 15 Jan 2013 15:27:45 +0000 Subject: [PATCH 04/24] metag: log core and timer frequencies from arch code Log core clock and Meta timer frequencies during init in architecture generic code, removing the need for equivalent log messages in SoC specific code. Signed-off-by: James Hogan Cc: John Stultz Cc: Thomas Gleixner --- arch/metag/kernel/clock.c | 2 ++ drivers/clocksource/metag_generic.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/metag/kernel/clock.c b/arch/metag/kernel/clock.c index 8bfd6a5deac9..6339c9c6d0ab 100644 --- a/arch/metag/kernel/clock.c +++ b/arch/metag/kernel/clock.c @@ -87,6 +87,8 @@ static void __init init_metag_core_clock(void) void __init init_metag_clocks(void) { init_metag_core_clock(); + + pr_info("Core clock frequency: %lu Hz\n", get_coreclock()); } /** diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c index ade7513a11d1..6722f0e2fe40 100644 --- a/drivers/clocksource/metag_generic.c +++ b/drivers/clocksource/metag_generic.c @@ -184,6 +184,8 @@ int __init metag_generic_timer_init(void) #ifdef CONFIG_METAG_META21 hwtimer_freq = get_coreclock() / (metag_in32(EXPAND_TIMER_DIV) + 1); #endif + pr_info("Timer frequency: %u Hz\n", hwtimer_freq); + clocksource_register_hz(&clocksource_metag, hwtimer_freq); setup_irq(tbisig_map(TBID_SIGNUM_TRT), &metag_timer_irq); From 32580ae701256290640e7c845441141aac4d1cdb Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 7 May 2013 16:48:21 +0100 Subject: [PATCH 05/24] metag/kernel/irq.c: Declare root_domain as static It is only referenced within the irq.c file, so restrict it's scope as appropriate. Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/kernel/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/metag/kernel/irq.c b/arch/metag/kernel/irq.c index 87707efeb0a3..d91b1e91346c 100644 --- a/arch/metag/kernel/irq.c +++ b/arch/metag/kernel/irq.c @@ -25,7 +25,7 @@ static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly; static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly; #endif -struct irq_domain *root_domain; +static struct irq_domain *root_domain; static unsigned int startup_meta_irq(struct irq_data *data) { From a85882d74b6d0fec122b2c7a77c1daa2e3b18909 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 7 May 2013 16:51:28 +0100 Subject: [PATCH 06/24] metag/asm/irq.h: Declare init_IRQ Fixes the following sparce warning: warning: symbol 'init_IRQ' was not declared. Should it be static? Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/include/asm/irq.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/metag/include/asm/irq.h b/arch/metag/include/asm/irq.h index be0c8f3c5a5d..ad6bd0edbc3b 100644 --- a/arch/metag/include/asm/irq.h +++ b/arch/metag/include/asm/irq.h @@ -17,6 +17,7 @@ struct pt_regs; int tbisig_map(unsigned int hw); extern void do_IRQ(int irq, struct pt_regs *regs); +extern void init_IRQ(void); #ifdef CONFIG_METAG_SUSPEND_MEM int traps_save_context(void); From 42ad59e37504d52e59926e910c720d3b60158dc9 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 8 May 2013 16:29:16 +0100 Subject: [PATCH 07/24] metag/mm/cache: Restrict scope for metag_lnkget_probe Hide symbol since it's only used within the cache.c file Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/mm/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/metag/mm/cache.c b/arch/metag/mm/cache.c index b5d3b2e7c160..a62285284ab8 100644 --- a/arch/metag/mm/cache.c +++ b/arch/metag/mm/cache.c @@ -45,7 +45,7 @@ static volatile u32 lnkget_testdata[16] __initdata __aligned(64); #define LNKGET_CONSTANT 0xdeadbeef -void __init metag_lnkget_probe(void) +static void __init metag_lnkget_probe(void) { int temp; long flags; From 6ce5764dbce55f0231fd5a714c1ff65527032365 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 8 May 2013 16:38:58 +0100 Subject: [PATCH 08/24] metag/setup: Restrict scope for the capabilities variable Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/kernel/setup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/metag/kernel/setup.c b/arch/metag/kernel/setup.c index e18cebb076bf..c396cd0b425f 100644 --- a/arch/metag/kernel/setup.c +++ b/arch/metag/kernel/setup.c @@ -591,20 +591,20 @@ PTBI pTBI_get(unsigned int cpu) EXPORT_SYMBOL(pTBI_get); #if defined(CONFIG_METAG_DSP) && defined(CONFIG_METAG_FPU) -char capabilites[] = "dsp fpu"; +static char capabilities[] = "dsp fpu"; #elif defined(CONFIG_METAG_DSP) -char capabilites[] = "dsp"; +static char capabilities[] = "dsp"; #elif defined(CONFIG_METAG_FPU) -char capabilites[] = "fpu"; +static char capabilities[] = "fpu"; #else -char capabilites[] = ""; +static char capabilities[] = ""; #endif static struct ctl_table caps_kern_table[] = { { .procname = "capabilities", - .data = capabilites, - .maxlen = sizeof(capabilites), + .data = capabilities, + .maxlen = sizeof(capabilities), .mode = 0444, .proc_handler = proc_dostring, }, From dca66a61cb3c82ebc86f1f99c22550b0ed7b3fbe Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 8 May 2013 16:42:29 +0100 Subject: [PATCH 09/24] metag/processor.h: Add missing cpuinfo_op declaration. Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/include/asm/processor.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h index 9b029a7911c3..f16477d1f571 100644 --- a/arch/metag/include/asm/processor.h +++ b/arch/metag/include/asm/processor.h @@ -199,4 +199,6 @@ extern void (*soc_halt)(void); extern void show_trace(struct task_struct *tsk, unsigned long *sp, struct pt_regs *regs); +extern const struct seq_operations cpuinfo_op; + #endif From b79e88e55d5f8d141f205173ce30b4ef05e458c3 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 9 May 2013 09:42:46 +0100 Subject: [PATCH 10/24] metag/traps: Mark die() as __noreturn to match the declaration. Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/include/asm/bug.h | 4 ++-- arch/metag/kernel/traps.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/metag/include/asm/bug.h b/arch/metag/include/asm/bug.h index d04b48cefecc..9f8967f10f8c 100644 --- a/arch/metag/include/asm/bug.h +++ b/arch/metag/include/asm/bug.h @@ -6,7 +6,7 @@ struct pt_regs; extern const char *trap_name(int trapno); -extern void die(const char *str, struct pt_regs *regs, long err, - unsigned long addr) __attribute__ ((noreturn)); +extern void __noreturn die(const char *str, struct pt_regs *regs, long err, + unsigned long addr); #endif diff --git a/arch/metag/kernel/traps.c b/arch/metag/kernel/traps.c index 2ceeaae5b199..a7051de20075 100644 --- a/arch/metag/kernel/traps.c +++ b/arch/metag/kernel/traps.c @@ -87,8 +87,8 @@ const char *trap_name(int trapno) static DEFINE_SPINLOCK(die_lock); -void die(const char *str, struct pt_regs *regs, long err, - unsigned long addr) +void __noreturn die(const char *str, struct pt_regs *regs, + long err, unsigned long addr) { static int die_counter; From 0184cd347a25f4a6218e197bb3498c22586cbbb0 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 9 May 2013 10:56:00 +0100 Subject: [PATCH 11/24] metag/traps: include setup.h for the per_cpu_trap_init declaration Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/kernel/traps.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/metag/kernel/traps.c b/arch/metag/kernel/traps.c index a7051de20075..c00ade0228ef 100644 --- a/arch/metag/kernel/traps.c +++ b/arch/metag/kernel/traps.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include From 1a5719a097b6c98816779dc40501213c2e68d30b Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 14 May 2013 16:22:43 +0100 Subject: [PATCH 12/24] metag/.gitignore: Extend the *.dtb pattern to match the dtb.S files The .SECONDARY rule for generating the *.dtb.S files added in 0b4184c26b18ecbc0ec0657f514b087c3a6216fb "metag: avoid unnecessary builtin dtb rebuilds" Signed-off-by: Markos Chandras Signed-off-by: James Hogan --- arch/metag/boot/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/metag/boot/.gitignore b/arch/metag/boot/.gitignore index a021da201156..2d6c0c160884 100644 --- a/arch/metag/boot/.gitignore +++ b/arch/metag/boot/.gitignore @@ -1,4 +1,4 @@ vmlinux* uImage* ramdisk.* -*.dtb +*.dtb* From 6ad59a58b002ab760c171f05148183d37f83a991 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 31 May 2013 16:17:24 +0100 Subject: [PATCH 13/24] metag: add symlink Add symlink to include/dt-bindings from arch/metag/boot/dts/include/ to match the one in arch/arm/... (see the commit below) so that preprocessed device tree files can include various useful constant definitions. Commit c58299aa87544a590c62bda0bf52b69fa56cb8d5 ("kbuild: create an "include chroot" for DT bindings") merged in v3.10-rc1. Signed-off-by: James Hogan Acked-by: Grant Likely Reviewed-by: Stephen Warren Cc: Michal Marek Cc: Shawn Guo Cc: Rob Herring Cc: linux-kbuild@vger.kernel.org Cc: devicetree-discuss@lists.ozlabs.org --- arch/metag/boot/dts/include/dt-bindings | 1 + 1 file changed, 1 insertion(+) create mode 120000 arch/metag/boot/dts/include/dt-bindings diff --git a/arch/metag/boot/dts/include/dt-bindings b/arch/metag/boot/dts/include/dt-bindings new file mode 120000 index 000000000000..08c00e4972fa --- /dev/null +++ b/arch/metag/boot/dts/include/dt-bindings @@ -0,0 +1 @@ +../../../../../include/dt-bindings \ No newline at end of file From d3087c03f0de99bb0fa5fb7de970ace8aabfd31d Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 31 May 2013 16:12:54 +0100 Subject: [PATCH 14/24] metag: *.dts: include using preprocessor Include *.dtsi files from *.dts using the preprocessor to set a good example for future device tree files. Files included in the old way don't get pre-processed. Signed-off-by: James Hogan Acked-by: Grant Likely Cc: devicetree-discuss@lists.ozlabs.org --- arch/metag/boot/dts/skeleton.dts | 2 +- arch/metag/boot/dts/tz1090.dtsi | 2 +- arch/metag/boot/dts/tz1090_generic.dts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/metag/boot/dts/skeleton.dts b/arch/metag/boot/dts/skeleton.dts index 7244d1f0d555..7a49aeb365d0 100644 --- a/arch/metag/boot/dts/skeleton.dts +++ b/arch/metag/boot/dts/skeleton.dts @@ -7,4 +7,4 @@ */ /dts-v1/; -/include/ "skeleton.dtsi" +#include "skeleton.dtsi" diff --git a/arch/metag/boot/dts/tz1090.dtsi b/arch/metag/boot/dts/tz1090.dtsi index ca057f07cac1..ff7bb74abc4b 100644 --- a/arch/metag/boot/dts/tz1090.dtsi +++ b/arch/metag/boot/dts/tz1090.dtsi @@ -6,7 +6,7 @@ * published by the Free Software Foundation. */ -/include/ "skeleton.dtsi" +#include "skeleton.dtsi" / { compatible = "toumaz,tz1090", "img,meta"; diff --git a/arch/metag/boot/dts/tz1090_generic.dts b/arch/metag/boot/dts/tz1090_generic.dts index aa826cb842de..f96090955964 100644 --- a/arch/metag/boot/dts/tz1090_generic.dts +++ b/arch/metag/boot/dts/tz1090_generic.dts @@ -7,4 +7,4 @@ */ /dts-v1/; -/include/ "tz1090.dtsi" +#include "tz1090.dtsi" From 30dd5f7a573f10383d1fef237c69e6f69a1589e8 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Mon, 24 Jun 2013 11:05:19 +0100 Subject: [PATCH 15/24] metag: panic if cache aliasing possible If the cache and page size configuration allows for cache aliasing to occur we warn on boot, but the log messages are easy to miss and will result is random crashes occuring in userland. Let's panic too in this case so that the user immediately knows they need to fix the cache configuration or configured page size. Also fix the warning messages which display the cache and page sizes to include newlines, and add the word "Potential" since an actual cache alias hasn't been detected. Signed-off-by: James Hogan --- arch/metag/kernel/cachepart.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/metag/kernel/cachepart.c b/arch/metag/kernel/cachepart.c index 954548b1bea8..0a2385fa2a1d 100644 --- a/arch/metag/kernel/cachepart.c +++ b/arch/metag/kernel/cachepart.c @@ -100,22 +100,23 @@ void check_for_cache_aliasing(int thread_id) thread_cache_size = get_thread_cache_size(cache_type, thread_id); if (thread_cache_size < 0) - pr_emerg("Can't read %s cache size", \ + pr_emerg("Can't read %s cache size\n", cache_type ? "DCACHE" : "ICACHE"); else if (thread_cache_size == 0) /* Cache is off. No need to check for aliasing */ continue; if (thread_cache_size / CACHE_ASSOCIATIVITY > PAGE_SIZE) { - pr_emerg("Cache aliasing detected in %s on Thread %d", + pr_emerg("Potential cache aliasing detected in %s on Thread %d\n", cache_type ? "DCACHE" : "ICACHE", thread_id); - pr_warn("Total %s size: %u bytes", - cache_type ? "DCACHE" : "ICACHE ", + pr_warn("Total %s size: %u bytes\n", + cache_type ? "DCACHE" : "ICACHE", cache_type ? get_dcache_size() : get_icache_size()); - pr_warn("Thread %s size: %d bytes", + pr_warn("Thread %s size: %d bytes\n", cache_type ? "CACHE" : "ICACHE", thread_cache_size); - pr_warn("Page Size: %lu bytes", PAGE_SIZE); + pr_warn("Page Size: %lu bytes\n", PAGE_SIZE); + panic("Potential cache aliasing detected"); } } } From f43b059d8dfb90f7c87b88eff0a57f5a79dd87ff Mon Sep 17 00:00:00 2001 From: James Hogan Date: Mon, 24 Jun 2013 11:12:38 +0100 Subject: [PATCH 16/24] metag: don't check for cache aliasing on smp cpu boot The cache configuration of the boot cpu is now duplicated to secondary cpus, so there's no need to check for cache aliasing again when a secondary cpu is booted. Therefore remove the check from secondary_start_kernel(). Signed-off-by: James Hogan --- arch/metag/kernel/smp.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c index f443ec9a7cbe..86fdda4a85c4 100644 --- a/arch/metag/kernel/smp.c +++ b/arch/metag/kernel/smp.c @@ -403,12 +403,6 @@ asmlinkage void secondary_start_kernel(void) */ set_cpu_online(cpu, true); - /* - * Check for cache aliasing. - * Preemption is disabled - */ - check_for_cache_aliasing(cpu); - /* * OK, it's off to the idle thread for us */ From 9630fa9fe6fec46b498d0784f00f8ef2bbd5b6ec Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 5 Oct 2012 12:33:07 +0100 Subject: [PATCH 17/24] metag: tz1090: select and instantiate pinctrl-tz1090 Select PINCTRL and PINCTRL_TZ1090 from SOC_TZ1090 to enable the main pin controller driver once it is merged, and instantiate it from tz1090.dtsi. Signed-off-by: James Hogan Acked-by: Linus Walleij Acked-by: Grant Likely --- arch/metag/Kconfig.soc | 2 ++ arch/metag/boot/dts/tz1090.dtsi | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/arch/metag/Kconfig.soc b/arch/metag/Kconfig.soc index 653b47917caf..6b11ca363ceb 100644 --- a/arch/metag/Kconfig.soc +++ b/arch/metag/Kconfig.soc @@ -19,6 +19,8 @@ config SOC_TZ1090 select METAG_LNKGET_AROUND_CACHE select METAG_META21 select METAG_SMP_WRITE_REORDERING + select PINCTRL + select PINCTRL_TZ1090 help This is a Toumaz Technology Xenif TZ1090 (A.K.A. Comet) SoC containing a 2-threaded HTP. diff --git a/arch/metag/boot/dts/tz1090.dtsi b/arch/metag/boot/dts/tz1090.dtsi index ff7bb74abc4b..697f3840e4d8 100644 --- a/arch/metag/boot/dts/tz1090.dtsi +++ b/arch/metag/boot/dts/tz1090.dtsi @@ -25,5 +25,11 @@ #address-cells = <1>; #size-cells = <1>; ranges; + + pinctrl: pinctrl@02005800 { + #gpio-range-cells = <3>; + compatible = "img,tz1090-pinctrl"; + reg = <0x02005800 0xe4>; + }; }; }; From 5a88130a2aac2bf02d3c50abc7e65ebac11a4fd4 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Mon, 22 Apr 2013 16:46:43 +0100 Subject: [PATCH 18/24] metag: tz1090: select and instantiate pinctrl-tz1090-pdc Select PINCTRL_TZ1090_PDC from SOC_TZ1090 to enable the PDC pin controller driver once it is merged, and instantiate it from tz1090.dtsi. Signed-off-by: James Hogan Acked-by: Linus Walleij Acked-by: Grant Likely --- arch/metag/Kconfig.soc | 1 + arch/metag/boot/dts/tz1090.dtsi | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/arch/metag/Kconfig.soc b/arch/metag/Kconfig.soc index 6b11ca363ceb..2a3c860c7525 100644 --- a/arch/metag/Kconfig.soc +++ b/arch/metag/Kconfig.soc @@ -21,6 +21,7 @@ config SOC_TZ1090 select METAG_SMP_WRITE_REORDERING select PINCTRL select PINCTRL_TZ1090 + select PINCTRL_TZ1090_PDC help This is a Toumaz Technology Xenif TZ1090 (A.K.A. Comet) SoC containing a 2-threaded HTP. diff --git a/arch/metag/boot/dts/tz1090.dtsi b/arch/metag/boot/dts/tz1090.dtsi index 697f3840e4d8..853744652b93 100644 --- a/arch/metag/boot/dts/tz1090.dtsi +++ b/arch/metag/boot/dts/tz1090.dtsi @@ -31,5 +31,11 @@ compatible = "img,tz1090-pinctrl"; reg = <0x02005800 0xe4>; }; + + pdc_pinctrl: pinctrl@02006500 { + #gpio-range-cells = <3>; + compatible = "img,tz1090-pdc-pinctrl"; + reg = <0x02006500 0x100>; + }; }; }; From 42748752f6ada54faa4f39fa471dabce62eaa79a Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 28 Jun 2013 16:09:47 +0100 Subject: [PATCH 19/24] metag: use clear_tasks_mm_cpumask() Checking for process->mm is not enough because process' main thread may exit or detach its mm via use_mm(), but other threads may still have a valid mm. To fix this we would need to use find_lock_task_mm(), which would walk up all threads and returns an appropriate task (with task lock held). clear_tasks_mm_cpumask() was introduced in v3.5-rc1 to fix this issue, so let's use it for metag too. Signed-off-by: James Hogan Cc: "Srivatsa S. Bhat" Cc: Thomas Gleixner Cc: Oleg Nesterov Cc: Anton Vorontsov --- arch/metag/kernel/smp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c index 86fdda4a85c4..b81351538c48 100644 --- a/arch/metag/kernel/smp.c +++ b/arch/metag/kernel/smp.c @@ -276,7 +276,6 @@ static DECLARE_COMPLETION(cpu_killed); int __cpuexit __cpu_disable(void) { unsigned int cpu = smp_processor_id(); - struct task_struct *p; /* * Take this CPU offline. Once we clear this, we can't return, @@ -296,12 +295,7 @@ int __cpuexit __cpu_disable(void) flush_cache_all(); local_flush_tlb_all(); - read_lock(&tasklist_lock); - for_each_process(p) { - if (p->mm) - cpumask_clear_cpu(cpu, mm_cpumask(p->mm)); - } - read_unlock(&tasklist_lock); + clear_tasks_mm_cpumask(cpu); return 0; } From 234c7f1ac109ad1af4ae410463d03ccebf3d6657 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 28 Jun 2013 13:56:02 +0100 Subject: [PATCH 20/24] metag: smp: enable irqs after set_cpu_online In secondary_start_kernel() interrupts should be enabled with local_irq_enable() after the cpu is marked as online with set_cpu_online(). Otherwise it's possible for a timer interrupt to trigger a softirq, which if the cpu is marked as offline may have it's affinity altered. Reported-by: Kirill Tkhai Signed-off-by: James Hogan Acked-by: Thomas Gleixner Reviewed-by: "Srivatsa S. Bhat" Cc: Kirill Tkhai --- arch/metag/kernel/smp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c index b81351538c48..09979f203a4d 100644 --- a/arch/metag/kernel/smp.c +++ b/arch/metag/kernel/smp.c @@ -379,12 +379,7 @@ asmlinkage void secondary_start_kernel(void) setup_priv(); - /* - * Enable local interrupts. - */ - tbi_startup_interrupt(TBID_SIGNUM_TRT); notify_cpu_starting(cpu); - local_irq_enable(); pr_info("CPU%u (thread %u): Booted secondary processor\n", cpu, cpu_2_hwthread_id[cpu]); @@ -397,6 +392,12 @@ asmlinkage void secondary_start_kernel(void) */ set_cpu_online(cpu, true); + /* + * Enable local interrupts. + */ + tbi_startup_interrupt(TBID_SIGNUM_TRT); + local_irq_enable(); + /* * OK, it's off to the idle thread for us */ From 9649814432faa9016952895684120942da0d8481 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 28 Jun 2013 15:03:05 +0100 Subject: [PATCH 21/24] metag: smp: don't spin waiting for CPU to start Use a completion to block until a secondary CPU has started up, like ARM do, instead of a loop of udelays. On Meta, SMP is really SMT, with each "CPU" being a different hardware thread on the same Meta processor core, so as well as being more efficient and latency friendly, using a completion prevents the bogomips of the secondary CPU from being drastically skewed every time by the execution of the tight in-cache udelay loop on the other CPU. Signed-off-by: James Hogan Acked-by: Thomas Gleixner Reviewed-by: "Srivatsa S. Bhat" --- arch/metag/kernel/smp.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c index 09979f203a4d..e413875cf6d2 100644 --- a/arch/metag/kernel/smp.c +++ b/arch/metag/kernel/smp.c @@ -8,6 +8,7 @@ * published by the Free Software Foundation. */ #include +#include #include #include #include @@ -62,6 +63,8 @@ static DEFINE_PER_CPU(struct ipi_data, ipi_data) = { static DEFINE_SPINLOCK(boot_lock); +static DECLARE_COMPLETION(cpu_running); + /* * "thread" is assumed to be a valid Meta hardware thread ID. */ @@ -235,20 +238,12 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) */ ret = boot_secondary(thread, idle); if (ret == 0) { - unsigned long timeout; - /* * CPU was successfully started, wait for it * to come online or time out. */ - timeout = jiffies + HZ; - while (time_before(jiffies, timeout)) { - if (cpu_online(cpu)) - break; - - udelay(10); - barrier(); - } + wait_for_completion_timeout(&cpu_running, + msecs_to_jiffies(1000)); if (!cpu_online(cpu)) ret = -EIO; @@ -391,6 +386,7 @@ asmlinkage void secondary_start_kernel(void) * OK, now it's safe to let the boot CPU continue */ set_cpu_online(cpu, true); + complete(&cpu_running); /* * Enable local interrupts. From f6b30d32d242243a967993789c4cf550d840727e Mon Sep 17 00:00:00 2001 From: James Hogan Date: Mon, 1 Jul 2013 13:44:10 +0100 Subject: [PATCH 22/24] metag: kick: add missing irq_enter/exit to kick_handler() kick_handler() doesn't have an irq_enter/exit pair, but it's used for handling SMP IPIs which require work to be done in softirqs, which are invoked from irq_exit() when the hard irq nest count reaches 0. The scheduler_ipi() callback in the IPI handler calls irq_enter/exit itself, but this is inside kick_handler()'s spin lock critical section, so if an invoked softirq issues an IPI the kick_handler() will be re-entered on the same CPU and will deadlock. This is easily fixed by adding the missing irq_enter/exit to kick_handler() so that the hard irq nest count doesn't reach 0 until after the spin lock has been released. Ideally the spin lock protected handler list will also be replaced by a lockless RCU protected list since it is certainly mostly read. That can be done in a later change though. Signed-off-by: James Hogan Acked-by: Thomas Gleixner --- arch/metag/kernel/kick.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/metag/kernel/kick.c b/arch/metag/kernel/kick.c index 50fcbec98cd2..beb377621322 100644 --- a/arch/metag/kernel/kick.c +++ b/arch/metag/kernel/kick.c @@ -26,6 +26,8 @@ * pass it as an argument. */ #include +#include +#include #include #include #include @@ -66,6 +68,7 @@ EXPORT_SYMBOL(kick_unregister_func); TBIRES kick_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI) { + struct pt_regs *old_regs; struct kick_irq_handler *kh; struct list_head *lh; int handled = 0; @@ -79,6 +82,9 @@ kick_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI) trace_hardirqs_off(); + old_regs = set_irq_regs((struct pt_regs *)State.Sig.pCtx); + irq_enter(); + /* * There is no need to disable interrupts here because we * can't nest KICK interrupts in a KICK interrupt handler. @@ -97,5 +103,8 @@ kick_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI) WARN_ON(!handled); + irq_exit(); + set_irq_regs(old_regs); + return tail_end(ret); } From 8b8b2412994fffd5a8ab3b9209fa0aa9f0fcee4c Mon Sep 17 00:00:00 2001 From: James Hogan Date: Mon, 1 Jul 2013 15:36:38 +0100 Subject: [PATCH 23/24] metag: cpu hotplug: route_irq: preserve irq mask The route_irq() function needs to preserve the irq mask by using the _irqsave/irqrestore variants of raw spin lock functions instead of the _irq variants. This is because it is called from __cpu_disable() (via migrate_irqs()), which is called with IRQs disabled, so using the _irq variants re-enables IRQs. This appears to have been causing occasional hits of the BUG_ON(!irqs_disabled()) in __irq_work_run() during CPU hotplug soak testing: BUG: failure at kernel/irq_work.c:122/__irq_work_run()! Signed-off-by: James Hogan Acked-by: Thomas Gleixner Reviewed-by: Srivatsa S. Bhat --- arch/metag/kernel/irq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/metag/kernel/irq.c b/arch/metag/kernel/irq.c index d91b1e91346c..2a2c9d55187e 100644 --- a/arch/metag/kernel/irq.c +++ b/arch/metag/kernel/irq.c @@ -279,11 +279,12 @@ static void route_irq(struct irq_data *data, unsigned int irq, unsigned int cpu) { struct irq_desc *desc = irq_to_desc(irq); struct irq_chip *chip = irq_data_get_irq_chip(data); + unsigned long flags; - raw_spin_lock_irq(&desc->lock); + raw_spin_lock_irqsave(&desc->lock, flags); if (chip->irq_set_affinity) chip->irq_set_affinity(data, cpumask_of(cpu), false); - raw_spin_unlock_irq(&desc->lock); + raw_spin_unlock_irqrestore(&desc->lock, flags); } /* From c20eb0f1d0918c019fb2674a104e6ab59d8e62ac Mon Sep 17 00:00:00 2001 From: James Hogan Date: Thu, 4 Jul 2013 09:47:45 +0100 Subject: [PATCH 24/24] metag: move EXPORT_SYMBOL(csum_partial) to metag_ksyms.c Move EXPORT_SYMBOL(csum_partial) from lib/checksum.c into metag_ksyms.c so that it doesn't get omitted by the static linker if it's not used by any other statically linked code, which can result in undefined symbols when building modules. For example a randconfig caused the following error: ERROR: "csum_partial" [fs/reiserfs/reiserfs.ko] undefined! Signed-off-by: James Hogan --- arch/metag/kernel/metag_ksyms.c | 5 +++++ arch/metag/lib/checksum.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/metag/kernel/metag_ksyms.c b/arch/metag/kernel/metag_ksyms.c index ec872ef14eb1..215c94ad63ac 100644 --- a/arch/metag/kernel/metag_ksyms.c +++ b/arch/metag/kernel/metag_ksyms.c @@ -1,5 +1,7 @@ #include +#include +#include #include #include #include @@ -15,6 +17,9 @@ EXPORT_SYMBOL(max_pfn); EXPORT_SYMBOL(min_low_pfn); #endif +/* Network checksum functions */ +EXPORT_SYMBOL(csum_partial); + /* TBI symbols */ EXPORT_SYMBOL(__TBI); EXPORT_SYMBOL(__TBIFindSeg); diff --git a/arch/metag/lib/checksum.c b/arch/metag/lib/checksum.c index 44d2e1913560..5d6a98a05e9d 100644 --- a/arch/metag/lib/checksum.c +++ b/arch/metag/lib/checksum.c @@ -124,7 +124,6 @@ __wsum csum_partial(const void *buff, int len, __wsum wsum) result += 1; return (__force __wsum)result; } -EXPORT_SYMBOL(csum_partial); /* * this routine is used for miscellaneous IP-like checksums, mainly