diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2005-07-13 04:11:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-13 14:25:25 -0400 |
commit | 96e2844999f99878fc5b03b81ccaa60580005b81 (patch) | |
tree | 353c1bc9a5602d556e6741f4a261010cde45e93b /arch/ppc64/kernel | |
parent | f13487c66c75f5db004a0631047309d9e7c5aab7 (diff) |
[PATCH] ppc64: kill bitfields in ppc64 hash code
This patch removes the use of bitfield types from the ppc64 hash table
manipulation code.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Acked-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/ppc64/kernel')
-rw-r--r-- | arch/ppc64/kernel/iSeries_htab.c | 51 | ||||
-rw-r--r-- | arch/ppc64/kernel/iSeries_setup.c | 18 | ||||
-rw-r--r-- | arch/ppc64/kernel/pSeries_lpar.c | 47 |
3 files changed, 45 insertions, 71 deletions
diff --git a/arch/ppc64/kernel/iSeries_htab.c b/arch/ppc64/kernel/iSeries_htab.c index aa9e8fdd1a4f..b0250ae4a72a 100644 --- a/arch/ppc64/kernel/iSeries_htab.c +++ b/arch/ppc64/kernel/iSeries_htab.c | |||
@@ -38,11 +38,12 @@ static inline void iSeries_hunlock(unsigned long slot) | |||
38 | } | 38 | } |
39 | 39 | ||
40 | static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va, | 40 | static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va, |
41 | unsigned long prpn, int secondary, | 41 | unsigned long prpn, unsigned long vflags, |
42 | unsigned long hpteflags, int bolted, int large) | 42 | unsigned long rflags) |
43 | { | 43 | { |
44 | long slot; | 44 | long slot; |
45 | HPTE lhpte; | 45 | hpte_t lhpte; |
46 | int secondary = 0; | ||
46 | 47 | ||
47 | /* | 48 | /* |
48 | * The hypervisor tries both primary and secondary. | 49 | * The hypervisor tries both primary and secondary. |
@@ -50,13 +51,13 @@ static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va, | |||
50 | * it means we have already tried both primary and secondary, | 51 | * it means we have already tried both primary and secondary, |
51 | * so we return failure immediately. | 52 | * so we return failure immediately. |
52 | */ | 53 | */ |
53 | if (secondary) | 54 | if (vflags & HPTE_V_SECONDARY) |
54 | return -1; | 55 | return -1; |
55 | 56 | ||
56 | iSeries_hlock(hpte_group); | 57 | iSeries_hlock(hpte_group); |
57 | 58 | ||
58 | slot = HvCallHpt_findValid(&lhpte, va >> PAGE_SHIFT); | 59 | slot = HvCallHpt_findValid(&lhpte, va >> PAGE_SHIFT); |
59 | BUG_ON(lhpte.dw0.dw0.v); | 60 | BUG_ON(lhpte.v & HPTE_V_VALID); |
60 | 61 | ||
61 | if (slot == -1) { /* No available entry found in either group */ | 62 | if (slot == -1) { /* No available entry found in either group */ |
62 | iSeries_hunlock(hpte_group); | 63 | iSeries_hunlock(hpte_group); |
@@ -64,19 +65,13 @@ static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va, | |||
64 | } | 65 | } |
65 | 66 | ||
66 | if (slot < 0) { /* MSB set means secondary group */ | 67 | if (slot < 0) { /* MSB set means secondary group */ |
68 | vflags |= HPTE_V_VALID; | ||
67 | secondary = 1; | 69 | secondary = 1; |
68 | slot &= 0x7fffffffffffffff; | 70 | slot &= 0x7fffffffffffffff; |
69 | } | 71 | } |
70 | 72 | ||
71 | lhpte.dw1.dword1 = 0; | 73 | lhpte.v = (va >> 23) << HPTE_V_AVPN_SHIFT | vflags | HPTE_V_VALID; |
72 | lhpte.dw1.dw1.rpn = physRpn_to_absRpn(prpn); | 74 | lhpte.r = (physRpn_to_absRpn(prpn) << HPTE_R_RPN_SHIFT) | rflags; |
73 | lhpte.dw1.flags.flags = hpteflags; | ||
74 | |||
75 | lhpte.dw0.dword0 = 0; | ||
76 | lhpte.dw0.dw0.avpn = va >> 23; | ||
77 | lhpte.dw0.dw0.h = secondary; | ||
78 | lhpte.dw0.dw0.bolted = bolted; | ||
79 | lhpte.dw0.dw0.v = 1; | ||
80 | 75 | ||
81 | /* Now fill in the actual HPTE */ | 76 | /* Now fill in the actual HPTE */ |
82 | HvCallHpt_addValidate(slot, secondary, &lhpte); | 77 | HvCallHpt_addValidate(slot, secondary, &lhpte); |
@@ -88,20 +83,17 @@ static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va, | |||
88 | 83 | ||
89 | static unsigned long iSeries_hpte_getword0(unsigned long slot) | 84 | static unsigned long iSeries_hpte_getword0(unsigned long slot) |
90 | { | 85 | { |
91 | unsigned long dword0; | 86 | hpte_t hpte; |
92 | HPTE hpte; | ||
93 | 87 | ||
94 | HvCallHpt_get(&hpte, slot); | 88 | HvCallHpt_get(&hpte, slot); |
95 | dword0 = hpte.dw0.dword0; | 89 | return hpte.v; |
96 | |||
97 | return dword0; | ||
98 | } | 90 | } |
99 | 91 | ||
100 | static long iSeries_hpte_remove(unsigned long hpte_group) | 92 | static long iSeries_hpte_remove(unsigned long hpte_group) |
101 | { | 93 | { |
102 | unsigned long slot_offset; | 94 | unsigned long slot_offset; |
103 | int i; | 95 | int i; |
104 | HPTE lhpte; | 96 | unsigned long hpte_v; |
105 | 97 | ||
106 | /* Pick a random slot to start at */ | 98 | /* Pick a random slot to start at */ |
107 | slot_offset = mftb() & 0x7; | 99 | slot_offset = mftb() & 0x7; |
@@ -109,10 +101,9 @@ static long iSeries_hpte_remove(unsigned long hpte_group) | |||
109 | iSeries_hlock(hpte_group); | 101 | iSeries_hlock(hpte_group); |
110 | 102 | ||
111 | for (i = 0; i < HPTES_PER_GROUP; i++) { | 103 | for (i = 0; i < HPTES_PER_GROUP; i++) { |
112 | lhpte.dw0.dword0 = | 104 | hpte_v = iSeries_hpte_getword0(hpte_group + slot_offset); |
113 | iSeries_hpte_getword0(hpte_group + slot_offset); | ||
114 | 105 | ||
115 | if (!lhpte.dw0.dw0.bolted) { | 106 | if (! (hpte_v & HPTE_V_BOLTED)) { |
116 | HvCallHpt_invalidateSetSwBitsGet(hpte_group + | 107 | HvCallHpt_invalidateSetSwBitsGet(hpte_group + |
117 | slot_offset, 0, 0); | 108 | slot_offset, 0, 0); |
118 | iSeries_hunlock(hpte_group); | 109 | iSeries_hunlock(hpte_group); |
@@ -137,13 +128,13 @@ static long iSeries_hpte_remove(unsigned long hpte_group) | |||
137 | static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp, | 128 | static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp, |
138 | unsigned long va, int large, int local) | 129 | unsigned long va, int large, int local) |
139 | { | 130 | { |
140 | HPTE hpte; | 131 | hpte_t hpte; |
141 | unsigned long avpn = va >> 23; | 132 | unsigned long avpn = va >> 23; |
142 | 133 | ||
143 | iSeries_hlock(slot); | 134 | iSeries_hlock(slot); |
144 | 135 | ||
145 | HvCallHpt_get(&hpte, slot); | 136 | HvCallHpt_get(&hpte, slot); |
146 | if ((hpte.dw0.dw0.avpn == avpn) && (hpte.dw0.dw0.v)) { | 137 | if ((HPTE_V_AVPN_VAL(hpte.v) == avpn) && (hpte.v & HPTE_V_VALID)) { |
147 | /* | 138 | /* |
148 | * Hypervisor expects bits as NPPP, which is | 139 | * Hypervisor expects bits as NPPP, which is |
149 | * different from how they are mapped in our PP. | 140 | * different from how they are mapped in our PP. |
@@ -167,7 +158,7 @@ static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp, | |||
167 | */ | 158 | */ |
168 | static long iSeries_hpte_find(unsigned long vpn) | 159 | static long iSeries_hpte_find(unsigned long vpn) |
169 | { | 160 | { |
170 | HPTE hpte; | 161 | hpte_t hpte; |
171 | long slot; | 162 | long slot; |
172 | 163 | ||
173 | /* | 164 | /* |
@@ -177,7 +168,7 @@ static long iSeries_hpte_find(unsigned long vpn) | |||
177 | * 0x80000000xxxxxxxx : Entry found in secondary group, slot x | 168 | * 0x80000000xxxxxxxx : Entry found in secondary group, slot x |
178 | */ | 169 | */ |
179 | slot = HvCallHpt_findValid(&hpte, vpn); | 170 | slot = HvCallHpt_findValid(&hpte, vpn); |
180 | if (hpte.dw0.dw0.v) { | 171 | if (hpte.v & HPTE_V_VALID) { |
181 | if (slot < 0) { | 172 | if (slot < 0) { |
182 | slot &= 0x7fffffffffffffff; | 173 | slot &= 0x7fffffffffffffff; |
183 | slot = -slot; | 174 | slot = -slot; |
@@ -212,7 +203,7 @@ static void iSeries_hpte_updateboltedpp(unsigned long newpp, unsigned long ea) | |||
212 | static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va, | 203 | static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va, |
213 | int large, int local) | 204 | int large, int local) |
214 | { | 205 | { |
215 | HPTE lhpte; | 206 | unsigned long hpte_v; |
216 | unsigned long avpn = va >> 23; | 207 | unsigned long avpn = va >> 23; |
217 | unsigned long flags; | 208 | unsigned long flags; |
218 | 209 | ||
@@ -220,9 +211,9 @@ static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va, | |||
220 | 211 | ||
221 | iSeries_hlock(slot); | 212 | iSeries_hlock(slot); |
222 | 213 | ||
223 | lhpte.dw0.dword0 = iSeries_hpte_getword0(slot); | 214 | hpte_v = iSeries_hpte_getword0(slot); |
224 | 215 | ||
225 | if ((lhpte.dw0.dw0.avpn == avpn) && lhpte.dw0.dw0.v) | 216 | if ((HPTE_V_AVPN_VAL(hpte_v) == avpn) && (hpte_v & HPTE_V_VALID)) |
226 | HvCallHpt_invalidateSetSwBitsGet(slot, 0, 0); | 217 | HvCallHpt_invalidateSetSwBitsGet(slot, 0, 0); |
227 | 218 | ||
228 | iSeries_hunlock(slot); | 219 | iSeries_hunlock(slot); |
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c index 077c82fc9f3a..a649edbb23b6 100644 --- a/arch/ppc64/kernel/iSeries_setup.c +++ b/arch/ppc64/kernel/iSeries_setup.c | |||
@@ -503,7 +503,7 @@ static void __init build_iSeries_Memory_Map(void) | |||
503 | 503 | ||
504 | /* Fill in the hashed page table hash mask */ | 504 | /* Fill in the hashed page table hash mask */ |
505 | num_ptegs = hptSizePages * | 505 | num_ptegs = hptSizePages * |
506 | (PAGE_SIZE / (sizeof(HPTE) * HPTES_PER_GROUP)); | 506 | (PAGE_SIZE / (sizeof(hpte_t) * HPTES_PER_GROUP)); |
507 | htab_hash_mask = num_ptegs - 1; | 507 | htab_hash_mask = num_ptegs - 1; |
508 | 508 | ||
509 | /* | 509 | /* |
@@ -618,25 +618,23 @@ static void __init setup_iSeries_cache_sizes(void) | |||
618 | static void iSeries_make_pte(unsigned long va, unsigned long pa, | 618 | static void iSeries_make_pte(unsigned long va, unsigned long pa, |
619 | int mode) | 619 | int mode) |
620 | { | 620 | { |
621 | HPTE local_hpte, rhpte; | 621 | hpte_t local_hpte, rhpte; |
622 | unsigned long hash, vpn; | 622 | unsigned long hash, vpn; |
623 | long slot; | 623 | long slot; |
624 | 624 | ||
625 | vpn = va >> PAGE_SHIFT; | 625 | vpn = va >> PAGE_SHIFT; |
626 | hash = hpt_hash(vpn, 0); | 626 | hash = hpt_hash(vpn, 0); |
627 | 627 | ||
628 | local_hpte.dw1.dword1 = pa | mode; | 628 | local_hpte.r = pa | mode; |
629 | local_hpte.dw0.dword0 = 0; | 629 | local_hpte.v = ((va >> 23) << HPTE_V_AVPN_SHIFT) |
630 | local_hpte.dw0.dw0.avpn = va >> 23; | 630 | | HPTE_V_BOLTED | HPTE_V_VALID; |
631 | local_hpte.dw0.dw0.bolted = 1; /* bolted */ | ||
632 | local_hpte.dw0.dw0.v = 1; | ||
633 | 631 | ||
634 | slot = HvCallHpt_findValid(&rhpte, vpn); | 632 | slot = HvCallHpt_findValid(&rhpte, vpn); |
635 | if (slot < 0) { | 633 | if (slot < 0) { |
636 | /* Must find space in primary group */ | 634 | /* Must find space in primary group */ |
637 | panic("hash_page: hpte already exists\n"); | 635 | panic("hash_page: hpte already exists\n"); |
638 | } | 636 | } |
639 | HvCallHpt_addValidate(slot, 0, (HPTE *)&local_hpte ); | 637 | HvCallHpt_addValidate(slot, 0, &local_hpte); |
640 | } | 638 | } |
641 | 639 | ||
642 | /* | 640 | /* |
@@ -646,7 +644,7 @@ static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr) | |||
646 | { | 644 | { |
647 | unsigned long pa; | 645 | unsigned long pa; |
648 | unsigned long mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX; | 646 | unsigned long mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX; |
649 | HPTE hpte; | 647 | hpte_t hpte; |
650 | 648 | ||
651 | for (pa = saddr; pa < eaddr ;pa += PAGE_SIZE) { | 649 | for (pa = saddr; pa < eaddr ;pa += PAGE_SIZE) { |
652 | unsigned long ea = (unsigned long)__va(pa); | 650 | unsigned long ea = (unsigned long)__va(pa); |
@@ -659,7 +657,7 @@ static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr) | |||
659 | if (!in_kernel_text(ea)) | 657 | if (!in_kernel_text(ea)) |
660 | mode_rw |= HW_NO_EXEC; | 658 | mode_rw |= HW_NO_EXEC; |
661 | 659 | ||
662 | if (hpte.dw0.dw0.v) { | 660 | if (hpte.v & HPTE_V_VALID) { |
663 | /* HPTE exists, so just bolt it */ | 661 | /* HPTE exists, so just bolt it */ |
664 | HvCallHpt_setSwBits(slot, 0x10, 0); | 662 | HvCallHpt_setSwBits(slot, 0x10, 0); |
665 | /* And make sure the pp bits are correct */ | 663 | /* And make sure the pp bits are correct */ |
diff --git a/arch/ppc64/kernel/pSeries_lpar.c b/arch/ppc64/kernel/pSeries_lpar.c index 6534812db437..74dd144dcce8 100644 --- a/arch/ppc64/kernel/pSeries_lpar.c +++ b/arch/ppc64/kernel/pSeries_lpar.c | |||
@@ -277,31 +277,20 @@ void vpa_init(int cpu) | |||
277 | 277 | ||
278 | long pSeries_lpar_hpte_insert(unsigned long hpte_group, | 278 | long pSeries_lpar_hpte_insert(unsigned long hpte_group, |
279 | unsigned long va, unsigned long prpn, | 279 | unsigned long va, unsigned long prpn, |
280 | int secondary, unsigned long hpteflags, | 280 | unsigned long vflags, unsigned long rflags) |
281 | int bolted, int large) | ||
282 | { | 281 | { |
283 | unsigned long arpn = physRpn_to_absRpn(prpn); | 282 | unsigned long arpn = physRpn_to_absRpn(prpn); |
284 | unsigned long lpar_rc; | 283 | unsigned long lpar_rc; |
285 | unsigned long flags; | 284 | unsigned long flags; |
286 | unsigned long slot; | 285 | unsigned long slot; |
287 | HPTE lhpte; | 286 | unsigned long hpte_v, hpte_r; |
288 | unsigned long dummy0, dummy1; | 287 | unsigned long dummy0, dummy1; |
289 | 288 | ||
290 | /* Fill in the local HPTE with absolute rpn, avpn and flags */ | 289 | hpte_v = ((va >> 23) << HPTE_V_AVPN_SHIFT) | vflags | HPTE_V_VALID; |
291 | lhpte.dw1.dword1 = 0; | 290 | if (vflags & HPTE_V_LARGE) |
292 | lhpte.dw1.dw1.rpn = arpn; | 291 | hpte_v &= ~(1UL << HPTE_V_AVPN_SHIFT); |
293 | lhpte.dw1.flags.flags = hpteflags; | ||
294 | 292 | ||
295 | lhpte.dw0.dword0 = 0; | 293 | hpte_r = (arpn << HPTE_R_RPN_SHIFT) | rflags; |
296 | lhpte.dw0.dw0.avpn = va >> 23; | ||
297 | lhpte.dw0.dw0.h = secondary; | ||
298 | lhpte.dw0.dw0.bolted = bolted; | ||
299 | lhpte.dw0.dw0.v = 1; | ||
300 | |||
301 | if (large) { | ||
302 | lhpte.dw0.dw0.l = 1; | ||
303 | lhpte.dw0.dw0.avpn &= ~0x1UL; | ||
304 | } | ||
305 | 294 | ||
306 | /* Now fill in the actual HPTE */ | 295 | /* Now fill in the actual HPTE */ |
307 | /* Set CEC cookie to 0 */ | 296 | /* Set CEC cookie to 0 */ |
@@ -312,11 +301,11 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group, | |||
312 | flags = 0; | 301 | flags = 0; |
313 | 302 | ||
314 | /* XXX why is this here? - Anton */ | 303 | /* XXX why is this here? - Anton */ |
315 | if (hpteflags & (_PAGE_GUARDED|_PAGE_NO_CACHE)) | 304 | if (rflags & (_PAGE_GUARDED|_PAGE_NO_CACHE)) |
316 | lhpte.dw1.flags.flags &= ~_PAGE_COHERENT; | 305 | hpte_r &= ~_PAGE_COHERENT; |
317 | 306 | ||
318 | lpar_rc = plpar_hcall(H_ENTER, flags, hpte_group, lhpte.dw0.dword0, | 307 | lpar_rc = plpar_hcall(H_ENTER, flags, hpte_group, hpte_v, |
319 | lhpte.dw1.dword1, &slot, &dummy0, &dummy1); | 308 | hpte_r, &slot, &dummy0, &dummy1); |
320 | 309 | ||
321 | if (unlikely(lpar_rc == H_PTEG_Full)) | 310 | if (unlikely(lpar_rc == H_PTEG_Full)) |
322 | return -1; | 311 | return -1; |
@@ -332,7 +321,7 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group, | |||
332 | /* Because of iSeries, we have to pass down the secondary | 321 | /* Because of iSeries, we have to pass down the secondary |
333 | * bucket bit here as well | 322 | * bucket bit here as well |
334 | */ | 323 | */ |
335 | return (slot & 7) | (secondary << 3); | 324 | return (slot & 7) | (!!(vflags & HPTE_V_SECONDARY) << 3); |
336 | } | 325 | } |
337 | 326 | ||
338 | static DEFINE_SPINLOCK(pSeries_lpar_tlbie_lock); | 327 | static DEFINE_SPINLOCK(pSeries_lpar_tlbie_lock); |
@@ -427,22 +416,18 @@ static long pSeries_lpar_hpte_find(unsigned long vpn) | |||
427 | unsigned long hash; | 416 | unsigned long hash; |
428 | unsigned long i, j; | 417 | unsigned long i, j; |
429 | long slot; | 418 | long slot; |
430 | union { | 419 | unsigned long hpte_v; |
431 | unsigned long dword0; | ||
432 | Hpte_dword0 dw0; | ||
433 | } hpte_dw0; | ||
434 | Hpte_dword0 dw0; | ||
435 | 420 | ||
436 | hash = hpt_hash(vpn, 0); | 421 | hash = hpt_hash(vpn, 0); |
437 | 422 | ||
438 | for (j = 0; j < 2; j++) { | 423 | for (j = 0; j < 2; j++) { |
439 | slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; | 424 | slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; |
440 | for (i = 0; i < HPTES_PER_GROUP; i++) { | 425 | for (i = 0; i < HPTES_PER_GROUP; i++) { |
441 | hpte_dw0.dword0 = pSeries_lpar_hpte_getword0(slot); | 426 | hpte_v = pSeries_lpar_hpte_getword0(slot); |
442 | dw0 = hpte_dw0.dw0; | ||
443 | 427 | ||
444 | if ((dw0.avpn == (vpn >> 11)) && dw0.v && | 428 | if ((HPTE_V_AVPN_VAL(hpte_v) == (vpn >> 11)) |
445 | (dw0.h == j)) { | 429 | && (hpte_v & HPTE_V_VALID) |
430 | && (!!(hpte_v & HPTE_V_SECONDARY) == j)) { | ||
446 | /* HPTE matches */ | 431 | /* HPTE matches */ |
447 | if (j) | 432 | if (j) |
448 | slot = -slot; | 433 | slot = -slot; |