Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54512
b: refs/heads/master
c: 9b50ffb
h: refs/heads/master
v: v3
  • Loading branch information
Bjorn Helgaas authored and Tony Luck committed Mar 30, 2007
1 parent fbdc80d commit e272e13
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c4add2e537e6f60048dce8dc518254e7e605301d
refs/heads/master: 9b50ffb0c0281bc5a08ccd56ae9bb84296c28f38
60 changes: 55 additions & 5 deletions trunk/arch/ia64/mm/ioremap.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (c) Copyright 2006 Hewlett-Packard Development Company, L.P.
* (c) Copyright 2006, 2007 Hewlett-Packard Development Company, L.P.
* Bjorn Helgaas <bjorn.helgaas@hp.com>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -10,20 +10,27 @@
#include <linux/compiler.h>
#include <linux/module.h>
#include <linux/efi.h>
#include <linux/io.h>
#include <linux/vmalloc.h>
#include <asm/io.h>
#include <asm/meminit.h>

static inline void __iomem *
__ioremap (unsigned long phys_addr, unsigned long size)
__ioremap (unsigned long phys_addr)
{
return (void __iomem *) (__IA64_UNCACHED_OFFSET | phys_addr);
}

void __iomem *
ioremap (unsigned long phys_addr, unsigned long size)
{
void __iomem *addr;
struct vm_struct *area;
unsigned long offset;
pgprot_t prot;
u64 attr;
unsigned long gran_base, gran_size;
unsigned long page_base;

/*
* For things in kern_memmap, we must use the same attribute
Expand All @@ -34,7 +41,7 @@ ioremap (unsigned long phys_addr, unsigned long size)
if (attr & EFI_MEMORY_WB)
return (void __iomem *) phys_to_virt(phys_addr);
else if (attr & EFI_MEMORY_UC)
return __ioremap(phys_addr, size);
return __ioremap(phys_addr);

/*
* Some chipsets don't support UC access to memory. If
Expand All @@ -45,7 +52,42 @@ ioremap (unsigned long phys_addr, unsigned long size)
if (efi_mem_attribute(gran_base, gran_size) & EFI_MEMORY_WB)
return (void __iomem *) phys_to_virt(phys_addr);

return __ioremap(phys_addr, size);
/*
* WB is not supported for the whole granule, so we can't use
* the region 7 identity mapping. If we can safely cover the
* area with kernel page table mappings, we can use those
* instead.
*/
page_base = phys_addr & PAGE_MASK;
size = PAGE_ALIGN(phys_addr + size) - page_base;
if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) {
prot = PAGE_KERNEL;

/*
* Mappings have to be page-aligned
*/
offset = phys_addr & ~PAGE_MASK;
phys_addr &= PAGE_MASK;

/*
* Ok, go for it..
*/
area = get_vm_area(size, VM_IOREMAP);
if (!area)
return NULL;

area->phys_addr = phys_addr;
addr = (void __iomem *) area->addr;
if (ioremap_page_range((unsigned long) addr,
(unsigned long) addr + size, phys_addr, prot)) {
vunmap((void __force *) addr);
return NULL;
}

return (void __iomem *) (offset + (char __iomem *)addr);
}

return __ioremap(phys_addr);
}
EXPORT_SYMBOL(ioremap);

Expand All @@ -55,6 +97,14 @@ ioremap_nocache (unsigned long phys_addr, unsigned long size)
if (kern_mem_attribute(phys_addr, size) & EFI_MEMORY_WB)
return NULL;

return __ioremap(phys_addr, size);
return __ioremap(phys_addr);
}
EXPORT_SYMBOL(ioremap_nocache);

void
iounmap (volatile void __iomem *addr)
{
if (REGION_NUMBER(addr) == RGN_GATE)
vunmap((void *) ((unsigned long) addr & PAGE_MASK));
}
EXPORT_SYMBOL(iounmap);
6 changes: 1 addition & 5 deletions trunk/include/asm-ia64/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,7 @@ __writeq (unsigned long val, volatile void __iomem *addr)

extern void __iomem * ioremap(unsigned long offset, unsigned long size);
extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);

static inline void
iounmap (volatile void __iomem *addr)
{
}
extern void iounmap (volatile void __iomem *addr);

/* Use normal IO mappings for DMI */
#define dmi_ioremap ioremap
Expand Down

0 comments on commit e272e13

Please sign in to comment.