SOURCES: NVIDIA_kernel-1.0-7174-1258475.diff (NEW) - patch that ad...

hawk hawk at pld-linux.org
Fri Mar 3 18:16:39 CET 2006


Author: hawk                         Date: Fri Mar  3 17:16:39 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- patch that addresses an X startup problem on Linux/x86-64 em64t systems
  with 4GB of RAM

---- Files affected:
SOURCES:
   NVIDIA_kernel-1.0-7174-1258475.diff (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/NVIDIA_kernel-1.0-7174-1258475.diff
diff -u /dev/null SOURCES/NVIDIA_kernel-1.0-7174-1258475.diff:1.1
--- /dev/null	Fri Mar  3 18:16:39 2006
+++ SOURCES/NVIDIA_kernel-1.0-7174-1258475.diff	Fri Mar  3 18:16:34 2006
@@ -0,0 +1,121 @@
+diff -ru usr/src/nv/nv-linux.h usr/src/nv.1258475/nv-linux.h
+--- usr/src/nv/nv-linux.h	2005-03-22 16:19:09.000000000 +0100
++++ usr/src/nv.1258475/nv-linux.h	2005-05-05 19:06:45.237118320 +0200
+@@ -200,7 +200,6 @@
+  */
+ #if defined(CONFIG_SWIOTLB)
+ #define NV_SWIOTLB 1
+-#define NV_SWIOTLB_MAX_RETRIES 16
+ extern int nv_swiotlb;
+ #endif
+ 
+@@ -1053,6 +1052,31 @@
+     }
+ 
+ #if defined(NV_SG_MAP_BUFFERS)
++
++static inline int nv_map_sg(struct pci_dev *dev, struct scatterlist *sg)
++    {
++        int ret;
++#if defined(KERNEL_2_6) && defined(CONFIG_SWIOTLB)
++        if (swiotlb)
++            ret = swiotlb_map_sg(&dev->dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
++        else
++#endif
++            ret = pci_map_sg(dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
++        return ret;
++    }
++
++static inline void nv_unmap_sg(struct pci_dev *dev, struct scatterlist *sg)
++    {
++#if defined(KERNEL_2_6) && defined(CONFIG_SWIOTLB)
++        if (swiotlb)
++            swiotlb_unmap_sg(&dev->dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
++        else
++#endif
++            pci_unmap_sg(dev, sg, 1, PCI_DMA_BIDIRECTIONAL);
++    }
++
++#define NV_MAP_SG_MAX_RETRIES 16
++
+ static inline int nv_sg_map_buffer(
+     struct pci_dev     *dev,
+     nv_pte_t          **page_list,
+@@ -1067,50 +1091,42 @@
+     sg_ptr->offset = (unsigned long)base & ~PAGE_MASK;
+     sg_ptr->length  = num_pages * PAGE_SIZE;
+ 
+-#if defined(NV_SWIOTLB)
+-    i = NV_SWIOTLB_MAX_RETRIES;
++    i = NV_MAP_SG_MAX_RETRIES;
+     do {
+-        if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++        if (nv_map_sg(dev, sg_ptr) == 0)
+             return 1;
+ 
+         if (sg_ptr->dma_address & ~PAGE_MASK)
+         {
+             struct scatterlist sg_tmp;
+-            pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
++            nv_unmap_sg(dev, sg_ptr);
+ 
+             memset(&sg_tmp, 0, sizeof(struct scatterlist));
+             sg_tmp.page = sg_ptr->page;
+             sg_tmp.offset = sg_ptr->offset;
+             sg_tmp.length = 2048;
+ 
+-            if (pci_map_sg(dev, &sg_tmp, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++            if (nv_map_sg(dev, &sg_tmp) == 0)
+                 return 1;
+ 
+-            if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++            if (nv_map_sg(dev, sg_ptr) == 0)
+             {
+-                pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
++                nv_unmap_sg(dev, &sg_tmp);
+                 return 1;
+             }
+ 
+-            pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
++            nv_unmap_sg(dev, &sg_tmp);
+         }
+     } while (i-- && sg_ptr->dma_address & ~PAGE_MASK);
+-#else
+-    if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
+-    {
+-        return 1;
+-    }
+-#endif
+ 
+     if (sg_ptr->dma_address & ~PAGE_MASK)
+     {
+         nv_printf(NV_DBG_ERRORS,
+             "NVRM: VM: nv_sg_map_buffer: failed to obtain aligned mapping\n");
+-        pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
++        nv_unmap_sg(dev, sg_ptr);
+         return 1;
+     }
+ 
+-    NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(sg_ptr->dma_address);
+ 
+     // this is a bit of a hack to make contiguous allocations easier to handle
+     // nv_sg_load below relies on the page_ptr addresses being filed in, as 
+@@ -1139,6 +1155,9 @@
+     // wire in the new page's addresses, but save the original off to free later
+     if (nv_swiotlb)
+     {
++        // note that we modify our local version, not the sg_ptr version that
++        // will be returned to the swiotlb pool
++        NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(page_ptr->dma_addr);
+         page_ptr->orig_phys_addr = page_ptr->phys_addr;
+         page_ptr->phys_addr      = page_ptr->dma_addr;
+         page_ptr->orig_virt_addr = page_ptr->virt_addr;
+@@ -1171,7 +1190,7 @@
+ 
+     if (page_ptr->dma_addr != page_ptr->phys_addr)
+     {
+-        pci_unmap_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL);
++        nv_unmap_sg(dev, sg_ptr);
+         page_ptr->dma_addr = 0;
+     }
+ }
================================================================


More information about the pld-cvs-commit mailing list