lkml.org 
[lkml]   [2007]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[RFC PATCH 05/12] PAT 64b: pci mmap conlfict patch
    Forward port of pci-mmap-conflict.patch to x86 tree.

    Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
    Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
    ---

    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;
    }
    --


    \
     
     \ /
      Last update: 2007-12-14 00:59    [W:4.454 / U:0.172 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site