Module Name:    src
Committed By:   rin
Date:           Mon Oct 11 07:32:52 UTC 2021

Modified Files:
        src/sys/arch/arm/arm32: cpu.c

Log Message:
For some classic CPUs, info->[id]cache_sets are not initialized.
Calculate and print numbers of sets in this case.


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/sys/arch/arm/arm32/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/arm/arm32/cpu.c
diff -u src/sys/arch/arm/arm32/cpu.c:1.150 src/sys/arch/arm/arm32/cpu.c:1.151
--- src/sys/arch/arm/arm32/cpu.c:1.150	Mon Oct 11 07:19:37 2021
+++ src/sys/arch/arm/arm32/cpu.c	Mon Oct 11 07:32:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.150 2021/10/11 07:19:37 rin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.151 2021/10/11 07:32:52 rin Exp $	*/
 
 /*
  * Copyright (c) 1995 Mark Brinicombe.
@@ -46,7 +46,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.150 2021/10/11 07:19:37 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.151 2021/10/11 07:32:52 rin Exp $");
 
 #include <sys/param.h>
 
@@ -612,7 +612,9 @@ print_cache_info(device_t dv, struct arm
 		    level + 1,
 		    info->dcache_size / 1024,
 		    info->dcache_line_size, info->dcache_ways,
-		    info->dcache_sets,
+		    info->dcache_sets ? info->dcache_sets :
+			info->dcache_size /
+			    (info->dcache_line_size * info->dcache_ways),
 		    wtnames[info->cache_type],
 		    info->dcache_type & CACHE_TYPE_PIxx ? 'P' : 'V',
 		    info->dcache_type & CACHE_TYPE_xxPT ? 'P' : 'V');
@@ -621,14 +623,18 @@ print_cache_info(device_t dv, struct arm
 		    level + 1,
 		    info->icache_size / 1024,
 		    info->icache_line_size, info->icache_ways,
-		    info->icache_sets,
+		    info->icache_sets ? info->icache_sets :
+			info->icache_size /
+			    (info->icache_line_size * info->icache_ways),
 		    info->icache_type & CACHE_TYPE_PIxx ? 'P' : 'V',
 		    info->icache_type & CACHE_TYPE_xxPT ? 'P' : 'V');
 		aprint_normal_dev(dv, "L%u %dKB/%dB %d-way (%u set) %s %cI%cT Data cache\n",
 		    level + 1,
 		    info->dcache_size / 1024,
 		    info->dcache_line_size, info->dcache_ways,
-		    info->dcache_sets,
+		    info->dcache_sets ? info->dcache_sets :
+			info->dcache_size /
+			    (info->dcache_line_size * info->dcache_ways),
 		    wtnames[info->cache_type],
 		    info->dcache_type & CACHE_TYPE_PIxx ? 'P' : 'V',
 		    info->dcache_type & CACHE_TYPE_xxPT ? 'P' : 'V');

Reply via email to