Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1673737 > unrolled thread
| Started by | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| First post | 2017-06-23 20:00 +0200 |
| Last post | 2017-06-23 20:00 +0200 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v2 0/7] ARM: Broadcom Brahma-B15 readahead cache support Florian Fainelli <f.fainelli@gmail.com> - 2017-06-23 20:00 +0200
[PATCH v2 6/7] ARM: B15: Register reboot notifier for KEXEC Florian Fainelli <f.fainelli@gmail.com> - 2017-06-23 20:00 +0200
[PATCH v2 1/7] ARM: v7: allow setting different cache functions Florian Fainelli <f.fainelli@gmail.com> - 2017-06-23 20:00 +0200
[PATCH v2 5/7] ARM: B15: Add suspend/resume hooks Florian Fainelli <f.fainelli@gmail.com> - 2017-06-23 20:00 +0200
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-06-23 20:00 +0200 |
| Subject | [PATCH v2 0/7] ARM: Broadcom Brahma-B15 readahead cache support |
| Message-ID | <tVB29-5e4-5@gated-at.bofh.it> |
Hi all, This patch series adds support for the Broadcom Brahma-B15 readahead cache. I submitted that patch series a couple of years ago, and then slept on it so here is another stab at it. Note that we did not implement this cache as a version of an outer cache for several reasons: - we initially thought we needed to intercept flush_icache_all and flush_kern_cache_louis but upon further inspection we convinced ourselves this is no longer needed, still, flush_cache_all() needs special handling here and needs to be wrapped around - the outer cache does not allow differentiating a DMA transfer direction this is a readahead cache, so it does not participate in writes, flushing it during reads *and* writes kills the performance completely - finally, most operations that outer_cache cares about are on MVA, which is transparent to the readahead cache here Changes in v2: - clarify that the read-ahead caches does invalidates on writes (IOW) based on Russell's feedback Florian Fainelli (7): ARM: v7: allow setting different cache functions ARM: Add Broadcom Brahma-B15 readahead cache support ARM: Hook B15 readahead cache functions based on processor ARM: B15: Add CPU hotplug awareness ARM: B15: Add suspend/resume hooks ARM: B15: Register reboot notifier for KEXEC MAINTAINERS: Update brcmstb entries to cover B15 code MAINTAINERS | 2 + arch/arm/include/asm/glue-cache.h | 4 + arch/arm/include/asm/hardware/cache-b15-rac.h | 10 + arch/arm/mm/Kconfig | 8 + arch/arm/mm/Makefile | 1 + arch/arm/mm/cache-b15-rac.c | 360 ++++++++++++++++++++++++++ arch/arm/mm/cache-v7.S | 21 ++ arch/arm/mm/proc-v7.S | 6 +- include/linux/cpuhotplug.h | 2 + 9 files changed, 411 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/hardware/cache-b15-rac.h create mode 100644 arch/arm/mm/cache-b15-rac.c -- 2.9.3
[toc] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-06-23 20:00 +0200 |
| Subject | [PATCH v2 6/7] ARM: B15: Register reboot notifier for KEXEC |
| Message-ID | <tVB2a-5e4-19@gated-at.bofh.it> |
| In reply to | #1673737 |
During kexec, we will go through kernel_kexec() -> syscore_suspend() if
CONFIG_KEXEC_JUMP is set, if not, down the road we end-up calling
kernel_restart_prepare() which invokes reboot notifiers with
SYS_RESTART.
We register a reboot notifier to make sure that the B15 read-ahead cache
is disabled, since it is another level of instruction and data cache,
and we want to avoid any potential side effects with booting a new
kernel with such a cache still turned on.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
arch/arm/mm/cache-b15-rac.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/arch/arm/mm/cache-b15-rac.c b/arch/arm/mm/cache-b15-rac.c
index 9ee1d89cced0..f76988790011 100644
--- a/arch/arm/mm/cache-b15-rac.c
+++ b/arch/arm/mm/cache-b15-rac.c
@@ -16,6 +16,7 @@
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/syscore_ops.h>
+#include <linux/reboot.h>
#include <asm/cacheflush.h>
#include <asm/hardware/cache-b15-rac.h>
@@ -151,6 +152,29 @@ static void b15_rac_enable(void)
__b15_rac_enable(enable);
}
+static int b15_rac_reboot_notifier(struct notifier_block *nb,
+ unsigned long action,
+ void *data)
+{
+ /* During kexec, we are not yet migrated on the boot CPU, so we need to
+ * make sure we are SMP safe here. Once the RAC is disabled, flag it as
+ * suspended such that the hotplug notifier returns early.
+ */
+ if (action == SYS_RESTART) {
+ spin_lock(&rac_lock);
+ b15_rac_disable_and_flush();
+ clear_bit(RAC_ENABLED, &b15_rac_flags);
+ set_bit(RAC_SUSPENDED, &b15_rac_flags);
+ spin_unlock(&rac_lock);
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block b15_rac_reboot_nb = {
+ .notifier_call = b15_rac_reboot_notifier,
+};
+
#ifdef CONFIG_HOTPLUG_CPU
/* The CPU hotplug case is the most interesting one, we basically need to make
* sure that the RAC is disabled for the entire system prior to having a CPU
@@ -191,6 +215,12 @@ static void b15_rac_enable(void)
/* Running on the dying CPU */
static int b15_rac_dying_cpu(unsigned int cpu)
{
+ /* During kexec/reboot, the RAC is disabled via the reboot notifier
+ * return early here.
+ */
+ if (test_bit(RAC_SUSPENDED, &b15_rac_flags))
+ return 0;
+
spin_lock(&rac_lock);
/* Indicate that we are starting a hotplug procedure */
@@ -207,6 +237,12 @@ static int b15_rac_dying_cpu(unsigned int cpu)
/* Running on a non-dying CPU */
static int b15_rac_dead_cpu(unsigned int cpu)
{
+ /* During kexec/reboot, the RAC is disabled via the reboot notifier
+ * return early here.
+ */
+ if (test_bit(RAC_SUSPENDED, &b15_rac_flags))
+ return 0;
+
spin_lock(&rac_lock);
/* And enable it */
@@ -272,6 +308,13 @@ static int __init b15_rac_init(void)
goto out;
}
+ ret = register_reboot_notifier(&b15_rac_reboot_nb);
+ if (ret) {
+ pr_err("failed to register reboot notifier\n");
+ iounmap(b15_rac_base);
+ goto out;
+ }
+
#ifdef CONFIG_HOTPLUG_CPU
ret = cpuhp_setup_state_nocalls(CPUHP_AP_ARM_CACHE_B15_RAC_DEAD,
"arm/cache-b15-rac:dead",
@@ -308,6 +351,7 @@ static int __init b15_rac_init(void)
out_cpu_dead:
cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CACHE_B15_RAC_DYING);
out_unmap:
+ unregister_reboot_notifier(&b15_rac_reboot_nb);
iounmap(b15_rac_base);
out:
of_node_put(dn);
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-06-23 20:00 +0200 |
| Subject | [PATCH v2 1/7] ARM: v7: allow setting different cache functions |
| Message-ID | <tVB2a-5e4-29@gated-at.bofh.it> |
| In reply to | #1673737 |
In preparation for adding support for the Broadcom Brahma-B15 read-ahead cache which requires a different set of cache functions, allow the __v7_proc macro to override the cache_fns settings, and default to v7_cache_fns unless specified otherwise. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> --- arch/arm/mm/proc-v7.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index 01d64c0b2563..812ac861cd23 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S @@ -567,7 +567,7 @@ __v7_setup_stack: /* * Standard v7 proc info content */ -.macro __v7_proc name, initfunc, mm_mmuflags = 0, io_mmuflags = 0, hwcaps = 0, proc_fns = v7_processor_functions +.macro __v7_proc name, initfunc, mm_mmuflags = 0, io_mmuflags = 0, hwcaps = 0, proc_fns = v7_processor_functions, cache_fns = v7_cache_fns ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \ PMD_SECT_AF | PMD_FLAGS_SMP | \mm_mmuflags) ALT_UP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \ @@ -583,7 +583,7 @@ __v7_setup_stack: .long \proc_fns .long v7wbi_tlb_fns .long v6_user_fns - .long v7_cache_fns + .long \cache_fns .endm #ifndef CONFIG_ARM_LPAE -- 2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-06-23 20:00 +0200 |
| Subject | [PATCH v2 5/7] ARM: B15: Add suspend/resume hooks |
| Message-ID | <tVB2a-5e4-31@gated-at.bofh.it> |
| In reply to | #1673737 |
The Broadcom Brahma-B15 CPU readahead cache registers will be restored
to their Power-on-Reset values after a S3 suspend/resume cycles, so we
want to restore what we had enabled before.
Another thing we want to take care of is disabling the read-ahead cache
prior to suspending to avoid any sort of side effect with the spinlock
we need to grab to serialize register accesses.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
arch/arm/mm/cache-b15-rac.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/arch/arm/mm/cache-b15-rac.c b/arch/arm/mm/cache-b15-rac.c
index d85b63211759..9ee1d89cced0 100644
--- a/arch/arm/mm/cache-b15-rac.c
+++ b/arch/arm/mm/cache-b15-rac.c
@@ -15,6 +15,7 @@
#include <linux/of_address.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
+#include <linux/syscore_ops.h>
#include <asm/cacheflush.h>
#include <asm/hardware/cache-b15-rac.h>
@@ -41,6 +42,10 @@ extern void v7_flush_kern_cache_all(void);
RACENPREF_MASK << RACENDATA_SHIFT)
#define RAC_ENABLED 0
+/* Special state where we want to bypass the spinlock and call directly
+ * into the v7 cache maintenance operations during suspend/resume
+ */
+#define RAC_SUSPENDED 1
static void __iomem *b15_rac_base;
static DEFINE_SPINLOCK(rac_lock);
@@ -96,6 +101,12 @@ void b15_flush_##name(void) \
unsigned int do_flush; \
u32 val = 0; \
\
+ if (test_bit(RAC_SUSPENDED, &b15_rac_flags)) { \
+ v7_flush_##name(); \
+ bar; \
+ return; \
+ } \
+ \
spin_lock(&rac_lock); \
do_flush = test_bit(RAC_ENABLED, &b15_rac_flags); \
if (do_flush) \
@@ -208,6 +219,39 @@ static int b15_rac_dead_cpu(unsigned int cpu)
}
#endif /* CONFIG_HOTPLUG_CPU */
+#ifdef CONFIG_PM_SLEEP
+static int b15_rac_suspend(void)
+{
+ /* Suspend the read-ahead cache oeprations, forcing our cache
+ * implementation to fallback to the regular ARMv7 calls.
+ *
+ * We are guaranteed to be running on the boot CPU at this point and
+ * with every other CPU quiesced, so setting RAC_SUSPENDED is not racy
+ * here.
+ */
+ rac_config0_reg = b15_rac_disable_and_flush();
+ set_bit(RAC_SUSPENDED, &b15_rac_flags);
+
+ return 0;
+}
+
+static void b15_rac_resume(void)
+{
+ /* Coming out of a S3 suspend/resume cycle, the read-ahead cache
+ * register RAC_CONFIG0_REG will be restored to its default value, make
+ * sure we re-enable it and set the enable flag, we are also guaranteed
+ * to run on the boot CPU, so not racy again.
+ */
+ __b15_rac_enable(rac_config0_reg);
+ clear_bit(RAC_SUSPENDED, &b15_rac_flags);
+}
+
+static struct syscore_ops b15_rac_syscore_ops = {
+ .suspend = b15_rac_suspend,
+ .resume = b15_rac_resume,
+};
+#endif
+
static int __init b15_rac_init(void)
{
struct device_node *dn;
@@ -242,6 +286,10 @@ static int __init b15_rac_init(void)
goto out_cpu_dead;
#endif
+#ifdef CONFIG_PM_SLEEP
+ register_syscore_ops(&b15_rac_syscore_ops);
+#endif
+
spin_lock(&rac_lock);
reg = __raw_readl(b15_rac_base + RAC_CONFIG0_REG);
for_each_possible_cpu(cpu)
--
2.9.3
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web