aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/octeon
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2010-10-07 19:03:42 -0400
committerRalf Baechle <ralf@linux-mips.org>2010-10-29 14:08:35 -0400
commitb8db85b5b5c22236d168eb03a67c2641bf7fa651 (patch)
treea372c5f0db85255ce60f2670a1211f205239d045 /arch/mips/include/asm/octeon
parenta70b13a9f07ae0e21870ed3e9b6829f556579c5c (diff)
MIPS: Octeon: Update L2 Cache code for CN63XX
The CN63XX has a different L2 cache architecture. Update the helper functions to reflect this. Some joining of split lines was also done to improve readability, as well as reformatting of comments. Signed-off-by: David Daney <ddaney@caviumnetworks.com> Patchwork: http://patchwork.linux-mips.org/patch/1663/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include/asm/octeon')
-rw-r--r--arch/mips/include/asm/octeon/cvmx-asm.h11
-rw-r--r--arch/mips/include/asm/octeon/cvmx-l2c.h225
2 files changed, 141 insertions, 95 deletions
diff --git a/arch/mips/include/asm/octeon/cvmx-asm.h b/arch/mips/include/asm/octeon/cvmx-asm.h
index b21d3fc1ef91..5de5de95311b 100644
--- a/arch/mips/include/asm/octeon/cvmx-asm.h
+++ b/arch/mips/include/asm/octeon/cvmx-asm.h
@@ -114,6 +114,17 @@
114#define CVMX_DCACHE_INVALIDATE \ 114#define CVMX_DCACHE_INVALIDATE \
115 { CVMX_SYNC; asm volatile ("cache 9, 0($0)" : : ); } 115 { CVMX_SYNC; asm volatile ("cache 9, 0($0)" : : ); }
116 116
117#define CVMX_CACHE(op, address, offset) \
118 asm volatile ("cache " CVMX_TMP_STR(op) ", " CVMX_TMP_STR(offset) "(%[rbase])" \
119 : : [rbase] "d" (address) )
120/* fetch and lock the state. */
121#define CVMX_CACHE_LCKL2(address, offset) CVMX_CACHE(31, address, offset)
122/* unlock the state. */
123#define CVMX_CACHE_WBIL2(address, offset) CVMX_CACHE(23, address, offset)
124/* invalidate the cache block and clear the USED bits for the block */
125#define CVMX_CACHE_WBIL2I(address, offset) CVMX_CACHE(3, address, offset)
126/* load virtual tag and data for the L2 cache block into L2C_TAD0_TAG register */
127#define CVMX_CACHE_LTGL2I(address, offset) CVMX_CACHE(7, address, offset)
117 128
118#define CVMX_POP(result, input) \ 129#define CVMX_POP(result, input) \
119 asm ("pop %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input)) 130 asm ("pop %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input))
diff --git a/arch/mips/include/asm/octeon/cvmx-l2c.h b/arch/mips/include/asm/octeon/cvmx-l2c.h
index 2a8c0902ea50..0b32c5b118e2 100644
--- a/arch/mips/include/asm/octeon/cvmx-l2c.h
+++ b/arch/mips/include/asm/octeon/cvmx-l2c.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -26,7 +26,6 @@
26 ***********************license end**************************************/ 26 ***********************license end**************************************/
27 27
28/* 28/*
29 *
30 * Interface to the Level 2 Cache (L2C) control, measurement, and debugging 29 * Interface to the Level 2 Cache (L2C) control, measurement, and debugging
31 * facilities. 30 * facilities.
32 */ 31 */
@@ -34,93 +33,126 @@
34#ifndef __CVMX_L2C_H__ 33#ifndef __CVMX_L2C_H__
35#define __CVMX_L2C_H__ 34#define __CVMX_L2C_H__
36 35
37/* Deprecated macro, use function */ 36#define CVMX_L2_ASSOC cvmx_l2c_get_num_assoc() /* Deprecated macro, use function */
38#define CVMX_L2_ASSOC cvmx_l2c_get_num_assoc() 37#define CVMX_L2_SET_BITS cvmx_l2c_get_set_bits() /* Deprecated macro, use function */
39 38#define CVMX_L2_SETS cvmx_l2c_get_num_sets() /* Deprecated macro, use function */
40/* Deprecated macro, use function */
41#define CVMX_L2_SET_BITS cvmx_l2c_get_set_bits()
42 39
43/* Deprecated macro, use function */
44#define CVMX_L2_SETS cvmx_l2c_get_num_sets()
45 40
46#define CVMX_L2C_IDX_ADDR_SHIFT 7 /* based on 128 byte cache line size */ 41#define CVMX_L2C_IDX_ADDR_SHIFT 7 /* based on 128 byte cache line size */
47#define CVMX_L2C_IDX_MASK (cvmx_l2c_get_num_sets() - 1) 42#define CVMX_L2C_IDX_MASK (cvmx_l2c_get_num_sets() - 1)
48 43
49/* Defines for index aliasing computations */ 44/* Defines for index aliasing computations */
50#define CVMX_L2C_TAG_ADDR_ALIAS_SHIFT \ 45#define CVMX_L2C_TAG_ADDR_ALIAS_SHIFT (CVMX_L2C_IDX_ADDR_SHIFT + cvmx_l2c_get_set_bits())
51 (CVMX_L2C_IDX_ADDR_SHIFT + cvmx_l2c_get_set_bits()) 46#define CVMX_L2C_ALIAS_MASK (CVMX_L2C_IDX_MASK << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT)
47#define CVMX_L2C_MEMBANK_SELECT_SIZE 4096
52 48
53#define CVMX_L2C_ALIAS_MASK \ 49/* Defines for Virtualizations, valid only from Octeon II onwards. */
54 (CVMX_L2C_IDX_MASK << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) 50#define CVMX_L2C_VRT_MAX_VIRTID_ALLOWED ((OCTEON_IS_MODEL(OCTEON_CN63XX)) ? 64 : 0)
51#define CVMX_L2C_VRT_MAX_MEMSZ_ALLOWED ((OCTEON_IS_MODEL(OCTEON_CN63XX)) ? 32 : 0)
55 52
56union cvmx_l2c_tag { 53union cvmx_l2c_tag {
57 uint64_t u64; 54 uint64_t u64;
58 struct { 55 struct {
59 uint64_t reserved:28; 56 uint64_t reserved:28;
60 uint64_t V:1; /* Line valid */ 57 uint64_t V:1; /* Line valid */
61 uint64_t D:1; /* Line dirty */ 58 uint64_t D:1; /* Line dirty */
62 uint64_t L:1; /* Line locked */ 59 uint64_t L:1; /* Line locked */
63 uint64_t U:1; /* Use, LRU eviction */ 60 uint64_t U:1; /* Use, LRU eviction */
64 uint64_t addr:32; /* Phys mem (not all bits valid) */ 61 uint64_t addr:32; /* Phys mem (not all bits valid) */
65 } s; 62 } s;
66}; 63};
67 64
65/* Number of L2C Tag-and-data sections (TADs) that are connected to LMC. */
66#define CVMX_L2C_TADS 1
67
68 /* L2C Performance Counter events. */ 68 /* L2C Performance Counter events. */
69enum cvmx_l2c_event { 69enum cvmx_l2c_event {
70 CVMX_L2C_EVENT_CYCLES = 0, 70 CVMX_L2C_EVENT_CYCLES = 0,
71 CVMX_L2C_EVENT_INSTRUCTION_MISS = 1, 71 CVMX_L2C_EVENT_INSTRUCTION_MISS = 1,
72 CVMX_L2C_EVENT_INSTRUCTION_HIT = 2, 72 CVMX_L2C_EVENT_INSTRUCTION_HIT = 2,
73 CVMX_L2C_EVENT_DATA_MISS = 3, 73 CVMX_L2C_EVENT_DATA_MISS = 3,
74 CVMX_L2C_EVENT_DATA_HIT = 4, 74 CVMX_L2C_EVENT_DATA_HIT = 4,
75 CVMX_L2C_EVENT_MISS = 5, 75 CVMX_L2C_EVENT_MISS = 5,
76 CVMX_L2C_EVENT_HIT = 6, 76 CVMX_L2C_EVENT_HIT = 6,
77 CVMX_L2C_EVENT_VICTIM_HIT = 7, 77 CVMX_L2C_EVENT_VICTIM_HIT = 7,
78 CVMX_L2C_EVENT_INDEX_CONFLICT = 8, 78 CVMX_L2C_EVENT_INDEX_CONFLICT = 8,
79 CVMX_L2C_EVENT_TAG_PROBE = 9, 79 CVMX_L2C_EVENT_TAG_PROBE = 9,
80 CVMX_L2C_EVENT_TAG_UPDATE = 10, 80 CVMX_L2C_EVENT_TAG_UPDATE = 10,
81 CVMX_L2C_EVENT_TAG_COMPLETE = 11, 81 CVMX_L2C_EVENT_TAG_COMPLETE = 11,
82 CVMX_L2C_EVENT_TAG_DIRTY = 12, 82 CVMX_L2C_EVENT_TAG_DIRTY = 12,
83 CVMX_L2C_EVENT_DATA_STORE_NOP = 13, 83 CVMX_L2C_EVENT_DATA_STORE_NOP = 13,
84 CVMX_L2C_EVENT_DATA_STORE_READ = 14, 84 CVMX_L2C_EVENT_DATA_STORE_READ = 14,
85 CVMX_L2C_EVENT_DATA_STORE_WRITE = 15, 85 CVMX_L2C_EVENT_DATA_STORE_WRITE = 15,
86 CVMX_L2C_EVENT_FILL_DATA_VALID = 16, 86 CVMX_L2C_EVENT_FILL_DATA_VALID = 16,
87 CVMX_L2C_EVENT_WRITE_REQUEST = 17, 87 CVMX_L2C_EVENT_WRITE_REQUEST = 17,
88 CVMX_L2C_EVENT_READ_REQUEST = 18, 88 CVMX_L2C_EVENT_READ_REQUEST = 18,
89 CVMX_L2C_EVENT_WRITE_DATA_VALID = 19, 89 CVMX_L2C_EVENT_WRITE_DATA_VALID = 19,
90 CVMX_L2C_EVENT_XMC_NOP = 20, 90 CVMX_L2C_EVENT_XMC_NOP = 20,
91 CVMX_L2C_EVENT_XMC_LDT = 21, 91 CVMX_L2C_EVENT_XMC_LDT = 21,
92 CVMX_L2C_EVENT_XMC_LDI = 22, 92 CVMX_L2C_EVENT_XMC_LDI = 22,
93 CVMX_L2C_EVENT_XMC_LDD = 23, 93 CVMX_L2C_EVENT_XMC_LDD = 23,
94 CVMX_L2C_EVENT_XMC_STF = 24, 94 CVMX_L2C_EVENT_XMC_STF = 24,
95 CVMX_L2C_EVENT_XMC_STT = 25, 95 CVMX_L2C_EVENT_XMC_STT = 25,
96 CVMX_L2C_EVENT_XMC_STP = 26, 96 CVMX_L2C_EVENT_XMC_STP = 26,
97 CVMX_L2C_EVENT_XMC_STC = 27, 97 CVMX_L2C_EVENT_XMC_STC = 27,
98 CVMX_L2C_EVENT_XMC_DWB = 28, 98 CVMX_L2C_EVENT_XMC_DWB = 28,
99 CVMX_L2C_EVENT_XMC_PL2 = 29, 99 CVMX_L2C_EVENT_XMC_PL2 = 29,
100 CVMX_L2C_EVENT_XMC_PSL1 = 30, 100 CVMX_L2C_EVENT_XMC_PSL1 = 30,
101 CVMX_L2C_EVENT_XMC_IOBLD = 31, 101 CVMX_L2C_EVENT_XMC_IOBLD = 31,
102 CVMX_L2C_EVENT_XMC_IOBST = 32, 102 CVMX_L2C_EVENT_XMC_IOBST = 32,
103 CVMX_L2C_EVENT_XMC_IOBDMA = 33, 103 CVMX_L2C_EVENT_XMC_IOBDMA = 33,
104 CVMX_L2C_EVENT_XMC_IOBRSP = 34, 104 CVMX_L2C_EVENT_XMC_IOBRSP = 34,
105 CVMX_L2C_EVENT_XMC_BUS_VALID = 35, 105 CVMX_L2C_EVENT_XMC_BUS_VALID = 35,
106 CVMX_L2C_EVENT_XMC_MEM_DATA = 36, 106 CVMX_L2C_EVENT_XMC_MEM_DATA = 36,
107 CVMX_L2C_EVENT_XMC_REFL_DATA = 37, 107 CVMX_L2C_EVENT_XMC_REFL_DATA = 37,
108 CVMX_L2C_EVENT_XMC_IOBRSP_DATA = 38, 108 CVMX_L2C_EVENT_XMC_IOBRSP_DATA = 38,
109 CVMX_L2C_EVENT_RSC_NOP = 39, 109 CVMX_L2C_EVENT_RSC_NOP = 39,
110 CVMX_L2C_EVENT_RSC_STDN = 40, 110 CVMX_L2C_EVENT_RSC_STDN = 40,
111 CVMX_L2C_EVENT_RSC_FILL = 41, 111 CVMX_L2C_EVENT_RSC_FILL = 41,
112 CVMX_L2C_EVENT_RSC_REFL = 42, 112 CVMX_L2C_EVENT_RSC_REFL = 42,
113 CVMX_L2C_EVENT_RSC_STIN = 43, 113 CVMX_L2C_EVENT_RSC_STIN = 43,
114 CVMX_L2C_EVENT_RSC_SCIN = 44, 114 CVMX_L2C_EVENT_RSC_SCIN = 44,
115 CVMX_L2C_EVENT_RSC_SCFL = 45, 115 CVMX_L2C_EVENT_RSC_SCFL = 45,
116 CVMX_L2C_EVENT_RSC_SCDN = 46, 116 CVMX_L2C_EVENT_RSC_SCDN = 46,
117 CVMX_L2C_EVENT_RSC_DATA_VALID = 47, 117 CVMX_L2C_EVENT_RSC_DATA_VALID = 47,
118 CVMX_L2C_EVENT_RSC_VALID_FILL = 48, 118 CVMX_L2C_EVENT_RSC_VALID_FILL = 48,
119 CVMX_L2C_EVENT_RSC_VALID_STRSP = 49, 119 CVMX_L2C_EVENT_RSC_VALID_STRSP = 49,
120 CVMX_L2C_EVENT_RSC_VALID_REFL = 50, 120 CVMX_L2C_EVENT_RSC_VALID_REFL = 50,
121 CVMX_L2C_EVENT_LRF_REQ = 51, 121 CVMX_L2C_EVENT_LRF_REQ = 51,
122 CVMX_L2C_EVENT_DT_RD_ALLOC = 52, 122 CVMX_L2C_EVENT_DT_RD_ALLOC = 52,
123 CVMX_L2C_EVENT_DT_WR_INVAL = 53 123 CVMX_L2C_EVENT_DT_WR_INVAL = 53,
124 CVMX_L2C_EVENT_MAX
125};
126
127/* L2C Performance Counter events for Octeon2. */
128enum cvmx_l2c_tad_event {
129 CVMX_L2C_TAD_EVENT_NONE = 0,
130 CVMX_L2C_TAD_EVENT_TAG_HIT = 1,
131 CVMX_L2C_TAD_EVENT_TAG_MISS = 2,
132 CVMX_L2C_TAD_EVENT_TAG_NOALLOC = 3,
133 CVMX_L2C_TAD_EVENT_TAG_VICTIM = 4,
134 CVMX_L2C_TAD_EVENT_SC_FAIL = 5,
135 CVMX_L2C_TAD_EVENT_SC_PASS = 6,
136 CVMX_L2C_TAD_EVENT_LFB_VALID = 7,
137 CVMX_L2C_TAD_EVENT_LFB_WAIT_LFB = 8,
138 CVMX_L2C_TAD_EVENT_LFB_WAIT_VAB = 9,
139 CVMX_L2C_TAD_EVENT_QUAD0_INDEX = 128,
140 CVMX_L2C_TAD_EVENT_QUAD0_READ = 129,
141 CVMX_L2C_TAD_EVENT_QUAD0_BANK = 130,
142 CVMX_L2C_TAD_EVENT_QUAD0_WDAT = 131,
143 CVMX_L2C_TAD_EVENT_QUAD1_INDEX = 144,
144 CVMX_L2C_TAD_EVENT_QUAD1_READ = 145,
145 CVMX_L2C_TAD_EVENT_QUAD1_BANK = 146,
146 CVMX_L2C_TAD_EVENT_QUAD1_WDAT = 147,
147 CVMX_L2C_TAD_EVENT_QUAD2_INDEX = 160,
148 CVMX_L2C_TAD_EVENT_QUAD2_READ = 161,
149 CVMX_L2C_TAD_EVENT_QUAD2_BANK = 162,
150 CVMX_L2C_TAD_EVENT_QUAD2_WDAT = 163,
151 CVMX_L2C_TAD_EVENT_QUAD3_INDEX = 176,
152 CVMX_L2C_TAD_EVENT_QUAD3_READ = 177,
153 CVMX_L2C_TAD_EVENT_QUAD3_BANK = 178,
154 CVMX_L2C_TAD_EVENT_QUAD3_WDAT = 179,
155 CVMX_L2C_TAD_EVENT_MAX
124}; 156};
125 157
126/** 158/**
@@ -132,10 +164,10 @@ enum cvmx_l2c_event {
132 * @clear_on_read: When asserted, any read of the performance counter 164 * @clear_on_read: When asserted, any read of the performance counter
133 * clears the counter. 165 * clears the counter.
134 * 166 *
135 * The routine does not clear the counter. 167 * @note The routine does not clear the counter.
136 */ 168 */
137void cvmx_l2c_config_perf(uint32_t counter, 169void cvmx_l2c_config_perf(uint32_t counter, enum cvmx_l2c_event event, uint32_t clear_on_read);
138 enum cvmx_l2c_event event, uint32_t clear_on_read); 170
139/** 171/**
140 * Read the given L2 Cache performance counter. The counter must be configured 172 * Read the given L2 Cache performance counter. The counter must be configured
141 * before reading, but this routine does not enforce this requirement. 173 * before reading, but this routine does not enforce this requirement.
@@ -160,18 +192,18 @@ int cvmx_l2c_get_core_way_partition(uint32_t core);
160/** 192/**
161 * Partitions the L2 cache for a core 193 * Partitions the L2 cache for a core
162 * 194 *
163 * @core: The core that the partitioning applies to. 195 * @core: The core that the partitioning applies to.
196 * @mask: The partitioning of the ways expressed as a binary
197 * mask. A 0 bit allows the core to evict cache lines from
198 * a way, while a 1 bit blocks the core from evicting any
199 * lines from that way. There must be at least one allowed
200 * way (0 bit) in the mask.
164 * 201 *
165 * @mask: The partitioning of the ways expressed as a binary mask. A 0 202
166 * bit allows the core to evict cache lines from a way, while a 203 * @note If any ways are blocked for all cores and the HW blocks, then
167 * 1 bit blocks the core from evicting any lines from that 204 * those ways will never have any cache lines evicted from them.
168 * way. There must be at least one allowed way (0 bit) in the 205 * All cores and the hardware blocks are free to read from all
169 * mask. 206 * ways regardless of the partitioning.
170 *
171 * If any ways are blocked for all cores and the HW blocks, then those
172 * ways will never have any cache lines evicted from them. All cores
173 * and the hardware blocks are free to read from all ways regardless
174 * of the partitioning.
175 */ 207 */
176int cvmx_l2c_set_core_way_partition(uint32_t core, uint32_t mask); 208int cvmx_l2c_set_core_way_partition(uint32_t core, uint32_t mask);
177 209
@@ -187,19 +219,21 @@ int cvmx_l2c_get_hw_way_partition(void);
187/** 219/**
188 * Partitions the L2 cache for the hardware blocks. 220 * Partitions the L2 cache for the hardware blocks.
189 * 221 *
190 * @mask: The partitioning of the ways expressed as a binary mask. A 0 222 * @mask: The partitioning of the ways expressed as a binary
191 * bit allows the core to evict cache lines from a way, while a 223 * mask. A 0 bit allows the core to evict cache lines from
192 * 1 bit blocks the core from evicting any lines from that 224 * a way, while a 1 bit blocks the core from evicting any
193 * way. There must be at least one allowed way (0 bit) in the 225 * lines from that way. There must be at least one allowed
194 * mask. 226 * way (0 bit) in the mask.
195 * 227 *
196 * If any ways are blocked for all cores and the HW blocks, then those 228
197 * ways will never have any cache lines evicted from them. All cores 229 * @note If any ways are blocked for all cores and the HW blocks, then
198 * and the hardware blocks are free to read from all ways regardless 230 * those ways will never have any cache lines evicted from them.
199 * of the partitioning. 231 * All cores and the hardware blocks are free to read from all
232 * ways regardless of the partitioning.
200 */ 233 */
201int cvmx_l2c_set_hw_way_partition(uint32_t mask); 234int cvmx_l2c_set_hw_way_partition(uint32_t mask);
202 235
236
203/** 237/**
204 * Locks a line in the L2 cache at the specified physical address 238 * Locks a line in the L2 cache at the specified physical address
205 * 239 *
@@ -263,13 +297,14 @@ int cvmx_l2c_unlock_mem_region(uint64_t start, uint64_t len);
263 */ 297 */
264union cvmx_l2c_tag cvmx_l2c_get_tag(uint32_t association, uint32_t index); 298union cvmx_l2c_tag cvmx_l2c_get_tag(uint32_t association, uint32_t index);
265 299
266/* Wrapper around deprecated old function name */ 300/* Wrapper providing a deprecated old function name */
267static inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association, 301static inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association, uint32_t index) __attribute__((deprecated));
268 uint32_t index) 302static inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association, uint32_t index)
269{ 303{
270 return cvmx_l2c_get_tag(association, index); 304 return cvmx_l2c_get_tag(association, index);
271} 305}
272 306
307
273/** 308/**
274 * Returns the cache index for a given physical address 309 * Returns the cache index for a given physical address
275 * 310 *