aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2005-10-27 02:45:38 -0400
committerStephen Rothwell <sfr@canb.auug.org.au>2005-10-27 22:53:48 -0400
commitecc81e0f719f566b75b222b8aef64c8b809b2e29 (patch)
tree34f021072504ef2e4e32b5d0900a34baa6d898a9
parent43f35ec35c2b9a1c984d885893084eed2101e1bf (diff)
ppc64: use lockc.c from powerpc/lib
since it is effectively the same as locks.c from ppc64/lib. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-rw-r--r--arch/powerpc/lib/Makefile6
-rw-r--r--arch/ppc64/lib/Makefile5
-rw-r--r--arch/ppc64/lib/locks.c95
3 files changed, 3 insertions, 103 deletions
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 3474c9309e2f..955c06421590 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -7,10 +7,10 @@ obj-y := strcase.o string.o
7obj-$(CONFIG_PPC32) += div64.o copy_32.o checksum_32.o 7obj-$(CONFIG_PPC32) += div64.o copy_32.o checksum_32.o
8obj-$(CONFIG_PPC64) += memcpy_64.o \ 8obj-$(CONFIG_PPC64) += memcpy_64.o \
9 usercopy_64.o sstep.o mem_64.o 9 usercopy_64.o sstep.o mem_64.o
10ifeq ($(CONFIG_PPC64),y)
11obj-$(CONFIG_SMP) += locks.o
12endif
13endif 10endif
14 11
15obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o 12obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o
16obj-$(CONFIG_PPC_ISERIES) += e2a.o 13obj-$(CONFIG_PPC_ISERIES) += e2a.o
14ifeq ($(CONFIG_PPC64),y)
15obj-$(CONFIG_SMP) += locks.o
16endif
diff --git a/arch/ppc64/lib/Makefile b/arch/ppc64/lib/Makefile
index f29e76559950..87c2ff5e1883 100644
--- a/arch/ppc64/lib/Makefile
+++ b/arch/ppc64/lib/Makefile
@@ -5,9 +5,4 @@
5lib-y := string.o strcase.o 5lib-y := string.o strcase.o
6lib-y += memcpy.o usercopy.o 6lib-y += memcpy.o usercopy.o
7 7
8# Lock primitives are defined as no-ops in include/linux/spinlock.h
9# for non-SMP configs. Don't build the real versions.
10
11lib-$(CONFIG_SMP) += locks.o
12
13lib-$(CONFIG_DEBUG_KERNEL) += sstep.o 8lib-$(CONFIG_DEBUG_KERNEL) += sstep.o
diff --git a/arch/ppc64/lib/locks.c b/arch/ppc64/lib/locks.c
deleted file mode 100644
index 033643ab69e0..000000000000
--- a/arch/ppc64/lib/locks.c
+++ /dev/null
@@ -1,95 +0,0 @@
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
15#include <linux/config.h>
16#include <linux/kernel.h>
17#include <linux/spinlock.h>
18#include <linux/module.h>
19#include <linux/stringify.h>
20#include <asm/hvcall.h>
21#include <asm/iSeries/HvCall.h>
22
23/* waiting for a spinlock... */
24#if defined(CONFIG_PPC_SPLPAR) || defined(CONFIG_PPC_ISERIES)
25
26void __spin_yield(raw_spinlock_t *lock)
27{
28 unsigned int lock_value, holder_cpu, yield_count;
29 struct paca_struct *holder_paca;
30
31 lock_value = lock->slock;
32 if (lock_value == 0)
33 return;
34 holder_cpu = lock_value & 0xffff;
35 BUG_ON(holder_cpu >= NR_CPUS);
36 holder_paca = &paca[holder_cpu];
37 yield_count = holder_paca->lppaca.yield_count;
38 if ((yield_count & 1) == 0)
39 return; /* virtual cpu is currently running */
40 rmb();
41 if (lock->slock != lock_value)
42 return; /* something has changed */
43#ifdef CONFIG_PPC_ISERIES
44 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc,
45 ((u64)holder_cpu << 32) | yield_count);
46#else
47 plpar_hcall_norets(H_CONFER, get_hard_smp_processor_id(holder_cpu),
48 yield_count);
49#endif
50}
51
52/*
53 * Waiting for a read lock or a write lock on a rwlock...
54 * This turns out to be the same for read and write locks, since
55 * we only know the holder if it is write-locked.
56 */
57void __rw_yield(raw_rwlock_t *rw)
58{
59 int lock_value;
60 unsigned int holder_cpu, yield_count;
61 struct paca_struct *holder_paca;
62
63 lock_value = rw->lock;
64 if (lock_value >= 0)
65 return; /* no write lock at present */
66 holder_cpu = lock_value & 0xffff;
67 BUG_ON(holder_cpu >= NR_CPUS);
68 holder_paca = &paca[holder_cpu];
69 yield_count = holder_paca->lppaca.yield_count;
70 if ((yield_count & 1) == 0)
71 return; /* virtual cpu is currently running */
72 rmb();
73 if (rw->lock != lock_value)
74 return; /* something has changed */
75#ifdef CONFIG_PPC_ISERIES
76 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc,
77 ((u64)holder_cpu << 32) | yield_count);
78#else
79 plpar_hcall_norets(H_CONFER, get_hard_smp_processor_id(holder_cpu),
80 yield_count);
81#endif
82}
83#endif
84
85void __raw_spin_unlock_wait(raw_spinlock_t *lock)
86{
87 while (lock->slock) {
88 HMT_low();
89 if (SHARED_PROCESSOR)
90 __spin_yield(lock);
91 }
92 HMT_medium();
93}
94
95EXPORT_SYMBOL(__raw_spin_unlock_wait);