drm/nouveau: Don't pass misaligned offsets to io_mapping_map_atomic_wc().
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 4 Aug 2010 03:10:57 +0000 (05:10 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 5 Aug 2010 22:34:50 +0000 (08:34 +1000)
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_bios.c

index 7369b5e7364946975294928ba13b65510fb54d47..66035283546a067acda808a745bb5e4632e7d562 100644 (file)
@@ -2083,9 +2083,10 @@ peek_fb(struct drm_device *dev, struct io_mapping *fb,
        uint32_t val = 0;
 
        if (off < pci_resource_len(dev->pdev, 1)) {
-               uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0);
+               uint32_t __iomem *p =
+                       io_mapping_map_atomic_wc(fb, off & PAGE_MASK, KM_USER0);
 
-               val = ioread32(p);
+               val = ioread32(p + (off & ~PAGE_MASK));
 
                io_mapping_unmap_atomic(p, KM_USER0);
        }
@@ -2098,9 +2099,10 @@ poke_fb(struct drm_device *dev, struct io_mapping *fb,
        uint32_t off, uint32_t val)
 {
        if (off < pci_resource_len(dev->pdev, 1)) {
-               uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0);
+               uint32_t __iomem *p =
+                       io_mapping_map_atomic_wc(fb, off & PAGE_MASK, KM_USER0);
 
-               iowrite32(val, p);
+               iowrite32(val, p + (off & ~PAGE_MASK));
                wmb();
 
                io_mapping_unmap_atomic(p, KM_USER0);