]> git.baikalelectronics.ru Git - kernel.git/commitdiff
MIPS: MSA: Fix a link error on `_init_msa_upper' with older GCC
authorMaciej W. Rozycki <macro@imgtec.com>
Tue, 17 May 2016 05:12:27 +0000 (06:12 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 17 May 2016 09:02:45 +0000 (11:02 +0200)
Fix a build regression from commit c9017757c532 ("MIPS: init upper 64b
of vector registers when MSA is first used"):

arch/mips/built-in.o: In function `enable_restore_fp_context':
traps.c:(.text+0xbb90): undefined reference to `_init_msa_upper'
traps.c:(.text+0xbb90): relocation truncated to fit: R_MIPS_26 against `_init_msa_upper'
traps.c:(.text+0xbef0): undefined reference to `_init_msa_upper'
traps.c:(.text+0xbef0): relocation truncated to fit: R_MIPS_26 against `_init_msa_upper'

to !CONFIG_CPU_HAS_MSA configurations with older GCC versions, which are
unable to figure out that calls to `_init_msa_upper' are indeed dead.
Of the many ways to tackle this failure choose the approach we have
already taken in `thread_msa_context_live'.

[ralf@linux-mips.org: Drop patch segment to junk file.]

Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: stable@vger.kernel.org # v3.16+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/13271/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/msa.h
arch/mips/kernel/traps.c

index bbb85fe21642f0e7f01b45bd4ba70076ed7a8b4c..6e4effa6f62611848831d8f48d793a96e5bfef71 100644 (file)
@@ -147,6 +147,19 @@ static inline void restore_msa(struct task_struct *t)
                _restore_msa(t);
 }
 
+static inline void init_msa_upper(void)
+{
+       /*
+        * Check cpu_has_msa only if it's a constant. This will allow the
+        * compiler to optimise out code for CPUs without MSA without adding
+        * an extra redundant check for CPUs with MSA.
+        */
+       if (__builtin_constant_p(cpu_has_msa) && !cpu_has_msa)
+               return;
+
+       _init_msa_upper();
+}
+
 #ifdef TOOLCHAIN_SUPPORTS_MSA
 
 #define __BUILD_MSA_CTL_REG(name, cs)                          \
index 56f4161b98b923a54210727d31cd97369fd2ad63..4a1712b5abdff6a2d3f3548901a479a05cb250ea 100644 (file)
@@ -1246,7 +1246,7 @@ static int enable_restore_fp_context(int msa)
                err = init_fpu();
                if (msa && !err) {
                        enable_msa();
-                       _init_msa_upper();
+                       init_msa_upper();
                        set_thread_flag(TIF_USEDMSA);
                        set_thread_flag(TIF_MSA_CTX_LIVE);
                }
@@ -1309,7 +1309,7 @@ static int enable_restore_fp_context(int msa)
         */
        prior_msa = test_and_set_thread_flag(TIF_MSA_CTX_LIVE);
        if (!prior_msa && was_fpu_owner) {
-               _init_msa_upper();
+               init_msa_upper();
 
                goto out;
        }
@@ -1326,7 +1326,7 @@ static int enable_restore_fp_context(int msa)
                 * of each vector register such that it cannot see data left
                 * behind by another task.
                 */
-               _init_msa_upper();
+               init_msa_upper();
        } else {
                /* We need to restore the vector context. */
                restore_msa(current);