Auto-update from upstream
[pandora-kernel.git] / arch / ia64 / pci / pci.c
index 20d76fa..61dd860 100644 (file)
@@ -31,7 +31,6 @@
 #include <asm/irq.h>
 #include <asm/hw_irq.h>
 
-
 /*
  * Low-level SAL-based PCI configuration access functions. Note that SAL
  * calls are already serialized (via sal_lock), so we don't need another
@@ -193,12 +192,12 @@ add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr)
                goto free_resource;
        }
 
-       min = addr->min_address_range;
+       min = addr->minimum;
        max = min + addr->address_length - 1;
-       if (addr->attribute.io.translation_attribute == ACPI_SPARSE_TRANSLATION)
+       if (addr->info.io.translation_type == ACPI_SPARSE_TRANSLATION)
                sparse = 1;
 
-       space_nr = new_space(addr->address_translation_offset, sparse);
+       space_nr = new_space(addr->translation_offset, sparse);
        if (space_nr == ~0)
                goto free_name;
 
@@ -285,7 +284,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
        if (addr.resource_type == ACPI_MEMORY_RANGE) {
                flags = IORESOURCE_MEM;
                root = &iomem_resource;
-               offset = addr.address_translation_offset;
+               offset = addr.translation_offset;
        } else if (addr.resource_type == ACPI_IO_RANGE) {
                flags = IORESOURCE_IO;
                root = &ioport_resource;
@@ -298,7 +297,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
        window = &info->controller->window[info->controller->windows++];
        window->resource.name = info->name;
        window->resource.flags = flags;
-       window->resource.start = addr.min_address_range + offset;
+       window->resource.start = addr.minimum + offset;
        window->resource.end = window->resource.start + addr.address_length - 1;
        window->resource.child = NULL;
        window->offset = offset;
@@ -353,7 +352,7 @@ pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
        pxm = acpi_get_pxm(controller->acpi_handle);
 #ifdef CONFIG_NUMA
        if (pxm >= 0)
-               controller->node = pxm_to_nid_map[pxm];
+               controller->node = pxm_to_node(pxm);
 #endif
 
        acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
@@ -454,14 +453,13 @@ static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
        return 0;
 }
 
-static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
+static void __devinit
+pcibios_fixup_resources(struct pci_dev *dev, int start, int limit)
 {
        struct pci_bus_region region;
        int i;
-       int limit = (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) ? \
-               PCI_BRIDGE_RESOURCES : PCI_NUM_RESOURCES;
 
-       for (i = 0; i < limit; i++) {
+       for (i = start; i < limit; i++) {
                if (!dev->resource[i].flags)
                        continue;
                region.start = dev->resource[i].start;
@@ -472,6 +470,16 @@ static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
        }
 }
 
+static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
+{
+       pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES);
+}
+
+static void __devinit pcibios_fixup_bridge_resources(struct pci_dev *dev)
+{
+       pcibios_fixup_resources(dev, PCI_BRIDGE_RESOURCES, PCI_NUM_RESOURCES);
+}
+
 /*
  *  Called after each bus is probed, but before its children are examined.
  */
@@ -482,7 +490,7 @@ pcibios_fixup_bus (struct pci_bus *b)
 
        if (b->self) {
                pci_read_bridge_bases(b);
-               pcibios_fixup_device_resources(b->self);
+               pcibios_fixup_bridge_resources(b->self);
        }
        list_for_each_entry(dev, &b->devices, bus_list)
                pcibios_fixup_device_resources(dev);
@@ -570,7 +578,7 @@ pcibios_align_resource (void *data, struct resource *res,
 char * __init
 pcibios_setup (char *str)
 {
-       return NULL;
+       return str;
 }
 
 int
@@ -637,18 +645,31 @@ char *ia64_pci_get_legacy_mem(struct pci_bus *bus)
 int
 pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma)
 {
+       unsigned long size = vma->vm_end - vma->vm_start;
+       pgprot_t prot;
        char *addr;
 
+       /*
+        * Avoid attribute aliasing.  See Documentation/ia64/aliasing.txt
+        * for more details.
+        */
+       if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size))
+               return -EINVAL;
+       prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
+                                   vma->vm_page_prot);
+       if (pgprot_val(prot) != pgprot_val(pgprot_noncached(vma->vm_page_prot)))
+               return -EINVAL;
+
        addr = pci_get_legacy_mem(bus);
        if (IS_ERR(addr))
                return PTR_ERR(addr);
 
        vma->vm_pgoff += (unsigned long)addr >> PAGE_SHIFT;
-       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+       vma->vm_page_prot = prot;
        vma->vm_flags |= (VM_SHM | VM_RESERVED | VM_IO);
 
        if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
-                           vma->vm_end - vma->vm_start, vma->vm_page_prot))
+                           size, vma->vm_page_prot))
                return -EAGAIN;
 
        return 0;
@@ -698,9 +719,9 @@ int ia64_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size)
  *
  * Simply writes @size bytes of @val to @port.
  */
-int ia64_pci_legacy_write(struct pci_dev *bus, u16 port, u32 val, u8 size)
+int ia64_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
 {
-       int ret = 0;
+       int ret = size;
 
        switch (size) {
        case 1: