4343
4444static DEFINE_RAW_SPINLOCK (native_tlbie_lock );
4545
46+ #ifdef CONFIG_LOCKDEP
47+ static struct lockdep_map hpte_lock_map =
48+ STATIC_LOCKDEP_MAP_INIT ("hpte_lock" , & hpte_lock_map );
49+
50+ static void acquire_hpte_lock (void )
51+ {
52+ lock_map_acquire (& hpte_lock_map );
53+ }
54+
55+ static void release_hpte_lock (void )
56+ {
57+ lock_map_release (& hpte_lock_map );
58+ }
59+ #else
60+ static void acquire_hpte_lock (void )
61+ {
62+ }
63+
64+ static void release_hpte_lock (void )
65+ {
66+ }
67+ #endif
68+
4669static inline unsigned long ___tlbie (unsigned long vpn , int psize ,
4770 int apsize , int ssize )
4871{
@@ -220,6 +243,7 @@ static inline void native_lock_hpte(struct hash_pte *hptep)
220243{
221244 unsigned long * word = (unsigned long * )& hptep -> v ;
222245
246+ acquire_hpte_lock ();
223247 while (1 ) {
224248 if (!test_and_set_bit_lock (HPTE_LOCK_BIT , word ))
225249 break ;
@@ -234,6 +258,7 @@ static inline void native_unlock_hpte(struct hash_pte *hptep)
234258{
235259 unsigned long * word = (unsigned long * )& hptep -> v ;
236260
261+ release_hpte_lock ();
237262 clear_bit_unlock (HPTE_LOCK_BIT , word );
238263}
239264
@@ -279,6 +304,7 @@ static long native_hpte_insert(unsigned long hpte_group, unsigned long vpn,
279304 hpte_v = hpte_old_to_new_v (hpte_v );
280305 }
281306
307+ release_hpte_lock ();
282308 hptep -> r = cpu_to_be64 (hpte_r );
283309 /* Guarantee the second dword is visible before the valid bit */
284310 eieio ();
@@ -327,6 +353,7 @@ static long native_hpte_remove(unsigned long hpte_group)
327353 return -1 ;
328354
329355 /* Invalidate the hpte. NOTE: this also unlocks it */
356+ release_hpte_lock ();
330357 hptep -> v = 0 ;
331358
332359 return i ;
@@ -517,10 +544,11 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn,
517544 /* recheck with locks held */
518545 hpte_v = hpte_get_old_v (hptep );
519546
520- if (HPTE_V_COMPARE (hpte_v , want_v ) && (hpte_v & HPTE_V_VALID ))
547+ if (HPTE_V_COMPARE (hpte_v , want_v ) && (hpte_v & HPTE_V_VALID )) {
521548 /* Invalidate the hpte. NOTE: this also unlocks it */
549+ release_hpte_lock ();
522550 hptep -> v = 0 ;
523- else
551+ } else
524552 native_unlock_hpte (hptep );
525553 }
526554 /*
@@ -580,10 +608,8 @@ static void native_hugepage_invalidate(unsigned long vsid,
580608 hpte_v = hpte_get_old_v (hptep );
581609
582610 if (HPTE_V_COMPARE (hpte_v , want_v ) && (hpte_v & HPTE_V_VALID )) {
583- /*
584- * Invalidate the hpte. NOTE: this also unlocks it
585- */
586-
611+ /* Invalidate the hpte. NOTE: this also unlocks it */
612+ release_hpte_lock ();
587613 hptep -> v = 0 ;
588614 } else
589615 native_unlock_hpte (hptep );
@@ -765,8 +791,10 @@ static void native_flush_hash_range(unsigned long number, int local)
765791
766792 if (!HPTE_V_COMPARE (hpte_v , want_v ) || !(hpte_v & HPTE_V_VALID ))
767793 native_unlock_hpte (hptep );
768- else
794+ else {
795+ release_hpte_lock ();
769796 hptep -> v = 0 ;
797+ }
770798
771799 } pte_iterate_hashed_end ();
772800 }
0 commit comments