aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-08-04 09:34:24 -0400
committerDave Airlie <airlied@redhat.com>2010-08-04 18:48:53 -0400
commitfca3ec01e0b40cab82cac7745e154b01969e6219 (patch)
tree731d6cdc321c8c1f8b2c4e8f0fdb0df59b5abbc9
parent430f70d59da643f1aa7c9cf3493423a76550b110 (diff)
drm,io-mapping: Specify slot to use for atomic mappings
This is required should we ever attempt to use an io-mapping where KM_USER0 is verboten, such as inside an IRQ context. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Eric Anholt <eric@anholt.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c9
-rw-r--r--drivers/gpu/drm/i915/intel_overlay.c5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c8
-rw-r--r--include/linux/io-mapping.h16
4 files changed, 22 insertions, 16 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4efd4fd3b340..2a4ed7ca8b4e 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -496,10 +496,10 @@ fast_user_write(struct io_mapping *mapping,
496 char *vaddr_atomic; 496 char *vaddr_atomic;
497 unsigned long unwritten; 497 unsigned long unwritten;
498 498
499 vaddr_atomic = io_mapping_map_atomic_wc(mapping, page_base); 499 vaddr_atomic = io_mapping_map_atomic_wc(mapping, page_base, KM_USER0);
500 unwritten = __copy_from_user_inatomic_nocache(vaddr_atomic + page_offset, 500 unwritten = __copy_from_user_inatomic_nocache(vaddr_atomic + page_offset,
501 user_data, length); 501 user_data, length);
502 io_mapping_unmap_atomic(vaddr_atomic); 502 io_mapping_unmap_atomic(vaddr_atomic, KM_USER0);
503 if (unwritten) 503 if (unwritten)
504 return -EFAULT; 504 return -EFAULT;
505 return 0; 505 return 0;
@@ -3487,7 +3487,8 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
3487 reloc_offset = obj_priv->gtt_offset + reloc->offset; 3487 reloc_offset = obj_priv->gtt_offset + reloc->offset;
3488 reloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping, 3488 reloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
3489 (reloc_offset & 3489 (reloc_offset &
3490 ~(PAGE_SIZE - 1))); 3490 ~(PAGE_SIZE - 1)),
3491 KM_USER0);
3491 reloc_entry = (uint32_t __iomem *)(reloc_page + 3492 reloc_entry = (uint32_t __iomem *)(reloc_page +
3492 (reloc_offset & (PAGE_SIZE - 1))); 3493 (reloc_offset & (PAGE_SIZE - 1)));
3493 reloc_val = target_obj_priv->gtt_offset + reloc->delta; 3494 reloc_val = target_obj_priv->gtt_offset + reloc->delta;
@@ -3498,7 +3499,7 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
3498 readl(reloc_entry), reloc_val); 3499 readl(reloc_entry), reloc_val);
3499#endif 3500#endif
3500 writel(reloc_val, reloc_entry); 3501 writel(reloc_val, reloc_entry);
3501 io_mapping_unmap_atomic(reloc_page); 3502 io_mapping_unmap_atomic(reloc_page, KM_USER0);
3502 3503
3503 /* The updated presumed offset for this entry will be 3504 /* The updated presumed offset for this entry will be
3504 * copied back out to the user. 3505 * copied back out to the user.
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index f26ec2f27d36..d39aea24eabe 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -185,7 +185,8 @@ static struct overlay_registers *intel_overlay_map_regs_atomic(struct intel_over
185 185
186 if (OVERLAY_NONPHYSICAL(overlay->dev)) { 186 if (OVERLAY_NONPHYSICAL(overlay->dev)) {
187 regs = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping, 187 regs = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
188 overlay->reg_bo->gtt_offset); 188 overlay->reg_bo->gtt_offset,
189 KM_USER0);
189 190
190 if (!regs) { 191 if (!regs) {
191 DRM_ERROR("failed to map overlay regs in GTT\n"); 192 DRM_ERROR("failed to map overlay regs in GTT\n");
@@ -200,7 +201,7 @@ static struct overlay_registers *intel_overlay_map_regs_atomic(struct intel_over
200static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay) 201static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay)
201{ 202{
202 if (OVERLAY_NONPHYSICAL(overlay->dev)) 203 if (OVERLAY_NONPHYSICAL(overlay->dev))
203 io_mapping_unmap_atomic(overlay->virt_addr); 204 io_mapping_unmap_atomic(overlay->virt_addr, KM_USER0);
204 205
205 overlay->virt_addr = NULL; 206 overlay->virt_addr = NULL;
206 207
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index b59f348f14fc..7369b5e73649 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -2083,11 +2083,11 @@ peek_fb(struct drm_device *dev, struct io_mapping *fb,
2083 uint32_t val = 0; 2083 uint32_t val = 0;
2084 2084
2085 if (off < pci_resource_len(dev->pdev, 1)) { 2085 if (off < pci_resource_len(dev->pdev, 1)) {
2086 uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off); 2086 uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0);
2087 2087
2088 val = ioread32(p); 2088 val = ioread32(p);
2089 2089
2090 io_mapping_unmap_atomic(p); 2090 io_mapping_unmap_atomic(p, KM_USER0);
2091 } 2091 }
2092 2092
2093 return val; 2093 return val;
@@ -2098,12 +2098,12 @@ poke_fb(struct drm_device *dev, struct io_mapping *fb,
2098 uint32_t off, uint32_t val) 2098 uint32_t off, uint32_t val)
2099{ 2099{
2100 if (off < pci_resource_len(dev->pdev, 1)) { 2100 if (off < pci_resource_len(dev->pdev, 1)) {
2101 uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off); 2101 uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0);
2102 2102
2103 iowrite32(val, p); 2103 iowrite32(val, p);
2104 wmb(); 2104 wmb();
2105 2105
2106 io_mapping_unmap_atomic(p); 2106 io_mapping_unmap_atomic(p, KM_USER0);
2107 } 2107 }
2108} 2108}
2109 2109
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
index 25085ddd955f..e0ea40f6c515 100644
--- a/include/linux/io-mapping.h
+++ b/include/linux/io-mapping.h
@@ -79,7 +79,9 @@ io_mapping_free(struct io_mapping *mapping)
79 79
80/* Atomic map/unmap */ 80/* Atomic map/unmap */
81static inline void * 81static inline void *
82io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) 82io_mapping_map_atomic_wc(struct io_mapping *mapping,
83 unsigned long offset,
84 int slot)
83{ 85{
84 resource_size_t phys_addr; 86 resource_size_t phys_addr;
85 unsigned long pfn; 87 unsigned long pfn;
@@ -87,13 +89,13 @@ io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
87 BUG_ON(offset >= mapping->size); 89 BUG_ON(offset >= mapping->size);
88 phys_addr = mapping->base + offset; 90 phys_addr = mapping->base + offset;
89 pfn = (unsigned long) (phys_addr >> PAGE_SHIFT); 91 pfn = (unsigned long) (phys_addr >> PAGE_SHIFT);
90 return iomap_atomic_prot_pfn(pfn, KM_USER0, mapping->prot); 92 return iomap_atomic_prot_pfn(pfn, slot, mapping->prot);
91} 93}
92 94
93static inline void 95static inline void
94io_mapping_unmap_atomic(void *vaddr) 96io_mapping_unmap_atomic(void *vaddr, int slot)
95{ 97{
96 iounmap_atomic(vaddr, KM_USER0); 98 iounmap_atomic(vaddr, slot);
97} 99}
98 100
99static inline void * 101static inline void *
@@ -133,13 +135,15 @@ io_mapping_free(struct io_mapping *mapping)
133 135
134/* Atomic map/unmap */ 136/* Atomic map/unmap */
135static inline void * 137static inline void *
136io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) 138io_mapping_map_atomic_wc(struct io_mapping *mapping,
139 unsigned long offset,
140 int slot)
137{ 141{
138 return ((char *) mapping) + offset; 142 return ((char *) mapping) + offset;
139} 143}
140 144
141static inline void 145static inline void
142io_mapping_unmap_atomic(void *vaddr) 146io_mapping_unmap_atomic(void *vaddr, int slot)
143{ 147{
144} 148}
145 149