]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - arch/ia64/pci/pci.c
[IA64] SN specific version of dma_get_required_mask()
[linux-2.6.git] / arch / ia64 / pci / pci.c
index 720a861f88be283675a5b568bbf8837950e31d72..61f1af5c23c187ec8f1a8c36e2a3f28b5c467078 100644 (file)
@@ -10,7 +10,6 @@
  *
  * Note: Above list of copyright holders is incomplete...
  */
-#include <linux/config.h>
 
 #include <linux/acpi.h>
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
+#include <linux/bootmem.h>
 
 #include <asm/machvec.h>
 #include <asm/page.h>
-#include <asm/segment.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/sal.h>
@@ -32,7 +30,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
@@ -47,8 +44,7 @@
 #define PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg)      \
        (((u64) seg << 28) | (bus << 20) | (devfn << 12) | (reg))
 
-static int
-pci_sal_read (unsigned int seg, unsigned int bus, unsigned int devfn,
+int raw_pci_read(unsigned int seg, unsigned int bus, unsigned int devfn,
              int reg, int len, u32 *value)
 {
        u64 addr, data = 0;
@@ -72,8 +68,7 @@ pci_sal_read (unsigned int seg, unsigned int bus, unsigned int devfn,
        return 0;
 }
 
-static int
-pci_sal_write (unsigned int seg, unsigned int bus, unsigned int devfn,
+int raw_pci_write(unsigned int seg, unsigned int bus, unsigned int devfn,
               int reg, int len, u32 value)
 {
        u64 addr;
@@ -95,24 +90,17 @@ pci_sal_write (unsigned int seg, unsigned int bus, unsigned int devfn,
        return 0;
 }
 
-static struct pci_raw_ops pci_sal_ops = {
-       .read =         pci_sal_read,
-       .write =        pci_sal_write
-};
-
-struct pci_raw_ops *raw_pci_ops = &pci_sal_ops;
-
-static int
-pci_read (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
+static int pci_read(struct pci_bus *bus, unsigned int devfn, int where,
+                                                       int size, u32 *value)
 {
-       return raw_pci_ops->read(pci_domain_nr(bus), bus->number,
+       return raw_pci_read(pci_domain_nr(bus), bus->number,
                                 devfn, where, size, value);
 }
 
-static int
-pci_write (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
+static int pci_write(struct pci_bus *bus, unsigned int devfn, int where,
+                                                       int size, u32 value)
 {
-       return raw_pci_ops->write(pci_domain_nr(bus), bus->number,
+       return raw_pci_write(pci_domain_nr(bus), bus->number,
                                  devfn, where, size, value);
 }
 
@@ -121,29 +109,6 @@ struct pci_ops pci_root_ops = {
        .write = pci_write,
 };
 
-#ifdef CONFIG_NUMA
-extern acpi_status acpi_map_iosapic(acpi_handle, u32, void *, void **);
-static void acpi_map_iosapics(void)
-{
-       acpi_get_devices(NULL, acpi_map_iosapic, NULL, NULL);
-}
-#else
-static void acpi_map_iosapics(void)
-{
-       return;
-}
-#endif /* CONFIG_NUMA */
-
-static int __init
-pci_acpi_init (void)
-{
-       acpi_map_iosapics();
-
-       return 0;
-}
-
-subsys_initcall(pci_acpi_init);
-
 /* Called by ACPI when it finds a new root bus.  */
 
 static struct pci_controller * __devinit
@@ -151,44 +116,130 @@ alloc_pci_controller (int seg)
 {
        struct pci_controller *controller;
 
-       controller = kmalloc(sizeof(*controller), GFP_KERNEL);
+       controller = kzalloc(sizeof(*controller), GFP_KERNEL);
        if (!controller)
                return NULL;
 
-       memset(controller, 0, sizeof(*controller));
        controller->segment = seg;
+       controller->node = -1;
        return controller;
 }
 
-static u64 __devinit
-add_io_space (struct acpi_resource_address64 *addr)
+struct pci_root_info {
+       struct pci_controller *controller;
+       char *name;
+};
+
+static unsigned int
+new_space (u64 phys_base, int sparse)
 {
-       u64 offset;
-       int sparse = 0;
+       u64 mmio_base;
        int i;
 
-       if (addr->address_translation_offset == 0)
-               return IO_SPACE_BASE(0);        /* part of legacy IO space */
+       if (phys_base == 0)
+               return 0;       /* legacy I/O port space */
 
-       if (addr->attribute.io.translation_attribute == ACPI_SPARSE_TRANSLATION)
-               sparse = 1;
-
-       offset = (u64) ioremap(addr->address_translation_offset, 0);
+       mmio_base = (u64) ioremap(phys_base, 0);
        for (i = 0; i < num_io_spaces; i++)
-               if (io_space[i].mmio_base == offset &&
+               if (io_space[i].mmio_base == mmio_base &&
                    io_space[i].sparse == sparse)
-                       return IO_SPACE_BASE(i);
+                       return i;
 
        if (num_io_spaces == MAX_IO_SPACES) {
-               printk("Too many IO port spaces\n");
+               printk(KERN_ERR "PCI: Too many IO port spaces "
+                       "(MAX_IO_SPACES=%lu)\n", MAX_IO_SPACES);
                return ~0;
        }
 
        i = num_io_spaces++;
-       io_space[i].mmio_base = offset;
+       io_space[i].mmio_base = mmio_base;
        io_space[i].sparse = sparse;
 
-       return IO_SPACE_BASE(i);
+       return i;
+}
+
+static u64 __devinit
+add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr)
+{
+       struct resource *resource;
+       char *name;
+       u64 base, min, max, base_port;
+       unsigned int sparse = 0, space_nr, len;
+
+       resource = kzalloc(sizeof(*resource), GFP_KERNEL);
+       if (!resource) {
+               printk(KERN_ERR "PCI: No memory for %s I/O port space\n",
+                       info->name);
+               goto out;
+       }
+
+       len = strlen(info->name) + 32;
+       name = kzalloc(len, GFP_KERNEL);
+       if (!name) {
+               printk(KERN_ERR "PCI: No memory for %s I/O port space name\n",
+                       info->name);
+               goto free_resource;
+       }
+
+       min = addr->minimum;
+       max = min + addr->address_length - 1;
+       if (addr->info.io.translation_type == ACPI_SPARSE_TRANSLATION)
+               sparse = 1;
+
+       space_nr = new_space(addr->translation_offset, sparse);
+       if (space_nr == ~0)
+               goto free_name;
+
+       base = __pa(io_space[space_nr].mmio_base);
+       base_port = IO_SPACE_BASE(space_nr);
+       snprintf(name, len, "%s I/O Ports %08lx-%08lx", info->name,
+               base_port + min, base_port + max);
+
+       /*
+        * The SDM guarantees the legacy 0-64K space is sparse, but if the
+        * mapping is done by the processor (not the bridge), ACPI may not
+        * mark it as sparse.
+        */
+       if (space_nr == 0)
+               sparse = 1;
+
+       resource->name  = name;
+       resource->flags = IORESOURCE_MEM;
+       resource->start = base + (sparse ? IO_SPACE_SPARSE_ENCODING(min) : min);
+       resource->end   = base + (sparse ? IO_SPACE_SPARSE_ENCODING(max) : max);
+       insert_resource(&iomem_resource, resource);
+
+       return base_port;
+
+free_name:
+       kfree(name);
+free_resource:
+       kfree(resource);
+out:
+       return ~0;
+}
+
+static acpi_status __devinit resource_to_window(struct acpi_resource *resource,
+       struct acpi_resource_address64 *addr)
+{
+       acpi_status status;
+
+       /*
+        * We're only interested in _CRS descriptors that are
+        *      - address space descriptors for memory or I/O space
+        *      - non-zero size
+        *      - producers, i.e., the address space is routed downstream,
+        *        not consumed by the bridge itself
+        */
+       status = acpi_resource_to_address64(resource, addr);
+       if (ACPI_SUCCESS(status) &&
+           (addr->resource_type == ACPI_MEMORY_RANGE ||
+            addr->resource_type == ACPI_IO_RANGE) &&
+           addr->address_length &&
+           addr->producer_consumer == ACPI_PRODUCER)
+               return AE_OK;
+
+       return AE_ERROR;
 }
 
 static acpi_status __devinit
@@ -198,20 +249,13 @@ count_window (struct acpi_resource *resource, void *data)
        struct acpi_resource_address64 addr;
        acpi_status status;
 
-       status = acpi_resource_to_address64(resource, &addr);
+       status = resource_to_window(resource, &addr);
        if (ACPI_SUCCESS(status))
-               if (addr.resource_type == ACPI_MEMORY_RANGE ||
-                   addr.resource_type == ACPI_IO_RANGE)
-                       (*windows)++;
+               (*windows)++;
 
        return AE_OK;
 }
 
-struct pci_root_info {
-       struct pci_controller *controller;
-       char *name;
-};
-
 static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
 {
        struct pci_root_info *info = data;
@@ -221,21 +265,19 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
        unsigned long flags, offset = 0;
        struct resource *root;
 
-       status = acpi_resource_to_address64(res, &addr);
+       /* Return AE_OK for non-window resources to keep scanning for more */
+       status = resource_to_window(res, &addr);
        if (!ACPI_SUCCESS(status))
                return AE_OK;
 
-       if (!addr.address_length)
-               return AE_OK;
-
        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;
-               offset = add_io_space(&addr);
+               offset = add_io_space(info, &addr);
                if (offset == ~0)
                        return AE_OK;
        } else
@@ -244,8 +286,8 @@ 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.end = addr.max_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;
 
@@ -283,11 +325,11 @@ pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
 struct pci_bus * __devinit
 pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
 {
-       struct pci_root_info info;
        struct pci_controller *controller;
        unsigned int windows = 0;
        struct pci_bus *pbus;
        char *name;
+       int pxm;
 
        controller = alloc_pci_controller(domain);
        if (!controller)
@@ -295,23 +337,39 @@ pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
 
        controller->acpi_handle = device->handle;
 
+       pxm = acpi_get_pxm(controller->acpi_handle);
+#ifdef CONFIG_NUMA
+       if (pxm >= 0)
+               controller->node = pxm_to_node(pxm);
+#endif
+
        acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
                        &windows);
-       controller->window = kmalloc(sizeof(*controller->window) * windows,
-                       GFP_KERNEL);
-       if (!controller->window)
-               goto out2;
-
-       name = kmalloc(16, GFP_KERNEL);
-       if (!name)
-               goto out3;
-
-       sprintf(name, "PCI Bus %04x:%02x", domain, bus);
-       info.controller = controller;
-       info.name = name;
-       acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window,
-                       &info);
-
+       if (windows) {
+               struct pci_root_info info;
+
+               controller->window =
+                       kmalloc_node(sizeof(*controller->window) * windows,
+                                    GFP_KERNEL, controller->node);
+               if (!controller->window)
+                       goto out2;
+
+               name = kmalloc(16, GFP_KERNEL);
+               if (!name)
+                       goto out3;
+
+               sprintf(name, "PCI Bus %04x:%02x", domain, bus);
+               info.controller = controller;
+               info.name = name;
+               acpi_walk_resources(device->handle, METHOD_NAME__CRS,
+                       add_window, &info);
+       }
+       /*
+        * See arch/x86/pci/acpi.c.
+        * The desired pci bus might already be scanned in a quirk. We
+        * should handle the case here, but it appears that IA64 hasn't
+        * such quirk. So we just ignore the case now.
+        */
        pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller);
        if (pbus)
                pcibios_setup_root_windows(pbus, controller);
@@ -372,6 +430,7 @@ void pcibios_bus_to_resource(struct pci_dev *dev,
        res->start = region->start + offset;
        res->end = region->end + offset;
 }
+EXPORT_SYMBOL(pcibios_bus_to_resource);
 
 static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
 {
@@ -392,14 +451,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;
@@ -410,6 +468,17 @@ static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
        }
 }
 
+void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
+{
+       pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES);
+}
+EXPORT_SYMBOL_GPL(pcibios_fixup_device_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.
  */
@@ -420,10 +489,11 @@ 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);
+       platform_pci_fixup_bus(b);
 
        return;
 }
@@ -436,87 +506,50 @@ pcibios_update_irq (struct pci_dev *dev, int irq)
        /* ??? FIXME -- record old value for shutdown.  */
 }
 
-static inline int
-pcibios_enable_resources (struct pci_dev *dev, int mask)
-{
-       u16 cmd, old_cmd;
-       int idx;
-       struct resource *r;
-       unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
-
-       if (!dev)
-               return -EINVAL;
-
-       pci_read_config_word(dev, PCI_COMMAND, &cmd);
-       old_cmd = cmd;
-       for (idx=0; idx<PCI_NUM_RESOURCES; idx++) {
-               /* Only set up the desired resources.  */
-               if (!(mask & (1 << idx)))
-                       continue;
-
-               r = &dev->resource[idx];
-               if (!(r->flags & type_mask))
-                       continue;
-               if ((idx == PCI_ROM_RESOURCE) &&
-                               (!(r->flags & IORESOURCE_ROM_ENABLE)))
-                       continue;
-               if (!r->start && r->end) {
-                       printk(KERN_ERR
-                              "PCI: Device %s not available because of resource collisions\n",
-                              pci_name(dev));
-                       return -EINVAL;
-               }
-               if (r->flags & IORESOURCE_IO)
-                       cmd |= PCI_COMMAND_IO;
-               if (r->flags & IORESOURCE_MEM)
-                       cmd |= PCI_COMMAND_MEMORY;
-       }
-       if (cmd != old_cmd) {
-               printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
-               pci_write_config_word(dev, PCI_COMMAND, cmd);
-       }
-       return 0;
-}
-
 int
 pcibios_enable_device (struct pci_dev *dev, int mask)
 {
        int ret;
 
-       ret = pcibios_enable_resources(dev, mask);
+       ret = pci_enable_resources(dev, mask);
        if (ret < 0)
                return ret;
 
-       return acpi_pci_irq_enable(dev);
+       if (!dev->msi_enabled)
+               return acpi_pci_irq_enable(dev);
+       return 0;
 }
 
-#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
 void
 pcibios_disable_device (struct pci_dev *dev)
 {
-       acpi_pci_irq_disable(dev);
+       BUG_ON(atomic_read(&dev->enable_cnt));
+       if (!dev->msi_enabled)
+               acpi_pci_irq_disable(dev);
 }
-#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
 
 void
 pcibios_align_resource (void *data, struct resource *res,
-                       unsigned long size, unsigned long align)
+                       resource_size_t size, resource_size_t align)
 {
 }
 
 /*
  * PCI BIOS setup, always defaults to SAL interface
  */
