]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.13/mips-msa-fix-a-link-error-on-_init_msa_upper-with-older-gcc.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.13 / mips-msa-fix-a-link-error-on-_init_msa_upper-with-older-gcc.patch
CommitLineData
e4a7c22d
GKH
1From e49d38488515057dba8f0c2ba4cfde5be4a7281f Mon Sep 17 00:00:00 2001
2From: "Maciej W. Rozycki" <macro@imgtec.com>
3Date: Tue, 17 May 2016 06:12:27 +0100
4Subject: MIPS: MSA: Fix a link error on `_init_msa_upper' with older GCC
5
6From: Maciej W. Rozycki <macro@imgtec.com>
7
8commit e49d38488515057dba8f0c2ba4cfde5be4a7281f upstream.
9
10Fix a build regression from commit c9017757c532 ("MIPS: init upper 64b
11of vector registers when MSA is first used"):
12
13arch/mips/built-in.o: In function `enable_restore_fp_context':
14traps.c:(.text+0xbb90): undefined reference to `_init_msa_upper'
15traps.c:(.text+0xbb90): relocation truncated to fit: R_MIPS_26 against `_init_msa_upper'
16traps.c:(.text+0xbef0): undefined reference to `_init_msa_upper'
17traps.c:(.text+0xbef0): relocation truncated to fit: R_MIPS_26 against `_init_msa_upper'
18
19to !CONFIG_CPU_HAS_MSA configurations with older GCC versions, which are
20unable to figure out that calls to `_init_msa_upper' are indeed dead.
21Of the many ways to tackle this failure choose the approach we have
22already taken in `thread_msa_context_live'.
23
24[ralf@linux-mips.org: Drop patch segment to junk file.]
25
26Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
27Cc: linux-mips@linux-mips.org
28Patchwork: https://patchwork.linux-mips.org/patch/13271/
29Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
30Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31
32---
33 arch/mips/include/asm/msa.h | 13 +++++++++++++
34 arch/mips/kernel/traps.c | 6 +++---
35 2 files changed, 16 insertions(+), 3 deletions(-)
36
37--- a/arch/mips/include/asm/msa.h
38+++ b/arch/mips/include/asm/msa.h
39@@ -147,6 +147,19 @@ static inline void restore_msa(struct ta
40 _restore_msa(t);
41 }
42
43+static inline void init_msa_upper(void)
44+{
45+ /*
46+ * Check cpu_has_msa only if it's a constant. This will allow the
47+ * compiler to optimise out code for CPUs without MSA without adding
48+ * an extra redundant check for CPUs with MSA.
49+ */
50+ if (__builtin_constant_p(cpu_has_msa) && !cpu_has_msa)
51+ return;
52+
53+ _init_msa_upper();
54+}
55+
56 #ifdef TOOLCHAIN_SUPPORTS_MSA
57
58 #define __BUILD_MSA_CTL_REG(name, cs) \
59--- a/arch/mips/kernel/traps.c
60+++ b/arch/mips/kernel/traps.c
61@@ -1241,7 +1241,7 @@ static int enable_restore_fp_context(int
62 err = init_fpu();
63 if (msa && !err) {
64 enable_msa();
65- _init_msa_upper();
66+ init_msa_upper();
67 set_thread_flag(TIF_USEDMSA);
68 set_thread_flag(TIF_MSA_CTX_LIVE);
69 }
70@@ -1304,7 +1304,7 @@ static int enable_restore_fp_context(int
71 */
72 prior_msa = test_and_set_thread_flag(TIF_MSA_CTX_LIVE);
73 if (!prior_msa && was_fpu_owner) {
74- _init_msa_upper();
75+ init_msa_upper();
76
77 goto out;
78 }
79@@ -1321,7 +1321,7 @@ static int enable_restore_fp_context(int
80 * of each vector register such that it cannot see data left
81 * behind by another task.
82 */
83- _init_msa_upper();
84+ init_msa_upper();
85 } else {
86 /* We need to restore the vector context. */
87 restore_msa(current);