powerpc: Remove FW_FEATURE ISERIES from arch code
[deliverable/linux.git] / arch / powerpc / lib / locks.c
CommitLineData
40ef8cbc
PM
1/*
2 * Spin and read/write lock operations.
3 *
4 * Copyright (C) 2001-2004 Paul Mackerras <paulus@au.ibm.com>, IBM
5 * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
6 * Copyright (C) 2002 Dave Engebretsen <engebret@us.ibm.com>, IBM
7 * Rework to support virtual processors
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
40ef8cbc
PM
15#include <linux/kernel.h>
16#include <linux/spinlock.h>
4b16f8e2 17#include <linux/export.h>
40ef8cbc 18#include <linux/stringify.h>
734d6524 19#include <linux/smp.h>
40ef8cbc
PM
20
21/* waiting for a spinlock... */
f5339277 22#if defined(CONFIG_PPC_SPLPAR)
40ef8cbc 23#include <asm/hvcall.h>
2249ca9d 24#include <asm/smp.h>
40ef8cbc 25
445c8951 26void __spin_yield(arch_spinlock_t *lock)
40ef8cbc
PM
27{
28 unsigned int lock_value, holder_cpu, yield_count;
40ef8cbc
PM
29
30 lock_value = lock->slock;
31 if (lock_value == 0)
32 return;
33 holder_cpu = lock_value & 0xffff;
34 BUG_ON(holder_cpu >= NR_CPUS);
8154c5d2 35 yield_count = lppaca_of(holder_cpu).yield_count;
40ef8cbc
PM
36 if ((yield_count & 1) == 0)
37 return; /* virtual cpu is currently running */
38 rmb();
39 if (lock->slock != lock_value)
40 return; /* something has changed */
f5339277
SR
41 plpar_hcall_norets(H_CONFER,
42 get_hard_smp_processor_id(holder_cpu), yield_count);
40ef8cbc
PM
43}
44
45/*
46 * Waiting for a read lock or a write lock on a rwlock...
47 * This turns out to be the same for read and write locks, since
48 * we only know the holder if it is write-locked.
49 */
fb3a6bbc 50void __rw_yield(arch_rwlock_t *rw)
40ef8cbc
PM
51{
52 int lock_value;
53 unsigned int holder_cpu, yield_count;
40ef8cbc
PM
54
55 lock_value = rw->lock;
56 if (lock_value >= 0)
57 return; /* no write lock at present */
58 holder_cpu = lock_value & 0xffff;
59 BUG_ON(holder_cpu >= NR_CPUS);
8154c5d2 60 yield_count = lppaca_of(holder_cpu).yield_count;
40ef8cbc
PM
61 if ((yield_count & 1) == 0)
62 return; /* virtual cpu is currently running */
63 rmb();
64 if (rw->lock != lock_value)
65 return; /* something has changed */
f5339277
SR
66 plpar_hcall_norets(H_CONFER,
67 get_hard_smp_processor_id(holder_cpu), yield_count);
40ef8cbc
PM
68}
69#endif
70
0199c4e6 71void arch_spin_unlock_wait(arch_spinlock_t *lock)
40ef8cbc
PM
72{
73 while (lock->slock) {
74 HMT_low();
75 if (SHARED_PROCESSOR)
76 __spin_yield(lock);
77 }
78 HMT_medium();
79}
80
0199c4e6 81EXPORT_SYMBOL(arch_spin_unlock_wait);
This page took 0.795999 seconds and 5 git commands to generate.