-char * __init
+char * __devinit
 pcibios_setup (char *str)
 {
-       return NULL;
+       return str;
 }
 
 int
 pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
                     enum pci_mmap_state mmap_state, int write_combine)
 {
+       unsigned long size = vma->vm_end - vma->vm_start;
+       pgprot_t prot;
+
        /*
         * I/O space cannot be accessed via normal processor loads and
         * stores on this platform.
@@ -530,17 +563,24 @@ pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
                 */
                return -EINVAL;
 
+       if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
+               return -EINVAL;
+
+       prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
+                                   vma->vm_page_prot);
+
        /*
-        * Leave vm_pgoff as-is, the PCI space address is the physical
-        * address on this platform.
+        * If the user requested WC, the kernel uses UC or WC for this region,
+        * and the chipset supports WC, we can use WC. Otherwise, we have to
+        * use the same attribute the kernel uses.
         */
-       vma->vm_flags |= (VM_SHM | VM_RESERVED | VM_IO);
-
-       if (write_combine && efi_range_is_wc(vma->vm_start,
-                                            vma->vm_end - vma->vm_start))
+       if (write_combine &&
+           ((pgprot_val(prot) & _PAGE_MA_MASK) == _PAGE_MA_UC ||
+            (pgprot_val(prot) & _PAGE_MA_MASK) == _PAGE_MA_WC) &&
+           efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start))
                vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
        else
-               vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+               vma->vm_page_prot = prot;
 
        if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
                             vma->vm_end - vma->vm_start, vma->vm_page_prot))
@@ -575,20 +615,35 @@ char *ia64_pci_get_legacy_mem(struct pci_bus *bus)
  * vector to get the base address.
  */
 int
-pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma)
+pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma,
+                          enum pci_mmap_state mmap_state)
 {
+       unsigned long size = vma->vm_end - vma->vm_start;
+       pgprot_t prot;
        char *addr;
 
+       /* We only support mmap'ing of legacy memory space */
+       if (mmap_state != pci_mmap_mem)
+               return -ENOSYS;
+
+       /*
+        * Avoid attribute aliasing.  See Documentation/ia64/aliasing.txt
+        * for more details.
+        */
+       if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
+               return -EINVAL;
+       prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
+                                   vma->vm_page_prot);
+
        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_flags |= (VM_SHM | VM_RESERVED | VM_IO);
+       vma->vm_page_prot = prot;
 
        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;
@@ -638,9 +693,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:
@@ -660,84 +715,70 @@ int ia64_pci_legacy_write(struct pci_dev *bus, u16 port, u32 val, u8 size)
        return ret;
 }
 
+/* It's defined in drivers/pci/pci.c */
+extern u8 pci_cache_line_size;
+
 /**
- * pci_cacheline_size - determine cacheline size for PCI devices
- * @dev: void
+ * set_pci_cacheline_size - determine cacheline size for PCI devices
  *
  * We want to use the line-size of the outer-most cache.  We assume
  * that this line-size is the same for all CPUs.
  *
  * Code mostly taken from arch/ia64/kernel/palinfo.c:cache_info().
- *
- * RETURNS: An appropriate -ERRNO error value on eror, or zero for success.
  */
