Advertisement
Guest User

Untitled

a guest
May 7th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.15 KB | None | 0 0
  1. commit c8477ed83c15cd69d0155f8bb8c4998c9fb27090
  2. Author: akpm <akpm>
  3. Date:   Sun Mar 14 21:49:48 2004 +0000
  4.  
  5.     [PATCH] move consistent_dma_mask to the generic device
  6.    
  7.     From: James Bottomley <James.Bottomley@SteelEye.com>
  8.    
  9.     pci_dev.consistent_dma_mask was introduced to get around problems in the
  10.     IA64 Altix machine.
  11.    
  12.     Now, we have a use for it in x86: the aacraid needs coherent memory in a
  13.     31 bit address range (2GB).  Unfortunately, x86 is converted to the dma
  14.     model, so it can't see the pci_dev by the time coherent memory is
  15.     allocated.
  16.    
  17.     The solution to all of this is to move pci_dev.consistent_dma_mask to
  18.     dev.coherent_dma_mask and make x86 use it in the dma_alloc_coherent()
  19.     calls.
  20.    
  21.     This should allow me to make the aacraid set the coherent mask instead
  22.     of using it's current dma_mask juggling.
  23.    
  24.     BKrev: 4054d37cpgL-07XPugpvCTBdf-k_Eg
  25.  
  26. diff --git a/arch/i386/kernel/pci-dma.c b/arch/i386/kernel/pci-dma.c
  27. index 0c02ccee..10dc6b7 100644
  28. --- a/arch/i386/kernel/pci-dma.c
  29. +++ b/arch/i386/kernel/pci-dma.c
  30. @@ -20,8 +20,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
  31.     /* ignore region specifiers */
  32.     gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
  33.  
  34. -   if (dev == NULL || (*dev->dma_mask < 0xffffffff))
  35. +   if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
  36.         gfp |= GFP_DMA;
  37. +
  38.     ret = (void *)__get_free_pages(gfp, get_order(size));
  39.  
  40.     if (ret != NULL) {
  41. diff --git a/arch/ia64/sn/io/machvec/pci_dma.c b/arch/ia64/sn/io/machvec/pci_dma.c
  42. index e5a5037..14f1fbf 100644
  43. --- a/arch/ia64/sn/io/machvec/pci_dma.c
  44. +++ b/arch/ia64/sn/io/machvec/pci_dma.c
  45. @@ -152,7 +152,7 @@ sn_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_hand
  46.      *   pcibr_dmatrans_addr ignores a missing PCIIO_DMA_A64 flag on
  47.      *   PCI-X buses.
  48.      */
  49. -   if (hwdev->consistent_dma_mask == ~0UL)
  50. +   if (hwdev->dev.coherent_dma_mask == ~0UL)
  51.         *dma_handle = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
  52.                       PCIIO_DMA_CMD | PCIIO_DMA_A64);
  53.     else {
  54. @@ -169,7 +169,7 @@ sn_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_hand
  55.         }
  56.     }
  57.  
  58. -   if (!*dma_handle || *dma_handle > hwdev->consistent_dma_mask) {
  59. +   if (!*dma_handle || *dma_handle > hwdev->dev.coherent_dma_mask) {
  60.         if (dma_map) {
  61.             pcibr_dmamap_done(dma_map);
  62.             pcibr_dmamap_free(dma_map);
  63. diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
  64. index bdb2af9..50130b9 100644
  65. --- a/arch/parisc/kernel/drivers.c
  66. +++ b/arch/parisc/kernel/drivers.c
  67. @@ -618,6 +618,7 @@ static void parisc_generic_device_register_recursive( struct parisc_device *dev
  68.          tmp1);
  69.     /* make the generic dma mask a pointer to the parisc one */
  70.     dev->dev.dma_mask = &dev->dma_mask;
  71. +   dev->dev.coherent_dma_mask = dev->dma_mask;
  72.     pr_debug("device_register(%s)\n", dev->dev.bus_id);
  73.     device_register(&dev->dev);
  74.  }
  75. diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
  76. index 25ee911..2485835 100644
  77. --- a/arch/parisc/kernel/pci-dma.c
  78. +++ b/arch/parisc/kernel/pci-dma.c
  79. @@ -372,7 +372,7 @@ static void * pa11_dma_alloc_consistent (struct device *dev, size_t size, dma_ad
  80.  ** ISA cards will certainly only support 24-bit DMA addressing.
  81.  ** Not clear if we can, want, or need to support ISA.
  82.  */
  83. -   if (!dev || *dev->dma_mask != 0xffffffff)
  84. +   if (!dev || *dev->coherent_dma_mask < 0xffffffff)
  85.         gfp |= GFP_DMA;
  86.  #endif
  87.     return (void *)vaddr;
  88. diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
  89. index 245c54f..9a520c4 100644
  90. --- a/arch/x86_64/kernel/pci-gart.c
  91. +++ b/arch/x86_64/kernel/pci-gart.c
  92. @@ -183,7 +183,7 @@ void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
  93.         gfp |= GFP_DMA;
  94.         dma_mask = 0xffffffff;
  95.     } else {
  96. -       dma_mask = hwdev->consistent_dma_mask;
  97. +       dma_mask = hwdev->dev.coherent_dma_mask;
  98.     }
  99.  
  100.     if (dma_mask == 0)
  101. diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
  102. index 368001a..af825fc 100644
  103. --- a/drivers/eisa/eisa-bus.c
  104. +++ b/drivers/eisa/eisa-bus.c
  105. @@ -187,6 +187,7 @@ static int __init eisa_init_device (struct eisa_root_device *root,
  106.     edev->dev.parent = root->dev;
  107.     edev->dev.bus = &eisa_bus_type;
  108.     edev->dev.dma_mask = &edev->dma_mask;
  109. +   edev->dev.coherent_dma_mask = edev->dma_mask;
  110.     sprintf (edev->dev.bus_id, "%02X:%02X", root->bus_nr, slot);
  111.  
  112.     for (i = 0; i < EISA_MAX_RESOURCES; i++) {
  113. diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c
  114. index d83f004..a967aad 100644
  115. --- a/drivers/mca/mca-bus.c
  116. +++ b/drivers/mca/mca-bus.c
  117. @@ -106,6 +106,7 @@ int __init mca_register_device(int bus, struct mca_device *mca_dev)
  118.     sprintf (mca_dev->dev.bus_id, "%02d:%02X", bus, mca_dev->slot);
  119.     mca_dev->dma_mask = mca_bus->default_dma_mask;
  120.     mca_dev->dev.dma_mask = &mca_dev->dma_mask;
  121. +   mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask;
  122.  
  123.     if (device_register(&mca_dev->dev))
  124.         return 0;
  125. diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
  126. index 8dee4e6..71b7b30 100644
  127. --- a/drivers/pci/pci.c
  128. +++ b/drivers/pci/pci.c
  129. @@ -686,7 +686,7 @@ pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
  130.     if (!pci_dma_supported(dev, mask))
  131.         return -EIO;
  132.  
  133. -   dev->consistent_dma_mask = mask;
  134. +   dev->dev.coherent_dma_mask = mask;
  135.  
  136.     return 0;
  137.  }
  138. diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
  139. index 298a898..0669ca63 100644
  140. --- a/drivers/pci/probe.c
  141. +++ b/drivers/pci/probe.c
  142. @@ -570,7 +570,6 @@ pci_scan_device(struct pci_bus *bus, int devfn)
  143.     /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer)
  144.        set this higher, assuming the system even supports it.  */
  145.     dev->dma_mask = 0xffffffff;
  146. -   dev->consistent_dma_mask = 0xffffffff;
  147.     if (pci_setup_device(dev) < 0) {
  148.         kfree(dev);
  149.         return NULL;
  150. @@ -582,6 +581,7 @@ pci_scan_device(struct pci_bus *bus, int devfn)
  151.     pci_name_device(dev);
  152.  
  153.     dev->dev.dma_mask = &dev->dma_mask;
  154. +   dev->dev.coherent_dma_mask = 0xffffffffull;
  155.  
  156.     return dev;
  157.  }
  158. diff --git a/include/linux/device.h b/include/linux/device.h
  159. index aef6b2f..28e101a 100644
  160. --- a/include/linux/device.h
  161. +++ b/include/linux/device.h
  162. @@ -285,6 +285,12 @@ struct device {
  163.                        detached from its driver. */
  164.  
  165.     u64     *dma_mask;  /* dma mask (if dma'able device) */
  166. +   u64     coherent_dma_mask;/* Like dma_mask, but for
  167. +                        alloc_coherent mappings as
  168. +                        not all hardware supports
  169. +                        64 bit addresses for consistent
  170. +                        allocations such descriptors. */
  171. +
  172.     struct list_head    dma_pools;  /* dma pools (if dma'ble) */
  173.  
  174.     void    (*release)(struct device * dev);
  175. diff --git a/include/linux/pci.h b/include/linux/pci.h
  176. index eb594a8..3f2b494 100644
  177. --- a/include/linux/pci.h
  178. +++ b/include/linux/pci.h
  179. @@ -393,11 +393,6 @@ struct pci_dev {
  180.                        this if your device has broken DMA
  181.                        or supports 64-bit transfers.  */
  182.  
  183. -   u64     consistent_dma_mask;/* Like dma_mask, but for
  184. -                          pci_alloc_consistent mappings as
  185. -                          not all hardware supports
  186. -                          64 bit addresses for consistent
  187. -                          allocations such descriptors. */
  188.     u32             current_state;  /* Current operating state. In ACPI-speak,
  189.                        this is D0-D3, D0 being fully functional,
  190.                        and D3 being off. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement