From 6360ff8b150c479da010620fef7b9f893422ad84 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Mar 2018 07:27:11 +0100 Subject: [PATCH] 4.14-stable patches added patches: mips-implement-__multi3-for-gcc7-mips64r6-builds.patch powerpc-pseries-enable-ras-hotplug-events-later.patch --- ...nt-__multi3-for-gcc7-mips64r6-builds.patch | 145 ++++++++++++++++++ ...ries-enable-ras-hotplug-events-later.patch | 79 ++++++++++ queue-4.14/series | 2 + 3 files changed, 226 insertions(+) create mode 100644 queue-4.14/mips-implement-__multi3-for-gcc7-mips64r6-builds.patch create mode 100644 queue-4.14/powerpc-pseries-enable-ras-hotplug-events-later.patch diff --git a/queue-4.14/mips-implement-__multi3-for-gcc7-mips64r6-builds.patch b/queue-4.14/mips-implement-__multi3-for-gcc7-mips64r6-builds.patch new file mode 100644 index 00000000000..f924501354c --- /dev/null +++ b/queue-4.14/mips-implement-__multi3-for-gcc7-mips64r6-builds.patch @@ -0,0 +1,145 @@ +From ebabcf17bcd7ce968b1631ebe08236275698f39b Mon Sep 17 00:00:00 2001 +From: James Hogan +Date: Thu, 7 Dec 2017 07:20:46 +0000 +Subject: MIPS: Implement __multi3 for GCC7 MIPS64r6 builds + +From: James Hogan + +commit ebabcf17bcd7ce968b1631ebe08236275698f39b upstream. + +GCC7 is a bit too eager to generate suboptimal __multi3 calls (128bit +multiply with 128bit result) for MIPS64r6 builds, even in code which +doesn't explicitly use 128bit types, such as the following: + +unsigned long func(unsigned long a, unsigned long b) +{ + return a > (~0UL) / b; +} + +Which GCC rearanges to: + +return (unsigned __int128)a * (unsigned __int128)b > 0xffffffffffffffff; + +Therefore implement __multi3, but only for MIPS64r6 with GCC7 as under +normal circumstances we wouldn't expect any calls to __multi3 to be +generated from kernel code. + +Reported-by: Thomas Petazzoni +Signed-off-by: James Hogan +Tested-by: Waldemar Brodkorb +Cc: Ralf Baechle +Cc: Maciej W. Rozycki +Cc: Matthew Fortune +Cc: Florian Fainelli +Cc: linux-mips@linux-mips.org +Patchwork: https://patchwork.linux-mips.org/patch/17890/ +Cc: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman + +--- + arch/mips/lib/Makefile | 3 +- + arch/mips/lib/libgcc.h | 17 +++++++++++++++ + arch/mips/lib/multi3.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 73 insertions(+), 1 deletion(-) + +--- a/arch/mips/lib/Makefile ++++ b/arch/mips/lib/Makefile +@@ -16,4 +16,5 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb + obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o + + # libgcc-style stuff needed in the kernel +-obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o ++obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o multi3.o \ ++ ucmpdi2.o +--- a/arch/mips/lib/libgcc.h ++++ b/arch/mips/lib/libgcc.h +@@ -10,10 +10,18 @@ typedef int word_type __attribute__ ((mo + struct DWstruct { + int high, low; + }; ++ ++struct TWstruct { ++ long long high, low; ++}; + #elif defined(__LITTLE_ENDIAN) + struct DWstruct { + int low, high; + }; ++ ++struct TWstruct { ++ long long low, high; ++}; + #else + #error I feel sick. + #endif +@@ -23,4 +31,13 @@ typedef union { + long long ll; + } DWunion; + ++#if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPSR6) ++typedef int ti_type __attribute__((mode(TI))); ++ ++typedef union { ++ struct TWstruct s; ++ ti_type ti; ++} TWunion; ++#endif ++ + #endif /* __ASM_LIBGCC_H */ +--- /dev/null ++++ b/arch/mips/lib/multi3.c +@@ -0,0 +1,54 @@ ++// SPDX-License-Identifier: GPL-2.0 ++#include ++ ++#include "libgcc.h" ++ ++/* ++ * GCC 7 suboptimally generates __multi3 calls for mips64r6, so for that ++ * specific case only we'll implement it here. ++ * ++ * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82981 ++ */ ++#if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPSR6) && (__GNUC__ == 7) ++ ++/* multiply 64-bit values, low 64-bits returned */ ++static inline long long notrace dmulu(long long a, long long b) ++{ ++ long long res; ++ ++ asm ("dmulu %0,%1,%2" : "=r" (res) : "r" (a), "r" (b)); ++ return res; ++} ++ ++/* multiply 64-bit unsigned values, high 64-bits of 128-bit result returned */ ++static inline long long notrace dmuhu(long long a, long long b) ++{ ++ long long res; ++ ++ asm ("dmuhu %0,%1,%2" : "=r" (res) : "r" (a), "r" (b)); ++ return res; ++} ++ ++/* multiply 128-bit values, low 128-bits returned */ ++ti_type notrace __multi3(ti_type a, ti_type b) ++{ ++ TWunion res, aa, bb; ++ ++ aa.ti = a; ++ bb.ti = b; ++ ++ /* ++ * a * b = (a.lo * b.lo) ++ * + 2^64 * (a.hi * b.lo + a.lo * b.hi) ++ * [+ 2^128 * (a.hi * b.hi)] ++ */ ++ res.s.low = dmulu(aa.s.low, bb.s.low); ++ res.s.high = dmuhu(aa.s.low, bb.s.low); ++ res.s.high += dmulu(aa.s.high, bb.s.low); ++ res.s.high += dmulu(aa.s.low, bb.s.high); ++ ++ return res.ti; ++} ++EXPORT_SYMBOL(__multi3); ++ ++#endif /* 64BIT && CPU_MIPSR6 && GCC7 */ diff --git a/queue-4.14/powerpc-pseries-enable-ras-hotplug-events-later.patch b/queue-4.14/powerpc-pseries-enable-ras-hotplug-events-later.patch new file mode 100644 index 00000000000..515f39ba73d --- /dev/null +++ b/queue-4.14/powerpc-pseries-enable-ras-hotplug-events-later.patch @@ -0,0 +1,79 @@ +From c9dccf1d074a67d36c510845f663980d69e3409b Mon Sep 17 00:00:00 2001 +From: Sam Bobroff +Date: Mon, 12 Feb 2018 11:19:29 +1100 +Subject: powerpc/pseries: Enable RAS hotplug events later + +From: Sam Bobroff + +commit c9dccf1d074a67d36c510845f663980d69e3409b upstream. + +Currently if the kernel receives a memory hot-unplug event early +enough, it may get stuck in an infinite loop in +dissolve_free_huge_pages(). This appears as a stall just after: + + pseries-hotplug-mem: Attempting to hot-remove XX LMB(s) at YYYYYYYY + +It appears to be caused by "minimum_order" being uninitialized, due to +init_ras_IRQ() executing before hugetlb_init(). + +To correct this, extract the part of init_ras_IRQ() that enables +hotplug event processing and place it in the machine_late_initcall +phase, which is guaranteed to be after hugetlb_init() is called. + +Signed-off-by: Sam Bobroff +Acked-by: Balbir Singh +[mpe: Reorder the functions to make the diff readable] +Signed-off-by: Michael Ellerman +Signed-off-by: Greg Kroah-Hartman + +--- + arch/powerpc/platforms/pseries/ras.c | 31 ++++++++++++++++++++++--------- + 1 file changed, 22 insertions(+), 9 deletions(-) + +--- a/arch/powerpc/platforms/pseries/ras.c ++++ b/arch/powerpc/platforms/pseries/ras.c +@@ -49,6 +49,28 @@ static irqreturn_t ras_error_interrupt(i + + + /* ++ * Enable the hotplug interrupt late because processing them may touch other ++ * devices or systems (e.g. hugepages) that have not been initialized at the ++ * subsys stage. ++ */ ++int __init init_ras_hotplug_IRQ(void) ++{ ++ struct device_node *np; ++ ++ /* Hotplug Events */ ++ np = of_find_node_by_path("/event-sources/hot-plug-events"); ++ if (np != NULL) { ++ if (dlpar_workqueue_init() == 0) ++ request_event_sources_irqs(np, ras_hotplug_interrupt, ++ "RAS_HOTPLUG"); ++ of_node_put(np); ++ } ++ ++ return 0; ++} ++machine_late_initcall(pseries, init_ras_hotplug_IRQ); ++ ++/* + * Initialize handlers for the set of interrupts caused by hardware errors + * and power system events. + */ +@@ -66,15 +88,6 @@ static int __init init_ras_IRQ(void) + of_node_put(np); + } + +- /* Hotplug Events */ +- np = of_find_node_by_path("/event-sources/hot-plug-events"); +- if (np != NULL) { +- if (dlpar_workqueue_init() == 0) +- request_event_sources_irqs(np, ras_hotplug_interrupt, +- "RAS_HOTPLUG"); +- of_node_put(np); +- } +- + /* EPOW Events */ + np = of_find_node_by_path("/event-sources/epow-events"); + if (np != NULL) { diff --git a/queue-4.14/series b/queue-4.14/series index 705a92177fe..dbb517d2281 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -105,3 +105,5 @@ net-gianfar_ptp-move-set_fipers-to-spinlock-protecting-area.patch of_mdio-avoid-mdio-bus-removal-when-a-phy-is-missing.patch nfp-always-unmask-aux-interrupts-at-init.patch mlxsw-pci-wait-after-reset-before-accessing-hw.patch +mips-implement-__multi3-for-gcc7-mips64r6-builds.patch +powerpc-pseries-enable-ras-hotplug-events-later.patch -- 2.47.3