diff options
| -rw-r--r-- | arch/x86/include/asm/iomap.h | 3 | ||||
| -rw-r--r-- | arch/x86/mm/iomap_32.c | 18 | ||||
| -rw-r--r-- | arch/x86/xen/enlighten.c | 3 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 9 | ||||
| -rw-r--r-- | include/linux/io-mapping.h | 46 |
5 files changed, 67 insertions, 12 deletions
diff --git a/arch/x86/include/asm/iomap.h b/arch/x86/include/asm/iomap.h index c1f06289b14..86af26091d6 100644 --- a/arch/x86/include/asm/iomap.h +++ b/arch/x86/include/asm/iomap.h | |||
| @@ -23,6 +23,9 @@ | |||
| 23 | #include <asm/pgtable.h> | 23 | #include <asm/pgtable.h> |
| 24 | #include <asm/tlbflush.h> | 24 | #include <asm/tlbflush.h> |
| 25 | 25 | ||
| 26 | int | ||
| 27 | is_io_mapping_possible(resource_size_t base, unsigned long size); | ||
| 28 | |||
| 26 | void * | 29 | void * |
| 27 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); | 30 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); |
| 28 | 31 | ||
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c index ca53224fc56..6c2b1af1692 100644 --- a/arch/x86/mm/iomap_32.c +++ b/arch/x86/mm/iomap_32.c | |||
| @@ -20,6 +20,24 @@ | |||
| 20 | #include <asm/pat.h> | 20 | #include <asm/pat.h> |
| 21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
| 22 | 22 | ||
| 23 | #ifdef CONFIG_X86_PAE | ||
| 24 | int | ||
| 25 | is_io_mapping_possible(resource_size_t base, unsigned long size) | ||
| 26 | { | ||
| 27 | return 1; | ||
| 28 | } | ||
| 29 | #else | ||
| 30 | int | ||
| 31 | is_io_mapping_possible(resource_size_t base, unsigned long size) | ||
| 32 | { | ||
| 33 | /* There is no way to map greater than 1 << 32 address without PAE */ | ||
| 34 | if (base + size > 0x100000000ULL) | ||
| 35 | return 0; | ||
| 36 | |||
| 37 | return 1; | ||
| 38 | } | ||
| 39 | #endif | ||
| 40 | |||
| 23 | /* Map 'pfn' using fixed map 'type' and protections 'prot' | 41 | /* Map 'pfn' using fixed map 'type' and protections 'prot' |
| 24 | */ | 42 | */ |
| 25 | void * | 43 | void * |
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 86497d5f44c..c52f4034c7f 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
| @@ -940,6 +940,9 @@ asmlinkage void __init xen_start_kernel(void) | |||
| 940 | possible map and a non-dummy shared_info. */ | 940 | possible map and a non-dummy shared_info. */ |
| 941 | per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; | 941 | per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; |
| 942 | 942 | ||
| 943 | local_irq_disable(); | ||
| 944 | early_boot_irqs_off(); | ||
| 945 | |||
| 943 | xen_raw_console_write("mapping kernel into physical memory\n"); | 946 | xen_raw_console_write("mapping kernel into physical memory\n"); |
| 944 | pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); | 947 | pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); |
| 945 | 948 | ||
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 2d797ffe813..6949c2d58f1 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
| @@ -1090,6 +1090,11 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
| 1090 | dev_priv->mm.gtt_mapping = | 1090 | dev_priv->mm.gtt_mapping = |
| 1091 | io_mapping_create_wc(dev->agp->base, | 1091 | io_mapping_create_wc(dev->agp->base, |
| 1092 | dev->agp->agp_info.aper_size * 1024*1024); | 1092 | dev->agp->agp_info.aper_size * 1024*1024); |
| 1093 | if (dev_priv->mm.gtt_mapping == NULL) { | ||
| 1094 | ret = -EIO; | ||
| 1095 | goto out_rmmap; | ||
| 1096 | } | ||
| 1097 | |||
| 1093 | /* Set up a WC MTRR for non-PAT systems. This is more common than | 1098 | /* Set up a WC MTRR for non-PAT systems. This is more common than |
| 1094 | * one would think, because the kernel disables PAT on first | 1099 | * one would think, because the kernel disables PAT on first |
| 1095 | * generation Core chips because WC PAT gets overridden by a UC | 1100 | * generation Core chips because WC PAT gets overridden by a UC |
| @@ -1122,7 +1127,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
| 1122 | if (!I915_NEED_GFX_HWS(dev)) { | 1127 | if (!I915_NEED_GFX_HWS(dev)) { |
| 1123 | ret = i915_init_phys_hws(dev); | 1128 | ret = i915_init_phys_hws(dev); |
| 1124 | if (ret != 0) | 1129 | if (ret != 0) |
| 1125 | goto out_rmmap; | 1130 | goto out_iomapfree; |
| 1126 | } | 1131 | } |
| 1127 | 1132 | ||
| 1128 | /* On the 945G/GM, the chipset reports the MSI capability on the | 1133 | /* On the 945G/GM, the chipset reports the MSI capability on the |
| @@ -1161,6 +1166,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
| 1161 | 1166 | ||
| 1162 | return 0; | 1167 | return 0; |
| 1163 | 1168 | ||
| 1169 | out_iomapfree: | ||
| 1170 | io_mapping_free(dev_priv->mm.gtt_mapping); | ||
| 1164 | out_rmmap: | 1171 | out_rmmap: |
| 1165 | iounmap(dev_priv->regs); | 1172 | iounmap(dev_priv->regs); |
| 1166 | free_priv: | 1173 | free_priv: |
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h index 82df31726a5..cbc2f0cd631 100644 --- a/include/linux/io-mapping.h +++ b/include/linux/io-mapping.h | |||
| @@ -30,11 +30,14 @@ | |||
| 30 | * See Documentation/io_mapping.txt | 30 | * See Documentation/io_mapping.txt |
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | /* this struct isn't actually defined anywhere */ | ||
| 34 | struct io_mapping; | ||
| 35 | |||
| 36 | #ifdef CONFIG_HAVE_ATOMIC_IOMAP | 33 | #ifdef CONFIG_HAVE_ATOMIC_IOMAP |
| 37 | 34 | ||
| 35 | struct io_mapping { | ||
| 36 | resource_size_t base; | ||
| 37 | unsigned long size; | ||
| 38 | pgprot_t prot; | ||
| 39 | }; | ||
| 40 | |||
| 38 | /* | 41 | /* |
| 39 | * For small address space machines, mapping large objects | 42 | * For small address space machines, mapping large objects |
| 40 | * into the kernel virtual space isn't practical. Where | 43 | * into the kernel virtual space isn't practical. Where |
| @@ -43,23 +46,40 @@ struct io_mapping; | |||
| 43 | */ | 46 | */ |
| 44 | 47 | ||
| 45 | static inline struct io_mapping * | 48 | static inline struct io_mapping * |
| 46 | io_mapping_create_wc(unsigned long base, unsigned long size) | 49 | io_mapping_create_wc(resource_size_t base, unsigned long size) |
| 47 | { | 50 | { |
| 48 | return (struct io_mapping *) base; | 51 | struct io_mapping *iomap; |
| 52 | |||
| 53 | if (!is_io_mapping_possible(base, size)) | ||
| 54 | return NULL; | ||
| 55 | |||
| 56 | iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); | ||
| 57 | if (!iomap) | ||
| 58 | return NULL; | ||
| 59 | |||
| 60 | iomap->base = base; | ||
| 61 | iomap->size = size; | ||
| 62 | iomap->prot = pgprot_writecombine(__pgprot(__PAGE_KERNEL)); | ||
| 63 | return iomap; | ||
| 49 | } | 64 | } |
| 50 | 65 | ||
| 51 | static inline void | 66 | static inline void |
| 52 | io_mapping_free(struct io_mapping *mapping) | 67 | io_mapping_free(struct io_mapping *mapping) |
| 53 | { | 68 | { |
| 69 | kfree(mapping); | ||
| 54 | } | 70 | } |
| 55 | 71 | ||
| 56 | /* Atomic map/unmap */ | 72 | /* Atomic map/unmap */ |
| 57 | static inline void * | 73 | static inline void * |
| 58 | io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) | 74 | io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) |
| 59 | { | 75 | { |
| 60 | offset += (unsigned long) mapping; | 76 | resource_size_t phys_addr; |
| 61 | return iomap_atomic_prot_pfn(offset >> PAGE_SHIFT, KM_USER0, | 77 | unsigned long pfn; |
| 62 | __pgprot(__PAGE_KERNEL_WC)); | 78 | |
| 79 | BUG_ON(offset >= mapping->size); | ||
| 80 | phys_addr = mapping->base + offset; | ||
| 81 | pfn = (unsigned long) (phys_addr >> PAGE_SHIFT); | ||
| 82 | return iomap_atomic_prot_pfn(pfn, KM_USER0, mapping->prot); | ||
| 63 | } | 83 | } |
| 64 | 84 | ||
| 65 | static inline void | 85 | static inline void |
| @@ -71,8 +91,9 @@ io_mapping_unmap_atomic(void *vaddr) | |||
| 71 | static inline void * | 91 | static inline void * |
| 72 | io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset) | 92 | io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset) |
| 73 | { | 93 | { |
| 74 | offset += (unsigned long) mapping; | 94 | BUG_ON(offset >= mapping->size); |
| 75 | return ioremap_wc(offset, PAGE_SIZE); | 95 | resource_size_t phys_addr = mapping->base + offset; |
| 96 | return ioremap_wc(phys_addr, PAGE_SIZE); | ||
| 76 | } | 97 | } |
| 77 | 98 | ||
| 78 | static inline void | 99 | static inline void |
| @@ -83,9 +104,12 @@ io_mapping_unmap(void *vaddr) | |||
| 83 | 104 | ||
| 84 | #else | 105 | #else |
| 85 | 106 | ||
| 107 | /* this struct isn't actually defined anywhere */ | ||
| 108 | struct io_mapping; | ||
| 109 | |||
| 86 | /* Create the io_mapping object*/ | 110 | /* Create the io_mapping object*/ |
| 87 | static inline struct io_mapping * | 111 | static inline struct io_mapping * |
| 88 | io_mapping_create_wc(unsigned long base, unsigned long size) | 112 | io_mapping_create_wc(resource_size_t base, unsigned long size) |
| 89 | { | 113 | { |
| 90 | return (struct io_mapping *) ioremap_wc(base, size); | 114 | return (struct io_mapping *) ioremap_wc(base, size); |
| 91 | } | 115 | } |
