diff options
22 files changed, 462 insertions, 298 deletions
diff --git a/patches/0001-ARM-at91-move-SoC-specific-definitions-to-SoC-folder.patch b/patches/0001-ARM-at91-move-SoC-specific-definitions-to-SoC-folder.patch index 64c8aefc54d8..69bb893c1288 100644 --- a/patches/0001-ARM-at91-move-SoC-specific-definitions-to-SoC-folder.patch +++ b/patches/0001-ARM-at91-move-SoC-specific-definitions-to-SoC-folder.patch @@ -1,11 +1,12 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:09 +0200 -Subject: [PATCH 01/12] ARM: at91: move SoC specific definitions to SoC folder +Date: Fri, 26 Apr 2019 23:47:10 +0200 +Subject: [PATCH 01/10] ARM: at91: move SoC specific definitions to SoC folder Move linux/atmel_tc.h to the SoC specific folder include/soc/at91. -Cc: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> +Acked-by: Thierry Reding <thierry.reding@gmail.com> +Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- drivers/clocksource/tcb_clksrc.c | 2 @@ -14,7 +15,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> include/linux/atmel_tc.h | 270 --------------------------------------- include/soc/at91/atmel_tcb.h | 270 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 273 insertions(+), 273 deletions(-) - rename include/{linux/atmel_tc.h => soc/at91/atmel_tcb.h} (99%) + delete mode 100644 include/linux/atmel_tc.h + create mode 100644 include/soc/at91/atmel_tcb.h --- a/drivers/clocksource/tcb_clksrc.c +++ b/drivers/clocksource/tcb_clksrc.c @@ -44,15 +46,18 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> * This is a thin library to solve the problem of how to portably allocate --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c -@@ -17,7 +17,7 @@ +@@ -17,10 +17,10 @@ #include <linux/ioport.h> #include <linux/io.h> #include <linux/platform_device.h> -#include <linux/atmel_tc.h> -+#include <soc/at91/atmel_tcb.h> #include <linux/pwm.h> #include <linux/of_device.h> #include <linux/slab.h> ++#include <soc/at91/atmel_tcb.h> + + #define NPWM 6 + --- a/include/linux/atmel_tc.h +++ /dev/null @@ -1,270 +0,0 @@ diff --git a/patches/0004-clocksource-drivers-tcb_clksrc-stop-depending-on-atm.patch b/patches/0002-clocksource-drivers-tcb_clksrc-stop-depending-on-atm.patch index e1db641b3b57..b2b5ccab5b44 100644 --- a/patches/0004-clocksource-drivers-tcb_clksrc-stop-depending-on-atm.patch +++ b/patches/0002-clocksource-drivers-tcb_clksrc-stop-depending-on-atm.patch @@ -1,6 +1,6 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:12 +0200 -Subject: [PATCH 04/12] clocksource/drivers/tcb_clksrc: stop depending on +Date: Fri, 26 Apr 2019 23:47:11 +0200 +Subject: [PATCH 02/10] clocksource/drivers/tcb_clksrc: stop depending on atmel_tclib atmel_tclib is probed too late in the boot process to be able to use the @@ -16,9 +16,9 @@ a bit more flexible as the TCB is not hardcoded in the kernel anymore. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- - drivers/clocksource/tcb_clksrc.c | 103 ++++++++++++++++++++++++--------------- + drivers/clocksource/tcb_clksrc.c | 108 ++++++++++++++++++++++++--------------- drivers/misc/Kconfig | 14 ----- - 2 files changed, 66 insertions(+), 51 deletions(-) + 2 files changed, 70 insertions(+), 52 deletions(-) --- a/drivers/clocksource/tcb_clksrc.c +++ b/drivers/clocksource/tcb_clksrc.c @@ -62,25 +62,33 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, /* Should be lower than at91rm9200's system timer */ -@@ -330,33 +322,64 @@ static void __init tcb_setup_single_chan +@@ -330,39 +322,73 @@ static void __init tcb_setup_single_chan writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); } -static int __init tcb_clksrc_init(void) -+static int __init tcb_clksrc_init(struct device_node *node) - { +-{ - static char bootinfo[] __initdata - = KERN_DEBUG "%s: tc%d at %d.%03d MHz\n"; -- ++static const u8 atmel_tcb_divisors[5] = { 2, 8, 32, 128, 0, }; ++ ++static const struct of_device_id atmel_tcb_of_match[] = { ++ { .compatible = "atmel,at91rm9200-tcb", .data = (void *)16, }, ++ { .compatible = "atmel,at91sam9x5-tcb", .data = (void *)32, }, ++ { /* sentinel */ } ++}; + - struct platform_device *pdev; - struct atmel_tc *tc; ++static int __init tcb_clksrc_init(struct device_node *node) ++{ + struct atmel_tc tc; struct clk *t0_clk; + const struct of_device_id *match; -+ int irq; u32 rate, divided_rate = 0; int best_divisor_idx = -1; int clk32k_divisor_idx = -1; ++ int bits; int i; int ret; @@ -88,9 +96,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - if (!tc) { - pr_debug("can't alloc TC for clocksource\n"); - return -ENODEV; -- } -- tcaddr = tc->regs; -- pdev = tc->pdev; + /* Protect against multiple calls */ + if (tcaddr) + return 0; @@ -107,10 +112,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + if (IS_ERR(tc.slow_clk)) + return PTR_ERR(tc.slow_clk); + -+ irq = of_irq_get(node->parent, 0); -+ if (irq <= 0) -+ return -EINVAL; -+ + tc.clk[0] = t0_clk; + tc.clk[1] = of_clk_get_by_name(node->parent, "t1_clk"); + if (IS_ERR(tc.clk[1])) @@ -119,21 +120,22 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + if (IS_ERR(tc.clk[2])) + tc.clk[2] = t0_clk; + -+ tc.irq[0] = irq; -+ tc.irq[1] = of_irq_get(node->parent, 1); -+ if (tc.irq[1] <= 0) -+ tc.irq[1] = irq; + tc.irq[2] = of_irq_get(node->parent, 2); -+ if (tc.irq[2] <= 0) -+ tc.irq[2] = irq; -+ -+ match = of_match_node(atmel_tcb_dt_ids, node->parent); -+ tc.tcb_config = match->data; ++ if (tc.irq[2] <= 0) { ++ tc.irq[2] = of_irq_get(node->parent, 0); ++ if (tc.irq[2] <= 0) ++ return -EINVAL; + } +- tcaddr = tc->regs; +- pdev = tc->pdev; + +- t0_clk = tc->clk[0]; ++ match = of_match_node(atmel_tcb_of_match, node->parent); ++ bits = (uintptr_t)match->data; + + for (i = 0; i < ARRAY_SIZE(tc.irq); i++) + writel(ATMEL_TC_ALL_IRQ, tc.regs + ATMEL_TC_REG(i, IDR)); - -- t0_clk = tc->clk[0]; ++ ret = clk_prepare_enable(t0_clk); if (ret) { pr_debug("can't enable T0 clk\n"); @@ -142,7 +144,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } /* How fast will we be counting? Pick something over 5 MHz. */ -@@ -381,27 +404,29 @@ static int __init tcb_clksrc_init(void) + rate = (u32) clk_get_rate(t0_clk); +- for (i = 0; i < 5; i++) { +- unsigned divisor = atmel_tc_divisors[i]; ++ for (i = 0; i < ARRAY_SIZE(atmel_tcb_divisors); i++) { ++ unsigned divisor = atmel_tcb_divisors[i]; + unsigned tmp; + + /* remember 32 KiHz clock for later */ +@@ -381,27 +407,29 @@ static int __init tcb_clksrc_init(void) best_divisor_idx = i; } @@ -157,7 +167,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - if (tc->tcb_config && tc->tcb_config->counter_width == 32) { + tcaddr = tc.regs; + -+ if (tc.tcb_config->counter_width == 32) { ++ if (bits == 32) { /* use apropriate function to read 32 bit counter */ clksrc.read = tc_get_cycles32; /* setup ony channel 0 */ @@ -180,7 +190,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } /* and away we go! */ -@@ -410,7 +435,7 @@ static int __init tcb_clksrc_init(void) +@@ -410,7 +438,7 @@ static int __init tcb_clksrc_init(void) goto err_disable_t1; /* channel 2: periodic and oneshot timer support */ @@ -189,13 +199,13 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> if (ret) goto err_unregister_clksrc; -@@ -420,14 +445,14 @@ static int __init tcb_clksrc_init(void) +@@ -420,14 +448,14 @@ static int __init tcb_clksrc_init(void) clocksource_unregister(&clksrc); err_disable_t1: - if (!tc->tcb_config || tc->tcb_config->counter_width != 32) - clk_disable_unprepare(tc->clk[1]); -+ if (tc.tcb_config->counter_width != 32) ++ if (bits != 32) + clk_disable_unprepare(tc.clk[1]); err_disable_t0: diff --git a/patches/0002-misc-atmel_tclib-drop-AVR32-support.patch b/patches/0002-misc-atmel_tclib-drop-AVR32-support.patch deleted file mode 100644 index 7958b43bd715..000000000000 --- a/patches/0002-misc-atmel_tclib-drop-AVR32-support.patch +++ /dev/null @@ -1,33 +0,0 @@ -From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:10 +0200 -Subject: [PATCH 02/12] misc: atmel_tclib: drop AVR32 support - -AVR32 is gone from the kernel, remove its support from tclib. - -Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> -Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> ---- - drivers/misc/atmel_tclib.c | 8 -------- - 1 file changed, 8 deletions(-) - ---- a/drivers/misc/atmel_tclib.c -+++ b/drivers/misc/atmel_tclib.c -@@ -17,18 +17,10 @@ - * share individual timers between different drivers. - */ - --#if defined(CONFIG_AVR32) --/* AVR32 has these divide PBB */ --const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, }; --EXPORT_SYMBOL(atmel_tc_divisors); -- --#elif defined(CONFIG_ARCH_AT91) - /* AT91 has these divide MCK */ - const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, }; - EXPORT_SYMBOL(atmel_tc_divisors); - --#endif -- - static DEFINE_SPINLOCK(tc_list_lock); - static LIST_HEAD(tc_list); - diff --git a/patches/0005-clocksource-drivers-tcb_clksrc-Use-tcb-as-sched_cloc.patch b/patches/0003-clocksource-drivers-tcb_clksrc-Use-tcb-as-sched_cloc.patch index 358553c15312..4e3a8a98c308 100644 --- a/patches/0005-clocksource-drivers-tcb_clksrc-Use-tcb-as-sched_cloc.patch +++ b/patches/0003-clocksource-drivers-tcb_clksrc-Use-tcb-as-sched_cloc.patch @@ -1,6 +1,6 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:13 +0200 -Subject: [PATCH 05/12] clocksource/drivers/tcb_clksrc: Use tcb as sched_clock +Date: Fri, 26 Apr 2019 23:47:12 +0200 +Subject: [PATCH 03/10] clocksource/drivers/tcb_clksrc: Use tcb as sched_clock Now that the driver is registered early enough, use the TCB as the sched_clock which is much more accurate than the jiffies implementation. @@ -38,15 +38,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> #ifdef CONFIG_GENERIC_CLOCKEVENTS struct tc_clkevt_device { -@@ -327,6 +338,7 @@ static int __init tcb_clksrc_init(struct +@@ -335,6 +346,7 @@ static int __init tcb_clksrc_init(struct struct atmel_tc tc; struct clk *t0_clk; const struct of_device_id *match; + u64 (*tc_sched_clock)(void); - int irq; u32 rate, divided_rate = 0; int best_divisor_idx = -1; -@@ -416,6 +428,7 @@ static int __init tcb_clksrc_init(struct + int clk32k_divisor_idx = -1; +@@ -419,6 +431,7 @@ static int __init tcb_clksrc_init(struct clksrc.read = tc_get_cycles32; /* setup ony channel 0 */ tcb_setup_single_chan(&tc, best_divisor_idx); @@ -54,7 +54,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } else { /* we have three clocks no matter what the * underlying platform supports. -@@ -427,6 +440,7 @@ static int __init tcb_clksrc_init(struct +@@ -430,6 +443,7 @@ static int __init tcb_clksrc_init(struct } /* setup both channel 0 & 1 */ tcb_setup_dual_chan(&tc, best_divisor_idx); @@ -62,7 +62,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } /* and away we go! */ -@@ -439,6 +453,8 @@ static int __init tcb_clksrc_init(struct +@@ -442,6 +456,8 @@ static int __init tcb_clksrc_init(struct if (ret) goto err_unregister_clksrc; diff --git a/patches/0003-misc-atmel_tclib-move-definitions-to-header-file.patch b/patches/0003-misc-atmel_tclib-move-definitions-to-header-file.patch deleted file mode 100644 index b999c1147004..000000000000 --- a/patches/0003-misc-atmel_tclib-move-definitions-to-header-file.patch +++ /dev/null @@ -1,85 +0,0 @@ -From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:11 +0200 -Subject: [PATCH 03/12] misc: atmel_tclib: move definitions to header file - -Move atmel_tc_divisors and atmel_tcb_dt_ids definitions to the header file -so they can be used without using tclib. - -Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> -Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> ---- - drivers/misc/atmel_tclib.c | 24 ------------------------ - include/soc/at91/atmel_tcb.h | 21 ++++++++++++++++++++- - 2 files changed, 20 insertions(+), 25 deletions(-) - ---- a/drivers/misc/atmel_tclib.c -+++ b/drivers/misc/atmel_tclib.c -@@ -17,10 +17,6 @@ - * share individual timers between different drivers. - */ - --/* AT91 has these divide MCK */ --const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, }; --EXPORT_SYMBOL(atmel_tc_divisors); -- - static DEFINE_SPINLOCK(tc_list_lock); - static LIST_HEAD(tc_list); - -@@ -72,26 +68,6 @@ void atmel_tc_free(struct atmel_tc *tc) - EXPORT_SYMBOL_GPL(atmel_tc_free); - - #if defined(CONFIG_OF) --static struct atmel_tcb_config tcb_rm9200_config = { -- .counter_width = 16, --}; -- --static struct atmel_tcb_config tcb_sam9x5_config = { -- .counter_width = 32, --}; -- --static const struct of_device_id atmel_tcb_dt_ids[] = { -- { -- .compatible = "atmel,at91rm9200-tcb", -- .data = &tcb_rm9200_config, -- }, { -- .compatible = "atmel,at91sam9x5-tcb", -- .data = &tcb_sam9x5_config, -- }, { -- /* sentinel */ -- } --}; -- - MODULE_DEVICE_TABLE(of, atmel_tcb_dt_ids); - #endif - ---- a/include/soc/at91/atmel_tcb.h -+++ b/include/soc/at91/atmel_tcb.h -@@ -76,8 +76,27 @@ extern struct atmel_tc *atmel_tc_alloc(u - extern void atmel_tc_free(struct atmel_tc *tc); - - /* platform-specific ATMEL_TC_TIMER_CLOCKx divisors (0 means 32KiHz) */ --extern const u8 atmel_tc_divisors[5]; -+static const u8 atmel_tc_divisors[] = { 2, 8, 32, 128, 0, }; - -+static const struct atmel_tcb_config tcb_rm9200_config = { -+ .counter_width = 16, -+}; -+ -+static const struct atmel_tcb_config tcb_sam9x5_config = { -+ .counter_width = 32, -+}; -+ -+static const struct of_device_id atmel_tcb_dt_ids[] = { -+ { -+ .compatible = "atmel,at91rm9200-tcb", -+ .data = &tcb_rm9200_config, -+ }, { -+ .compatible = "atmel,at91sam9x5-tcb", -+ .data = &tcb_sam9x5_config, -+ }, { -+ /* sentinel */ -+ } -+}; - - /* - * Two registers have block-wide controls. These are: configuring the three diff --git a/patches/0006-ARM-at91-Implement-clocksource-selection.patch b/patches/0004-ARM-at91-Implement-clocksource-selection.patch index 710bd9122336..38a539600fad 100644 --- a/patches/0006-ARM-at91-Implement-clocksource-selection.patch +++ b/patches/0004-ARM-at91-Implement-clocksource-selection.patch @@ -1,6 +1,6 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:14 +0200 -Subject: [PATCH 06/12] ARM: at91: Implement clocksource selection +Date: Fri, 26 Apr 2019 23:47:13 +0200 +Subject: [PATCH 04/10] ARM: at91: Implement clocksource selection Allow selecting and unselecting the PIT clocksource driver so it doesn't have to be compiled when unused. diff --git a/patches/0007-clocksource-drivers-tcb_clksrc-move-Kconfig-option.patch b/patches/0005-clocksource-drivers-tcb_clksrc-move-Kconfig-option.patch index 883fc957af99..08bfcc36dcc0 100644 --- a/patches/0007-clocksource-drivers-tcb_clksrc-move-Kconfig-option.patch +++ b/patches/0005-clocksource-drivers-tcb_clksrc-move-Kconfig-option.patch @@ -1,10 +1,11 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:15 +0200 -Subject: [PATCH 07/12] clocksource/drivers/tcb_clksrc: move Kconfig option +Date: Fri, 26 Apr 2019 23:47:14 +0200 +Subject: [PATCH 05/10] clocksource/drivers/tcb_clksrc: move Kconfig option Move the ATMEL_TCB_CLKSRC option to drivers/clocksource and make it silent if COMPILE_TEST is not selected. +Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- diff --git a/patches/0008-clocksource-drivers-timer-atmel-pit-rework-Kconfig-o.patch b/patches/0006-clocksource-drivers-timer-atmel-pit-rework-Kconfig-o.patch index 65212342d6dd..e32305ea1598 100644 --- a/patches/0008-clocksource-drivers-timer-atmel-pit-rework-Kconfig-o.patch +++ b/patches/0006-clocksource-drivers-timer-atmel-pit-rework-Kconfig-o.patch @@ -1,6 +1,6 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:16 +0200 -Subject: [PATCH 08/12] clocksource/drivers/timer-atmel-pit: rework Kconfig +Date: Fri, 26 Apr 2019 23:47:15 +0200 +Subject: [PATCH 06/10] clocksource/drivers/timer-atmel-pit: rework Kconfig option Allow building the PIT driver when COMPILE_TEST is enabled. Also remove its diff --git a/patches/0009-clocksource-drivers-tcb_clksrc-Rename-the-file-for-c.patch b/patches/0007-clocksource-drivers-tcb_clksrc-Rename-the-file-for-c.patch index 3cd0c377e7fd..d0d64e1da636 100644 --- a/patches/0009-clocksource-drivers-tcb_clksrc-Rename-the-file-for-c.patch +++ b/patches/0007-clocksource-drivers-tcb_clksrc-Rename-the-file-for-c.patch @@ -1,6 +1,6 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:17 +0200 -Subject: [PATCH 09/12] clocksource/drivers/tcb_clksrc: Rename the file for +Date: Fri, 26 Apr 2019 23:47:16 +0200 +Subject: [PATCH 07/10] clocksource/drivers/tcb_clksrc: Rename the file for consistency For the sake of consistency, let's rename the file to a name similar @@ -9,13 +9,12 @@ to other file names in this directory. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- - drivers/clocksource/Makefile | 2 +- - drivers/clocksource/{tcb_clksrc.c => timer-atmel-tcb.c} | 0 drivers/clocksource/Makefile | 2 - drivers/clocksource/tcb_clksrc.c | 474 ---------------------------------- - drivers/clocksource/timer-atmel-tcb.c | 474 ++++++++++++++++++++++++++++++++++ - 3 files changed, 475 insertions(+), 475 deletions(-) - rename drivers/clocksource/{tcb_clksrc.c => timer-atmel-tcb.c} (100%) + drivers/clocksource/tcb_clksrc.c | 477 ---------------------------------- + drivers/clocksource/timer-atmel-tcb.c | 477 ++++++++++++++++++++++++++++++++++ + 3 files changed, 478 insertions(+), 478 deletions(-) + delete mode 100644 drivers/clocksource/tcb_clksrc.c + create mode 100644 drivers/clocksource/timer-atmel-tcb.c --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -30,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o --- a/drivers/clocksource/tcb_clksrc.c +++ /dev/null -@@ -1,474 +0,0 @@ +@@ -1,477 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include <linux/init.h> -#include <linux/clocksource.h> @@ -366,16 +365,24 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); -} - +-static const u8 atmel_tcb_divisors[5] = { 2, 8, 32, 128, 0, }; +- +-static const struct of_device_id atmel_tcb_of_match[] = { +- { .compatible = "atmel,at91rm9200-tcb", .data = (void *)16, }, +- { .compatible = "atmel,at91sam9x5-tcb", .data = (void *)32, }, +- { /* sentinel */ } +-}; +- -static int __init tcb_clksrc_init(struct device_node *node) -{ - struct atmel_tc tc; - struct clk *t0_clk; - const struct of_device_id *match; - u64 (*tc_sched_clock)(void); -- int irq; - u32 rate, divided_rate = 0; - int best_divisor_idx = -1; - int clk32k_divisor_idx = -1; +- int bits; - int i; - int ret; - @@ -395,10 +402,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - if (IS_ERR(tc.slow_clk)) - return PTR_ERR(tc.slow_clk); - -- irq = of_irq_get(node->parent, 0); -- if (irq <= 0) -- return -EINVAL; -- - tc.clk[0] = t0_clk; - tc.clk[1] = of_clk_get_by_name(node->parent, "t1_clk"); - if (IS_ERR(tc.clk[1])) @@ -407,16 +410,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - if (IS_ERR(tc.clk[2])) - tc.clk[2] = t0_clk; - -- tc.irq[0] = irq; -- tc.irq[1] = of_irq_get(node->parent, 1); -- if (tc.irq[1] <= 0) -- tc.irq[1] = irq; - tc.irq[2] = of_irq_get(node->parent, 2); -- if (tc.irq[2] <= 0) -- tc.irq[2] = irq; +- if (tc.irq[2] <= 0) { +- tc.irq[2] = of_irq_get(node->parent, 0); +- if (tc.irq[2] <= 0) +- return -EINVAL; +- } - -- match = of_match_node(atmel_tcb_dt_ids, node->parent); -- tc.tcb_config = match->data; +- match = of_match_node(atmel_tcb_of_match, node->parent); +- bits = (uintptr_t)match->data; - - for (i = 0; i < ARRAY_SIZE(tc.irq); i++) - writel(ATMEL_TC_ALL_IRQ, tc.regs + ATMEL_TC_REG(i, IDR)); @@ -429,8 +431,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - - /* How fast will we be counting? Pick something over 5 MHz. */ - rate = (u32) clk_get_rate(t0_clk); -- for (i = 0; i < 5; i++) { -- unsigned divisor = atmel_tc_divisors[i]; +- for (i = 0; i < ARRAY_SIZE(atmel_tcb_divisors); i++) { +- unsigned divisor = atmel_tcb_divisors[i]; - unsigned tmp; - - /* remember 32 KiHz clock for later */ @@ -456,7 +458,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - - tcaddr = tc.regs; - -- if (tc.tcb_config->counter_width == 32) { +- if (bits == 32) { - /* use apropriate function to read 32 bit counter */ - clksrc.read = tc_get_cycles32; - /* setup ony channel 0 */ @@ -494,7 +496,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> - clocksource_unregister(&clksrc); - -err_disable_t1: -- if (tc.tcb_config->counter_width != 32) +- if (bits != 32) - clk_disable_unprepare(tc.clk[1]); - -err_disable_t0: @@ -507,7 +509,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> -TIMER_OF_DECLARE(atmel_tcb_clksrc, "atmel,tcb-timer", tcb_clksrc_init); --- /dev/null +++ b/drivers/clocksource/timer-atmel-tcb.c -@@ -0,0 +1,474 @@ +@@ -0,0 +1,477 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/init.h> +#include <linux/clocksource.h> @@ -843,16 +845,24 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); +} + ++static const u8 atmel_tcb_divisors[5] = { 2, 8, 32, 128, 0, }; ++ ++static const struct of_device_id atmel_tcb_of_match[] = { ++ { .compatible = "atmel,at91rm9200-tcb", .data = (void *)16, }, ++ { .compatible = "atmel,at91sam9x5-tcb", .data = (void *)32, }, ++ { /* sentinel */ } ++}; ++ +static int __init tcb_clksrc_init(struct device_node *node) +{ + struct atmel_tc tc; + struct clk *t0_clk; + const struct of_device_id *match; + u64 (*tc_sched_clock)(void); -+ int irq; + u32 rate, divided_rate = 0; + int best_divisor_idx = -1; + int clk32k_divisor_idx = -1; ++ int bits; + int i; + int ret; + @@ -872,10 +882,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + if (IS_ERR(tc.slow_clk)) + return PTR_ERR(tc.slow_clk); + -+ irq = of_irq_get(node->parent, 0); -+ if (irq <= 0) -+ return -EINVAL; -+ + tc.clk[0] = t0_clk; + tc.clk[1] = of_clk_get_by_name(node->parent, "t1_clk"); + if (IS_ERR(tc.clk[1])) @@ -884,16 +890,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + if (IS_ERR(tc.clk[2])) + tc.clk[2] = t0_clk; + -+ tc.irq[0] = irq; -+ tc.irq[1] = of_irq_get(node->parent, 1); -+ if (tc.irq[1] <= 0) -+ tc.irq[1] = irq; + tc.irq[2] = of_irq_get(node->parent, 2); -+ if (tc.irq[2] <= 0) -+ tc.irq[2] = irq; ++ if (tc.irq[2] <= 0) { ++ tc.irq[2] = of_irq_get(node->parent, 0); ++ if (tc.irq[2] <= 0) ++ return -EINVAL; ++ } + -+ match = of_match_node(atmel_tcb_dt_ids, node->parent); -+ tc.tcb_config = match->data; ++ match = of_match_node(atmel_tcb_of_match, node->parent); ++ bits = (uintptr_t)match->data; + + for (i = 0; i < ARRAY_SIZE(tc.irq); i++) + writel(ATMEL_TC_ALL_IRQ, tc.regs + ATMEL_TC_REG(i, IDR)); @@ -906,8 +911,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + + /* How fast will we be counting? Pick something over 5 MHz. */ + rate = (u32) clk_get_rate(t0_clk); -+ for (i = 0; i < 5; i++) { -+ unsigned divisor = atmel_tc_divisors[i]; ++ for (i = 0; i < ARRAY_SIZE(atmel_tcb_divisors); i++) { ++ unsigned divisor = atmel_tcb_divisors[i]; + unsigned tmp; + + /* remember 32 KiHz clock for later */ @@ -933,7 +938,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + + tcaddr = tc.regs; + -+ if (tc.tcb_config->counter_width == 32) { ++ if (bits == 32) { + /* use apropriate function to read 32 bit counter */ + clksrc.read = tc_get_cycles32; + /* setup ony channel 0 */ @@ -971,7 +976,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + clocksource_unregister(&clksrc); + +err_disable_t1: -+ if (tc.tcb_config->counter_width != 32) ++ if (bits != 32) + clk_disable_unprepare(tc.clk[1]); + +err_disable_t0: diff --git a/patches/0008-clocksource-drivers-timer-atmel-tcb-tc_clksrc_suspen.patch b/patches/0008-clocksource-drivers-timer-atmel-tcb-tc_clksrc_suspen.patch new file mode 100644 index 000000000000..7f8878bac5db --- /dev/null +++ b/patches/0008-clocksource-drivers-timer-atmel-tcb-tc_clksrc_suspen.patch @@ -0,0 +1,34 @@ +From: kbuild test robot <lkp@intel.com> +Date: Fri, 26 Apr 2019 23:47:17 +0200 +Subject: [PATCH 08/10] clocksource/drivers/timer-atmel-tcb: + tc_clksrc_suspend() can be static + +Statisticize tc_clksrc_suspend and tc_clksrc_resume. + +Signed-off-by: kbuild test robot <lkp@intel.com> +Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + drivers/clocksource/timer-atmel-tcb.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/clocksource/timer-atmel-tcb.c ++++ b/drivers/clocksource/timer-atmel-tcb.c +@@ -66,7 +66,7 @@ static u64 tc_get_cycles32(struct clocks + return readl_relaxed(tcaddr + ATMEL_TC_REG(0, CV)); + } + +-void tc_clksrc_suspend(struct clocksource *cs) ++static void tc_clksrc_suspend(struct clocksource *cs) + { + int i; + +@@ -81,7 +81,7 @@ void tc_clksrc_suspend(struct clocksourc + bmr_cache = readl(tcaddr + ATMEL_TC_BMR); + } + +-void tc_clksrc_resume(struct clocksource *cs) ++static void tc_clksrc_resume(struct clocksource *cs) + { + int i; + diff --git a/patches/0011-misc-atmel_tclib-do-not-probe-already-used-TCBs.patch b/patches/0009-misc-atmel_tclib-do-not-probe-already-used-TCBs.patch index ba907067bbc7..6b366716f46c 100644 --- a/patches/0011-misc-atmel_tclib-do-not-probe-already-used-TCBs.patch +++ b/patches/0009-misc-atmel_tclib-do-not-probe-already-used-TCBs.patch @@ -1,10 +1,11 @@ From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:19 +0200 -Subject: [PATCH 11/12] misc: atmel_tclib: do not probe already used TCBs +Date: Fri, 26 Apr 2019 23:47:18 +0200 +Subject: [PATCH 09/10] misc: atmel_tclib: do not probe already used TCBs -The TCBs that have children are using the new (proper) DT bindings and -don't need to be handled by tclib. +The TCBs that have children are using the proper DT bindings and don't need +to be handled by tclib. +Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- @@ -13,12 +14,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- a/drivers/misc/atmel_tclib.c +++ b/drivers/misc/atmel_tclib.c -@@ -79,6 +79,9 @@ static int __init tc_probe(struct platfo +@@ -111,6 +111,9 @@ static int __init tc_probe(struct platfo struct resource *r; unsigned int i; + if (of_get_child_count(pdev->dev.of_node)) -+ return 0; ++ return -EBUSY; + irq = platform_get_irq(pdev, 0); if (irq < 0) diff --git a/patches/0010-ARM-configs-at91-unselect-PIT.patch b/patches/0010-ARM-configs-at91-unselect-PIT.patch deleted file mode 100644 index 625ed09b3677..000000000000 --- a/patches/0010-ARM-configs-at91-unselect-PIT.patch +++ /dev/null @@ -1,35 +0,0 @@ -From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:18 +0200 -Subject: [PATCH 10/12] ARM: configs: at91: unselect PIT - -The PIT is not required anymore to successfully boot and may actually harm -in case preempt-rt is used because the PIT interrupt is shared. -Disable it so the TCB clocksource is used. - -Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> -Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> ---- - arch/arm/configs/at91_dt_defconfig | 1 + - arch/arm/configs/sama5_defconfig | 1 + - 2 files changed, 2 insertions(+) - ---- a/arch/arm/configs/at91_dt_defconfig -+++ b/arch/arm/configs/at91_dt_defconfig -@@ -19,6 +19,7 @@ CONFIG_ARCH_MULTI_V5=y - CONFIG_ARCH_AT91=y - CONFIG_SOC_AT91RM9200=y - CONFIG_SOC_AT91SAM9=y -+# CONFIG_ATMEL_CLOCKSOURCE_PIT is not set - CONFIG_AEABI=y - CONFIG_UACCESS_WITH_MEMCPY=y - CONFIG_ZBOOT_ROM_TEXT=0x0 ---- a/arch/arm/configs/sama5_defconfig -+++ b/arch/arm/configs/sama5_defconfig -@@ -20,6 +20,7 @@ CONFIG_ARCH_AT91=y - CONFIG_SOC_SAMA5D2=y - CONFIG_SOC_SAMA5D3=y - CONFIG_SOC_SAMA5D4=y -+# CONFIG_ATMEL_CLOCKSOURCE_PIT is not set - CONFIG_AEABI=y - CONFIG_UACCESS_WITH_MEMCPY=y - CONFIG_ZBOOT_ROM_TEXT=0x0 diff --git a/patches/0012-clocksource-drivers-timer-atmel-tcb-Use-ARRAY_SIZE-i.patch b/patches/0012-clocksource-drivers-timer-atmel-tcb-Use-ARRAY_SIZE-i.patch deleted file mode 100644 index 474fe589120a..000000000000 --- a/patches/0012-clocksource-drivers-timer-atmel-tcb-Use-ARRAY_SIZE-i.patch +++ /dev/null @@ -1,25 +0,0 @@ -From: Alexandre Belloni <alexandre.belloni@bootlin.com> -Date: Wed, 3 Apr 2019 16:11:20 +0200 -Subject: [PATCH 12/12] clocksource/drivers/timer-atmel-tcb: Use ARRAY_SIZE - instead of hardcoded size - -Use ARRAY_SIZE to replace the hardcoded size so we will never have a -mismatch. - -Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> -Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> ---- - drivers/clocksource/timer-atmel-tcb.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/clocksource/timer-atmel-tcb.c -+++ b/drivers/clocksource/timer-atmel-tcb.c -@@ -396,7 +396,7 @@ static int __init tcb_clksrc_init(struct - - /* How fast will we be counting? Pick something over 5 MHz. */ - rate = (u32) clk_get_rate(t0_clk); -- for (i = 0; i < 5; i++) { -+ for (i = 0; i < ARRAY_SIZE(atmel_tc_divisors); i++) { - unsigned divisor = atmel_tc_divisors[i]; - unsigned tmp; - diff --git a/patches/0028-x86-fpu-Fault-in-user-stack-if-copy_fpstate_to_sigfr.patch b/patches/0028-x86-fpu-Fault-in-user-stack-if-copy_fpstate_to_sigfr.patch new file mode 100644 index 000000000000..f76d1f3fd5c4 --- /dev/null +++ b/patches/0028-x86-fpu-Fault-in-user-stack-if-copy_fpstate_to_sigfr.patch @@ -0,0 +1,104 @@ +From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Date: Mon, 29 Apr 2019 18:39:53 +0200 +Subject: [PATCH] x86/fpu: Fault-in user stack if copy_fpstate_to_sigframe() + fails + +In the compacted form, XSAVES may save only the XMM+SSE state but skip +FP (x87 state). + +This is denoted by header->xfeatures = 6. The fastpath +(copy_fpregs_to_sigframe()) does that but _also_ initialises the FP +state (cwd to 0x37f, mxcsr as we do, remaining fields to 0). + +The slowpath (copy_xstate_to_user()) leaves most of the FP +state untouched. Only mxcsr and mxcsr_flags are set due to +xfeatures_mxcsr_quirk(). Now that XFEATURE_MASK_FP is set +unconditionally, see + + 04944b793e18 ("x86: xsave: set FP, SSE bits in the xsave header in the user sigcontext"), + +on return from the signal, random garbage is loaded as the FP state. + +Instead of utilizing copy_xstate_to_user(), fault-in the user memory +and retry the fast path. Ideally, the fast path succeeds on the second +attempt but may be retried again if the memory is swapped out due +to memory pressure. If the user memory can not be faulted-in then +get_user_pages() returns an error so we don't loop forever. + +Fault in memory via get_user_pages() so copy_fpregs_to_sigframe() +succeeds without a fault. + +Fixes: 69277c98f5eef ("x86/fpu: Always store the registers in copy_fpstate_to_sigframe()") +Reported-by: Kurt Kanzenbach <kurt.kanzenbach@linutronix.de> +Suggested-by: Dave Hansen <dave.hansen@intel.com> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Signed-off-by: Borislav Petkov <bp@suse.de> +Acked-by: Thomas Gleixner <tglx@linutronix.de> +Cc: Andy Lutomirski <luto@amacapital.net> +Cc: Dave Hansen <dave.hansen@intel.com> +Cc: "H. Peter Anvin" <hpa@zytor.com> +Cc: Ingo Molnar <mingo@kernel.org> +Cc: Jann Horn <jannh@google.com> +Cc: Jason@zx2c4.com +Cc: kvm ML <kvm@vger.kernel.org> +Cc: Paolo Bonzini <pbonzini@redhat.com> +Cc: Rik van Riel <riel@surriel.com> +Cc: rkrcmar@redhat.com +Cc: x86-ml <x86@kernel.org> +Link: https://lkml.kernel.org/r/20190429163953.gqxgsc5okqxp4olv@linutronix.de +--- + arch/x86/kernel/fpu/signal.c | 25 ++++++++++++++----------- + 1 file changed, 14 insertions(+), 11 deletions(-) + +--- a/arch/x86/kernel/fpu/signal.c ++++ b/arch/x86/kernel/fpu/signal.c +@@ -158,7 +158,6 @@ static inline int copy_fpregs_to_sigfram + int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) + { + struct fpu *fpu = ¤t->thread.fpu; +- struct xregs_state *xsave = &fpu->state.xsave; + struct task_struct *tsk = current; + int ia32_fxstate = (buf != buf_fx); + int ret = -EFAULT; +@@ -174,12 +173,13 @@ int copy_fpstate_to_sigframe(void __user + sizeof(struct user_i387_ia32_struct), NULL, + (struct _fpstate_32 __user *) buf) ? -1 : 1; + ++retry: + fpregs_lock(); + /* + * Load the FPU register if they are not valid for the current task. + * With a valid FPU state we can attempt to save the state directly to +- * userland's stack frame which will likely succeed. If it does not, do +- * the slowpath. ++ * userland's stack frame which will likely succeed. If it does not, ++ * resolve the fault in the user memory and try again. + */ + if (test_thread_flag(TIF_NEED_FPU_LOAD)) + __fpregs_load_activate(); +@@ -193,14 +193,17 @@ int copy_fpstate_to_sigframe(void __user + fpregs_unlock(); + + if (ret) { +- if (using_compacted_format()) { +- if (copy_xstate_to_user(buf_fx, xsave, 0, size)) +- return -1; +- } else { +- fpstate_sanitize_xstate(fpu); +- if (__copy_to_user(buf_fx, xsave, fpu_user_xstate_size)) +- return -1; +- } ++ int aligned_size; ++ int nr_pages; ++ ++ aligned_size = offset_in_page(buf_fx) + fpu_user_xstate_size; ++ nr_pages = DIV_ROUND_UP(aligned_size, PAGE_SIZE); ++ ++ ret = get_user_pages((unsigned long)buf_fx, nr_pages, ++ FOLL_WRITE, NULL, NULL); ++ if (ret == nr_pages) ++ goto retry; ++ return -EFAULT; + } + + /* Save the fsave header for the 32-bit frames. */ diff --git a/patches/0029-x86-fpu-Remove-unnecessary-saving-of-FPU-registers-i.patch b/patches/0029-x86-fpu-Remove-unnecessary-saving-of-FPU-registers-i.patch new file mode 100644 index 000000000000..435d1f0f5135 --- /dev/null +++ b/patches/0029-x86-fpu-Remove-unnecessary-saving-of-FPU-registers-i.patch @@ -0,0 +1,66 @@ +From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Date: Tue, 30 Apr 2019 10:31:26 +0200 +Subject: [PATCH] x86/fpu: Remove unnecessary saving of FPU registers in + copy_fpstate_to_sigframe() + +Since commit: + + eeec00d73be2e ("x86/fpu: Fault-in user stack if copy_fpstate_to_sigframe() fails") + +there is no need to have FPU registers saved if +copy_fpregs_to_sigframe() fails, because we retry it after we resolved +the fault condition. + +Saving the registers is not wrong but it is not necessary and it forces us +to load the FPU registers on the retry attempt. + +Don't save the FPU registers if copy_fpstate_to_sigframe() fails. + +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Cc: Andy Lutomirski <luto@kernel.org> +Cc: Borislav Petkov <bp@alien8.de> +Cc: Dave Hansen <dave.hansen@intel.com> +Cc: Fenghua Yu <fenghua.yu@intel.com> +Cc: H. Peter Anvin <hpa@zytor.com> +Cc: Jason@zx2c4.com +Cc: Linus Torvalds <torvalds@linux-foundation.org> +Cc: Oleg Nesterov <oleg@redhat.com> +Cc: Peter Zijlstra <peterz@infradead.org> +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: bp@suse.de +Cc: jannh@google.com +Cc: kurt.kanzenbach@linutronix.de +Cc: kvm@vger.kernel.org +Cc: pbonzini@redhat.com +Cc: riel@surriel.com +Cc: rkrcmar@redhat.com +Link: http://lkml.kernel.org/r/20190430083126.rilbb76yc27vrem5@linutronix.de +Signed-off-by: Ingo Molnar <mingo@kernel.org> +--- + arch/x86/kernel/fpu/signal.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +--- a/arch/x86/kernel/fpu/signal.c ++++ b/arch/x86/kernel/fpu/signal.c +@@ -157,10 +157,9 @@ static inline int copy_fpregs_to_sigfram + */ + int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) + { +- struct fpu *fpu = ¤t->thread.fpu; + struct task_struct *tsk = current; + int ia32_fxstate = (buf != buf_fx); +- int ret = -EFAULT; ++ int ret; + + ia32_fxstate &= (IS_ENABLED(CONFIG_X86_32) || + IS_ENABLED(CONFIG_IA32_EMULATION)); +@@ -187,9 +186,6 @@ int copy_fpstate_to_sigframe(void __user + pagefault_disable(); + ret = copy_fpregs_to_sigframe(buf_fx); + pagefault_enable(); +- if (ret && !test_thread_flag(TIF_NEED_FPU_LOAD)) +- copy_fpregs_to_fpstate(fpu); +- set_thread_flag(TIF_NEED_FPU_LOAD); + fpregs_unlock(); + + if (ret) { diff --git a/patches/clocksource-tclib-allow-higher-clockrates.patch b/patches/clocksource-tclib-allow-higher-clockrates.patch index 7c9a84236e91..3967f9aa56cd 100644 --- a/patches/clocksource-tclib-allow-higher-clockrates.patch +++ b/patches/clocksource-tclib-allow-higher-clockrates.patch @@ -131,7 +131,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> return ret; } -@@ -474,7 +476,11 @@ static int __init tcb_clksrc_init(struct +@@ -477,7 +479,11 @@ static int __init tcb_clksrc_init(struct goto err_disable_t1; /* channel 2: periodic and oneshot timer support */ diff --git a/patches/localversion.patch b/patches/localversion.patch index 4c1841b6475d..bbb08330835d 100644 --- a/patches/localversion.patch +++ b/patches/localversion.patch @@ -10,4 +10,4 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- /dev/null +++ b/localversion-rt @@ -0,0 +1 @@ -+-rt6 ++-rt7 diff --git a/patches/printk-kmsg_dump-remove-mutex-usage.patch b/patches/printk-kmsg_dump-remove-mutex-usage.patch new file mode 100644 index 000000000000..dc86a5a82148 --- /dev/null +++ b/patches/printk-kmsg_dump-remove-mutex-usage.patch @@ -0,0 +1,84 @@ +From: John Ogness <john.ogness@linutronix.de> +Date: Wed, 24 Apr 2019 16:36:04 +0200 +Subject: [PATCH] printk: kmsg_dump: remove mutex usage + +The kmsg dumper can be called from any context, but the dumping +helpers were using a mutex to synchronize the iterator against +concurrent dumps. + +Rather than trying to synchronize the iterator, use a local copy +of the iterator during the dump. Then no synchronization is +required. + +Reported-by: Scott Wood <swood@redhat.com> +Signed-off-by: John Ogness <john.ogness@linutronix.de> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + kernel/printk/printk.c | 23 ++++++++++------------- + 1 file changed, 10 insertions(+), 13 deletions(-) + +--- a/kernel/printk/printk.c ++++ b/kernel/printk/printk.c +@@ -359,8 +359,6 @@ static u64 syslog_seq; + static size_t syslog_partial; + static bool syslog_time; + +-static DEFINE_MUTEX(kmsg_dump_lock); +- + /* the last printk record at the last 'clear' command */ + static u64 clear_seq; + +@@ -2820,6 +2818,7 @@ module_param_named(always_kmsg_dump, alw + */ + void kmsg_dump(enum kmsg_dump_reason reason) + { ++ struct kmsg_dumper dumper_local; + struct kmsg_dumper *dumper; + + if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump) +@@ -2830,16 +2829,18 @@ void kmsg_dump(enum kmsg_dump_reason rea + if (dumper->max_reason && reason > dumper->max_reason) + continue; + +- /* initialize iterator with data about the stored records */ +- dumper->active = true; ++ /* ++ * use a local copy to avoid modifying the ++ * iterator used by any other cpus/contexts ++ */ ++ memcpy(&dumper_local, dumper, sizeof(dumper_local)); + +- kmsg_dump_rewind(dumper); ++ /* initialize iterator with data about the stored records */ ++ dumper_local.active = true; ++ kmsg_dump_rewind(&dumper_local); + + /* invoke dumper which will iterate over records */ +- dumper->dump(dumper, reason); +- +- /* reset iterator */ +- dumper->active = false; ++ dumper_local.dump(&dumper_local, reason); + } + rcu_read_unlock(); + } +@@ -2951,9 +2952,7 @@ bool kmsg_dump_get_line(struct kmsg_dump + { + bool ret; + +- mutex_lock(&kmsg_dump_lock); + ret = kmsg_dump_get_line_nolock(dumper, syslog, line, size, len); +- mutex_unlock(&kmsg_dump_lock); + + return ret; + } +@@ -3105,9 +3104,7 @@ void kmsg_dump_rewind_nolock(struct kmsg + */ + void kmsg_dump_rewind(struct kmsg_dumper *dumper) + { +- mutex_lock(&kmsg_dump_lock); + kmsg_dump_rewind_nolock(dumper); +- mutex_unlock(&kmsg_dump_lock); + } + EXPORT_SYMBOL_GPL(kmsg_dump_rewind); + diff --git a/patches/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch b/patches/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch index 21d1c44da560..c48c56dffa99 100644 --- a/patches/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch +++ b/patches/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch @@ -41,14 +41,14 @@ the approach. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- - include/linux/rwsem_rt.h | 68 ++++++++++ + include/linux/rwsem-rt.h | 68 ++++++++++ kernel/locking/rwsem-rt.c | 293 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 361 insertions(+) - create mode 100644 include/linux/rwsem_rt.h + create mode 100644 include/linux/rwsem-rt.h create mode 100644 kernel/locking/rwsem-rt.c --- /dev/null -+++ b/include/linux/rwsem_rt.h ++++ b/include/linux/rwsem-rt.h @@ -0,0 +1,68 @@ +#ifndef _LINUX_RWSEM_RT_H +#define _LINUX_RWSEM_RT_H diff --git a/patches/rtmutex-wire-up-RT-s-locking.patch b/patches/rtmutex-wire-up-RT-s-locking.patch index 0040b7ecfac3..83005e2e0d74 100644 --- a/patches/rtmutex-wire-up-RT-s-locking.patch +++ b/patches/rtmutex-wire-up-RT-s-locking.patch @@ -63,7 +63,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> #endif +#ifdef CONFIG_PREEMPT_RT_FULL -+#include <linux/rwsem_rt.h> ++#include <linux/rwsem-rt.h> +#else /* PREEMPT_RT_FULL */ + struct rw_semaphore; diff --git a/patches/series b/patches/series index 6b16d5b07831..925859dc5531 100644 --- a/patches/series +++ b/patches/series @@ -11,23 +11,21 @@ tty-sysrq-Convert-show_lock-to-raw_spinlock_t.patch # POSTED by others ############################################################ # AT91 -# Alexandre Belloni | [PATCH 00/12] clocksource: improve Atmel TCB timer driver -# Date: Wed, 3 Apr 2019 16:11:08 +0200 +# Alexandre Belloni | [PATCH v3 0/9] clocksource: improve Atmel TCB timer driver +# Date: Fri, 26 Apr 2019 23:47:09 +0200 0001-ARM-at91-move-SoC-specific-definitions-to-SoC-folder.patch -0002-misc-atmel_tclib-drop-AVR32-support.patch -0003-misc-atmel_tclib-move-definitions-to-header-file.patch -0004-clocksource-drivers-tcb_clksrc-stop-depending-on-atm.patch -0005-clocksource-drivers-tcb_clksrc-Use-tcb-as-sched_cloc.patch -0006-ARM-at91-Implement-clocksource-selection.patch -0007-clocksource-drivers-tcb_clksrc-move-Kconfig-option.patch -0008-clocksource-drivers-timer-atmel-pit-rework-Kconfig-o.patch -0009-clocksource-drivers-tcb_clksrc-Rename-the-file-for-c.patch -0010-ARM-configs-at91-unselect-PIT.patch -0011-misc-atmel_tclib-do-not-probe-already-used-TCBs.patch -0012-clocksource-drivers-timer-atmel-tcb-Use-ARRAY_SIZE-i.patch +0002-clocksource-drivers-tcb_clksrc-stop-depending-on-atm.patch +0003-clocksource-drivers-tcb_clksrc-Use-tcb-as-sched_cloc.patch +0004-ARM-at91-Implement-clocksource-selection.patch +0005-clocksource-drivers-tcb_clksrc-move-Kconfig-option.patch +0006-clocksource-drivers-timer-atmel-pit-rework-Kconfig-o.patch +0007-clocksource-drivers-tcb_clksrc-Rename-the-file-for-c.patch +0008-clocksource-drivers-timer-atmel-tcb-tc_clksrc_suspen.patch +0009-misc-atmel_tclib-do-not-probe-already-used-TCBs.patch kthread-convert-worker-lock-to-raw-spinlock.patch sched-fair-Robustify-CFS-bandwidth-timer-locking.patch +x86-ima-Check-EFI_RUNTIME_SERVICES-before-using.patch # John's printk series # [RFC PATCH v1 00/25] printk: new implementation @@ -65,6 +63,7 @@ arm-remove-printk_nmi_.patch printk-only-allow-kernel-to-emergency-message.patch printk-devkmsg-llseek-reset-clear-if-it-is-lost.patch printk-print-rate-limitted-message-as-info.patch +printk-kmsg_dump-remove-mutex-usage.patch ############################################################ # POSTED @@ -109,6 +108,8 @@ drm-i915-Don-t-disable-interrupts-independently-of-t.patch 0025-x86-fpu-Add-a-fastpath-to-copy_fpstate_to_sigframe.patch 0026-x86-fpu-Restore-FPU-register-in-copy_fpstate_to_sigf.patch 0027-x86-pkeys-add-PKRU-value-to-init_fpstate.patch +0028-x86-fpu-Fault-in-user-stack-if-copy_fpstate_to_sigfr.patch +0029-x86-fpu-Remove-unnecessary-saving-of-FPU-registers-i.patch ############################################################ # Ready for posting diff --git a/patches/x86-ima-Check-EFI_RUNTIME_SERVICES-before-using.patch b/patches/x86-ima-Check-EFI_RUNTIME_SERVICES-before-using.patch new file mode 100644 index 000000000000..f3837ad94db6 --- /dev/null +++ b/patches/x86-ima-Check-EFI_RUNTIME_SERVICES-before-using.patch @@ -0,0 +1,31 @@ +From: Scott Wood <swood@redhat.com> +Date: Tue, 23 Apr 2019 17:48:07 -0500 +Subject: [PATCH] x86/ima: Check EFI_RUNTIME_SERVICES before using + +Checking efi_enabled(EFI_BOOT) is not sufficient to ensure that +EFI runtime services are available, e.g. if efi=noruntime is used. + +Without this, I get an oops on a PREEMPT_RT kernel where efi=noruntime is +the default. + +Fixes: 399574c64eaf94e8 ("x86/ima: retry detecting secure boot mode") +Signed-off-by: Scott Wood <swood@redhat.com> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + arch/x86/kernel/ima_arch.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/arch/x86/kernel/ima_arch.c ++++ b/arch/x86/kernel/ima_arch.c +@@ -17,6 +17,11 @@ static enum efi_secureboot_mode get_sb_m + + size = sizeof(secboot); + ++ if (!efi_enabled(EFI_RUNTIME_SERVICES)) { ++ pr_info("ima: secureboot mode unknown, no efi\n"); ++ return efi_secureboot_mode_unknown; ++ } ++ + /* Get variable contents into buffer */ + status = efi.get_variable(efi_SecureBoot_name, &efi_variable_guid, + NULL, &size, &secboot); |