Clang's compiler based static context analysis does not work with locks
that are conditionally taken like in __pSeries_lpar_hugepage_invalidate().

lpar.c:1240:6: error: spinlock 'pSeries_lpar_tlbie_lock' is not held on every 
path through here [-Werror,-Wthread-safety-analysis]

But this also simplifies the function definition in my opinion - so this
is also a win.

No functional change intended.

Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
---
 arch/powerpc/platforms/pseries/lpar.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/lpar.c 
b/arch/powerpc/platforms/pseries/lpar.c
index 94cd30e9f6e1..abd77c45cbf4 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -1224,26 +1224,33 @@ static void hugepage_bulk_invalidate(unsigned long 
*slot, unsigned long *vpn,
                BUG_ON(rc != H_SUCCESS);
        }
 }
-
-static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
+static void __pSeries_lpar_hugepage_invalidate_unlocked(unsigned long *slot,
                                                      unsigned long *vpn,
                                                      int count, int psize,
                                                      int ssize)
 {
-       unsigned long flags = 0;
-       int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
-
-       if (lock_tlbie)
-               spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);
-
        /* Assuming THP size is 16M */
        if (is_supported_hlbkrm(psize, MMU_PAGE_16M))
                hugepage_block_invalidate(slot, vpn, count, psize, ssize);
        else
                hugepage_bulk_invalidate(slot, vpn, count, psize, ssize);
+}
 
-       if (lock_tlbie)
+static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
+                                                     unsigned long *vpn,
+                                                     int count, int psize,
+                                                     int ssize)
+{
+       unsigned long flags = 0;
+
+       if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE)) {
+               spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);
+               __pSeries_lpar_hugepage_invalidate_unlocked(slot, vpn, count, 
psize, ssize);
                spin_unlock_irqrestore(&pSeries_lpar_tlbie_lock, flags);
+               return;
+       }
+
+       __pSeries_lpar_hugepage_invalidate_unlocked(slot, vpn, count, psize, 
ssize);
 }
 
 static void pSeries_lpar_hugepage_invalidate(unsigned long vsid,
-- 
2.39.5


Reply via email to