diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-09-29 21:54:11 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-09-29 23:50:04 -0400 |
commit | dd7e52224fd7438d701b4bb9834a9ddc06828210 (patch) | |
tree | 35aaa417df982ff97482153b7ba9c3fb8110fd04 /arch | |
parent | 73436a1d2501575f9c2e6ddb26889145e23cefd8 (diff) |
x86: mtrr_cleanup prepare to make gran_size to less 1M
make the print out right with size < 1M
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/main.c | 103 |
1 files changed, 79 insertions, 24 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index ae0ca97e20bd..b1bd1038c913 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -905,6 +905,27 @@ set_var_mtrr_all(unsigned int address_bits) | |||
905 | } | 905 | } |
906 | } | 906 | } |
907 | 907 | ||
908 | static unsigned long to_size_factor(unsigned long sizek, char *factorp) | ||
909 | { | ||
910 | char factor; | ||
911 | unsigned long base = sizek; | ||
912 | |||
913 | if (base & ((1<<10) - 1)) { | ||
914 | /* not MB alignment */ | ||
915 | factor = 'K'; | ||
916 | } else if (base & ((1<<20) - 1)){ | ||
917 | factor = 'M'; | ||
918 | base >>= 10; | ||
919 | } else { | ||
920 | factor = 'G'; | ||
921 | base >>= 20; | ||
922 | } | ||
923 | |||
924 | *factorp = factor; | ||
925 | |||
926 | return base; | ||
927 | } | ||
928 | |||
908 | static unsigned int __init | 929 | static unsigned int __init |
909 | range_to_mtrr(unsigned int reg, unsigned long range_startk, | 930 | range_to_mtrr(unsigned int reg, unsigned long range_startk, |
910 | unsigned long range_sizek, unsigned char type) | 931 | unsigned long range_sizek, unsigned char type) |
@@ -926,13 +947,21 @@ range_to_mtrr(unsigned int reg, unsigned long range_startk, | |||
926 | align = max_align; | 947 | align = max_align; |
927 | 948 | ||
928 | sizek = 1 << align; | 949 | sizek = 1 << align; |
929 | if (debug_print) | 950 | if (debug_print) { |
951 | char start_factor = 'K', size_factor = 'K'; | ||
952 | unsigned long start_base, size_base; | ||
953 | |||
954 | start_base = to_size_factor(range_startk, &start_factor), | ||
955 | size_base = to_size_factor(sizek, &size_factor), | ||
956 | |||
930 | printk(KERN_DEBUG "Setting variable MTRR %d, " | 957 | printk(KERN_DEBUG "Setting variable MTRR %d, " |
931 | "base: %ldMB, range: %ldMB, type %s\n", | 958 | "base: %ld%cB, range: %ld%cB, type %s\n", |
932 | reg, range_startk >> 10, sizek >> 10, | 959 | reg, start_base, start_factor, |
960 | size_base, size_factor, | ||
933 | (type == MTRR_TYPE_UNCACHABLE)?"UC": | 961 | (type == MTRR_TYPE_UNCACHABLE)?"UC": |
934 | ((type == MTRR_TYPE_WRBACK)?"WB":"Other") | 962 | ((type == MTRR_TYPE_WRBACK)?"WB":"Other") |
935 | ); | 963 | ); |
964 | } | ||
936 | save_var_mtrr(reg++, range_startk, sizek, type); | 965 | save_var_mtrr(reg++, range_startk, sizek, type); |
937 | range_startk += sizek; | 966 | range_startk += sizek; |
938 | range_sizek -= sizek; | 967 | range_sizek -= sizek; |
@@ -1245,6 +1274,8 @@ static int __init mtrr_cleanup(unsigned address_bits) | |||
1245 | 1274 | ||
1246 | if (mtrr_chunk_size && mtrr_gran_size) { | 1275 | if (mtrr_chunk_size && mtrr_gran_size) { |
1247 | int num_reg; | 1276 | int num_reg; |
1277 | char gran_factor, chunk_factor, lose_factor; | ||
1278 | unsigned long gran_base, chunk_base, lose_base; | ||
1248 | 1279 | ||
1249 | debug_print++; | 1280 | debug_print++; |
1250 | /* convert ranges to var ranges state */ | 1281 | /* convert ranges to var ranges state */ |
@@ -1270,12 +1301,15 @@ static int __init mtrr_cleanup(unsigned address_bits) | |||
1270 | result[i].lose_cover_sizek = | 1301 | result[i].lose_cover_sizek = |
1271 | (range_sums - range_sums_new) << PSHIFT; | 1302 | (range_sums - range_sums_new) << PSHIFT; |
1272 | 1303 | ||
1273 | printk(KERN_INFO "%sgran_size: %ldM \tchunk_size: %ldM \t", | 1304 | gran_base = to_size_factor(result[i].gran_sizek, &gran_factor), |
1274 | result[i].bad?"*BAD*":" ", result[i].gran_sizek >> 10, | 1305 | chunk_base = to_size_factor(result[i].chunk_sizek, &chunk_factor), |
1275 | result[i].chunk_sizek >> 10); | 1306 | lose_base = to_size_factor(result[i].lose_cover_sizek, &lose_factor), |
1276 | printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ldM \n", | 1307 | printk(KERN_INFO "%sgran_size: %ld%c \tchunk_size: %ld%c \t", |
1308 | result[i].bad?"*BAD*":" ", | ||
1309 | gran_base, gran_factor, chunk_base, chunk_factor); | ||
1310 | printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ld%c\n", | ||
1277 | result[i].num_reg, result[i].bad?"-":"", | 1311 | result[i].num_reg, result[i].bad?"-":"", |
1278 | result[i].lose_cover_sizek >> 10); | 1312 | lose_base, lose_factor); |
1279 | if (!result[i].bad) { | 1313 | if (!result[i].bad) { |
1280 | set_var_mtrr_all(address_bits); | 1314 | set_var_mtrr_all(address_bits); |
1281 | return 1; | 1315 | return 1; |
@@ -1290,14 +1324,25 @@ static int __init mtrr_cleanup(unsigned address_bits) | |||
1290 | memset(min_loss_pfn, 0xff, sizeof(min_loss_pfn)); | 1324 | memset(min_loss_pfn, 0xff, sizeof(min_loss_pfn)); |
1291 | memset(result, 0, sizeof(result)); | 1325 | memset(result, 0, sizeof(result)); |
1292 | for (gran_size = (1ULL<<20); gran_size < (1ULL<<32); gran_size <<= 1) { | 1326 | for (gran_size = (1ULL<<20); gran_size < (1ULL<<32); gran_size <<= 1) { |
1327 | char gran_factor; | ||
1328 | unsigned long gran_base; | ||
1329 | |||
1330 | if (debug_print) | ||
1331 | gran_base = to_size_factor(gran_size >> 10, &gran_factor); | ||
1332 | |||
1293 | for (chunk_size = gran_size; chunk_size < (1ULL<<32); | 1333 | for (chunk_size = gran_size; chunk_size < (1ULL<<32); |
1294 | chunk_size <<= 1) { | 1334 | chunk_size <<= 1) { |
1295 | int num_reg; | 1335 | int num_reg; |
1296 | 1336 | ||
1297 | if (debug_print) | 1337 | if (debug_print) { |
1298 | printk(KERN_INFO | 1338 | char chunk_factor; |
1299 | "\ngran_size: %lldM chunk_size_size: %lldM\n", | 1339 | unsigned long chunk_base; |
1300 | gran_size >> 20, chunk_size >> 20); | 1340 | |
1341 | chunk_base = to_size_factor(chunk_size>>10, &chunk_factor), | ||
1342 | printk(KERN_INFO "\n"); | ||
1343 | printk(KERN_INFO "gran_size: %ld%c chunk_size: %ld%c \n", | ||
1344 | gran_base, gran_factor, chunk_base, chunk_factor); | ||
1345 | } | ||
1301 | if (i >= NUM_RESULT) | 1346 | if (i >= NUM_RESULT) |
1302 | continue; | 1347 | continue; |
1303 | 1348 | ||
@@ -1340,12 +1385,18 @@ static int __init mtrr_cleanup(unsigned address_bits) | |||
1340 | 1385 | ||
1341 | /* print out all */ | 1386 | /* print out all */ |
1342 | for (i = 0; i < NUM_RESULT; i++) { | 1387 | for (i = 0; i < NUM_RESULT; i++) { |
1343 | printk(KERN_INFO "%sgran_size: %ldM \tchunk_size: %ldM \t", | 1388 | char gran_factor, chunk_factor, lose_factor; |
1344 | result[i].bad?"*BAD* ":" ", result[i].gran_sizek >> 10, | 1389 | unsigned long gran_base, chunk_base, lose_base; |
1345 | result[i].chunk_sizek >> 10); | 1390 | |
1346 | printk(KERN_CONT "num_reg: %d \tlose RAM: %s%ldM\n", | 1391 | gran_base = to_size_factor(result[i].gran_sizek, &gran_factor), |
1347 | result[i].num_reg, result[i].bad?"-":"", | 1392 | chunk_base = to_size_factor(result[i].chunk_sizek, &chunk_factor), |
1348 | result[i].lose_cover_sizek >> 10); | 1393 | lose_base = to_size_factor(result[i].lose_cover_sizek, &lose_factor), |
1394 | printk(KERN_INFO "%sgran_size: %ld%c \tchunk_size: %ld%c \t", | ||
1395 | result[i].bad?"*BAD*":" ", | ||
1396 | gran_base, gran_factor, chunk_base, chunk_factor); | ||
1397 | printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ld%c\n", | ||
1398 | result[i].num_reg, result[i].bad?"-":"", | ||
1399 | lose_base, lose_factor); | ||
1349 | } | 1400 | } |
1350 | 1401 | ||
1351 | /* try to find the optimal index */ | 1402 | /* try to find the optimal index */ |
@@ -1370,14 +1421,18 @@ static int __init mtrr_cleanup(unsigned address_bits) | |||
1370 | } | 1421 | } |
1371 | 1422 | ||
1372 | if (index_good != -1) { | 1423 | if (index_good != -1) { |
1424 | char gran_factor, chunk_factor, lose_factor; | ||
1425 | unsigned long gran_base, chunk_base, lose_base; | ||
1426 | |||
1373 | printk(KERN_INFO "Found optimal setting for mtrr clean up\n"); | 1427 | printk(KERN_INFO "Found optimal setting for mtrr clean up\n"); |
1374 | i = index_good; | 1428 | i = index_good; |
1375 | printk(KERN_INFO "gran_size: %ldM \tchunk_size: %ldM \t", | 1429 | gran_base = to_size_factor(result[i].gran_sizek, &gran_factor), |
1376 | result[i].gran_sizek >> 10, | 1430 | chunk_base = to_size_factor(result[i].chunk_sizek, &chunk_factor), |
1377 | result[i].chunk_sizek >> 10); | 1431 | lose_base = to_size_factor(result[i].lose_cover_sizek, &lose_factor), |
1378 | printk(KERN_CONT "num_reg: %d \tlose RAM: %ldM\n", | 1432 | printk(KERN_INFO "gran_size: %ld%c \tchunk_size: %ld%c \t", |
1379 | result[i].num_reg, | 1433 | gran_base, gran_factor, chunk_base, chunk_factor); |
1380 | result[i].lose_cover_sizek >> 10); | 1434 | printk(KERN_CONT "num_reg: %d \tlose RAM: %ld%c\n", |
1435 | result[i].num_reg, lose_base, lose_factor); | ||
1381 | /* convert ranges to var ranges state */ | 1436 | /* convert ranges to var ranges state */ |
1382 | chunk_size = result[i].chunk_sizek; | 1437 | chunk_size = result[i].chunk_sizek; |
1383 | chunk_size <<= 10; | 1438 | chunk_size <<= 10; |