powerpc: define helpers to get L1 icache sizes
authorAlastair D'Silva <alastair@d-silva.org>
Mon, 4 Nov 2019 02:32:55 +0000 (13:32 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 7 Nov 2019 11:48:34 +0000 (22:48 +1100)
This patch adds helpers to retrieve icache sizes, and renames the existing
helpers to make it clear that they are for dcache.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20191104023305.9581-4-alastair@au1.ibm.com
arch/powerpc/include/asm/cache.h
arch/powerpc/include/asm/cacheflush.h

index 45e3137..afb8875 100644 (file)
@@ -55,25 +55,46 @@ struct ppc64_caches {
 
 extern struct ppc64_caches ppc64_caches;
 
-static inline u32 l1_cache_shift(void)
+static inline u32 l1_dcache_shift(void)
 {
        return ppc64_caches.l1d.log_block_size;
 }
 
-static inline u32 l1_cache_bytes(void)
+static inline u32 l1_dcache_bytes(void)
 {
        return ppc64_caches.l1d.block_size;
 }
+
+static inline u32 l1_icache_shift(void)
+{
+       return ppc64_caches.l1i.log_block_size;
+}
+
+static inline u32 l1_icache_bytes(void)
+{
+       return ppc64_caches.l1i.block_size;
+}
 #else
-static inline u32 l1_cache_shift(void)
+static inline u32 l1_dcache_shift(void)
 {
        return L1_CACHE_SHIFT;
 }
 
-static inline u32 l1_cache_bytes(void)
+static inline u32 l1_dcache_bytes(void)
 {
        return L1_CACHE_BYTES;
 }
+
+static inline u32 l1_icache_shift(void)
+{
+       return L1_CACHE_SHIFT;
+}
+
+static inline u32 l1_icache_bytes(void)
+{
+       return L1_CACHE_BYTES;
+}
+
 #endif
 #endif /* ! __ASSEMBLY__ */
 
index eef388f..ed57843 100644 (file)
@@ -63,8 +63,8 @@ static inline void __flush_dcache_icache_phys(unsigned long physaddr)
  */
 static inline void flush_dcache_range(unsigned long start, unsigned long stop)
 {
-       unsigned long shift = l1_cache_shift();
-       unsigned long bytes = l1_cache_bytes();
+       unsigned long shift = l1_dcache_shift();
+       unsigned long bytes = l1_dcache_bytes();
        void *addr = (void *)(start & ~(bytes - 1));
        unsigned long size = stop - (unsigned long)addr + (bytes - 1);
        unsigned long i;
@@ -89,8 +89,8 @@ static inline void flush_dcache_range(unsigned long start, unsigned long stop)
  */
 static inline void clean_dcache_range(unsigned long start, unsigned long stop)
 {
-       unsigned long shift = l1_cache_shift();
-       unsigned long bytes = l1_cache_bytes();
+       unsigned long shift = l1_dcache_shift();
+       unsigned long bytes = l1_dcache_bytes();
        void *addr = (void *)(start & ~(bytes - 1));
        unsigned long size = stop - (unsigned long)addr + (bytes - 1);
        unsigned long i;
@@ -108,8 +108,8 @@ static inline void clean_dcache_range(unsigned long start, unsigned long stop)
 static inline void invalidate_dcache_range(unsigned long start,
                                           unsigned long stop)
 {
-       unsigned long shift = l1_cache_shift();
-       unsigned long bytes = l1_cache_bytes();
+       unsigned long shift = l1_dcache_shift();
+       unsigned long bytes = l1_dcache_bytes();
        void *addr = (void *)(start & ~(bytes - 1));
        unsigned long size = stop - (unsigned long)addr + (bytes - 1);
        unsigned long i;