* [PATCH] MIPS: Avoid a BUG warning during prctl(PR_SET_FP_MODE, ...)
@ 2016-08-31 10:33 Marcin Nowakowski
2016-08-31 10:33 ` Marcin Nowakowski
2016-09-19 14:11 ` Ralf Baechle
0 siblings, 2 replies; 3+ messages in thread
From: Marcin Nowakowski @ 2016-08-31 10:33 UTC (permalink / raw)
To: linux-mips; +Cc: ralf, Marcin Nowakowski
cpu_has_fpu macro uses smp_processor_id() and is currently executed
with preemption enabled, that triggers the warning at runtime.
It is assumed throughout the kernel that if any CPU has an FPU, then all
CPUs would have an FPU as well, so it is safe to perform the check with
preemption enabled - change the code to use raw_ variant of the check to
avoid the warning.
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
---
arch/mips/kernel/process.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 7429ad0..d2d0615 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -605,14 +605,14 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
return -EOPNOTSUPP;
/* Avoid inadvertently triggering emulation */
- if ((value & PR_FP_MODE_FR) && cpu_has_fpu &&
- !(current_cpu_data.fpu_id & MIPS_FPIR_F64))
+ if ((value & PR_FP_MODE_FR) && raw_cpu_has_fpu &&
+ !(raw_current_cpu_data.fpu_id & MIPS_FPIR_F64))
return -EOPNOTSUPP;
- if ((value & PR_FP_MODE_FRE) && cpu_has_fpu && !cpu_has_fre)
+ if ((value & PR_FP_MODE_FRE) && raw_cpu_has_fpu && !cpu_has_fre)
return -EOPNOTSUPP;
/* FR = 0 not supported in MIPS R6 */
- if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
+ if (!(value & PR_FP_MODE_FR) && raw_cpu_has_fpu && cpu_has_mips_r6)
return -EOPNOTSUPP;
/* Proceed with the mode switch */
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] MIPS: Avoid a BUG warning during prctl(PR_SET_FP_MODE, ...)
2016-08-31 10:33 [PATCH] MIPS: Avoid a BUG warning during prctl(PR_SET_FP_MODE, ...) Marcin Nowakowski
@ 2016-08-31 10:33 ` Marcin Nowakowski
2016-09-19 14:11 ` Ralf Baechle
1 sibling, 0 replies; 3+ messages in thread
From: Marcin Nowakowski @ 2016-08-31 10:33 UTC (permalink / raw)
To: linux-mips; +Cc: ralf, Marcin Nowakowski
cpu_has_fpu macro uses smp_processor_id() and is currently executed
with preemption enabled, that triggers the warning at runtime.
It is assumed throughout the kernel that if any CPU has an FPU, then all
CPUs would have an FPU as well, so it is safe to perform the check with
preemption enabled - change the code to use raw_ variant of the check to
avoid the warning.
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
---
arch/mips/kernel/process.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 7429ad0..d2d0615 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -605,14 +605,14 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
return -EOPNOTSUPP;
/* Avoid inadvertently triggering emulation */
- if ((value & PR_FP_MODE_FR) && cpu_has_fpu &&
- !(current_cpu_data.fpu_id & MIPS_FPIR_F64))
+ if ((value & PR_FP_MODE_FR) && raw_cpu_has_fpu &&
+ !(raw_current_cpu_data.fpu_id & MIPS_FPIR_F64))
return -EOPNOTSUPP;
- if ((value & PR_FP_MODE_FRE) && cpu_has_fpu && !cpu_has_fre)
+ if ((value & PR_FP_MODE_FRE) && raw_cpu_has_fpu && !cpu_has_fre)
return -EOPNOTSUPP;
/* FR = 0 not supported in MIPS R6 */
- if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
+ if (!(value & PR_FP_MODE_FR) && raw_cpu_has_fpu && cpu_has_mips_r6)
return -EOPNOTSUPP;
/* Proceed with the mode switch */
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Avoid a BUG warning during prctl(PR_SET_FP_MODE, ...)
2016-08-31 10:33 [PATCH] MIPS: Avoid a BUG warning during prctl(PR_SET_FP_MODE, ...) Marcin Nowakowski
2016-08-31 10:33 ` Marcin Nowakowski
@ 2016-09-19 14:11 ` Ralf Baechle
1 sibling, 0 replies; 3+ messages in thread
From: Ralf Baechle @ 2016-09-19 14:11 UTC (permalink / raw)
To: Marcin Nowakowski; +Cc: linux-mips
On Wed, Aug 31, 2016 at 12:33:23PM +0200, Marcin Nowakowski wrote:
> cpu_has_fpu macro uses smp_processor_id() and is currently executed
> with preemption enabled, that triggers the warning at runtime.
>
> It is assumed throughout the kernel that if any CPU has an FPU, then all
> CPUs would have an FPU as well, so it is safe to perform the check with
> preemption enabled - change the code to use raw_ variant of the check to
> avoid the warning.
(Resending this, doesn't seem to have gone out the first time.)
That assumption is wrong. With VSMP and previously also SMTC kernels
there used to be CPU configurations where a single core had only one FPU
which would be associated with (virtual) processor 0.
There are some older discrete MP systems where not necessarily all CPUs
and FPUs have the save revision and handling FPU errata may have require
disabling some but not all FPUs.
But in all practice, your patch is probably a good solution before
something sort out all the othe issues with mixed CPU/FPU versions.
Ralf
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-19 14:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-31 10:33 [PATCH] MIPS: Avoid a BUG warning during prctl(PR_SET_FP_MODE, ...) Marcin Nowakowski
2016-08-31 10:33 ` Marcin Nowakowski
2016-09-19 14:11 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox