Blame view
arch/arm/vfp/vfpmodule.c
15.8 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 |
/* * linux/arch/arm/vfp/vfpmodule.c * * Copyright (C) 2004 ARM Limited. * Written by Deep Blue Solutions Limited. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ |
1da177e4c Linux-2.6.12-rc2 |
11 |
#include <linux/types.h> |
90b44199e ARM: VFP: re-init... |
12 |
#include <linux/cpu.h> |
746a9d196 ARM: vfp: Use cpu... |
13 |
#include <linux/cpu_pm.h> |
1da177e4c Linux-2.6.12-rc2 |
14 |
#include <linux/kernel.h> |
90b44199e ARM: VFP: re-init... |
15 |
#include <linux/notifier.h> |
1da177e4c Linux-2.6.12-rc2 |
16 17 |
#include <linux/signal.h> #include <linux/sched.h> |
90b44199e ARM: VFP: re-init... |
18 |
#include <linux/smp.h> |
1da177e4c Linux-2.6.12-rc2 |
19 |
#include <linux/init.h> |
d6551e884 [ARM] Add thread_... |
20 |
|
5aaf25440 ARM: 6203/1: Make... |
21 |
#include <asm/cputype.h> |
d6551e884 [ARM] Add thread_... |
22 |
#include <asm/thread_notify.h> |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 26 27 28 29 30 31 32 |
#include <asm/vfp.h> #include "vfpinstr.h" #include "vfp.h" /* * Our undef handlers (in entry.S) */ void vfp_testing_entry(void); void vfp_support_entry(void); |
5d4cae5fe [ARM] VFP: fix se... |
33 |
void vfp_null_entry(void); |
1da177e4c Linux-2.6.12-rc2 |
34 |
|
5d4cae5fe [ARM] VFP: fix se... |
35 |
void (*vfp_vector)(void) = vfp_null_entry; |
af61bdf03 ARM: vfp: rename ... |
36 37 |
/* |
f8f2a8522 ARM: vfp: fix a h... |
38 39 40 41 42 43 44 |
* Dual-use variable. * Used in startup: set to non-zero if VFP checks fail * After startup, holds VFP architecture */ unsigned int VFP_arch; /* |
af61bdf03 ARM: vfp: rename ... |
45 46 47 |
* The pointer to the vfpstate structure of the thread which currently * owns the context held in the VFP hardware, or NULL if the hardware * context is invalid. |
f8f2a8522 ARM: vfp: fix a h... |
48 49 50 51 |
* * For UP, this is sufficient to tell which thread owns the VFP context. * However, for SMP, we also need to check the CPU number stored in the * saved state too to catch migrations. |
af61bdf03 ARM: vfp: rename ... |
52 53 |
*/ union vfp_state *vfp_current_hw_state[NR_CPUS]; |
1da177e4c Linux-2.6.12-rc2 |
54 55 |
/* |
f8f2a8522 ARM: vfp: fix a h... |
56 57 |
* Is 'thread's most up to date state stored in this CPUs hardware? * Must be called from non-preemptible context. |
1da177e4c Linux-2.6.12-rc2 |
58 |
*/ |
f8f2a8522 ARM: vfp: fix a h... |
59 60 61 62 63 64 65 66 67 68 69 70 |
static bool vfp_state_in_hw(unsigned int cpu, struct thread_info *thread) { #ifdef CONFIG_SMP if (thread->vfpstate.hard.cpu != cpu) return false; #endif return vfp_current_hw_state[cpu] == &thread->vfpstate; } /* * Force a reload of the VFP context from the thread structure. We do * this by ensuring that access to the VFP hardware is disabled, and |
48af9feab ARM: vfp: Fix the... |
71 |
* clear vfp_current_hw_state. Must be called from non-preemptible context. |
f8f2a8522 ARM: vfp: fix a h... |
72 73 74 75 76 77 78 79 80 81 82 |
*/ static void vfp_force_reload(unsigned int cpu, struct thread_info *thread) { if (vfp_state_in_hw(cpu, thread)) { fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); vfp_current_hw_state[cpu] = NULL; } #ifdef CONFIG_SMP thread->vfpstate.hard.cpu = NR_CPUS; #endif } |
1da177e4c Linux-2.6.12-rc2 |
83 |
|
0d782dc43 ARM: VFP: fix vfp... |
84 85 86 87 88 89 90 |
/* * Per-thread VFP initialization. */ static void vfp_thread_flush(struct thread_info *thread) { union vfp_state *vfp = &thread->vfpstate; unsigned int cpu; |
0d782dc43 ARM: VFP: fix vfp... |
91 92 |
/* * Disable VFP to ensure we initialize it first. We must ensure |
19dad35fe ARM: vfp: ensure ... |
93 94 95 96 97 |
* that the modification of vfp_current_hw_state[] and hardware * disable are done for the same CPU and without preemption. * * Do this first to ensure that preemption won't overwrite our * state saving should access to the VFP be enabled at this point. |
0d782dc43 ARM: VFP: fix vfp... |
98 99 |
*/ cpu = get_cpu(); |
af61bdf03 ARM: vfp: rename ... |
100 101 |
if (vfp_current_hw_state[cpu] == vfp) vfp_current_hw_state[cpu] = NULL; |
0d782dc43 ARM: VFP: fix vfp... |
102 103 |
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); put_cpu(); |
19dad35fe ARM: vfp: ensure ... |
104 105 106 107 108 109 110 111 |
memset(vfp, 0, sizeof(union vfp_state)); vfp->hard.fpexc = FPEXC_EN; vfp->hard.fpscr = FPSCR_ROUND_NEAREST; #ifdef CONFIG_SMP vfp->hard.cpu = NR_CPUS; #endif |
0d782dc43 ARM: VFP: fix vfp... |
112 |
} |
797245f5d ARM: Convert VFP/... |
113 |
static void vfp_thread_exit(struct thread_info *thread) |
0d782dc43 ARM: VFP: fix vfp... |
114 115 116 |
{ /* release case: Per-thread VFP cleanup. */ union vfp_state *vfp = &thread->vfpstate; |
797245f5d ARM: Convert VFP/... |
117 |
unsigned int cpu = get_cpu(); |
0d782dc43 ARM: VFP: fix vfp... |
118 |
|
af61bdf03 ARM: vfp: rename ... |
119 120 |
if (vfp_current_hw_state[cpu] == vfp) vfp_current_hw_state[cpu] = NULL; |
797245f5d ARM: Convert VFP/... |
121 |
put_cpu(); |
0d782dc43 ARM: VFP: fix vfp... |
122 |
} |
c98c09773 ARM: 6868/1: Pres... |
123 124 125 126 127 128 |
static void vfp_thread_copy(struct thread_info *thread) { struct thread_info *parent = current_thread_info(); vfp_sync_hwstate(parent); thread->vfpstate = parent->vfpstate; |
f8f2a8522 ARM: vfp: fix a h... |
129 130 131 |
#ifdef CONFIG_SMP thread->vfpstate.hard.cpu = NR_CPUS; #endif |
c98c09773 ARM: 6868/1: Pres... |
132 |
} |
0d782dc43 ARM: VFP: fix vfp... |
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
/* * When this function is called with the following 'cmd's, the following * is true while this function is being run: * THREAD_NOFTIFY_SWTICH: * - the previously running thread will not be scheduled onto another CPU. * - the next thread to be run (v) will not be running on another CPU. * - thread->cpu is the local CPU number * - not preemptible as we're called in the middle of a thread switch * THREAD_NOTIFY_FLUSH: * - the thread (v) will be running on the local CPU, so * v === current_thread_info() * - thread->cpu is the local CPU number at the time it is accessed, * but may change at any time. * - we could be preempted if tree preempt rcu is enabled, so * it is unsafe to use thread->cpu. |
797245f5d ARM: Convert VFP/... |
148 149 150 151 152 153 154 |
* THREAD_NOTIFY_EXIT * - the thread (v) will be running on the local CPU, so * v === current_thread_info() * - thread->cpu is the local CPU number at the time it is accessed, * but may change at any time. * - we could be preempted if tree preempt rcu is enabled, so * it is unsafe to use thread->cpu. |
0d782dc43 ARM: VFP: fix vfp... |
155 |
*/ |
d6551e884 [ARM] Add thread_... |
156 |
static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v) |
1da177e4c Linux-2.6.12-rc2 |
157 |
{ |
d6551e884 [ARM] Add thread_... |
158 |
struct thread_info *thread = v; |
2e82669ac ARM: 6867/1: Intr... |
159 160 161 162 |
u32 fpexc; #ifdef CONFIG_SMP unsigned int cpu; #endif |
1da177e4c Linux-2.6.12-rc2 |
163 |
|
2e82669ac ARM: 6867/1: Intr... |
164 165 166 |
switch (cmd) { case THREAD_NOTIFY_SWITCH: fpexc = fmrx(FPEXC); |
c64284648 [ARM] 4111/1: All... |
167 168 |
#ifdef CONFIG_SMP |
2e82669ac ARM: 6867/1: Intr... |
169 |
cpu = thread->cpu; |
0d782dc43 ARM: VFP: fix vfp... |
170 |
|
c64284648 [ARM] 4111/1: All... |
171 172 173 174 175 |
/* * On SMP, if VFP is enabled, save the old state in * case the thread migrates to a different CPU. The * restoring is done lazily. */ |
f8f2a8522 ARM: vfp: fix a h... |
176 |
if ((fpexc & FPEXC_EN) && vfp_current_hw_state[cpu]) |
af61bdf03 ARM: vfp: rename ... |
177 |
vfp_save_state(vfp_current_hw_state[cpu], fpexc); |
c64284648 [ARM] 4111/1: All... |
178 |
#endif |
681a4991f [ARM] Optimise VF... |
179 180 181 182 |
/* * Always disable VFP so we can lazily save/restore the * old state. */ |
228adef16 [ARM] vfp: make f... |
183 |
fmxr(FPEXC, fpexc & ~FPEXC_EN); |
2e82669ac ARM: 6867/1: Intr... |
184 |
break; |
681a4991f [ARM] Optimise VF... |
185 |
|
2e82669ac ARM: 6867/1: Intr... |
186 |
case THREAD_NOTIFY_FLUSH: |
0d782dc43 ARM: VFP: fix vfp... |
187 |
vfp_thread_flush(thread); |
2e82669ac ARM: 6867/1: Intr... |
188 189 190 |
break; case THREAD_NOTIFY_EXIT: |
797245f5d ARM: Convert VFP/... |
191 |
vfp_thread_exit(thread); |
c98c09773 ARM: 6868/1: Pres... |
192 193 194 195 |
break; case THREAD_NOTIFY_COPY: vfp_thread_copy(thread); |
2e82669ac ARM: 6867/1: Intr... |
196 197 |
break; } |
681a4991f [ARM] Optimise VF... |
198 |
|
d6551e884 [ARM] Add thread_... |
199 |
return NOTIFY_DONE; |
1da177e4c Linux-2.6.12-rc2 |
200 |
} |
d6551e884 [ARM] Add thread_... |
201 202 203 |
static struct notifier_block vfp_notifier_block = { .notifier_call = vfp_notifier, }; |
1da177e4c Linux-2.6.12-rc2 |
204 205 206 207 |
/* * Raise a SIGFPE for the current process. * sicode describes the signal being raised. */ |
2bbd7e9b7 ARM: fix some spa... |
208 |
static void vfp_raise_sigfpe(unsigned int sicode, struct pt_regs *regs) |
1da177e4c Linux-2.6.12-rc2 |
209 210 211 212 213 214 215 |
{ siginfo_t info; memset(&info, 0, sizeof(info)); info.si_signo = SIGFPE; info.si_code = sicode; |
35d59fc5d [PATCH] arm __use... |
216 |
info.si_addr = (void __user *)(instruction_pointer(regs) - 4); |
1da177e4c Linux-2.6.12-rc2 |
217 218 219 220 221 222 223 |
/* * This is the same as NWFPE, because it's not clear what * this is used for */ current->thread.error_code = 0; current->thread.trap_no = 6; |
da41119af [PATCH] ARM: Don'... |
224 |
send_sig_info(SIGFPE, &info, current); |
1da177e4c Linux-2.6.12-rc2 |
225 |
} |
c98929c07 [ARM] 4582/2: Add... |
226 |
static void vfp_panic(char *reason, u32 inst) |
1da177e4c Linux-2.6.12-rc2 |
227 228 229 230 231 232 233 |
{ int i; printk(KERN_ERR "VFP: Error: %s ", reason); printk(KERN_ERR "VFP: EXC 0x%08x SCR 0x%08x INST 0x%08x ", |
c98929c07 [ARM] 4582/2: Add... |
234 |
fmrx(FPEXC), fmrx(FPSCR), inst); |
1da177e4c Linux-2.6.12-rc2 |
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
for (i = 0; i < 32; i += 2) printk(KERN_ERR "VFP: s%2u: 0x%08x s%2u: 0x%08x ", i, vfp_get_float(i), i+1, vfp_get_float(i+1)); } /* * Process bitmask of exception conditions. */ static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_regs *regs) { int si_code = 0; pr_debug("VFP: raising exceptions %08x ", exceptions); |
7c6f25141 [ARM] 3748/3: Cor... |
250 |
if (exceptions == VFP_EXCEPTION_ERROR) { |
c98929c07 [ARM] 4582/2: Add... |
251 |
vfp_panic("unhandled bounce", inst); |
1da177e4c Linux-2.6.12-rc2 |
252 253 254 255 256 |
vfp_raise_sigfpe(0, regs); return; } /* |
dbead4058 ARM: 5909/1: ARM:... |
257 |
* If any of the status flags are set, update the FPSCR. |
1da177e4c Linux-2.6.12-rc2 |
258 259 260 |
* Comparison instructions always return at least one of * these flags set. */ |
dbead4058 ARM: 5909/1: ARM:... |
261 262 |
if (exceptions & (FPSCR_N|FPSCR_Z|FPSCR_C|FPSCR_V)) fpscr &= ~(FPSCR_N|FPSCR_Z|FPSCR_C|FPSCR_V); |
1da177e4c Linux-2.6.12-rc2 |
263 264 265 266 267 268 269 270 271 272 273 |
fpscr |= exceptions; fmxr(FPSCR, fpscr); #define RAISE(stat,en,sig) \ if (exceptions & stat && fpscr & en) \ si_code = sig; /* * These are arranged in priority order, least to highest. */ |
e0f205d9c [ARM] 3900/1: Fix... |
274 |
RAISE(FPSCR_DZC, FPSCR_DZE, FPE_FLTDIV); |
1da177e4c Linux-2.6.12-rc2 |
275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
RAISE(FPSCR_IXC, FPSCR_IXE, FPE_FLTRES); RAISE(FPSCR_UFC, FPSCR_UFE, FPE_FLTUND); RAISE(FPSCR_OFC, FPSCR_OFE, FPE_FLTOVF); RAISE(FPSCR_IOC, FPSCR_IOE, FPE_FLTINV); if (si_code) vfp_raise_sigfpe(si_code, regs); } /* * Emulate a VFP instruction. */ static u32 vfp_emulate_instruction(u32 inst, u32 fpscr, struct pt_regs *regs) { |
7c6f25141 [ARM] 3748/3: Cor... |
289 |
u32 exceptions = VFP_EXCEPTION_ERROR; |
1da177e4c Linux-2.6.12-rc2 |
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
pr_debug("VFP: emulate: INST=0x%08x SCR=0x%08x ", inst, fpscr); if (INST_CPRTDO(inst)) { if (!INST_CPRT(inst)) { /* * CPDO */ if (vfp_single(inst)) { exceptions = vfp_single_cpdo(inst, fpscr); } else { exceptions = vfp_double_cpdo(inst, fpscr); } } else { /* * A CPRT instruction can not appear in FPINST2, nor * can it cause an exception. Therefore, we do not * have to emulate it. */ } } else { /* * A CPDT instruction can not appear in FPINST2, nor can * it cause an exception. Therefore, we do not have to * emulate it. */ } |
928bd1b47 [ARM] vfp: fix le... |
318 |
return exceptions & ~VFP_NAN_FLAG; |
1da177e4c Linux-2.6.12-rc2 |
319 320 321 322 323 |
} /* * Package up a bounce condition. */ |
c98929c07 [ARM] 4582/2: Add... |
324 |
void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs) |
1da177e4c Linux-2.6.12-rc2 |
325 |
{ |
c98929c07 [ARM] 4582/2: Add... |
326 |
u32 fpscr, orig_fpscr, fpsid, exceptions; |
1da177e4c Linux-2.6.12-rc2 |
327 328 329 330 331 |
pr_debug("VFP: bounce: trigger %08x fpexc %08x ", trigger, fpexc); /* |
c98929c07 [ARM] 4582/2: Add... |
332 333 334 335 336 337 338 339 340 341 342 |
* At this point, FPEXC can have the following configuration: * * EX DEX IXE * 0 1 x - synchronous exception * 1 x 0 - asynchronous exception * 1 x 1 - sychronous on VFP subarch 1 and asynchronous on later * 0 0 1 - synchronous on VFP9 (non-standard subarch 1 * implementation), undefined otherwise * * Clear various bits and enable access to the VFP so we can * handle the bounce. |
1da177e4c Linux-2.6.12-rc2 |
343 |
*/ |
c98929c07 [ARM] 4582/2: Add... |
344 |
fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_DEX|FPEXC_FP2V|FPEXC_VV|FPEXC_TRAP_MASK)); |
1da177e4c Linux-2.6.12-rc2 |
345 |
|
c98929c07 [ARM] 4582/2: Add... |
346 |
fpsid = fmrx(FPSID); |
1da177e4c Linux-2.6.12-rc2 |
347 348 349 |
orig_fpscr = fpscr = fmrx(FPSCR); /* |
c98929c07 [ARM] 4582/2: Add... |
350 |
* Check for the special VFP subarch 1 and FPSCR.IXE bit case |
1da177e4c Linux-2.6.12-rc2 |
351 |
*/ |
c98929c07 [ARM] 4582/2: Add... |
352 353 354 355 356 |
if ((fpsid & FPSID_ARCH_MASK) == (1 << FPSID_ARCH_BIT) && (fpscr & FPSCR_IXE)) { /* * Synchronous exception, emulate the trigger instruction */ |
1da177e4c Linux-2.6.12-rc2 |
357 358 |
goto emulate; } |
c98929c07 [ARM] 4582/2: Add... |
359 |
if (fpexc & FPEXC_EX) { |
85d6943af Fix the VFP handl... |
360 |
#ifndef CONFIG_CPU_FEROCEON |
c98929c07 [ARM] 4582/2: Add... |
361 362 363 364 365 366 |
/* * Asynchronous exception. The instruction is read from FPINST * and the interrupted instruction has to be restarted. */ trigger = fmrx(FPINST); regs->ARM_pc -= 4; |
85d6943af Fix the VFP handl... |
367 |
#endif |
c98929c07 [ARM] 4582/2: Add... |
368 369 370 371 372 373 374 |
} else if (!(fpexc & FPEXC_DEX)) { /* * Illegal combination of bits. It can be caused by an * unallocated VFP instruction but with FPSCR.IXE set and not * on VFP subarch 1. */ vfp_raise_exceptions(VFP_EXCEPTION_ERROR, trigger, fpscr, regs); |
f2255be81 [ARM] 5440/1: Fix... |
375 |
goto exit; |
c98929c07 [ARM] 4582/2: Add... |
376 |
} |
1da177e4c Linux-2.6.12-rc2 |
377 378 |
/* |
c98929c07 [ARM] 4582/2: Add... |
379 380 381 |
* Modify fpscr to indicate the number of iterations remaining. * If FPEXC.EX is 0, FPEXC.DEX is 1 and the FPEXC.VV bit indicates * whether FPEXC.VECITR or FPSCR.LEN is used. |
1da177e4c Linux-2.6.12-rc2 |
382 |
*/ |
c98929c07 [ARM] 4582/2: Add... |
383 |
if (fpexc & (FPEXC_EX | FPEXC_VV)) { |
1da177e4c Linux-2.6.12-rc2 |
384 385 386 387 388 389 390 391 392 393 394 395 396 |
u32 len; len = fpexc + (1 << FPEXC_LENGTH_BIT); fpscr &= ~FPSCR_LENGTH_MASK; fpscr |= (len & FPEXC_LENGTH_MASK) << (FPSCR_LENGTH_BIT - FPEXC_LENGTH_BIT); } /* * Handle the first FP instruction. We used to take note of the * FPEXC bounce reason, but this appears to be unreliable. * Emulate the bounced instruction instead. */ |
c98929c07 [ARM] 4582/2: Add... |
397 |
exceptions = vfp_emulate_instruction(trigger, fpscr, regs); |
1da177e4c Linux-2.6.12-rc2 |
398 |
if (exceptions) |
c98929c07 [ARM] 4582/2: Add... |
399 |
vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs); |
1da177e4c Linux-2.6.12-rc2 |
400 401 |
/* |
c98929c07 [ARM] 4582/2: Add... |
402 403 |
* If there isn't a second FP instruction, exit now. Note that * the FPEXC.FP2V bit is valid only if FPEXC.EX is 1. |
1da177e4c Linux-2.6.12-rc2 |
404 |
*/ |
c98929c07 [ARM] 4582/2: Add... |
405 |
if (fpexc ^ (FPEXC_EX | FPEXC_FP2V)) |
f2255be81 [ARM] 5440/1: Fix... |
406 |
goto exit; |
1da177e4c Linux-2.6.12-rc2 |
407 408 409 410 411 412 413 |
/* * The barrier() here prevents fpinst2 being read * before the condition above. */ barrier(); trigger = fmrx(FPINST2); |
1da177e4c Linux-2.6.12-rc2 |
414 415 |
emulate: |
c98929c07 [ARM] 4582/2: Add... |
416 |
exceptions = vfp_emulate_instruction(trigger, orig_fpscr, regs); |
1da177e4c Linux-2.6.12-rc2 |
417 418 |
if (exceptions) vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs); |
f2255be81 [ARM] 5440/1: Fix... |
419 420 |
exit: preempt_enable(); |
1da177e4c Linux-2.6.12-rc2 |
421 |
} |
efe90d273 [ARM] Handle HWCA... |
422 |
|
8e140362f [ARM] Fix VFP ini... |
423 424 425 426 427 428 429 430 431 |
static void vfp_enable(void *unused) { u32 access = get_copro_access(); /* * Enable full access to VFP (cp10 and cp11) */ set_copro_access(access | CPACC_FULL(10) | CPACC_FULL(11)); } |
746a9d196 ARM: vfp: Use cpu... |
432 |
#ifdef CONFIG_CPU_PM |
328f5cc30 ARM: Use struct s... |
433 |
static int vfp_pm_suspend(void) |
fc0b7a203 [ARM] 5349/1: VFP... |
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
{ struct thread_info *ti = current_thread_info(); u32 fpexc = fmrx(FPEXC); /* if vfp is on, then save state for resumption */ if (fpexc & FPEXC_EN) { printk(KERN_DEBUG "%s: saving vfp state ", __func__); vfp_save_state(&ti->vfpstate, fpexc); /* disable, just in case */ fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); } /* clear any information we had about last context state */ |
af61bdf03 ARM: vfp: rename ... |
449 |
memset(vfp_current_hw_state, 0, sizeof(vfp_current_hw_state)); |
fc0b7a203 [ARM] 5349/1: VFP... |
450 451 452 |
return 0; } |
328f5cc30 ARM: Use struct s... |
453 |
static void vfp_pm_resume(void) |
fc0b7a203 [ARM] 5349/1: VFP... |
454 455 456 457 458 459 |
{ /* ensure we have access to the vfp */ vfp_enable(NULL); /* and disable it to ensure the next usage restores the state */ fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); |
fc0b7a203 [ARM] 5349/1: VFP... |
460 |
} |
746a9d196 ARM: vfp: Use cpu... |
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
static int vfp_cpu_pm_notifier(struct notifier_block *self, unsigned long cmd, void *v) { switch (cmd) { case CPU_PM_ENTER: vfp_pm_suspend(); break; case CPU_PM_ENTER_FAILED: case CPU_PM_EXIT: vfp_pm_resume(); break; } return NOTIFY_OK; } static struct notifier_block vfp_cpu_pm_notifier_block = { .notifier_call = vfp_cpu_pm_notifier, |
fc0b7a203 [ARM] 5349/1: VFP... |
478 |
}; |
fc0b7a203 [ARM] 5349/1: VFP... |
479 480 |
static void vfp_pm_init(void) { |
746a9d196 ARM: vfp: Use cpu... |
481 |
cpu_pm_register_notifier(&vfp_cpu_pm_notifier_block); |
fc0b7a203 [ARM] 5349/1: VFP... |
482 |
} |
fc0b7a203 [ARM] 5349/1: VFP... |
483 484 |
#else static inline void vfp_pm_init(void) { } |
746a9d196 ARM: vfp: Use cpu... |
485 |
#endif /* CONFIG_CPU_PM */ |
fc0b7a203 [ARM] 5349/1: VFP... |
486 |
|
f8f2a8522 ARM: vfp: fix a h... |
487 488 489 490 |
/* * Ensure that the VFP state stored in 'thread->vfpstate' is up to date * with the hardware state. */ |
ad187f956 ARM: vfp ptrace: ... |
491 |
void vfp_sync_hwstate(struct thread_info *thread) |
3d1228ead [ARM] 5387/1: Add... |
492 493 |
{ unsigned int cpu = get_cpu(); |
3d1228ead [ARM] 5387/1: Add... |
494 |
|
f8f2a8522 ARM: vfp: fix a h... |
495 |
if (vfp_state_in_hw(cpu, thread)) { |
54cb3dbb4 ARM: vfp: fix vfp... |
496 |
u32 fpexc = fmrx(FPEXC); |
3d1228ead [ARM] 5387/1: Add... |
497 |
|
54cb3dbb4 ARM: vfp: fix vfp... |
498 499 500 501 502 |
/* * Save the last VFP state on this CPU. */ fmxr(FPEXC, fpexc | FPEXC_EN); vfp_save_state(&thread->vfpstate, fpexc | FPEXC_EN); |
ad187f956 ARM: vfp ptrace: ... |
503 504 |
fmxr(FPEXC, fpexc); } |
3d1228ead [ARM] 5387/1: Add... |
505 |
|
ad187f956 ARM: vfp ptrace: ... |
506 507 |
put_cpu(); } |
f8f2a8522 ARM: vfp: fix a h... |
508 |
/* Ensure that the thread reloads the hardware VFP state on the next use. */ |
ad187f956 ARM: vfp ptrace: ... |
509 510 511 |
void vfp_flush_hwstate(struct thread_info *thread) { unsigned int cpu = get_cpu(); |
3d1228ead [ARM] 5387/1: Add... |
512 |
|
f8f2a8522 ARM: vfp: fix a h... |
513 |
vfp_force_reload(cpu, thread); |
ad187f956 ARM: vfp ptrace: ... |
514 |
|
3d1228ead [ARM] 5387/1: Add... |
515 516 |
put_cpu(); } |
3d1228ead [ARM] 5387/1: Add... |
517 |
|
90b44199e ARM: VFP: re-init... |
518 519 |
/* * VFP hardware can lose all context when a CPU goes offline. |
74c25beeb ARM: vfp: improve... |
520 521 522 523 524 |
* As we will be running in SMP mode with CPU hotplug, we will save the * hardware state at every thread switch. We clear our held state when * a CPU has been killed, indicating that the VFP hardware doesn't contain * a threads VFP state. When a CPU starts up, we re-enable access to the * VFP hardware. |
90b44199e ARM: VFP: re-init... |
525 526 527 528 529 530 531 532 |
* * Both CPU_DYING and CPU_STARTING are called on the CPU which * is being offlined/onlined. */ static int vfp_hotplug(struct notifier_block *b, unsigned long action, void *hcpu) { if (action == CPU_DYING || action == CPU_DYING_FROZEN) { |
f8f2a8522 ARM: vfp: fix a h... |
533 |
vfp_force_reload((long)hcpu, current_thread_info()); |
90b44199e ARM: VFP: re-init... |
534 535 536 537 |
} else if (action == CPU_STARTING || action == CPU_STARTING_FROZEN) vfp_enable(NULL); return NOTIFY_OK; } |
8e140362f [ARM] Fix VFP ini... |
538 |
|
1da177e4c Linux-2.6.12-rc2 |
539 540 541 542 543 544 |
/* * VFP support code initialisation. */ static int __init vfp_init(void) { unsigned int vfpsid; |
efe90d273 [ARM] Handle HWCA... |
545 |
unsigned int cpu_arch = cpu_architecture(); |
efe90d273 [ARM] Handle HWCA... |
546 |
|
c98929c07 [ARM] 4582/2: Add... |
547 548 |
if (cpu_arch >= CPU_ARCH_ARMv6) vfp_enable(NULL); |
1da177e4c Linux-2.6.12-rc2 |
549 550 551 552 553 554 |
/* * First check that there is a VFP that we can use. * The handler is already setup to just log calls, so * we just need to read the VFPSID register. */ |
5d4cae5fe [ARM] VFP: fix se... |
555 |
vfp_vector = vfp_testing_entry; |
b9338a78f [ARM] 4567/1: Fix... |
556 |
barrier(); |
1da177e4c Linux-2.6.12-rc2 |
557 |
vfpsid = fmrx(FPSID); |
8e140362f [ARM] Fix VFP ini... |
558 |
barrier(); |
5d4cae5fe [ARM] VFP: fix se... |
559 |
vfp_vector = vfp_null_entry; |
1da177e4c Linux-2.6.12-rc2 |
560 561 |
printk(KERN_INFO "VFP support v0.3: "); |
c98929c07 [ARM] 4582/2: Add... |
562 |
if (VFP_arch) |
1da177e4c Linux-2.6.12-rc2 |
563 564 |
printk("not present "); |
c98929c07 [ARM] 4582/2: Add... |
565 |
else if (vfpsid & FPSID_NODOUBLE) { |
1da177e4c Linux-2.6.12-rc2 |
566 567 568 |
printk("no double precision support "); } else { |
90b44199e ARM: VFP: re-init... |
569 |
hotcpu_notifier(vfp_hotplug, 0); |
8691e5a8f smp_call_function... |
570 |
smp_call_function(vfp_enable, NULL, 1); |
8e140362f [ARM] Fix VFP ini... |
571 |
|
1da177e4c Linux-2.6.12-rc2 |
572 573 574 575 576 577 578 579 |
VFP_arch = (vfpsid & FPSID_ARCH_MASK) >> FPSID_ARCH_BIT; /* Extract the architecture version */ printk("implementor %02x architecture %d part %02x variant %x rev %x ", (vfpsid & FPSID_IMPLEMENTER_MASK) >> FPSID_IMPLEMENTER_BIT, (vfpsid & FPSID_ARCH_MASK) >> FPSID_ARCH_BIT, (vfpsid & FPSID_PART_MASK) >> FPSID_PART_BIT, (vfpsid & FPSID_VARIANT_MASK) >> FPSID_VARIANT_BIT, (vfpsid & FPSID_REV_MASK) >> FPSID_REV_BIT); |
efe90d273 [ARM] Handle HWCA... |
580 |
|
1da177e4c Linux-2.6.12-rc2 |
581 |
vfp_vector = vfp_support_entry; |
d6551e884 [ARM] Add thread_... |
582 583 |
thread_register_notifier(&vfp_notifier_block); |
fc0b7a203 [ARM] 5349/1: VFP... |
584 |
vfp_pm_init(); |
efe90d273 [ARM] Handle HWCA... |
585 586 587 588 589 590 |
/* * We detected VFP, and the support code is * in place; report VFP support to userspace. */ elf_hwcap |= HWCAP_VFP; |
7279dc3e9 [ARM] 5388/1: Add... |
591 |
#ifdef CONFIG_VFPv3 |
325ffc363 ARM: 5997/1: ARM:... |
592 |
if (VFP_arch >= 2) { |
7279dc3e9 [ARM] 5388/1: Add... |
593 594 595 596 597 598 599 600 601 602 |
elf_hwcap |= HWCAP_VFPv3; /* * Check for VFPv3 D16. CPUs in this configuration * only have 16 x 64bit registers. */ if (((fmrx(MVFR0) & MVFR0_A_SIMD_MASK)) == 1) elf_hwcap |= HWCAP_VFPv3D16; } #endif |
2bedbdf41 Add HWCAP_NEON to... |
603 604 605 |
/* * Check for the presence of the Advanced SIMD * load/store instructions, integer and single |
5aaf25440 ARM: 6203/1: Make... |
606 607 |
* precision floating point operations. Only check * for NEON if the hardware has the MVFR registers. |
2bedbdf41 Add HWCAP_NEON to... |
608 |
*/ |
5aaf25440 ARM: 6203/1: Make... |
609 |
if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) { |
18b9dc130 ARM: vfp: add VFP... |
610 |
#ifdef CONFIG_NEON |
5aaf25440 ARM: 6203/1: Make... |
611 612 |
if ((fmrx(MVFR1) & 0x000fff00) == 0x00011100) elf_hwcap |= HWCAP_NEON; |
2bedbdf41 Add HWCAP_NEON to... |
613 |
#endif |
18b9dc130 ARM: vfp: add VFP... |
614 615 616 |
if ((fmrx(MVFR1) & 0xf0000000) == 0x10000000) elf_hwcap |= HWCAP_VFPv4; } |
1da177e4c Linux-2.6.12-rc2 |
617 618 619 620 621 |
} return 0; } late_initcall(vfp_init); |