aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-05-10 01:40:52 -0400
committerThomas Gleixner <tglx@linutronix.de>2008-05-25 04:55:10 -0400
commit3f03c54a34fa3da680b3341dd3ba965ef3394bd1 (patch)
tree0f9c12e57a0a55c9eade7983501c54c892b5d317 /arch/x86/kernel/cpu
parent8004dd965b13b01a96def054d420f6df7ff22d53 (diff)
x86: mtrr cleanup for converting continuous to discrete layout - fix #2
disable the noisy print out. also use the one the less spare mtrr reg. Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu')
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c79
1 files changed, 48 insertions, 31 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index e6c162c379ac..0642201784e0 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -730,6 +730,7 @@ struct var_mtrr_range_state {
730}; 730};
731 731
732struct var_mtrr_range_state __initdata range_state[RANGE_NUM]; 732struct var_mtrr_range_state __initdata range_state[RANGE_NUM];
733static int __initdata debug_print;
733 734
734static int __init 735static int __init
735x86_get_mtrr_mem_range(struct res_range *range, int nr_range, 736x86_get_mtrr_mem_range(struct res_range *range, int nr_range,
@@ -748,10 +749,12 @@ x86_get_mtrr_mem_range(struct res_range *range, int nr_range,
748 nr_range = add_range_with_merge(range, nr_range, base, 749 nr_range = add_range_with_merge(range, nr_range, base,
749 base + size - 1); 750 base + size - 1);
750 } 751 }
751 printk(KERN_DEBUG "After WB checking\n"); 752 if (debug_print) {
752 for (i = 0; i < nr_range; i++) 753 printk(KERN_DEBUG "After WB checking\n");
753 printk(KERN_DEBUG "MTRR MAP PFN: %016lx - %016lx\n", 754 for (i = 0; i < nr_range; i++)
755 printk(KERN_DEBUG "MTRR MAP PFN: %016lx - %016lx\n",
754 range[i].start, range[i].end + 1); 756 range[i].start, range[i].end + 1);
757 }
755 758
756 /* take out UC ranges */ 759 /* take out UC ranges */
757 for (i = 0; i < num_var_ranges; i++) { 760 for (i = 0; i < num_var_ranges; i++) {
@@ -775,17 +778,21 @@ x86_get_mtrr_mem_range(struct res_range *range, int nr_range,
775 continue; 778 continue;
776 nr_range++; 779 nr_range++;
777 } 780 }
778 printk(KERN_DEBUG "After UC checking\n"); 781 if (debug_print) {
779 for (i = 0; i < nr_range; i++) 782 printk(KERN_DEBUG "After UC checking\n");
780 printk(KERN_DEBUG "MTRR MAP PFN: %016lx - %016lx\n", 783 for (i = 0; i < nr_range; i++)
781 range[i].start, range[i].end + 1); 784 printk(KERN_DEBUG "MTRR MAP PFN: %016lx - %016lx\n",
785 range[i].start, range[i].end + 1);
786 }
782 787
783 /* sort the ranges */ 788 /* sort the ranges */
784 sort(range, nr_range, sizeof(struct res_range), cmp_range, NULL); 789 sort(range, nr_range, sizeof(struct res_range), cmp_range, NULL);
785 printk(KERN_DEBUG "After sorting\n"); 790 if (debug_print) {
786 for (i = 0; i < nr_range; i++) 791 printk(KERN_DEBUG "After sorting\n");
787 printk(KERN_DEBUG "MTRR MAP PFN: %016lx - %016lx\n", 792 for (i = 0; i < nr_range; i++)
793 printk(KERN_DEBUG "MTRR MAP PFN: %016lx - %016lx\n",
788 range[i].start, range[i].end + 1); 794 range[i].start, range[i].end + 1);
795 }
789 796
790 /* clear those is not used */ 797 /* clear those is not used */
791 for (i = nr_range; i < RANGE_NUM; i++) 798 for (i = nr_range; i < RANGE_NUM; i++)
@@ -912,12 +919,13 @@ range_to_mtrr(unsigned int reg, unsigned long range_startk,
912 align = max_align; 919 align = max_align;
913 920
914 sizek = 1 << align; 921 sizek = 1 << align;
915 printk(KERN_DEBUG "Setting variable MTRR %d, base: %ldMB, " 922 if (debug_print)
916 "range: %ldMB, type %s\n", 923 printk(KERN_DEBUG "Setting variable MTRR %d, "
917 reg, range_startk >> 10, sizek >> 10, 924 "base: %ldMB, range: %ldMB, type %s\n",
918 (type == MTRR_TYPE_UNCACHABLE)?"UC": 925 reg, range_startk >> 10, sizek >> 10,
919 ((type == MTRR_TYPE_WRBACK)?"WB":"Other") 926 (type == MTRR_TYPE_UNCACHABLE)?"UC":
920 ); 927 ((type == MTRR_TYPE_WRBACK)?"WB":"Other")
928 );
921 save_var_mtrr(reg++, range_startk, sizek, type); 929 save_var_mtrr(reg++, range_startk, sizek, type);
922 range_startk += sizek; 930 range_startk += sizek;
923 range_sizek -= sizek; 931 range_sizek -= sizek;
@@ -963,7 +971,9 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek,
963 range0_basek = state->range_startk; 971 range0_basek = state->range_startk;
964 range0_sizek = ALIGN(state->range_sizek, chunk_sizek); 972 range0_sizek = ALIGN(state->range_sizek, chunk_sizek);
965 if (range0_sizek == state->range_sizek) { 973 if (range0_sizek == state->range_sizek) {
966 printk(KERN_DEBUG "rangeX: %016lx - %016lx\n", range0_basek<<10, 974 if (debug_print)
975 printk(KERN_DEBUG "rangeX: %016lx - %016lx\n",
976 range0_basek<<10,
967 (range0_basek + state->range_sizek)<<10); 977 (range0_basek + state->range_sizek)<<10);
968 state->reg = range_to_mtrr(state->reg, range0_basek, 978 state->reg = range_to_mtrr(state->reg, range0_basek,
969 state->range_sizek, MTRR_TYPE_WRBACK); 979 state->range_sizek, MTRR_TYPE_WRBACK);
@@ -980,7 +990,9 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek,
980 } 990 }
981 991
982 if (range0_sizek) { 992 if (range0_sizek) {
983 printk(KERN_DEBUG "range0: %016lx - %016lx\n", range0_basek<<10, 993 if (debug_print)
994 printk(KERN_DEBUG "range0: %016lx - %016lx\n",
995 range0_basek<<10,
984 (range0_basek + range0_sizek)<<10); 996 (range0_basek + range0_sizek)<<10);
985 state->reg = range_to_mtrr(state->reg, range0_basek, 997 state->reg = range_to_mtrr(state->reg, range0_basek,
986 range0_sizek, MTRR_TYPE_WRBACK); 998 range0_sizek, MTRR_TYPE_WRBACK);
@@ -1016,13 +1028,15 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek,
1016 second_sizek = 0; 1028 second_sizek = 0;
1017 } 1029 }
1018 1030
1019 printk(KERN_DEBUG "range: %016lx - %016lx\n", range_basek<<10, 1031 if (debug_print)
1032 printk(KERN_DEBUG "range: %016lx - %016lx\n", range_basek<<10,
1020 (range_basek + range_sizek)<<10); 1033 (range_basek + range_sizek)<<10);
1021 state->reg = range_to_mtrr(state->reg, range_basek, range_sizek, 1034 state->reg = range_to_mtrr(state->reg, range_basek, range_sizek,
1022 MTRR_TYPE_WRBACK); 1035 MTRR_TYPE_WRBACK);
1023 if (hole_sizek) { 1036 if (hole_sizek) {
1024 printk(KERN_DEBUG "hole: %016lx - %016lx\n", hole_basek<<10, 1037 if (debug_print)
1025 (hole_basek + hole_sizek)<<10); 1038 printk(KERN_DEBUG "hole: %016lx - %016lx\n",
1039 hole_basek<<10, (hole_basek + hole_sizek)<<10);
1026 state->reg = range_to_mtrr(state->reg, hole_basek, hole_sizek, 1040 state->reg = range_to_mtrr(state->reg, hole_basek, hole_sizek,
1027 MTRR_TYPE_UNCACHABLE); 1041 MTRR_TYPE_UNCACHABLE);
1028 1042
@@ -1120,7 +1134,6 @@ x86_setup_var_mtrrs(struct res_range *range, int nr_range,
1120 /* Write the last range */ 1134 /* Write the last range */
1121 if (var_state.range_sizek != 0) 1135 if (var_state.range_sizek != 0)
1122 range_to_mtrr_with_hole(&var_state, 0, 0); 1136 range_to_mtrr_with_hole(&var_state, 0, 0);
1123 printk(KERN_DEBUG "DONE variable MTRRs\n");
1124 1137
1125 num_reg = var_state.reg; 1138 num_reg = var_state.reg;
1126 /* Clear out the extra MTRR's */ 1139 /* Clear out the extra MTRR's */
@@ -1219,6 +1232,7 @@ static int __init mtrr_cleanup(unsigned address_bits)
1219 if (mtrr_chunk_size && mtrr_gran_size) { 1232 if (mtrr_chunk_size && mtrr_gran_size) {
1220 int num_reg; 1233 int num_reg;
1221 1234
1235 debug_print = 1;
1222 /* convert ranges to var ranges state */ 1236 /* convert ranges to var ranges state */
1223 num_reg = x86_setup_var_mtrrs(range, nr_range, mtrr_chunk_size, 1237 num_reg = x86_setup_var_mtrrs(range, nr_range, mtrr_chunk_size,
1224 mtrr_gran_size); 1238 mtrr_gran_size);
@@ -1242,8 +1256,8 @@ static int __init mtrr_cleanup(unsigned address_bits)
1242 result[i].lose_cover_sizek = 1256 result[i].lose_cover_sizek =
1243 (range_sums - range_sums_new) << PSHIFT; 1257 (range_sums - range_sums_new) << PSHIFT;
1244 1258
1245 printk(KERN_INFO " %sgran_size: %ldM \tchunk_size: %ldM \t", 1259 printk(KERN_INFO "%sgran_size: %ldM \tchunk_size: %ldM \t",
1246 result[i].bad?" BAD ":"", result[i].gran_sizek >> 10, 1260 result[i].bad?"*BAD*":" ", result[i].gran_sizek >> 10,
1247 result[i].chunk_sizek >> 10); 1261 result[i].chunk_sizek >> 10);
1248 printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ldM \n", 1262 printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ldM \n",
1249 result[i].num_reg, result[i].bad?"-":"", 1263 result[i].num_reg, result[i].bad?"-":"",
@@ -1254,6 +1268,7 @@ static int __init mtrr_cleanup(unsigned address_bits)
1254 } 1268 }
1255 printk(KERN_INFO "invalid mtrr_gran_size or mtrr_chunk_size, " 1269 printk(KERN_INFO "invalid mtrr_gran_size or mtrr_chunk_size, "
1256 "will find optimal one\n"); 1270 "will find optimal one\n");
1271 debug_print = 0;
1257 memset(result, 0, sizeof(result[0])); 1272 memset(result, 0, sizeof(result[0]));
1258 } 1273 }
1259 1274
@@ -1265,9 +1280,10 @@ static int __init mtrr_cleanup(unsigned address_bits)
1265 chunk_size <<= 1) { 1280 chunk_size <<= 1) {
1266 int num_reg; 1281 int num_reg;
1267 1282
1268 printk(KERN_INFO 1283 if (debug_print)
1284 printk(KERN_INFO
1269 "\ngran_size: %lldM chunk_size_size: %lldM\n", 1285 "\ngran_size: %lldM chunk_size_size: %lldM\n",
1270 gran_size >> 20, chunk_size >> 20); 1286 gran_size >> 20, chunk_size >> 20);
1271 if (i >= NUM_RESULT) 1287 if (i >= NUM_RESULT)
1272 continue; 1288 continue;
1273 1289
@@ -1310,10 +1326,10 @@ static int __init mtrr_cleanup(unsigned address_bits)
1310 1326
1311 /* print out all */ 1327 /* print out all */
1312 for (i = 0; i < NUM_RESULT; i++) { 1328 for (i = 0; i < NUM_RESULT; i++) {
1313 printk(KERN_INFO "%sgran_size: %ldM \tchunk_size: %ldM \t", 1329 printk(KERN_INFO "%sgran_size: %ldM \tchunk_size: %ldM \t",
1314 result[i].bad?"*BAD* ":" ", result[i].gran_sizek >> 10, 1330 result[i].bad?"*BAD* ":" ", result[i].gran_sizek >> 10,
1315 result[i].chunk_sizek >> 10); 1331 result[i].chunk_sizek >> 10);
1316 printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ldM \n", 1332 printk(KERN_CONT "num_reg: %d \tlose RAM: %s%ldM\n",
1317 result[i].num_reg, result[i].bad?"-":"", 1333 result[i].num_reg, result[i].bad?"-":"",
1318 result[i].lose_cover_sizek >> 10); 1334 result[i].lose_cover_sizek >> 10);
1319 } 1335 }
@@ -1322,7 +1338,7 @@ static int __init mtrr_cleanup(unsigned address_bits)
1322 if (nr_mtrr_spare_reg >= num_var_ranges) 1338 if (nr_mtrr_spare_reg >= num_var_ranges)
1323 nr_mtrr_spare_reg = num_var_ranges - 1; 1339 nr_mtrr_spare_reg = num_var_ranges - 1;
1324 num_reg_good = -1; 1340 num_reg_good = -1;
1325 for (i = 1; i < num_var_ranges + 1 - nr_mtrr_spare_reg; i++) { 1341 for (i = num_var_ranges - nr_mtrr_spare_reg; i > 0; i--) {
1326 if (!min_loss_pfn[i]) { 1342 if (!min_loss_pfn[i]) {
1327 num_reg_good = i; 1343 num_reg_good = i;
1328 break; 1344 break;
@@ -1344,10 +1360,10 @@ static int __init mtrr_cleanup(unsigned address_bits)
1344 if (index_good != -1) { 1360 if (index_good != -1) {
1345 printk(KERN_INFO "Found optimal setting for mtrr clean up\n"); 1361 printk(KERN_INFO "Found optimal setting for mtrr clean up\n");
1346 i = index_good; 1362 i = index_good;
1347 printk(KERN_INFO "gran_size: %ldM \tchunk_size: %ldM \t", 1363 printk(KERN_INFO "gran_size: %ldM \tchunk_size: %ldM \t",
1348 result[i].gran_sizek >> 10, 1364 result[i].gran_sizek >> 10,
1349 result[i].chunk_sizek >> 10); 1365 result[i].chunk_sizek >> 10);
1350 printk(KERN_CONT "num_reg: %d \tlose cover RAM: %ldM \n", 1366 printk(KERN_CONT "num_reg: %d \tlose RAM: %ldM\n",
1351 result[i].num_reg, 1367 result[i].num_reg,
1352 result[i].lose_cover_sizek >> 10); 1368 result[i].lose_cover_sizek >> 10);
1353 /* convert ranges to var ranges state */ 1369 /* convert ranges to var ranges state */
@@ -1355,6 +1371,7 @@ static int __init mtrr_cleanup(unsigned address_bits)
1355 chunk_size <<= 10; 1371 chunk_size <<= 10;
1356 gran_size = result[i].gran_sizek; 1372 gran_size = result[i].gran_sizek;
1357 gran_size <<= 10; 1373 gran_size <<= 10;
1374 debug_print = 1;
1358 x86_setup_var_mtrrs(range, nr_range, chunk_size, gran_size); 1375 x86_setup_var_mtrrs(range, nr_range, chunk_size, gran_size);
1359 set_var_mtrr_all(address_bits); 1376 set_var_mtrr_all(address_bits);
1360 return 1; 1377 return 1;