powerpc: iommu: use bitmap library
Subsystems (2)
PATCH 1/1 powerpc: iommu: use bitmap library
- Caluculate the bitmap size with BITS_TO_LONGS()
- Use bitmap_empty() to verify that all bits are cleared
This also includes a printk to pr_warn() conversion.
--- arch/powerpc/kernel/iommu.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
arch/powerpc/kernel/iommu.c +5 -11
@@ -656,7 +656,7 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)struct iommu_pool *p;/* number of bytes needed for the bitmap */ - sz = (tbl->it_size +7 ) >>3 ; + sz =BITS_TO_LONGS (tbl->it_size) *sizeof (unsigned long ); page =alloc_pages_node (nid,GFP_ATOMIC ,get_order (sz));if (!page)
@@ -708,7 +708,7 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)void iommu_free_table (struct iommu_table *tbl,const char *node_name) { -unsigned long bitmap_sz, i; +unsigned long bitmap_sz;unsigned int order;if (!tbl || !tbl->it_map) {
@@ -718,17 +718,11 @@ void iommu_free_table(struct iommu_table *tbl, const char *node_name) }/* verify that table contains no entries */ -/* it_size is in entries, and we're examining 64 at a time */ -for (i =0 ; i < (tbl->it_size/64 ); i++) { -if (tbl->it_map[i] !=0 ) { -printk (KERN_WARNING "%s: Unexpected TCEs for %s\n" , - __func__, node_name); -break ; - } - } +if (!bitmap_empty (tbl->it_map, tbl->it_size)) +pr_warn ("%s: Unexpected TCEs for %s\n" , __func__, node_name);/* calculate bitmap size in bytes */ - bitmap_sz = (tbl->it_size +7 ) /8 ; + bitmap_sz =BITS_TO_LONGS (tbl->it_size) *sizeof (unsigned long );/* free bitmap */ order =get_order (bitmap_sz);
Signature · 1 line
1.7.11.7
PATCH 1/1 powerpc: remove BITOP_MASK and BITOP_WORD from asm/bitops.h
Replace BITOP_MASK and BITOP_WORD with BIT_MASK and BIT_WORD defined in linux/bitops.h and remove BITOP_* which are not used anymore.
--- arch/powerpc/include/asm/bitops.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/bitops.h +9 -11
@@ -52,8 +52,6 @@#define smp_mb__before_clear_bit () smp_mb()#define smp_mb__after_clear_bit () smp_mb() -#define BITOP_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BITOP_WORD (nr) ((nr) / BITS_PER_LONG)#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)/* Macro for generating the ***_bits() functions */
@@ -83,22 +81,22 @@ DEFINE_BITOP(change_bits, xor, "", "")static __inline__void set_bit (int nr,volatile unsigned long *addr) { -set_bits (BITOP_MASK (nr), addr +BITOP_WORD (nr)); +set_bits (BIT_MASK (nr), addr +BIT_WORD (nr)); }static __inline__void clear_bit (int nr,volatile unsigned long *addr) { -clear_bits (BITOP_MASK (nr), addr +BITOP_WORD (nr)); +clear_bits (BIT_MASK (nr), addr +BIT_WORD (nr)); }static __inline__void clear_bit_unlock (int nr,volatile unsigned long *addr) { -clear_bits_unlock (BITOP_MASK (nr), addr +BITOP_WORD (nr)); +clear_bits_unlock (BIT_MASK (nr), addr +BIT_WORD (nr)); }static __inline__void change_bit (int nr,volatile unsigned long *addr) { -change_bits (BITOP_MASK (nr), addr +BITOP_WORD (nr)); +change_bits (BIT_MASK (nr), addr +BIT_WORD (nr)); }/* Like DEFINE_BITOP(), with changes to the arguments to 'op' and the output
@@ -136,26 +134,26 @@ DEFINE_TESTOP(test_and_change_bits, xor, PPC_ATOMIC_ENTRY_BARRIER,static __inline__int test_and_set_bit (unsigned long nr,volatile unsigned long *addr) { -return test_and_set_bits (BITOP_MASK (nr), addr +BITOP_WORD (nr)) !=0 ; +return test_and_set_bits (BIT_MASK (nr), addr +BIT_WORD (nr)) !=0 ; }static __inline__int test_and_set_bit_lock (unsigned long nr,volatile unsigned long *addr) { -return test_and_set_bits_lock (BITOP_MASK (nr), - addr +BITOP_WORD (nr)) !=0 ; +return test_and_set_bits_lock (BIT_MASK (nr), + addr +BIT_WORD (nr)) !=0 ; }static __inline__int test_and_clear_bit (unsigned long nr,volatile unsigned long *addr) { -return test_and_clear_bits (BITOP_MASK (nr), addr +BITOP_WORD (nr)) !=0 ; +return test_and_clear_bits (BIT_MASK (nr), addr +BIT_WORD (nr)) !=0 ; }static __inline__int test_and_change_bit (unsigned long nr,volatile unsigned long *addr) { -return test_and_change_bits (BITOP_MASK (nr), addr +BITOP_WORD (nr)) !=0 ; +return test_and_change_bits (BIT_MASK (nr), addr +BIT_WORD (nr)) !=0 ; }#include <asm-generic/bitops/non-atomic.h>
Signature · 1 line
1.7.11.7
PATCH 1/1 powerpc: use asm-generic/bitops/le.h
In reply to Akinobu MitaThe only difference between powerpc and asm-generic le-bitops is test_bit_le(). Usually all bitops require a long aligned bitmap. But powerpc test_bit_le() can take an unaligned address.
There is no special callsite of test_bit_le() that needs unaligned access in powerpc as far as I can see. So convert to use asm-generic/bitops/le.h for powerpc.
--- arch/powerpc/include/asm/bitops.h | 55 +-------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-)
arch/powerpc/include/asm/bitops.h +1 -54
@@ -278,61 +278,8 @@ unsigned long __arch_hweight64(__u64 w);#include <asm-generic/bitops/find.h> /* Little-endian versions */ +#include <asm-generic/bitops/le.h> -static __inline__int test_bit_le (unsigned long nr, - __const__ void *addr) -{ - __const__ unsigned char *tmp = (__const__ unsigned char *) addr; -return (tmp[nr >>3 ] >> (nr &7 )) &1 ; -} - -static inline void set_bit_le (int nr,void *addr) -{ -set_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -static inline void clear_bit_le (int nr,void *addr) -{ -clear_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -static inline void __set_bit_le (int nr,void *addr) -{ -__set_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -static inline void __clear_bit_le (int nr,void *addr) -{ -__clear_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -static inline int test_and_set_bit_le (int nr,void *addr) -{ -return test_and_set_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -static inline int test_and_clear_bit_le (int nr,void *addr) -{ -return test_and_clear_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -static inline int __test_and_set_bit_le (int nr,void *addr) -{ -return __test_and_set_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -static inline int __test_and_clear_bit_le (int nr,void *addr) -{ -return __test_and_clear_bit (nr ^BITOP_LE_SWIZZLE , addr); -} - -#define find_first_zero_bit_le (addr, size) \ - find_next_zero_bit_le((addr), (size), 0) -unsigned long find_next_zero_bit_le (const void *addr, -unsigned long size,unsigned long offset); - -unsigned long find_next_bit_le (const void *addr, -unsigned long size,unsigned long offset);/* Bitmap functions for the ext2 filesystem */ #include <asm-generic/bitops/ext2-atomic-setbit.h>
Signature · 1 line
1.7.11.7