Commit fca3ec01 authored by Chris Wilson's avatar Chris Wilson Committed by Dave Airlie

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 430f70d5
...@@ -496,10 +496,10 @@ fast_user_write(struct io_mapping *mapping, ...@@ -496,10 +496,10 @@ fast_user_write(struct io_mapping *mapping,
char *vaddr_atomic; char *vaddr_atomic;
unsigned long unwritten; unsigned long unwritten;
vaddr_atomic = io_mapping_map_atomic_wc(mapping, page_base); vaddr_atomic = io_mapping_map_atomic_wc(mapping, page_base, KM_USER0);
unwritten = __copy_from_user_inatomic_nocache(vaddr_atomic + page_offset, unwritten = __copy_from_user_inatomic_nocache(vaddr_atomic + page_offset,
user_data, length); user_data, length);
io_mapping_unmap_atomic(vaddr_atomic); io_mapping_unmap_atomic(vaddr_atomic, KM_USER0);
if (unwritten) if (unwritten)
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -3487,7 +3487,8 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj, ...@@ -3487,7 +3487,8 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
reloc_offset = obj_priv->gtt_offset + reloc->offset; reloc_offset = obj_priv->gtt_offset + reloc->offset;
reloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping, reloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
(reloc_offset & (reloc_offset &
~(PAGE_SIZE - 1))); ~(PAGE_SIZE - 1)),
KM_USER0);
reloc_entry = (uint32_t __iomem *)(reloc_page + reloc_entry = (uint32_t __iomem *)(reloc_page +
(reloc_offset & (PAGE_SIZE - 1))); (reloc_offset & (PAGE_SIZE - 1)));
reloc_val = target_obj_priv->gtt_offset + reloc->delta; 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,7 +3499,7 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
readl(reloc_entry), reloc_val); readl(reloc_entry), reloc_val);
#endif #endif
writel(reloc_val, reloc_entry); writel(reloc_val, reloc_entry);
io_mapping_unmap_atomic(reloc_page); io_mapping_unmap_atomic(reloc_page, KM_USER0);
/* The updated presumed offset for this entry will be /* The updated presumed offset for this entry will be
* copied back out to the user. * copied back out to the user.
......
...@@ -185,7 +185,8 @@ static struct overlay_registers *intel_overlay_map_regs_atomic(struct intel_over ...@@ -185,7 +185,8 @@ static struct overlay_registers *intel_overlay_map_regs_atomic(struct intel_over
if (OVERLAY_NONPHYSICAL(overlay->dev)) { if (OVERLAY_NONPHYSICAL(overlay->dev)) {
regs = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping, regs = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
overlay->reg_bo->gtt_offset); overlay->reg_bo->gtt_offset,
KM_USER0);
if (!regs) { if (!regs) {
DRM_ERROR("failed to map overlay regs in GTT\n"); 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 ...@@ -200,7 +201,7 @@ static struct overlay_registers *intel_overlay_map_regs_atomic(struct intel_over
static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay) static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay)
{ {
if (OVERLAY_NONPHYSICAL(overlay->dev)) if (OVERLAY_NONPHYSICAL(overlay->dev))
io_mapping_unmap_atomic(overlay->virt_addr); io_mapping_unmap_atomic(overlay->virt_addr, KM_USER0);
overlay->virt_addr = NULL; overlay->virt_addr = NULL;
......
...@@ -2083,11 +2083,11 @@ peek_fb(struct drm_device *dev, struct io_mapping *fb, ...@@ -2083,11 +2083,11 @@ peek_fb(struct drm_device *dev, struct io_mapping *fb,
uint32_t val = 0; uint32_t val = 0;
if (off < pci_resource_len(dev->pdev, 1)) { if (off < pci_resource_len(dev->pdev, 1)) {
uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off); uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0);
val = ioread32(p); val = ioread32(p);
io_mapping_unmap_atomic(p); io_mapping_unmap_atomic(p, KM_USER0);
} }
return val; return val;
...@@ -2098,12 +2098,12 @@ poke_fb(struct drm_device *dev, struct io_mapping *fb, ...@@ -2098,12 +2098,12 @@ poke_fb(struct drm_device *dev, struct io_mapping *fb,
uint32_t off, uint32_t val) uint32_t off, uint32_t val)
{ {
if (off < pci_resource_len(dev->pdev, 1)) { if (off < pci_resource_len(dev->pdev, 1)) {
uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off); uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0);
iowrite32(val, p); iowrite32(val, p);
wmb(); wmb();
io_mapping_unmap_atomic(p); io_mapping_unmap_atomic(p, KM_USER0);
} }
} }
......
...@@ -79,7 +79,9 @@ io_mapping_free(struct io_mapping *mapping) ...@@ -79,7 +79,9 @@ io_mapping_free(struct io_mapping *mapping)
/* Atomic map/unmap */ /* Atomic map/unmap */
static inline void * static inline void *
io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) io_mapping_map_atomic_wc(struct io_mapping *mapping,
unsigned long offset,
int slot)
{ {
resource_size_t phys_addr; resource_size_t phys_addr;
unsigned long pfn; unsigned long pfn;
...@@ -87,13 +89,13 @@ io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) ...@@ -87,13 +89,13 @@ io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
BUG_ON(offset >= mapping->size); BUG_ON(offset >= mapping->size);
phys_addr = mapping->base + offset; phys_addr = mapping->base + offset;
pfn = (unsigned long) (phys_addr >> PAGE_SHIFT); pfn = (unsigned long) (phys_addr >> PAGE_SHIFT);
return iomap_atomic_prot_pfn(pfn, KM_USER0, mapping->prot); return iomap_atomic_prot_pfn(pfn, slot, mapping->prot);
} }
static inline void static inline void
io_mapping_unmap_atomic(void *vaddr) io_mapping_unmap_atomic(void *vaddr, int slot)
{ {
iounmap_atomic(vaddr, KM_USER0); iounmap_atomic(vaddr, slot);
} }
static inline void * static inline void *
...@@ -133,13 +135,15 @@ io_mapping_free(struct io_mapping *mapping) ...@@ -133,13 +135,15 @@ io_mapping_free(struct io_mapping *mapping)
/* Atomic map/unmap */ /* Atomic map/unmap */
static inline void * static inline void *
io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) io_mapping_map_atomic_wc(struct io_mapping *mapping,
unsigned long offset,
int slot)
{ {
return ((char *) mapping) + offset; return ((char *) mapping) + offset;
} }
static inline void static inline void
io_mapping_unmap_atomic(void *vaddr) io_mapping_unmap_atomic(void *vaddr, int slot)
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment