diff options
author | Jerome Glisse <jglisse@redhat.com> | 2011-11-09 17:15:26 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-12-06 05:40:02 -0500 |
commit | 8e7e70522d760c4ccd4cd370ebfa0ba69e006c6e (patch) | |
tree | a2b0f931e513f3aeba174b974bd5e869685fe288 /include/drm | |
parent | 3230cfc34fca9d17c1628cf0e4ac25199592a69a (diff) |
drm/ttm: isolate dma data from ttm_tt V4
Move dma data to a superset ttm_dma_tt structure which herit
from ttm_tt. This allow driver that don't use dma functionalities
to not have to waste memory for it.
V2 Rebase on top of no memory account changes (where/when is my
delorean when i need it ?)
V3 Make sure page list is initialized empty
V4 typo/syntax fixes
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 32 | ||||
-rw-r--r-- | include/drm/ttm/ttm_page_alloc.h | 33 |
2 files changed, 31 insertions, 34 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index beef9abaaefd..b2a0848a4d02 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -103,8 +103,6 @@ enum ttm_caching_state { | |||
103 | * @swap_storage: Pointer to shmem struct file for swap storage. | 103 | * @swap_storage: Pointer to shmem struct file for swap storage. |
104 | * @caching_state: The current caching state of the pages. | 104 | * @caching_state: The current caching state of the pages. |
105 | * @state: The current binding state of the pages. | 105 | * @state: The current binding state of the pages. |
106 | * @dma_address: The DMA (bus) addresses of the pages (if TTM_PAGE_FLAG_DMA32) | ||
107 | * @alloc_list: used by some page allocation backend | ||
108 | * | 106 | * |
109 | * This is a structure holding the pages, caching- and aperture binding | 107 | * This is a structure holding the pages, caching- and aperture binding |
110 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) | 108 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) |
@@ -127,8 +125,23 @@ struct ttm_tt { | |||
127 | tt_unbound, | 125 | tt_unbound, |
128 | tt_unpopulated, | 126 | tt_unpopulated, |
129 | } state; | 127 | } state; |
128 | }; | ||
129 | |||
130 | /** | ||
131 | * struct ttm_dma_tt | ||
132 | * | ||
133 | * @ttm: Base ttm_tt struct. | ||
134 | * @dma_address: The DMA (bus) addresses of the pages | ||
135 | * @pages_list: used by some page allocation backend | ||
136 | * | ||
137 | * This is a structure holding the pages, caching- and aperture binding | ||
138 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) | ||
139 | * memory. | ||
140 | */ | ||
141 | struct ttm_dma_tt { | ||
142 | struct ttm_tt ttm; | ||
130 | dma_addr_t *dma_address; | 143 | dma_addr_t *dma_address; |
131 | struct list_head alloc_list; | 144 | struct list_head pages_list; |
132 | }; | 145 | }; |
133 | 146 | ||
134 | #define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ | 147 | #define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ |
@@ -595,6 +608,19 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask) | |||
595 | extern int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev, | 608 | extern int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev, |
596 | unsigned long size, uint32_t page_flags, | 609 | unsigned long size, uint32_t page_flags, |
597 | struct page *dummy_read_page); | 610 | struct page *dummy_read_page); |
611 | extern int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, | ||
612 | unsigned long size, uint32_t page_flags, | ||
613 | struct page *dummy_read_page); | ||
614 | |||
615 | /** | ||
616 | * ttm_tt_fini | ||
617 | * | ||
618 | * @ttm: the ttm_tt structure. | ||
619 | * | ||
620 | * Free memory of ttm_tt structure | ||
621 | */ | ||
622 | extern void ttm_tt_fini(struct ttm_tt *ttm); | ||
623 | extern void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma); | ||
598 | 624 | ||
599 | /** | 625 | /** |
600 | * ttm_ttm_bind: | 626 | * ttm_ttm_bind: |
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h index 1e1337e81f31..5fe27400d176 100644 --- a/include/drm/ttm/ttm_page_alloc.h +++ b/include/drm/ttm/ttm_page_alloc.h | |||
@@ -30,35 +30,6 @@ | |||
30 | #include "ttm_memory.h" | 30 | #include "ttm_memory.h" |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Get count number of pages from pool to pages list. | ||
34 | * | ||
35 | * @pages: head of empty linked list where pages are filled. | ||
36 | * @flags: ttm flags for page allocation. | ||
37 | * @cstate: ttm caching state for the page. | ||
38 | * @count: number of pages to allocate. | ||
39 | * @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set). | ||
40 | */ | ||
41 | int ttm_get_pages(struct page **pages, | ||
42 | int flags, | ||
43 | enum ttm_caching_state cstate, | ||
44 | unsigned npages, | ||
45 | dma_addr_t *dma_address); | ||
46 | /** | ||
47 | * Put linked list of pages to pool. | ||
48 | * | ||
49 | * @pages: list of pages to free. | ||
50 | * @page_count: number of pages in the list. Zero can be passed for unknown | ||
51 | * count. | ||
52 | * @flags: ttm flags for page allocation. | ||
53 | * @cstate: ttm caching state. | ||
54 | * @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set). | ||
55 | */ | ||
56 | void ttm_put_pages(struct page **pages, | ||
57 | unsigned npages, | ||
58 | int flags, | ||
59 | enum ttm_caching_state cstate, | ||
60 | dma_addr_t *dma_address); | ||
61 | /** | ||
62 | * Initialize pool allocator. | 33 | * Initialize pool allocator. |
63 | */ | 34 | */ |
64 | int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages); | 35 | int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages); |
@@ -107,8 +78,8 @@ void ttm_dma_page_alloc_fini(void); | |||
107 | */ | 78 | */ |
108 | extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data); | 79 | extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data); |
109 | 80 | ||
110 | int ttm_dma_populate(struct ttm_tt *ttm, struct device *dev); | 81 | extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev); |
111 | extern void ttm_dma_unpopulate(struct ttm_tt *ttm, struct device *dev); | 82 | extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev); |
112 | 83 | ||
113 | #else | 84 | #else |
114 | static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, | 85 | static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, |