diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2012-07-17 14:02:39 -0400 |
---|---|---|
committer | Christian König <deathsimple@vodafone.de> | 2012-07-18 07:53:38 -0400 |
commit | 03eec93bbc944ad4e467e083dd768d92d00213f0 (patch) | |
tree | 6e315efaaaf63f7807ed9815fc3c80735f87c1d2 /drivers/gpu | |
parent | 75923280e580b76463a5572da457faa994a8b31d (diff) |
drm/radeon: document non-VM functions in radeon_gart.c (v2)
Document the non-VM functions in radeon_gart.c
v2: adjust per Christian's suggestions
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_gart.c | 125 |
1 files changed, 122 insertions, 3 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 56752da4b816..12135ec94e8d 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c | |||
@@ -31,8 +31,38 @@ | |||
31 | #include "radeon_reg.h" | 31 | #include "radeon_reg.h" |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * GART | ||
35 | * The GART (Graphics Aperture Remapping Table) is an aperture | ||
36 | * in the GPU's address space. System pages can be mapped into | ||
37 | * the aperture and look like contiguous pages from the GPU's | ||
38 | * perspective. A page table maps the pages in the aperture | ||
39 | * to the actual backing pages in system memory. | ||
40 | * | ||
41 | * Radeon GPUs support both an internal GART, as described above, | ||
42 | * and AGP. AGP works similarly, but the GART table is configured | ||
43 | * and maintained by the northbridge rather than the driver. | ||
44 | * Radeon hw has a separate AGP aperture that is programmed to | ||
45 | * point to the AGP aperture provided by the northbridge and the | ||
46 | * requests are passed through to the northbridge aperture. | ||
47 | * Both AGP and internal GART can be used at the same time, however | ||
48 | * that is not currently supported by the driver. | ||
49 | * | ||
50 | * This file handles the common internal GART management. | ||
51 | */ | ||
52 | |||
53 | /* | ||
34 | * Common GART table functions. | 54 | * Common GART table functions. |
35 | */ | 55 | */ |
56 | /** | ||
57 | * radeon_gart_table_ram_alloc - allocate system ram for gart page table | ||
58 | * | ||
59 | * @rdev: radeon_device pointer | ||
60 | * | ||
61 | * Allocate system memory for GART page table | ||
62 | * (r1xx-r3xx, non-pcie r4xx, rs400). These asics require the | ||
63 | * gart table to be in system memory. | ||
64 | * Returns 0 for success, -ENOMEM for failure. | ||
65 | */ | ||
36 | int radeon_gart_table_ram_alloc(struct radeon_device *rdev) | 66 | int radeon_gart_table_ram_alloc(struct radeon_device *rdev) |
37 | { | 67 | { |
38 | void *ptr; | 68 | void *ptr; |
@@ -54,6 +84,15 @@ int radeon_gart_table_ram_alloc(struct radeon_device *rdev) | |||
54 | return 0; | 84 | return 0; |
55 | } | 85 | } |
56 | 86 | ||
87 | /** | ||
88 | * radeon_gart_table_ram_free - free system ram for gart page table | ||
89 | * | ||
90 | * @rdev: radeon_device pointer | ||
91 | * | ||
92 | * Free system memory for GART page table | ||
93 | * (r1xx-r3xx, non-pcie r4xx, rs400). These asics require the | ||
94 | * gart table to be in system memory. | ||
95 | */ | ||
57 | void radeon_gart_table_ram_free(struct radeon_device *rdev) | 96 | void radeon_gart_table_ram_free(struct radeon_device *rdev) |
58 | { | 97 | { |
59 | if (rdev->gart.ptr == NULL) { | 98 | if (rdev->gart.ptr == NULL) { |
@@ -73,6 +112,16 @@ void radeon_gart_table_ram_free(struct radeon_device *rdev) | |||
73 | rdev->gart.table_addr = 0; | 112 | rdev->gart.table_addr = 0; |
74 | } | 113 | } |
75 | 114 | ||
115 | /** | ||
116 | * radeon_gart_table_vram_alloc - allocate vram for gart page table | ||
117 | * | ||
118 | * @rdev: radeon_device pointer | ||
119 | * | ||
120 | * Allocate video memory for GART page table | ||
121 | * (pcie r4xx, r5xx+). These asics require the | ||
122 | * gart table to be in video memory. | ||
123 | * Returns 0 for success, error for failure. | ||
124 | */ | ||
76 | int radeon_gart_table_vram_alloc(struct radeon_device *rdev) | 125 | int radeon_gart_table_vram_alloc(struct radeon_device *rdev) |
77 | { | 126 | { |
78 | int r; | 127 | int r; |
@@ -88,6 +137,16 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev) | |||
88 | return 0; | 137 | return 0; |
89 | } | 138 | } |
90 | 139 | ||
140 | /** | ||
141 | * radeon_gart_table_vram_pin - pin gart page table in vram | ||
142 | * | ||
143 | * @rdev: radeon_device pointer | ||
144 | * | ||
145 | * Pin the GART page table in vram so it will not be moved | ||
146 | * by the memory manager (pcie r4xx, r5xx+). These asics require the | ||
147 | * gart table to be in video memory. | ||
148 | * Returns 0 for success, error for failure. | ||
149 | */ | ||
91 | int radeon_gart_table_vram_pin(struct radeon_device *rdev) | 150 | int radeon_gart_table_vram_pin(struct radeon_device *rdev) |
92 | { | 151 | { |
93 | uint64_t gpu_addr; | 152 | uint64_t gpu_addr; |
@@ -110,6 +169,14 @@ int radeon_gart_table_vram_pin(struct radeon_device *rdev) | |||
110 | return r; | 169 | return r; |
111 | } | 170 | } |
112 | 171 | ||
172 | /** | ||
173 | * radeon_gart_table_vram_unpin - unpin gart page table in vram | ||
174 | * | ||
175 | * @rdev: radeon_device pointer | ||
176 | * | ||
177 | * Unpin the GART page table in vram (pcie r4xx, r5xx+). | ||
178 | * These asics require the gart table to be in video memory. | ||
179 | */ | ||
113 | void radeon_gart_table_vram_unpin(struct radeon_device *rdev) | 180 | void radeon_gart_table_vram_unpin(struct radeon_device *rdev) |
114 | { | 181 | { |
115 | int r; | 182 | int r; |
@@ -126,6 +193,15 @@ void radeon_gart_table_vram_unpin(struct radeon_device *rdev) | |||
126 | } | 193 | } |
127 | } | 194 | } |
128 | 195 | ||
196 | /** | ||
197 | * radeon_gart_table_vram_free - free gart page table vram | ||
198 | * | ||
199 | * @rdev: radeon_device pointer | ||
200 | * | ||
201 | * Free the video memory used for the GART page table | ||
202 | * (pcie r4xx, r5xx+). These asics require the gart table to | ||
203 | * be in video memory. | ||
204 | */ | ||
129 | void radeon_gart_table_vram_free(struct radeon_device *rdev) | 205 | void radeon_gart_table_vram_free(struct radeon_device *rdev) |
130 | { | 206 | { |
131 | if (rdev->gart.robj == NULL) { | 207 | if (rdev->gart.robj == NULL) { |
@@ -135,12 +211,19 @@ void radeon_gart_table_vram_free(struct radeon_device *rdev) | |||
135 | radeon_bo_unref(&rdev->gart.robj); | 211 | radeon_bo_unref(&rdev->gart.robj); |
136 | } | 212 | } |
137 | 213 | ||
138 | |||
139 | |||
140 | |||
141 | /* | 214 | /* |
142 | * Common gart functions. | 215 | * Common gart functions. |
143 | */ | 216 | */ |
217 | /** | ||
218 | * radeon_gart_unbind - unbind pages from the gart page table | ||
219 | * | ||
220 | * @rdev: radeon_device pointer | ||
221 | * @offset: offset into the GPU's gart aperture | ||
222 | * @pages: number of pages to unbind | ||
223 | * | ||
224 | * Unbinds the requested pages from the gart page table and | ||
225 | * replaces them with the dummy page (all asics). | ||
226 | */ | ||
144 | void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset, | 227 | void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset, |
145 | int pages) | 228 | int pages) |
146 | { | 229 | { |
@@ -172,6 +255,19 @@ void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset, | |||
172 | radeon_gart_tlb_flush(rdev); | 255 | radeon_gart_tlb_flush(rdev); |
173 | } | 256 | } |
174 | 257 | ||
258 | /** | ||
259 | * radeon_gart_bind - bind pages into the gart page table | ||
260 | * | ||
261 | * @rdev: radeon_device pointer | ||
262 | * @offset: offset into the GPU's gart aperture | ||
263 | * @pages: number of pages to bind | ||
264 | * @pagelist: pages to bind | ||
265 | * @dma_addr: DMA addresses of pages | ||
266 | * | ||
267 | * Binds the requested pages to the gart page table | ||
268 | * (all asics). | ||
269 | * Returns 0 for success, -EINVAL for failure. | ||
270 | */ | ||
175 | int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, | 271 | int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, |
176 | int pages, struct page **pagelist, dma_addr_t *dma_addr) | 272 | int pages, struct page **pagelist, dma_addr_t *dma_addr) |
177 | { | 273 | { |
@@ -203,6 +299,14 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, | |||
203 | return 0; | 299 | return 0; |
204 | } | 300 | } |
205 | 301 | ||
302 | /** | ||
303 | * radeon_gart_restore - bind all pages in the gart page table | ||
304 | * | ||
305 | * @rdev: radeon_device pointer | ||
306 | * | ||
307 | * Binds all pages in the gart page table (all asics). | ||
308 | * Used to rebuild the gart table on device startup or resume. | ||
309 | */ | ||
206 | void radeon_gart_restore(struct radeon_device *rdev) | 310 | void radeon_gart_restore(struct radeon_device *rdev) |
207 | { | 311 | { |
208 | int i, j, t; | 312 | int i, j, t; |
@@ -222,6 +326,14 @@ void radeon_gart_restore(struct radeon_device *rdev) | |||
222 | radeon_gart_tlb_flush(rdev); | 326 | radeon_gart_tlb_flush(rdev); |
223 | } | 327 | } |
224 | 328 | ||
329 | /** | ||
330 | * radeon_gart_init - init the driver info for managing the gart | ||
331 | * | ||
332 | * @rdev: radeon_device pointer | ||
333 | * | ||
334 | * Allocate the dummy page and init the gart driver info (all asics). | ||
335 | * Returns 0 for success, error for failure. | ||
336 | */ | ||
225 | int radeon_gart_init(struct radeon_device *rdev) | 337 | int radeon_gart_init(struct radeon_device *rdev) |
226 | { | 338 | { |
227 | int r, i; | 339 | int r, i; |
@@ -262,6 +374,13 @@ int radeon_gart_init(struct radeon_device *rdev) | |||
262 | return 0; | 374 | return 0; |
263 | } | 375 | } |
264 | 376 | ||
377 | /** | ||
378 | * radeon_gart_fini - tear down the driver info for managing the gart | ||
379 | * | ||
380 | * @rdev: radeon_device pointer | ||
381 | * | ||
382 | * Tear down the gart driver info and free the dummy page (all asics). | ||
383 | */ | ||
265 | void radeon_gart_fini(struct radeon_device *rdev) | 384 | void radeon_gart_fini(struct radeon_device *rdev) |
266 | { | 385 | { |
267 | if (rdev->gart.pages && rdev->gart.pages_addr && rdev->gart.ready) { | 386 | if (rdev->gart.pages && rdev->gart.pages_addr && rdev->gart.ready) { |