diff options
author | Antonino A. Daplas <adaplas@gmail.com> | 2005-07-29 17:03:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-29 18:01:13 -0400 |
commit | 80625942094b114d85811e5ff1fbc9e06dabe0ff (patch) | |
tree | 66c6e49c4a24d7338d4510be449e4cc17dc95e29 | |
parent | 655a0a7799cddf9a469916c07ac22f1106abc2be (diff) |
[PATCH] vesafb: Fix mtrr bugs
>> vesafb: mode is 800x600x16, linelength=1600, pages=16
>> vesafb: scrolling: redraw
>> vesafb: Truecolor: size=0:5:6:5, shift=0:11:5:0
>> mtrr: type mismatch for fc000000,1000000 old: write-back new: write-
>> combining
Range is already set to write-back, vesafb attempts to add a write-combining
mtrr (default for vesafb).
>> mtrr: size and base must be multiples of 4 kiB
This is a bug, vesafb attempts to add a size < PAGE_SIZE triggering
the messages below.
To eliminate the warning messages, you can add the option mtrr:2 to add a
write-back mtrr for vesafb. Or just use nomtrr option.
1. Fix algorithm for finding the best power of 2 size with mtrr_add().
2. Add option to choose the mtrr type by extending the mtrr boot option:
mtrr:n where n
0 = no mtrr (equivalent to using the nomtrr option)
1 = uncachable
2 = write back
3 = write combining (default)
4 = write through
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/video/vesafb.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c index 9ed1a931dd31..a272592b0373 100644 --- a/drivers/video/vesafb.c +++ b/drivers/video/vesafb.c | |||
@@ -45,7 +45,7 @@ static struct fb_fix_screeninfo vesafb_fix __initdata = { | |||
45 | }; | 45 | }; |
46 | 46 | ||
47 | static int inverse = 0; | 47 | static int inverse = 0; |
48 | static int mtrr = 1; | 48 | static int mtrr = 3; /* default to write-combining */ |
49 | static int vram_remap __initdata = 0; /* Set amount of memory to be used */ | 49 | static int vram_remap __initdata = 0; /* Set amount of memory to be used */ |
50 | static int vram_total __initdata = 0; /* Set total amount of memory */ | 50 | static int vram_total __initdata = 0; /* Set total amount of memory */ |
51 | static int pmi_setpal = 0; /* pmi for palette changes ??? */ | 51 | static int pmi_setpal = 0; /* pmi for palette changes ??? */ |
@@ -204,8 +204,8 @@ static int __init vesafb_setup(char *options) | |||
204 | pmi_setpal=0; | 204 | pmi_setpal=0; |
205 | else if (! strcmp(this_opt, "pmipal")) | 205 | else if (! strcmp(this_opt, "pmipal")) |
206 | pmi_setpal=1; | 206 | pmi_setpal=1; |
207 | else if (! strcmp(this_opt, "mtrr")) | 207 | else if (! strncmp(this_opt, "mtrr:", 5)) |
208 | mtrr=1; | 208 | mtrr = simple_strtoul(this_opt+5, NULL, 0); |
209 | else if (! strcmp(this_opt, "nomtrr")) | 209 | else if (! strcmp(this_opt, "nomtrr")) |
210 | mtrr=0; | 210 | mtrr=0; |
211 | else if (! strncmp(this_opt, "vtotal:", 7)) | 211 | else if (! strncmp(this_opt, "vtotal:", 7)) |
@@ -387,14 +387,39 @@ static int __init vesafb_probe(struct device *device) | |||
387 | 387 | ||
388 | if (mtrr) { | 388 | if (mtrr) { |
389 | unsigned int temp_size = size_total; | 389 | unsigned int temp_size = size_total; |
390 | /* Find the largest power-of-two */ | 390 | unsigned int type = 0; |
391 | while (temp_size & (temp_size - 1)) | 391 | |
392 | temp_size &= (temp_size - 1); | 392 | switch (mtrr) { |
393 | 393 | case 1: | |
394 | /* Try and find a power of two to add */ | 394 | type = MTRR_TYPE_UNCACHABLE; |
395 | while (temp_size > PAGE_SIZE && | 395 | break; |
396 | mtrr_add(vesafb_fix.smem_start, temp_size, MTRR_TYPE_WRCOMB, 1)==-EINVAL) { | 396 | case 2: |
397 | temp_size >>= 1; | 397 | type = MTRR_TYPE_WRBACK; |
398 | break; | ||
399 | case 3: | ||
400 | type = MTRR_TYPE_WRCOMB; | ||
401 | break; | ||
402 | case 4: | ||
403 | type = MTRR_TYPE_WRTHROUGH; | ||
404 | break; | ||
405 | default: | ||
406 | type = 0; | ||
407 | break; | ||
408 | } | ||
409 | |||
410 | if (type) { | ||
411 | int rc; | ||
412 | |||
413 | /* Find the largest power-of-two */ | ||
414 | while (temp_size & (temp_size - 1)) | ||
415 | temp_size &= (temp_size - 1); | ||
416 | |||
417 | /* Try and find a power of two to add */ | ||
418 | do { | ||
419 | rc = mtrr_add(vesafb_fix.smem_start, temp_size, | ||
420 | type, 1); | ||
421 | temp_size >>= 1; | ||
422 | } while (temp_size >= PAGE_SIZE && rc == -EINVAL); | ||
398 | } | 423 | } |
399 | } | 424 | } |
400 | 425 | ||