Skip to content

Commit 1046cc8

Browse files
shuangluo.zhangtian.he
andcommitted
CPID: minimize the register access for cpu attribute
Change-Id: I83a4386046a9341650a7351fab94d8869bffd7f5 Co-authored-by: tian.he <ht412853@alibaba-inc.com>
1 parent 07bca37 commit 1046cc8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

feature.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void setup_features(void)
2828
unsigned int i, idx, cpu_type = 0, cpu_ver = 0xFFFF, cpu_tnmodel = 0xFFFF;
2929
volatile unsigned long version = 0;
3030

31-
for (i = 8; i != 0; i--) {
31+
for (i = 7; i != 0; i--) {
3232
version = csr_read(CSR_MCPUID);
3333
idx = (version >> 28) & 0xf;
3434
if (idx == 0) {
@@ -37,6 +37,9 @@ void setup_features(void)
3737
} else if (idx == 1) {
3838
cpu_ver = (version >> 12) & 0xffff;
3939
}
40+
if (cpu_ver != 0xFFFF && cpu_tnmodel != 0xFFFF) {
41+
break;
42+
}
4043
}
4144

4245
/*

0 commit comments

Comments
 (0)