1 diff -ru usr/src/nv/nv-linux.h usr/src/nv.1258475/nv-linux.h
2 --- usr/src/nv/nv-linux.h 2005-03-22 16:19:09.000000000 +0100
3 +++ usr/src/nv.1258475/nv-linux.h 2005-05-05 19:06:45.237118320 +0200
6 #if defined(CONFIG_SWIOTLB)
8 -#define NV_SWIOTLB_MAX_RETRIES 16
12 @@ -1053,6 +1052,31 @@
15 #if defined(NV_SG_MAP_BUFFERS)
17 +static inline int nv_map_sg(struct pci_dev *dev, struct scatterlist *sg)
20 +#if defined(KERNEL_2_6) && defined(CONFIG_SWIOTLB)
22 + ret = swiotlb_map_sg(&dev->dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
25 + ret = pci_map_sg(dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
29 +static inline void nv_unmap_sg(struct pci_dev *dev, struct scatterlist *sg)
31 +#if defined(KERNEL_2_6) && defined(CONFIG_SWIOTLB)
33 + swiotlb_unmap_sg(&dev->dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
36 + pci_unmap_sg(dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
39 +#define NV_MAP_SG_MAX_RETRIES 16
41 static inline int nv_sg_map_buffer(
44 @@ -1067,50 +1091,42 @@
45 sg_ptr->offset = (unsigned long)base & ~PAGE_MASK;
46 sg_ptr->length = num_pages * PAGE_SIZE;
48 -#if defined(NV_SWIOTLB)
49 - i = NV_SWIOTLB_MAX_RETRIES;
50 + i = NV_MAP_SG_MAX_RETRIES;
52 - if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
53 + if (nv_map_sg(dev, sg_ptr) == 0)
56 if (sg_ptr->dma_address & ~PAGE_MASK)
58 struct scatterlist sg_tmp;
59 - pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
60 + nv_unmap_sg(dev, sg_ptr);
62 memset(&sg_tmp, 0, sizeof(struct scatterlist));
63 sg_tmp.page = sg_ptr->page;
64 sg_tmp.offset = sg_ptr->offset;
67 - if (pci_map_sg(dev, &sg_tmp, 1, PCI_DMA_BIDIRECTIONAL) == 0)
68 + if (nv_map_sg(dev, &sg_tmp) == 0)
71 - if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
72 + if (nv_map_sg(dev, sg_ptr) == 0)
74 - pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
75 + nv_unmap_sg(dev, &sg_tmp);
79 - pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
80 + nv_unmap_sg(dev, &sg_tmp);
82 } while (i-- && sg_ptr->dma_address & ~PAGE_MASK);
84 - if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
90 if (sg_ptr->dma_address & ~PAGE_MASK)
92 nv_printf(NV_DBG_ERRORS,
93 "NVRM: VM: nv_sg_map_buffer: failed to obtain aligned mapping\n");
94 - pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
95 + nv_unmap_sg(dev, sg_ptr);
99 - NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(sg_ptr->dma_address);
101 // this is a bit of a hack to make contiguous allocations easier to handle
102 // nv_sg_load below relies on the page_ptr addresses being filed in, as
103 @@ -1139,6 +1155,9 @@
104 // wire in the new page's addresses, but save the original off to free later
107 + // note that we modify our local version, not the sg_ptr version that
108 + // will be returned to the swiotlb pool
109 + NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(page_ptr->dma_addr);
110 page_ptr->orig_phys_addr = page_ptr->phys_addr;
111 page_ptr->phys_addr = page_ptr->dma_addr;
112 page_ptr->orig_virt_addr = page_ptr->virt_addr;
113 @@ -1171,7 +1190,7 @@
115 if (page_ptr->dma_addr != page_ptr->phys_addr)
117 - pci_unmap_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL);
118 + nv_unmap_sg(dev, sg_ptr);
119 page_ptr->dma_addr = 0;