-static unsigned long
-pci_cacheline_size (void)
+static void __init set_pci_cacheline_size(void)
 {
        u64 levels, unique_caches;
        s64 status;
        pal_cache_config_info_t cci;
-       static u8 cacheline_size;
-
-       if (cacheline_size)
-               return cacheline_size;
 
        status = ia64_pal_cache_summary(&levels, &unique_caches);
        if (status != 0) {
-               printk(KERN_ERR "%s: ia64_pal_cache_summary() failed (status=%ld)\n",
-                      __FUNCTION__, status);
-               return SMP_CACHE_BYTES;
+               printk(KERN_ERR "%s: ia64_pal_cache_summary() failed "
+                       "(status=%ld)\n", __func__, status);
+               return;
        }
 
-       status = ia64_pal_cache_config_info(levels - 1, /* cache_type (data_or_unified)= */ 2,
-                                           &cci);
+       status = ia64_pal_cache_config_info(levels - 1,
+                               /* cache_type (data_or_unified)= */ 2, &cci);
        if (status != 0) {
-               printk(KERN_ERR "%s: ia64_pal_cache_config_info() failed (status=%ld)\n",
-                      __FUNCTION__, status);
-               return SMP_CACHE_BYTES;
+               printk(KERN_ERR "%s: ia64_pal_cache_config_info() failed "
+                       "(status=%ld)\n", __func__, status);
+               return;
        }
-       cacheline_size = 1 << cci.pcci_line_size;
-       return cacheline_size;
+       pci_cache_line_size = (1 << cci.pcci_line_size) / 4;
 }
 
