diff options
Diffstat (limited to 'drivers/char/drm/drm_pci.c')
-rw-r--r-- | drivers/char/drm/drm_pci.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/char/drm/drm_pci.c b/drivers/char/drm/drm_pci.c index 1fd7ff164817..b28ca9cea8a2 100644 --- a/drivers/char/drm/drm_pci.c +++ b/drivers/char/drm/drm_pci.c | |||
@@ -50,6 +50,10 @@ drm_dma_handle_t *drm_pci_alloc(drm_device_t * dev, size_t size, size_t align, | |||
50 | dma_addr_t maxaddr) | 50 | dma_addr_t maxaddr) |
51 | { | 51 | { |
52 | drm_dma_handle_t *dmah; | 52 | drm_dma_handle_t *dmah; |
53 | #if 1 | ||
54 | unsigned long addr; | ||
55 | size_t sz; | ||
56 | #endif | ||
53 | #ifdef DRM_DEBUG_MEMORY | 57 | #ifdef DRM_DEBUG_MEMORY |
54 | int area = DRM_MEM_DMA; | 58 | int area = DRM_MEM_DMA; |
55 | 59 | ||
@@ -79,7 +83,7 @@ drm_dma_handle_t *drm_pci_alloc(drm_device_t * dev, size_t size, size_t align, | |||
79 | return NULL; | 83 | return NULL; |
80 | 84 | ||
81 | dmah->size = size; | 85 | dmah->size = size; |
82 | dmah->vaddr = pci_alloc_consistent(dev->pdev, size, &dmah->busaddr); | 86 | dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP); |
83 | 87 | ||
84 | #ifdef DRM_DEBUG_MEMORY | 88 | #ifdef DRM_DEBUG_MEMORY |
85 | if (dmah->vaddr == NULL) { | 89 | if (dmah->vaddr == NULL) { |
@@ -104,18 +108,29 @@ drm_dma_handle_t *drm_pci_alloc(drm_device_t * dev, size_t size, size_t align, | |||
104 | 108 | ||
105 | memset(dmah->vaddr, 0, size); | 109 | memset(dmah->vaddr, 0, size); |
106 | 110 | ||
111 | /* XXX - Is virt_to_page() legal for consistent mem? */ | ||
112 | /* Reserve */ | ||
113 | for (addr = (unsigned long)dmah->vaddr, sz = size; | ||
114 | sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { | ||
115 | SetPageReserved(virt_to_page(addr)); | ||
116 | } | ||
117 | |||
107 | return dmah; | 118 | return dmah; |
108 | } | 119 | } |
109 | 120 | ||
110 | EXPORT_SYMBOL(drm_pci_alloc); | 121 | EXPORT_SYMBOL(drm_pci_alloc); |
111 | 122 | ||
112 | /** | 123 | /** |
113 | * \brief Free a PCI consistent memory block with freeing its descriptor. | 124 | * \brief Free a PCI consistent memory block without freeing its descriptor. |
114 | * | 125 | * |
115 | * This function is for internal use in the Linux-specific DRM core code. | 126 | * This function is for internal use in the Linux-specific DRM core code. |
116 | */ | 127 | */ |
117 | void __drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah) | 128 | void __drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah) |
118 | { | 129 | { |
130 | #if 1 | ||
131 | unsigned long addr; | ||
132 | size_t sz; | ||
133 | #endif | ||
119 | #ifdef DRM_DEBUG_MEMORY | 134 | #ifdef DRM_DEBUG_MEMORY |
120 | int area = DRM_MEM_DMA; | 135 | int area = DRM_MEM_DMA; |
121 | int alloc_count; | 136 | int alloc_count; |
@@ -127,8 +142,14 @@ void __drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah) | |||
127 | DRM_MEM_ERROR(area, "Attempt to free address 0\n"); | 142 | DRM_MEM_ERROR(area, "Attempt to free address 0\n"); |
128 | #endif | 143 | #endif |
129 | } else { | 144 | } else { |
130 | pci_free_consistent(dev->pdev, dmah->size, dmah->vaddr, | 145 | /* XXX - Is virt_to_page() legal for consistent mem? */ |
131 | dmah->busaddr); | 146 | /* Unreserve */ |
147 | for (addr = (unsigned long)dmah->vaddr, sz = dmah->size; | ||
148 | sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { | ||
149 | ClearPageReserved(virt_to_page(addr)); | ||
150 | } | ||
151 | dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr, | ||
152 | dmah->busaddr); | ||
132 | } | 153 | } |
133 | 154 | ||
134 | #ifdef DRM_DEBUG_MEMORY | 155 | #ifdef DRM_DEBUG_MEMORY |