1 /***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * * Neither the name of Cavium Networks nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
23 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
47 * Implementation of the Level 2 Cache (L2C) control,
48 * measurement, and debugging facilities.
50 * <hr>$Revision: 41586 $<hr>
53 #include "cvmx-config.h"
56 #include "cvmx-spinlock.h"
57 #include "cvmx-interrupt.h"
60 #ifndef CVMX_BUILD_FOR_LINUX_HOST
61 /* This spinlock is used internally to ensure that only one core is performing
62 ** certain L2 operations at a time.
64 ** NOTE: This only protects calls from within a single application - if multiple applications
65 ** or operating systems are running, then it is up to the user program to coordinate between them.
67 CVMX_SHARED cvmx_spinlock_t cvmx_l2c_spinlock;
70 static inline int l2_size_half(void)
72 uint64_t val = cvmx_read_csr(CVMX_L2D_FUS3);
73 return !!(val & (1ull << 34));
75 int cvmx_l2c_get_core_way_partition(uint32_t core)
79 /* Validate the core number */
80 if (core >= cvmx_octeon_num_cores())
83 /* Use the lower two bits of the coreNumber to determine the bit offset
84 * of the UMSK[] field in the L2C_SPAR register.
86 field = (core & 0x3) * 8;
88 /* Return the UMSK[] field from the appropriate L2C_SPAR register based
95 return((cvmx_read_csr(CVMX_L2C_SPAR0) & (0xFF << field)) >> field);
97 return((cvmx_read_csr(CVMX_L2C_SPAR1) & (0xFF << field)) >> field);
99 return((cvmx_read_csr(CVMX_L2C_SPAR2) & (0xFF << field)) >> field);
101 return((cvmx_read_csr(CVMX_L2C_SPAR3) & (0xFF << field)) >> field);
106 int cvmx_l2c_set_core_way_partition(uint32_t core, uint32_t mask)
111 valid_mask = (0x1 << cvmx_l2c_get_num_assoc()) - 1;
115 /* A UMSK setting which blocks all L2C Ways is an error. */
116 if (mask == valid_mask)
119 /* Validate the core number */
120 if (core >= cvmx_octeon_num_cores())
123 /* Check to make sure current mask & new mask don't block all ways */
124 if (((mask | cvmx_l2c_get_core_way_partition(core)) & valid_mask) == valid_mask)
128 /* Use the lower two bits of core to determine the bit offset of the
129 * UMSK[] field in the L2C_SPAR register.
131 field = (core & 0x3) * 8;
133 /* Assign the new mask setting to the UMSK[] field in the appropriate
134 * L2C_SPAR register based on the core_num.
140 cvmx_write_csr(CVMX_L2C_SPAR0,
141 (cvmx_read_csr(CVMX_L2C_SPAR0) & ~(0xFF << field)) |
145 cvmx_write_csr(CVMX_L2C_SPAR1,
146 (cvmx_read_csr(CVMX_L2C_SPAR1) & ~(0xFF << field)) |
150 cvmx_write_csr(CVMX_L2C_SPAR2,
151 (cvmx_read_csr(CVMX_L2C_SPAR2) & ~(0xFF << field)) |
155 cvmx_write_csr(CVMX_L2C_SPAR3,
156 (cvmx_read_csr(CVMX_L2C_SPAR3) & ~(0xFF << field)) |
164 int cvmx_l2c_set_hw_way_partition(uint32_t mask)
168 valid_mask = (0x1 << cvmx_l2c_get_num_assoc()) - 1;
171 /* A UMSK setting which blocks all L2C Ways is an error. */
172 if (mask == valid_mask)
174 /* Check to make sure current mask & new mask don't block all ways */
175 if (((mask | cvmx_l2c_get_hw_way_partition()) & valid_mask) == valid_mask)
178 cvmx_write_csr(CVMX_L2C_SPAR4, (cvmx_read_csr(CVMX_L2C_SPAR4) & ~0xFF) | mask);
182 int cvmx_l2c_get_hw_way_partition(void)
184 return(cvmx_read_csr(CVMX_L2C_SPAR4) & (0xFF));
188 void cvmx_l2c_config_perf(uint32_t counter, cvmx_l2c_event_t event,
189 uint32_t clear_on_read)
190 { cvmx_l2c_pfctl_t pfctl;
192 pfctl.u64 = cvmx_read_csr(CVMX_L2C_PFCTL);
197 pfctl.s.cnt0sel = event;
199 if (!cvmx_octeon_is_pass1())
200 pfctl.s.cnt0rdclr = clear_on_read;
203 pfctl.s.cnt1sel = event;
205 if (!cvmx_octeon_is_pass1())
206 pfctl.s.cnt1rdclr = clear_on_read;
209 pfctl.s.cnt2sel = event;
211 if (!cvmx_octeon_is_pass1())
212 pfctl.s.cnt2rdclr = clear_on_read;
216 pfctl.s.cnt3sel = event;
218 if (!cvmx_octeon_is_pass1())
219 pfctl.s.cnt3rdclr = clear_on_read;
223 cvmx_write_csr(CVMX_L2C_PFCTL, pfctl.u64);
226 uint64_t cvmx_l2c_read_perf(uint32_t counter)
231 return(cvmx_read_csr(CVMX_L2C_PFC0));
233 return(cvmx_read_csr(CVMX_L2C_PFC1));
235 return(cvmx_read_csr(CVMX_L2C_PFC2));
238 return(cvmx_read_csr(CVMX_L2C_PFC3));
242 #ifndef CVMX_BUILD_FOR_LINUX_HOST
245 * Helper function use to fault in cache lines for L2 cache locking
247 * @param addr Address of base of memory region to read into L2 cache
248 * @param len Length (in bytes) of region to fault in
250 static void fault_in(uint64_t addr, int len)
254 /* Adjust addr and length so we get all cache lines even for
255 ** small ranges spanning two cache lines */
256 len += addr & CVMX_CACHE_LINE_MASK;
257 addr &= ~CVMX_CACHE_LINE_MASK;
258 ptr = (volatile char *)cvmx_phys_to_ptr(addr);
259 CVMX_DCACHE_INVALIDATE; /* Invalidate L1 cache to make sure all loads result in data being in L2 */
263 len -= CVMX_CACHE_LINE_SIZE;
264 ptr += CVMX_CACHE_LINE_SIZE;
268 int cvmx_l2c_lock_line(uint64_t addr)
271 cvmx_l2c_dbg_t l2cdbg;
272 cvmx_l2c_lckbase_t lckbase;
273 cvmx_l2c_lckoff_t lckoff;
274 cvmx_l2t_err_t l2t_err;
279 cvmx_spinlock_lock(&cvmx_l2c_spinlock);
281 /* Clear l2t error bits if set */
282 l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
283 l2t_err.s.lckerr = 1;
284 l2t_err.s.lckerr2 = 1;
285 cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64);
287 addr &= ~CVMX_CACHE_LINE_MASK;
289 /* Set this core as debug core */
290 l2cdbg.s.ppnum = cvmx_get_core_num();
292 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64);
293 cvmx_read_csr(CVMX_L2C_DBG);
295 lckoff.s.lck_offset = 0; /* Only lock 1 line at a time */
296 cvmx_write_csr(CVMX_L2C_LCKOFF, lckoff.u64);
297 cvmx_read_csr(CVMX_L2C_LCKOFF);
299 if (((cvmx_l2c_cfg_t)(cvmx_read_csr(CVMX_L2C_CFG))).s.idxalias)
301 int alias_shift = CVMX_L2C_IDX_ADDR_SHIFT + 2 * CVMX_L2_SET_BITS - 1;
302 uint64_t addr_tmp = addr ^ (addr & ((1 << alias_shift) - 1)) >> CVMX_L2_SET_BITS;
303 lckbase.s.lck_base = addr_tmp >> 7;
307 lckbase.s.lck_base = addr >> 7;
310 lckbase.s.lck_ena = 1;
311 cvmx_write_csr(CVMX_L2C_LCKBASE, lckbase.u64);
312 cvmx_read_csr(CVMX_L2C_LCKBASE); // Make sure it gets there
314 fault_in(addr, CVMX_CACHE_LINE_SIZE);
316 lckbase.s.lck_ena = 0;
317 cvmx_write_csr(CVMX_L2C_LCKBASE, lckbase.u64);
318 cvmx_read_csr(CVMX_L2C_LCKBASE); // Make sure it gets there
320 /* Stop being debug core */
321 cvmx_write_csr(CVMX_L2C_DBG, 0);
322 cvmx_read_csr(CVMX_L2C_DBG);
324 l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
325 if (l2t_err.s.lckerr || l2t_err.s.lckerr2)
326 retval = 1; /* We were unable to lock the line */
328 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
334 int cvmx_l2c_lock_mem_region(uint64_t start, uint64_t len)
338 /* Round start/end to cache line boundaries */
339 len += start & CVMX_CACHE_LINE_MASK;
340 start &= ~CVMX_CACHE_LINE_MASK;
341 len = (len + CVMX_CACHE_LINE_MASK) & ~CVMX_CACHE_LINE_MASK;
345 retval += cvmx_l2c_lock_line(start);
346 start += CVMX_CACHE_LINE_SIZE;
347 len -= CVMX_CACHE_LINE_SIZE;
354 void cvmx_l2c_flush(void)
357 uint64_t n_assoc, n_set;
358 cvmx_l2c_dbg_t l2cdbg;
360 cvmx_spinlock_lock(&cvmx_l2c_spinlock);
363 if (!OCTEON_IS_MODEL(OCTEON_CN30XX))
364 l2cdbg.s.ppnum = cvmx_get_core_num();
366 n_set = CVMX_L2_SETS;
367 n_assoc = l2_size_half() ? (CVMX_L2_ASSOC/2) : CVMX_L2_ASSOC ;
368 for(set=0; set < n_set; set++)
370 for(assoc = 0; assoc < n_assoc; assoc++)
372 l2cdbg.s.set = assoc;
373 /* Enter debug mode, and make sure all other writes complete before we
374 ** enter debug mode */
376 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64);
377 cvmx_read_csr(CVMX_L2C_DBG);
379 CVMX_PREPARE_FOR_STORE (CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, set*CVMX_CACHE_LINE_SIZE), 0);
380 CVMX_SYNCW; /* Push STF out to L2 */
381 /* Exit debug mode */
383 cvmx_write_csr(CVMX_L2C_DBG, 0);
384 cvmx_read_csr(CVMX_L2C_DBG);
388 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
392 int cvmx_l2c_unlock_line(uint64_t address)
396 cvmx_l2c_dbg_t l2cdbg;
399 uint32_t index = cvmx_l2c_address_to_index(address);
401 cvmx_spinlock_lock(&cvmx_l2c_spinlock);
402 /* Compute portion of address that is stored in tag */
403 tag_addr = ((address >> CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) & ((1 << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) - 1));
404 for(assoc = 0; assoc < CVMX_L2_ASSOC; assoc++)
406 tag = cvmx_get_l2c_tag(assoc, index);
408 if (tag.s.V && (tag.s.addr == tag_addr))
411 l2cdbg.s.ppnum = cvmx_get_core_num();
412 l2cdbg.s.set = assoc;
416 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64); /* Enter debug mode */
417 cvmx_read_csr(CVMX_L2C_DBG);
419 CVMX_PREPARE_FOR_STORE (CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, address), 0);
421 /* Exit debug mode */
422 cvmx_write_csr(CVMX_L2C_DBG, 0);
423 cvmx_read_csr(CVMX_L2C_DBG);
424 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
428 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
432 int cvmx_l2c_unlock_mem_region(uint64_t start, uint64_t len)
434 int num_unlocked = 0;
435 /* Round start/end to cache line boundaries */
436 len += start & CVMX_CACHE_LINE_MASK;
437 start &= ~CVMX_CACHE_LINE_MASK;
438 len = (len + CVMX_CACHE_LINE_MASK) & ~CVMX_CACHE_LINE_MASK;
441 num_unlocked += cvmx_l2c_unlock_line(start);
442 start += CVMX_CACHE_LINE_SIZE;
443 len -= CVMX_CACHE_LINE_SIZE;
450 /* Internal l2c tag types. These are converted to a generic structure
451 ** that can be used on all chips */
455 #if __BYTE_ORDER == __BIG_ENDIAN
456 struct cvmx_l2c_tag_cn50xx
458 uint64_t reserved : 40;
459 uint64_t V : 1; // Line valid
460 uint64_t D : 1; // Line dirty
461 uint64_t L : 1; // Line locked
462 uint64_t U : 1; // Use, LRU eviction
463 uint64_t addr : 20; // Phys mem addr (33..14)
465 struct cvmx_l2c_tag_cn30xx
467 uint64_t reserved : 41;
468 uint64_t V : 1; // Line valid
469 uint64_t D : 1; // Line dirty
470 uint64_t L : 1; // Line locked
471 uint64_t U : 1; // Use, LRU eviction
472 uint64_t addr : 19; // Phys mem addr (33..15)
474 struct cvmx_l2c_tag_cn31xx
476 uint64_t reserved : 42;
477 uint64_t V : 1; // Line valid
478 uint64_t D : 1; // Line dirty
479 uint64_t L : 1; // Line locked
480 uint64_t U : 1; // Use, LRU eviction
481 uint64_t addr : 18; // Phys mem addr (33..16)
483 struct cvmx_l2c_tag_cn38xx
485 uint64_t reserved : 43;
486 uint64_t V : 1; // Line valid
487 uint64_t D : 1; // Line dirty
488 uint64_t L : 1; // Line locked
489 uint64_t U : 1; // Use, LRU eviction
490 uint64_t addr : 17; // Phys mem addr (33..17)
492 struct cvmx_l2c_tag_cn58xx
494 uint64_t reserved : 44;
495 uint64_t V : 1; // Line valid
496 uint64_t D : 1; // Line dirty
497 uint64_t L : 1; // Line locked
498 uint64_t U : 1; // Use, LRU eviction
499 uint64_t addr : 16; // Phys mem addr (33..18)
501 struct cvmx_l2c_tag_cn58xx cn56xx; /* 2048 sets */
502 struct cvmx_l2c_tag_cn31xx cn52xx; /* 512 sets */
509 * Function to read a L2C tag. This code make the current core
510 * the 'debug core' for the L2. This code must only be executed by
513 * @param assoc Association (way) of the tag to dump
514 * @param index Index of the cacheline
516 * @return The Octeon model specific tag structure. This is translated by a wrapper
517 * function to a generic form that is easier for applications to use.
519 static __cvmx_l2c_tag_t __read_l2_tag(uint64_t assoc, uint64_t index)
522 uint64_t debug_tag_addr = (((1ULL << 63) | (index << 7)) + 96);
523 uint64_t core = cvmx_get_core_num();
524 __cvmx_l2c_tag_t tag_val;
525 uint64_t dbg_addr = CVMX_L2C_DBG;
528 cvmx_l2c_dbg_t debug_val;
530 /* For low core count parts, the core number is always small enough
531 ** to stay in the correct field and not set any reserved bits */
532 debug_val.s.ppnum = core;
534 debug_val.s.set = assoc;
536 CVMX_SYNC; /* Make sure core is quiet (no prefetches, etc.) before entering debug mode */
537 CVMX_DCACHE_INVALIDATE; /* Flush L1 to make sure debug load misses L1 */
539 flags = cvmx_interrupt_disable_save();
541 /* The following must be done in assembly as when in debug mode all data loads from
542 ** L2 return special debug data, not normal memory contents. Also, interrupts must be disabled,
543 ** since if an interrupt occurs while in debug mode the ISR will get debug data from all its memory
544 ** reads instead of the contents of memory */
550 " sd %[dbg_val], 0(%[dbg_addr]) \n" /* Enter debug mode, wait for store */
551 " ld $0, 0(%[dbg_addr]) \n"
552 " ld %[tag_val], 0(%[tag_addr]) \n" /* Read L2C tag data */
553 " sd $0, 0(%[dbg_addr]) \n" /* Exit debug mode, wait for store */
554 " ld $0, 0(%[dbg_addr]) \n"
555 " cache 9, 0($0) \n" /* Invalidate dcache to discard debug data */
557 :[tag_val] "=r" (tag_val): [dbg_addr] "r" (dbg_addr), [dbg_val] "r" (debug_val), [tag_addr] "r" (debug_tag_addr) : "memory");
559 cvmx_interrupt_restore(flags);
566 cvmx_l2c_tag_t cvmx_l2c_get_tag(uint32_t association, uint32_t index)
568 __cvmx_l2c_tag_t tmp_tag;
572 if ((int)association >= cvmx_l2c_get_num_assoc())
574 cvmx_dprintf("ERROR: cvmx_get_l2c_tag association out of range\n");
577 if ((int)index >= cvmx_l2c_get_num_sets())
579 cvmx_dprintf("ERROR: cvmx_get_l2c_tag index out of range (arg: %d, max: %d)\n", (int)index, cvmx_l2c_get_num_sets());
582 /* __read_l2_tag is intended for internal use only */
583 tmp_tag = __read_l2_tag(association, index);
585 /* Convert all tag structure types to generic version, as it can represent all models */
586 if (OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN56XX))
588 tag.s.V = tmp_tag.cn58xx.V;
589 tag.s.D = tmp_tag.cn58xx.D;
590 tag.s.L = tmp_tag.cn58xx.L;
591 tag.s.U = tmp_tag.cn58xx.U;
592 tag.s.addr = tmp_tag.cn58xx.addr;
594 else if (OCTEON_IS_MODEL(OCTEON_CN38XX))
596 tag.s.V = tmp_tag.cn38xx.V;
597 tag.s.D = tmp_tag.cn38xx.D;
598 tag.s.L = tmp_tag.cn38xx.L;
599 tag.s.U = tmp_tag.cn38xx.U;
600 tag.s.addr = tmp_tag.cn38xx.addr;
602 else if (OCTEON_IS_MODEL(OCTEON_CN31XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
604 tag.s.V = tmp_tag.cn31xx.V;
605 tag.s.D = tmp_tag.cn31xx.D;
606 tag.s.L = tmp_tag.cn31xx.L;
607 tag.s.U = tmp_tag.cn31xx.U;
608 tag.s.addr = tmp_tag.cn31xx.addr;
610 else if (OCTEON_IS_MODEL(OCTEON_CN30XX))
612 tag.s.V = tmp_tag.cn30xx.V;
613 tag.s.D = tmp_tag.cn30xx.D;
614 tag.s.L = tmp_tag.cn30xx.L;
615 tag.s.U = tmp_tag.cn30xx.U;
616 tag.s.addr = tmp_tag.cn30xx.addr;
618 else if (OCTEON_IS_MODEL(OCTEON_CN50XX))
620 tag.s.V = tmp_tag.cn50xx.V;
621 tag.s.D = tmp_tag.cn50xx.D;
622 tag.s.L = tmp_tag.cn50xx.L;
623 tag.s.U = tmp_tag.cn50xx.U;
624 tag.s.addr = tmp_tag.cn50xx.addr;
628 cvmx_dprintf("Unsupported OCTEON Model in %s\n", __FUNCTION__);
636 uint32_t cvmx_l2c_address_to_index (uint64_t addr)
638 uint64_t idx = addr >> CVMX_L2C_IDX_ADDR_SHIFT;
639 cvmx_l2c_cfg_t l2c_cfg;
640 l2c_cfg.u64 = cvmx_read_csr(CVMX_L2C_CFG);
642 if (l2c_cfg.s.idxalias)
644 idx ^= ((addr & CVMX_L2C_ALIAS_MASK) >> CVMX_L2C_TAG_ADDR_ALIAS_SHIFT);
646 idx &= CVMX_L2C_IDX_MASK;
650 int cvmx_l2c_get_cache_size_bytes(void)
652 return (cvmx_l2c_get_num_sets() * cvmx_l2c_get_num_assoc() * CVMX_CACHE_LINE_SIZE);
656 * Return log base 2 of the number of sets in the L2 cache
659 int cvmx_l2c_get_set_bits(void)
662 if (OCTEON_IS_MODEL(OCTEON_CN56XX) ||
663 OCTEON_IS_MODEL(OCTEON_CN58XX))
664 l2_set_bits = 11; /* 2048 sets */
665 else if (OCTEON_IS_MODEL(OCTEON_CN38XX))
666 l2_set_bits = 10; /* 1024 sets */
667 else if (OCTEON_IS_MODEL(OCTEON_CN31XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
668 l2_set_bits = 9; /* 512 sets */
669 else if (OCTEON_IS_MODEL(OCTEON_CN30XX))
670 l2_set_bits = 8; /* 256 sets */
671 else if (OCTEON_IS_MODEL(OCTEON_CN50XX))
672 l2_set_bits = 7; /* 128 sets */
675 cvmx_dprintf("Unsupported OCTEON Model in %s\n", __FUNCTION__);
676 l2_set_bits = 11; /* 2048 sets */
682 /* Return the number of sets in the L2 Cache */
683 int cvmx_l2c_get_num_sets(void)
685 return (1 << cvmx_l2c_get_set_bits());
688 /* Return the number of associations in the L2 Cache */
689 int cvmx_l2c_get_num_assoc(void)
692 if (OCTEON_IS_MODEL(OCTEON_CN56XX) ||
693 OCTEON_IS_MODEL(OCTEON_CN52XX) ||
694 OCTEON_IS_MODEL(OCTEON_CN58XX) ||
695 OCTEON_IS_MODEL(OCTEON_CN50XX) ||
696 OCTEON_IS_MODEL(OCTEON_CN38XX))
698 else if (OCTEON_IS_MODEL(OCTEON_CN31XX) ||
699 OCTEON_IS_MODEL(OCTEON_CN30XX))
703 cvmx_dprintf("Unsupported OCTEON Model in %s\n", __FUNCTION__);
707 /* Check to see if part of the cache is disabled */
708 if (cvmx_fuse_read(265))
709 l2_assoc = l2_assoc >> 2;
710 else if (cvmx_fuse_read(264))
711 l2_assoc = l2_assoc >> 1;
717 #ifndef CVMX_BUILD_FOR_LINUX_HOST
719 * Flush a line from the L2 cache
720 * This should only be called from one core at a time, as this routine
721 * sets the core to the 'debug' core in order to flush the line.
723 * @param assoc Association (or way) to flush
724 * @param index Index to flush
726 void cvmx_l2c_flush_line(uint32_t assoc, uint32_t index)
728 cvmx_l2c_dbg_t l2cdbg;
731 l2cdbg.s.ppnum = cvmx_get_core_num();
734 l2cdbg.s.set = assoc;
735 /* Enter debug mode, and make sure all other writes complete before we
736 ** enter debug mode */
737 asm volatile ("sync \n"::: "memory");
738 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64);
739 cvmx_read_csr(CVMX_L2C_DBG);
741 CVMX_PREPARE_FOR_STORE (((1ULL << 63) + (index)*128), 0);
742 /* Exit debug mode */
743 asm volatile ("sync \n"::: "memory");
744 cvmx_write_csr(CVMX_L2C_DBG, 0);
745 cvmx_read_csr(CVMX_L2C_DBG);