-/**
- * pcibios_prep_mwi - helper function for drivers/pci/pci.c:pci_set_mwi()
- * @dev: the PCI device for which MWI is enabled
- *
- * For ia64, we can get the cacheline sizes from PAL.
- *
- * RETURNS: An appropriate -ERRNO error value on eror, or zero for success.
- */
-int
-pcibios_prep_mwi (struct pci_dev *dev)
-{
-       unsigned long desired_linesize, current_linesize;
-       int rc = 0;
-       u8 pci_linesize;
-
-       desired_linesize = pci_cacheline_size();
-
-       pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_linesize);
-       current_linesize = 4 * pci_linesize;
-       if (desired_linesize != current_linesize) {
-               printk(KERN_WARNING "PCI: slot %s has incorrect PCI cache line size of %lu bytes,",
-                      pci_name(dev), current_linesize);
-               if (current_linesize > desired_linesize) {
-                       printk(" expected %lu bytes instead\n", desired_linesize);
-                       rc = -EINVAL;
-               } else {
-                       printk(" correcting to %lu\n", desired_linesize);
-                       pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, desired_linesize / 4);
-               }
+u64 ia64_dma_get_required_mask(struct device *dev)
+{
+       u32 low_totalram = ((max_pfn - 1) << PAGE_SHIFT);
+       u32 high_totalram = ((max_pfn - 1) >> (32 - PAGE_SHIFT));
+       u64 mask;
+
+       if (!high_totalram) {
+               /* convert to mask just covering totalram */
+               low_totalram = (1 << (fls(low_totalram) - 1));
+               low_totalram += low_totalram - 1;
+               mask = low_totalram;
+       } else {
+               high_totalram = (1 << (fls(high_totalram) - 1));
+               high_totalram += high_totalram - 1;
+               mask = (((u64)high_totalram) << 32) + 0xffffffff;
        }
-       return rc;
+       return mask;
 }
+EXPORT_SYMBOL_GPL(ia64_dma_get_required_mask);
 
-int pci_vector_resources(int last, int nr_released)
+u64 dma_get_required_mask(struct device *dev)
 {
-       int count = nr_released;
-
-       count += (IA64_LAST_DEVICE_VECTOR - last);
+       return platform_dma_get_required_mask(dev);
+}
+EXPORT_SYMBOL_GPL(dma_get_required_mask);
 
-       return count;
+static int __init pcibios_init(void)
+{
+       set_pci_cacheline_size();
+       return 0;
 }
+
+subsys_initcall(pcibios_init);