Module Name: src
Committed By: palle
Date: Wed Feb 11 04:44:11 UTC 2015
Modified Files:
src/sys/arch/sparc64/sparc64: cpu.c
Log Message:
sun4v: Ensure that sane values are returned in scenarios where no
x_cache_associativity info is present, e.g. in a simulated environment like the
Legion simulator
To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/sparc64/sparc64/cpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.122 src/sys/arch/sparc64/sparc64/cpu.c:1.123
--- src/sys/arch/sparc64/sparc64/cpu.c:1.122 Sat Jan 24 20:17:22 2015
+++ src/sys/arch/sparc64/sparc64/cpu.c Wed Feb 11 04:44:11 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.122 2015/01/24 20:17:22 palle Exp $ */
+/* $NetBSD: cpu.c,v 1.123 2015/02/11 04:44:11 palle Exp $ */
/*
* Copyright (c) 1996
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.122 2015/01/24 20:17:22 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.123 2015/02/11 04:44:11 palle Exp $");
#include "opt_multiprocessor.h"
@@ -210,9 +210,13 @@ cpu_icache_nlines(int node)
static int
cpu_icache_associativity(int node)
{
- if (CPU_ISSUN4V)
- return cpu_cache_info_sun4v("instn", 1, "associativity");
- else
+ if (CPU_ISSUN4V) {
+ int val;
+ val = cpu_cache_info_sun4v("instn", 1, "associativity");
+ if (val == 0)
+ val = 1;
+ return val;
+ } else
return prom_getpropint(node, "icache-associativity", 1);
}
@@ -246,9 +250,13 @@ cpu_dcache_nlines(int node)
static int
cpu_dcache_associativity(int node)
{
- if (CPU_ISSUN4V)
- return cpu_cache_info_sun4v("data", 1, "associativity");
- else
+ if (CPU_ISSUN4V) {
+ int val;
+ val = cpu_cache_info_sun4v("data", 1, "associativity");
+ if (val == 0)
+ val = 1;
+ return val;
+ } else
return prom_getpropint(node, "dcache-associativity", 1);
}
@@ -282,9 +290,13 @@ cpu_ecache_nlines(int node)
static int
cpu_ecache_associativity(int node)
{
- if (CPU_ISSUN4V)
- return cpu_cache_info_sun4v(NULL, 2, "associativity");
- else
+ if (CPU_ISSUN4V) {
+ int val;
+ val = cpu_cache_info_sun4v(NULL, 2, "associativity");
+ if (val == 0)
+ val = 1;
+ return val;
+ } else
return prom_getpropint(node, "ecache-associativity", 1);
}