Skip to content

Commit 5d72b4f

Browse files
Toshi Kanitorvalds
authored andcommitted
x86, mm: support huge I/O mapping capability I/F
Implement huge I/O mapping capability interfaces for ioremap() on x86. IOREMAP_MAX_ORDER is defined to PUD_SHIFT on x86/64 and PMD_SHIFT on x86/32, which overrides the default value defined in <linux/vmalloc.h>. Signed-off-by: Toshi Kani <toshi.kani@hp.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Robert Elliott <Elliott@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b9820d8 commit 5d72b4f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

arch/x86/include/asm/page_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040

4141
#ifdef CONFIG_X86_64
4242
#include <asm/page_64_types.h>
43+
#define IOREMAP_MAX_ORDER (PUD_SHIFT)
4344
#else
4445
#include <asm/page_32_types.h>
46+
#define IOREMAP_MAX_ORDER (PMD_SHIFT)
4547
#endif /* CONFIG_X86_64 */
4648

4749
#ifndef __ASSEMBLY__

arch/x86/mm/ioremap.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
6767

6868
/*
6969
* Remap an arbitrary physical address space into the kernel virtual
70-
* address space. Needed when the kernel wants to access high addresses
71-
* directly.
70+
* address space. It transparently creates kernel huge I/O mapping when
71+
* the physical address is aligned by a huge page size (1GB or 2MB) and
72+
* the requested size is at least the huge page size.
73+
*
74+
* NOTE: MTRRs can override PAT memory types with a 4KB granularity.
75+
* Therefore, the mapping code falls back to use a smaller page toward 4KB
76+
* when a mapping range is covered by non-WB type of MTRRs.
7277
*
7378
* NOTE! We need to allow non-page-aligned mappings too: we will obviously
7479
* have to convert them into an offset in a page-aligned mapping, but the
@@ -326,6 +331,20 @@ void iounmap(volatile void __iomem *addr)
326331
}
327332
EXPORT_SYMBOL(iounmap);
328333

334+
int arch_ioremap_pud_supported(void)
335+
{
336+
#ifdef CONFIG_X86_64
337+
return cpu_has_gbpages;
338+
#else
339+
return 0;
340+
#endif
341+
}
342+
343+
int arch_ioremap_pmd_supported(void)
344+
{
345+
return cpu_has_pse;
346+
}
347+
329348
/*
330349
* Convert a physical pointer to a virtual kernel pointer for /dev/mem
331350
* access

0 commit comments

Comments
 (0)