hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/powerpc/include/asm/cache.h
....@@ -6,7 +6,7 @@
66
77
88 /* bytes per L1 cache line */
9
-#if defined(CONFIG_PPC_8xx) || defined(CONFIG_403GCX)
9
+#if defined(CONFIG_PPC_8xx)
1010 #define L1_CACHE_SHIFT 4
1111 #define MAX_COPY_PREFETCH 1
1212 #define IFETCH_ALIGN_SHIFT 2
....@@ -33,7 +33,8 @@
3333
3434 #define IFETCH_ALIGN_BYTES (1 << IFETCH_ALIGN_SHIFT)
3535
36
-#if defined(__powerpc64__) && !defined(__ASSEMBLY__)
36
+#if !defined(__ASSEMBLY__)
37
+#ifdef CONFIG_PPC64
3738
3839 struct ppc_cache_info {
3940 u32 size;
....@@ -53,25 +54,52 @@
5354 };
5455
5556 extern struct ppc64_caches ppc64_caches;
56
-#endif /* __powerpc64__ && ! __ASSEMBLY__ */
5757
58
-#if defined(__ASSEMBLY__)
59
-/*
60
- * For a snooping icache, we still need a dummy icbi to purge all the
61
- * prefetched instructions from the ifetch buffers. We also need a sync
62
- * before the icbi to order the the actual stores to memory that might
63
- * have modified instructions with the icbi.
64
- */
65
-#define PURGE_PREFETCHED_INS \
66
- sync; \
67
- icbi 0,r3; \
68
- sync; \
69
- isync
58
+static inline u32 l1_dcache_shift(void)
59
+{
60
+ return ppc64_caches.l1d.log_block_size;
61
+}
7062
63
+static inline u32 l1_dcache_bytes(void)
64
+{
65
+ return ppc64_caches.l1d.block_size;
66
+}
67
+
68
+static inline u32 l1_icache_shift(void)
69
+{
70
+ return ppc64_caches.l1i.log_block_size;
71
+}
72
+
73
+static inline u32 l1_icache_bytes(void)
74
+{
75
+ return ppc64_caches.l1i.block_size;
76
+}
7177 #else
72
-#define __read_mostly __attribute__((__section__(".data..read_mostly")))
78
+static inline u32 l1_dcache_shift(void)
79
+{
80
+ return L1_CACHE_SHIFT;
81
+}
7382
74
-#ifdef CONFIG_6xx
83
+static inline u32 l1_dcache_bytes(void)
84
+{
85
+ return L1_CACHE_BYTES;
86
+}
87
+
88
+static inline u32 l1_icache_shift(void)
89
+{
90
+ return L1_CACHE_SHIFT;
91
+}
92
+
93
+static inline u32 l1_icache_bytes(void)
94
+{
95
+ return L1_CACHE_BYTES;
96
+}
97
+
98
+#endif
99
+
100
+#define __read_mostly __section(".data..read_mostly")
101
+
102
+#ifdef CONFIG_PPC_BOOK3S_32
75103 extern long _get_L2CR(void);
76104 extern long _get_L3CR(void);
77105 extern void _set_L2CR(unsigned long);
....@@ -102,6 +130,17 @@
102130 {
103131 __asm__ __volatile__ ("dcbst 0, %0" : : "r"(addr) : "memory");
104132 }
133
+
134
+static inline void icbi(void *addr)
135
+{
136
+ asm volatile ("icbi 0, %0" : : "r"(addr) : "memory");
137
+}
138
+
139
+static inline void iccci(void *addr)
140
+{
141
+ asm volatile ("iccci 0, %0" : : "r"(addr) : "memory");
142
+}
143
+
105144 #endif /* !__ASSEMBLY__ */
106145 #endif /* __KERNEL__ */
107146 #endif /* _ASM_POWERPC_CACHE_H */