diff options
author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2010-11-29 13:52:18 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-01-27 16:02:31 -0500 |
commit | f9820a46dd7888b05a36e81166fb1abcc47dcc3f (patch) | |
tree | c29e32a8fe8b08bc42120ce66c6536afd5c102df | |
parent | e53beacd23d9cb47590da6a7a7f6d417b941a994 (diff) |
ttm: Introduce a placeholder for DMA (bus) addresses.
This is right now limited to only non-pool constructs.
[v2: Fixed indentation issues, add review-by tag]
Reviewed-by: Thomas Hellstrom <thomas@shipmail.org>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Ian Campbell <ian.campbell@citrix.com>
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_page_alloc.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_tt.c | 10 | ||||
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 2 | ||||
-rw-r--r-- | include/drm/ttm/ttm_page_alloc.h | 8 |
4 files changed, 21 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index b1e02fffd3cc..9d9d92945f8c 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
39 | #include <linux/seq_file.h> /* for seq_printf */ | 39 | #include <linux/seq_file.h> /* for seq_printf */ |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/dma-mapping.h> | ||
41 | 42 | ||
42 | #include <asm/atomic.h> | 43 | #include <asm/atomic.h> |
43 | 44 | ||
@@ -662,7 +663,8 @@ out: | |||
662 | * cached pages. | 663 | * cached pages. |
663 | */ | 664 | */ |
664 | int ttm_get_pages(struct list_head *pages, int flags, | 665 | int ttm_get_pages(struct list_head *pages, int flags, |
665 | enum ttm_caching_state cstate, unsigned count) | 666 | enum ttm_caching_state cstate, unsigned count, |
667 | dma_addr_t *dma_address) | ||
666 | { | 668 | { |
667 | struct ttm_page_pool *pool = ttm_get_pool(flags, cstate); | 669 | struct ttm_page_pool *pool = ttm_get_pool(flags, cstate); |
668 | struct page *p = NULL; | 670 | struct page *p = NULL; |
@@ -720,7 +722,7 @@ int ttm_get_pages(struct list_head *pages, int flags, | |||
720 | printk(KERN_ERR TTM_PFX | 722 | printk(KERN_ERR TTM_PFX |
721 | "Failed to allocate extra pages " | 723 | "Failed to allocate extra pages " |
722 | "for large request."); | 724 | "for large request."); |
723 | ttm_put_pages(pages, 0, flags, cstate); | 725 | ttm_put_pages(pages, 0, flags, cstate, NULL); |
724 | return r; | 726 | return r; |
725 | } | 727 | } |
726 | } | 728 | } |
@@ -731,7 +733,7 @@ int ttm_get_pages(struct list_head *pages, int flags, | |||
731 | 733 | ||
732 | /* Put all pages in pages list to correct pool to wait for reuse */ | 734 | /* Put all pages in pages list to correct pool to wait for reuse */ |
733 | void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags, | 735 | void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags, |
734 | enum ttm_caching_state cstate) | 736 | enum ttm_caching_state cstate, dma_addr_t *dma_address) |
735 | { | 737 | { |
736 | unsigned long irq_flags; | 738 | unsigned long irq_flags; |
737 | struct ttm_page_pool *pool = ttm_get_pool(flags, cstate); | 739 | struct ttm_page_pool *pool = ttm_get_pool(flags, cstate); |
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index af789dc869b9..0d39001259fb 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c | |||
@@ -49,12 +49,16 @@ static int ttm_tt_swapin(struct ttm_tt *ttm); | |||
49 | static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm) | 49 | static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm) |
50 | { | 50 | { |
51 | ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages)); | 51 | ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages)); |
52 | ttm->dma_address = drm_calloc_large(ttm->num_pages, | ||
53 | sizeof(*ttm->dma_address)); | ||
52 | } | 54 | } |
53 | 55 | ||
54 | static void ttm_tt_free_page_directory(struct ttm_tt *ttm) | 56 | static void ttm_tt_free_page_directory(struct ttm_tt *ttm) |
55 | { | 57 | { |
56 | drm_free_large(ttm->pages); | 58 | drm_free_large(ttm->pages); |
57 | ttm->pages = NULL; | 59 | ttm->pages = NULL; |
60 | drm_free_large(ttm->dma_address); | ||
61 | ttm->dma_address = NULL; | ||
58 | } | 62 | } |
59 | 63 | ||
60 | static void ttm_tt_free_user_pages(struct ttm_tt *ttm) | 64 | static void ttm_tt_free_user_pages(struct ttm_tt *ttm) |
@@ -105,7 +109,8 @@ static struct page *__ttm_tt_get_page(struct ttm_tt *ttm, int index) | |||
105 | 109 | ||
106 | INIT_LIST_HEAD(&h); | 110 | INIT_LIST_HEAD(&h); |
107 | 111 | ||
108 | ret = ttm_get_pages(&h, ttm->page_flags, ttm->caching_state, 1); | 112 | ret = ttm_get_pages(&h, ttm->page_flags, ttm->caching_state, 1, |
113 | &ttm->dma_address[index]); | ||
109 | 114 | ||
110 | if (ret != 0) | 115 | if (ret != 0) |
111 | return NULL; | 116 | return NULL; |
@@ -298,7 +303,8 @@ static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm) | |||
298 | count++; | 303 | count++; |
299 | } | 304 | } |
300 | } | 305 | } |
301 | ttm_put_pages(&h, count, ttm->page_flags, ttm->caching_state); | 306 | ttm_put_pages(&h, count, ttm->page_flags, ttm->caching_state, |
307 | ttm->dma_address); | ||
302 | ttm->state = tt_unpopulated; | 308 | ttm->state = tt_unpopulated; |
303 | ttm->first_himem_page = ttm->num_pages; | 309 | ttm->first_himem_page = ttm->num_pages; |
304 | ttm->last_lomem_page = -1; | 310 | ttm->last_lomem_page = -1; |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 8e0c848326b6..6dc4fccda73c 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -149,6 +149,7 @@ enum ttm_caching_state { | |||
149 | * @swap_storage: Pointer to shmem struct file for swap storage. | 149 | * @swap_storage: Pointer to shmem struct file for swap storage. |
150 | * @caching_state: The current caching state of the pages. | 150 | * @caching_state: The current caching state of the pages. |
151 | * @state: The current binding state of the pages. | 151 | * @state: The current binding state of the pages. |
152 | * @dma_address: The DMA (bus) addresses of the pages (if TTM_PAGE_FLAG_DMA32) | ||
152 | * | 153 | * |
153 | * This is a structure holding the pages, caching- and aperture binding | 154 | * This is a structure holding the pages, caching- and aperture binding |
154 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) | 155 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) |
@@ -173,6 +174,7 @@ struct ttm_tt { | |||
173 | tt_unbound, | 174 | tt_unbound, |
174 | tt_unpopulated, | 175 | tt_unpopulated, |
175 | } state; | 176 | } state; |
177 | dma_addr_t *dma_address; | ||
176 | }; | 178 | }; |
177 | 179 | ||
178 | #define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ | 180 | #define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ |
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h index 116821448c38..8062890f725e 100644 --- a/include/drm/ttm/ttm_page_alloc.h +++ b/include/drm/ttm/ttm_page_alloc.h | |||
@@ -36,11 +36,13 @@ | |||
36 | * @flags: ttm flags for page allocation. | 36 | * @flags: ttm flags for page allocation. |
37 | * @cstate: ttm caching state for the page. | 37 | * @cstate: ttm caching state for the page. |
38 | * @count: number of pages to allocate. | 38 | * @count: number of pages to allocate. |
39 | * @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set). | ||
39 | */ | 40 | */ |
40 | int ttm_get_pages(struct list_head *pages, | 41 | int ttm_get_pages(struct list_head *pages, |
41 | int flags, | 42 | int flags, |
42 | enum ttm_caching_state cstate, | 43 | enum ttm_caching_state cstate, |
43 | unsigned count); | 44 | unsigned count, |
45 | dma_addr_t *dma_address); | ||
44 | /** | 46 | /** |
45 | * Put linked list of pages to pool. | 47 | * Put linked list of pages to pool. |
46 | * | 48 | * |
@@ -49,11 +51,13 @@ int ttm_get_pages(struct list_head *pages, | |||
49 | * count. | 51 | * count. |
50 | * @flags: ttm flags for page allocation. | 52 | * @flags: ttm flags for page allocation. |
51 | * @cstate: ttm caching state. | 53 | * @cstate: ttm caching state. |
54 | * @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set). | ||
52 | */ | 55 | */ |
53 | void ttm_put_pages(struct list_head *pages, | 56 | void ttm_put_pages(struct list_head *pages, |
54 | unsigned page_count, | 57 | unsigned page_count, |
55 | int flags, | 58 | int flags, |
56 | enum ttm_caching_state cstate); | 59 | enum ttm_caching_state cstate, |
60 | dma_addr_t *dma_address); | ||
57 | /** | 61 | /** |
58 | * Initialize pool allocator. | 62 | * Initialize pool allocator. |
59 | */ | 63 | */ |