diff options
Diffstat (limited to 'drivers/char/drm/drm_memory.h')
-rw-r--r-- | drivers/char/drm/drm_memory.h | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/drivers/char/drm/drm_memory.h b/drivers/char/drm/drm_memory.h index 422b94268709..3732a61c3762 100644 --- a/drivers/char/drm/drm_memory.h +++ b/drivers/char/drm/drm_memory.h | |||
@@ -1,12 +1,12 @@ | |||
1 | /** | 1 | /** |
2 | * \file drm_memory.h | 2 | * \file drm_memory.h |
3 | * Memory management wrappers for DRM | 3 | * Memory management wrappers for DRM |
4 | * | 4 | * |
5 | * \author Rickard E. (Rik) Faith <faith@valinux.com> | 5 | * \author Rickard E. (Rik) Faith <faith@valinux.com> |
6 | * \author Gareth Hughes <gareth@valinux.com> | 6 | * \author Gareth Hughes <gareth@valinux.com> |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* | 9 | /* |
10 | * Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com | 10 | * Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com |
11 | * | 11 | * |
12 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | 12 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
@@ -40,7 +40,7 @@ | |||
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Cut down version of drm_memory_debug.h, which used to be called | 42 | * Cut down version of drm_memory_debug.h, which used to be called |
43 | * drm_memory.h. | 43 | * drm_memory.h. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | #if __OS_HAS_AGP | 46 | #if __OS_HAS_AGP |
@@ -60,8 +60,8 @@ | |||
60 | /* | 60 | /* |
61 | * Find the drm_map that covers the range [offset, offset+size). | 61 | * Find the drm_map that covers the range [offset, offset+size). |
62 | */ | 62 | */ |
63 | static inline drm_map_t * | 63 | static inline drm_map_t *drm_lookup_map(unsigned long offset, |
64 | drm_lookup_map (unsigned long offset, unsigned long size, drm_device_t *dev) | 64 | unsigned long size, drm_device_t * dev) |
65 | { | 65 | { |
66 | struct list_head *list; | 66 | struct list_head *list; |
67 | drm_map_list_t *r_list; | 67 | drm_map_list_t *r_list; |
@@ -72,16 +72,18 @@ drm_lookup_map (unsigned long offset, unsigned long size, drm_device_t *dev) | |||
72 | map = r_list->map; | 72 | map = r_list->map; |
73 | if (!map) | 73 | if (!map) |
74 | continue; | 74 | continue; |
75 | if (map->offset <= offset && (offset + size) <= (map->offset + map->size)) | 75 | if (map->offset <= offset |
76 | && (offset + size) <= (map->offset + map->size)) | ||
76 | return map; | 77 | return map; |
77 | } | 78 | } |
78 | return NULL; | 79 | return NULL; |
79 | } | 80 | } |
80 | 81 | ||
81 | static inline void * | 82 | static inline void *agp_remap(unsigned long offset, unsigned long size, |
82 | agp_remap (unsigned long offset, unsigned long size, drm_device_t *dev) | 83 | drm_device_t * dev) |
83 | { | 84 | { |
84 | unsigned long *phys_addr_map, i, num_pages = PAGE_ALIGN(size) / PAGE_SIZE; | 85 | unsigned long *phys_addr_map, i, num_pages = |
86 | PAGE_ALIGN(size) / PAGE_SIZE; | ||
85 | struct drm_agp_mem *agpmem; | 87 | struct drm_agp_mem *agpmem; |
86 | struct page **page_map; | 88 | struct page **page_map; |
87 | void *addr; | 89 | void *addr; |
@@ -94,7 +96,8 @@ agp_remap (unsigned long offset, unsigned long size, drm_device_t *dev) | |||
94 | 96 | ||
95 | for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) | 97 | for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) |
96 | if (agpmem->bound <= offset | 98 | if (agpmem->bound <= offset |
97 | && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= (offset + size)) | 99 | && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= |
100 | (offset + size)) | ||
98 | break; | 101 | break; |
99 | if (!agpmem) | 102 | if (!agpmem) |
100 | return NULL; | 103 | return NULL; |
@@ -109,7 +112,8 @@ agp_remap (unsigned long offset, unsigned long size, drm_device_t *dev) | |||
109 | if (!page_map) | 112 | if (!page_map) |
110 | return NULL; | 113 | return NULL; |
111 | 114 | ||
112 | phys_addr_map = agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE; | 115 | phys_addr_map = |
116 | agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE; | ||
113 | for (i = 0; i < num_pages; ++i) | 117 | for (i = 0; i < num_pages; ++i) |
114 | page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT); | 118 | page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT); |
115 | addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP); | 119 | addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP); |
@@ -118,36 +122,38 @@ agp_remap (unsigned long offset, unsigned long size, drm_device_t *dev) | |||
118 | return addr; | 122 | return addr; |
119 | } | 123 | } |
120 | 124 | ||
121 | static inline unsigned long | 125 | static inline unsigned long drm_follow_page(void *vaddr) |
122 | drm_follow_page (void *vaddr) | ||
123 | { | 126 | { |
124 | pgd_t *pgd = pgd_offset_k((unsigned long) vaddr); | 127 | pgd_t *pgd = pgd_offset_k((unsigned long)vaddr); |
125 | pud_t *pud = pud_offset(pgd, (unsigned long) vaddr); | 128 | pud_t *pud = pud_offset(pgd, (unsigned long)vaddr); |
126 | pmd_t *pmd = pmd_offset(pud, (unsigned long) vaddr); | 129 | pmd_t *pmd = pmd_offset(pud, (unsigned long)vaddr); |
127 | pte_t *ptep = pte_offset_kernel(pmd, (unsigned long) vaddr); | 130 | pte_t *ptep = pte_offset_kernel(pmd, (unsigned long)vaddr); |
128 | return pte_pfn(*ptep) << PAGE_SHIFT; | 131 | return pte_pfn(*ptep) << PAGE_SHIFT; |
129 | } | 132 | } |
130 | 133 | ||
131 | #else /* __OS_HAS_AGP */ | 134 | #else /* __OS_HAS_AGP */ |
132 | 135 | ||
133 | static inline drm_map_t *drm_lookup_map(unsigned long offset, unsigned long size, drm_device_t *dev) | 136 | static inline drm_map_t *drm_lookup_map(unsigned long offset, |
137 | unsigned long size, drm_device_t * dev) | ||
134 | { | 138 | { |
135 | return NULL; | 139 | return NULL; |
136 | } | 140 | } |
137 | 141 | ||
138 | static inline void *agp_remap(unsigned long offset, unsigned long size, drm_device_t *dev) | 142 | static inline void *agp_remap(unsigned long offset, unsigned long size, |
143 | drm_device_t * dev) | ||
139 | { | 144 | { |
140 | return NULL; | 145 | return NULL; |
141 | } | 146 | } |
142 | 147 | ||
143 | static inline unsigned long drm_follow_page (void *vaddr) | 148 | static inline unsigned long drm_follow_page(void *vaddr) |
144 | { | 149 | { |
145 | return 0; | 150 | return 0; |
146 | } | 151 | } |
147 | 152 | ||
148 | #endif | 153 | #endif |
149 | 154 | ||
150 | static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev) | 155 | static inline void *drm_ioremap(unsigned long offset, unsigned long size, |
156 | drm_device_t * dev) | ||
151 | { | 157 | { |
152 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { | 158 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { |
153 | drm_map_t *map = drm_lookup_map(offset, size, dev); | 159 | drm_map_t *map = drm_lookup_map(offset, size, dev); |
@@ -158,8 +164,8 @@ static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_de | |||
158 | return ioremap(offset, size); | 164 | return ioremap(offset, size); |
159 | } | 165 | } |
160 | 166 | ||
161 | static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size, | 167 | static inline void *drm_ioremap_nocache(unsigned long offset, |
162 | drm_device_t *dev) | 168 | unsigned long size, drm_device_t * dev) |
163 | { | 169 | { |
164 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { | 170 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { |
165 | drm_map_t *map = drm_lookup_map(offset, size, dev); | 171 | drm_map_t *map = drm_lookup_map(offset, size, dev); |
@@ -170,7 +176,8 @@ static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size | |||
170 | return ioremap_nocache(offset, size); | 176 | return ioremap_nocache(offset, size); |
171 | } | 177 | } |
172 | 178 | ||
173 | static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev) | 179 | static inline void drm_ioremapfree(void *pt, unsigned long size, |
180 | drm_device_t * dev) | ||
174 | { | 181 | { |
175 | /* | 182 | /* |
176 | * This is a bit ugly. It would be much cleaner if the DRM API would use separate | 183 | * This is a bit ugly. It would be much cleaner if the DRM API would use separate |
@@ -178,12 +185,12 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d | |||
178 | * a future revision of the interface... | 185 | * a future revision of the interface... |
179 | */ | 186 | */ |
180 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture | 187 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture |
181 | && ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END)) | 188 | && ((unsigned long)pt >= VMALLOC_START |
182 | { | 189 | && (unsigned long)pt < VMALLOC_END)) { |
183 | unsigned long offset; | 190 | unsigned long offset; |
184 | drm_map_t *map; | 191 | drm_map_t *map; |
185 | 192 | ||
186 | offset = drm_follow_page(pt) | ((unsigned long) pt & ~PAGE_MASK); | 193 | offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK); |
187 | map = drm_lookup_map(offset, size, dev); | 194 | map = drm_lookup_map(offset, size, dev); |
188 | if (map && map->type == _DRM_AGP) { | 195 | if (map && map->type == _DRM_AGP) { |
189 | vunmap(pt); | 196 | vunmap(pt); |
@@ -193,5 +200,3 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d | |||
193 | 200 | ||
194 | iounmap(pt); | 201 | iounmap(pt); |
195 | } | 202 | } |
196 | |||
197 | |||