]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/ia64/sn/pci/pci_dma.c
[IA64] Altix pcibus_to_node implementation
[linux-2.6-omap-h63xx.git] / arch / ia64 / sn / pci / pci_dma.c
index a2f7a88aefbb0bd925647668acc641438ac73b5c..0e4b9ad9ef0250f2a1898dcae7c4a79c6a4f4bcc 100644 (file)
@@ -79,6 +79,7 @@ void *sn_dma_alloc_coherent(struct device *dev, size_t size,
 {
        void *cpuaddr;
        unsigned long phys_addr;
+       int node;
        struct pci_dev *pdev = to_pci_dev(dev);
        struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
 
@@ -86,10 +87,19 @@ void *sn_dma_alloc_coherent(struct device *dev, size_t size,
 
        /*
         * Allocate the memory.
-        * FIXME: We should be doing alloc_pages_node for the node closest
-        *        to the PCI device.
         */
-       if (!(cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size))))
+       node = pcibus_to_node(pdev->bus);
+       if (likely(node >=0)) {
+               struct page *p = alloc_pages_node(node, GFP_ATOMIC, get_order(size));
+
+               if (likely(p))
+                       cpuaddr = page_address(p);
+               else
+                       return NULL;
+       } else
+               cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
+
+       if (unlikely(!cpuaddr))
                return NULL;
 
        memset(cpuaddr, 0x0, size);