Skip to content

Commit a361ee5

Browse files
Venkatesh PallipadiIngo Molnar
authored andcommitted
x86: fix /dev/mem compatibility under PAT
Add ioremap_default(), which gives a sane mapping without worrying about type conflicts. Use it in /dev/mem read in place of ioremap(), as with ioremap(), any mapping of the region (other than UC_MINUS) will cause a conflict and failure of /dev/mem read. Should address the vbetest failure reported at: http://bugzilla.kernel.org/show_bug.cgi?id=11057 Signed-off-by: Venkatesh Pallipadi <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent a1716d5 commit a361ee5

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

arch/x86/mm/ioremap.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,29 @@ void __iomem *ioremap_cache(resource_size_t phys_addr, unsigned long size)
300300
}
301301
EXPORT_SYMBOL(ioremap_cache);
302302

303+
static void __iomem *ioremap_default(resource_size_t phys_addr,
304+
unsigned long size)
305+
{
306+
unsigned long flags;
307+
void *ret;
308+
int err;
309+
310+
/*
311+
* - WB for WB-able memory and no other conflicting mappings
312+
* - UC_MINUS for non-WB-able memory with no other conflicting mappings
313+
* - Inherit from confliting mappings otherwise
314+
*/
315+
err = reserve_memtype(phys_addr, phys_addr + size, -1, &flags);
316+
if (err < 0)
317+
return NULL;
318+
319+
ret = (void *) __ioremap_caller(phys_addr, size, flags,
320+
__builtin_return_address(0));
321+
322+
free_memtype(phys_addr, phys_addr + size);
323+
return (void __iomem *)ret;
324+
}
325+
303326
/**
304327
* iounmap - Free a IO remapping
305328
* @addr: virtual address from ioremap_*
@@ -365,7 +388,7 @@ void *xlate_dev_mem_ptr(unsigned long phys)
365388
if (page_is_ram(start >> PAGE_SHIFT))
366389
return __va(phys);
367390

368-
addr = (void *)ioremap(start, PAGE_SIZE);
391+
addr = (void *)ioremap_default(start, PAGE_SIZE);
369392
if (addr)
370393
addr = (void *)((unsigned long)addr | (phys & ~PAGE_MASK));
371394

0 commit comments

Comments
 (0)