提交 5cca0cf1 编写于 作者: S Suresh Siddha 提交者: Ingo Molnar

x86, pat: fix reserve_memtype() for legacy 1MB range

Thierry Vignaud reported:
> http://bugzilla.kernel.org/show_bug.cgi?id=12372
>
> On P4 with an SiS motherboard (video card is a SiS 651)
> X server fails to start with error:
> xf86MapVidMem: Could not mmap framebuffer (0x00000000,0x2000) (Invalid
> argument)

Here X is trying to map first 8KB of memory using /dev/mem. Existing
code treats first 0-4KB of memory as non-RAM and 4KB-8KB as RAM. Recent
code changes don't allow to map memory with different attributes
at the same time.

Fix this by treating the first 1MB legacy region as special and always
track the attribute requests with in this region using linear linked
list (and don't bother if the range is RAM or non-RAM or mixed)
Reported-and-tested-by: NThierry Vignaud <tvignaud@mandriva.com>
Signed-off-by: NSuresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: NVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 c8399943
...@@ -333,11 +333,20 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type, ...@@ -333,11 +333,20 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
req_type & _PAGE_CACHE_MASK); req_type & _PAGE_CACHE_MASK);
} }
is_range_ram = pagerange_is_ram(start, end); /*
if (is_range_ram == 1) * For legacy reasons, some parts of the physical address range in the
return reserve_ram_pages_type(start, end, req_type, new_type); * legacy 1MB region is treated as non-RAM (even when listed as RAM in
else if (is_range_ram < 0) * the e820 tables). So we will track the memory attributes of this
return -EINVAL; * legacy 1MB region using the linear memtype_list always.
*/
if (end >= ISA_END_ADDRESS) {
is_range_ram = pagerange_is_ram(start, end);
if (is_range_ram == 1)
return reserve_ram_pages_type(start, end, req_type,
new_type);
else if (is_range_ram < 0)
return -EINVAL;
}
new = kmalloc(sizeof(struct memtype), GFP_KERNEL); new = kmalloc(sizeof(struct memtype), GFP_KERNEL);
if (!new) if (!new)
...@@ -437,11 +446,19 @@ int free_memtype(u64 start, u64 end) ...@@ -437,11 +446,19 @@ int free_memtype(u64 start, u64 end)
if (is_ISA_range(start, end - 1)) if (is_ISA_range(start, end - 1))
return 0; return 0;
is_range_ram = pagerange_is_ram(start, end); /*
if (is_range_ram == 1) * For legacy reasons, some parts of the physical address range in the
return free_ram_pages_type(start, end); * legacy 1MB region is treated as non-RAM (even when listed as RAM in
else if (is_range_ram < 0) * the e820 tables). So we will track the memory attributes of this
return -EINVAL; * legacy 1MB region using the linear memtype_list always.
*/
if (end >= ISA_END_ADDRESS) {
is_range_ram = pagerange_is_ram(start, end);
if (is_range_ram == 1)
return free_ram_pages_type(start, end);
else if (is_range_ram < 0)
return -EINVAL;
}
spin_lock(&memtype_lock); spin_lock(&memtype_lock);
list_for_each_entry(entry, &memtype_list, nd) { list_for_each_entry(entry, &memtype_list, nd) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册