Forward port of pci-mmap-conflict.patch to x86 tree.

Signed-off-by: Venkatesh Pallipadi <[EMAIL PROTECTED]>
Signed-off-by: Suresh Siddha <[EMAIL PROTECTED]>
---

Index: linux-2.6.24-rc4/arch/x86/pci/i386.c
===================================================================
--- linux-2.6.24-rc4.orig/arch/x86/pci/i386.c   2007-12-11 15:08:12.000000000 
-0800
+++ linux-2.6.24-rc4/arch/x86/pci/i386.c        2007-12-11 15:43:14.000000000 
-0800
@@ -30,6 +30,8 @@
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/errno.h>
+#include <asm/pat.h>
+#include <asm/cacheflush.h>
 
 #include "pci.h"
 
@@ -297,9 +299,25 @@
        pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
 }
 
+static void pci_unmap_page_range(struct vm_area_struct *vma)
+{
+       u64 adr = (u64)vma->vm_pgoff << PAGE_SHIFT;
+       free_mattr(adr, adr + vma->vm_end - vma->vm_start,
+               pgprot_val(vma->vm_page_prot) & _PAGE_CACHE_MASK);
+}
+
+static struct vm_operations_struct pci_mmap_ops = {
+       .close = pci_unmap_page_range
+};
+
 int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
                        enum pci_mmap_state mmap_state, int write_combine)
 {
+       u64 addr = vma->vm_pgoff << PAGE_SHIFT;
+       unsigned long len = vma->vm_end - vma->vm_start;
+       unsigned long attr;
+       int err;
+
        /* I/O space cannot be accessed via normal processor loads and
         * stores on this platform.
         */
@@ -314,10 +332,24 @@
        else
                vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
+       attr = pgprot_val(vma->vm_page_prot) & _PAGE_CACHE_MASK;
+       err = reserve_mattr(addr, addr+len, attr, NULL);
+       if (err)
+               return -EBUSY;
+
+       err = change_page_attr_addr(addr, len >> PAGE_SHIFT,
+                               __pgprot(__PAGE_KERNEL | attr));
+       if (err) {
+               free_mattr(addr, addr+len, attr);
+               return err;
+       }
+
        if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
                               vma->vm_end - vma->vm_start,
                               vma->vm_page_prot))
                return -EAGAIN;
 
+       vma->vm_ops = &pci_mmap_ops;
+
        return 0;
 }

-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to