aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/ttm
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2011-11-01 20:46:13 -0400
committerDave Airlie <airlied@redhat.com>2011-12-06 05:39:17 -0500
commit649bf3ca77343e3be1e0af8e21356fa569b1abd9 (patch)
tree01ad6a5f3f74b087cb791f5965d3190916975789 /include/drm/ttm
parent822c4d9ae0d55a4fcea9f0a462bc6406a06692e2 (diff)
drm/ttm: merge ttm_backend and ttm_tt V5
ttm_backend will only exist with a ttm_tt, and ttm_tt will only be of interest when bound to a backend. Merge them to avoid code and data duplication. V2 Rebase on top of memory accounting overhaul V3 Rebase on top of more memory accounting changes V4 Rebase on top of no memory account changes (where/when is my delorean when i need it ?) V5 make sure ttm is unbound before destroying, change commit message on suggestion from Tormod Volden Signed-off-by: Jerome Glisse <jglisse@redhat.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Diffstat (limited to 'include/drm/ttm')
-rw-r--r--include/drm/ttm/ttm_bo_driver.h104
1 files changed, 41 insertions, 63 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 6d171406e1ee..6b8c5cd690a0 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -43,36 +43,9 @@ struct ttm_backend;
43 43
44struct ttm_backend_func { 44struct ttm_backend_func {
45 /** 45 /**
46 * struct ttm_backend_func member populate
47 *
48 * @backend: Pointer to a struct ttm_backend.
49 * @num_pages: Number of pages to populate.
50 * @pages: Array of pointers to ttm pages.
51 * @dummy_read_page: Page to be used instead of NULL pages in the
52 * array @pages.
53 * @dma_addrs: Array of DMA (bus) address of the ttm pages.
54 *
55 * Populate the backend with ttm pages. Depending on the backend,
56 * it may or may not copy the @pages array.
57 */
58 int (*populate) (struct ttm_backend *backend,
59 unsigned long num_pages, struct page **pages,
60 struct page *dummy_read_page,
61 dma_addr_t *dma_addrs);
62 /**
63 * struct ttm_backend_func member clear
64 *
65 * @backend: Pointer to a struct ttm_backend.
66 *
67 * This is an "unpopulate" function. Release all resources
68 * allocated with populate.
69 */
70 void (*clear) (struct ttm_backend *backend);
71
72 /**
73 * struct ttm_backend_func member bind 46 * struct ttm_backend_func member bind
74 * 47 *
75 * @backend: Pointer to a struct ttm_backend. 48 * @ttm: Pointer to a struct ttm_tt.
76 * @bo_mem: Pointer to a struct ttm_mem_reg describing the 49 * @bo_mem: Pointer to a struct ttm_mem_reg describing the
77 * memory type and location for binding. 50 * memory type and location for binding.
78 * 51 *
@@ -80,40 +53,27 @@ struct ttm_backend_func {
80 * indicated by @bo_mem. This function should be able to handle 53 * indicated by @bo_mem. This function should be able to handle
81 * differences between aperture and system page sizes. 54 * differences between aperture and system page sizes.
82 */ 55 */
83 int (*bind) (struct ttm_backend *backend, struct ttm_mem_reg *bo_mem); 56 int (*bind) (struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
84 57
85 /** 58 /**
86 * struct ttm_backend_func member unbind 59 * struct ttm_backend_func member unbind
87 * 60 *
88 * @backend: Pointer to a struct ttm_backend. 61 * @ttm: Pointer to a struct ttm_tt.
89 * 62 *
90 * Unbind previously bound backend pages. This function should be 63 * Unbind previously bound backend pages. This function should be
91 * able to handle differences between aperture and system page sizes. 64 * able to handle differences between aperture and system page sizes.
92 */ 65 */
93 int (*unbind) (struct ttm_backend *backend); 66 int (*unbind) (struct ttm_tt *ttm);
94 67
95 /** 68 /**
96 * struct ttm_backend_func member destroy 69 * struct ttm_backend_func member destroy
97 * 70 *
98 * @backend: Pointer to a struct ttm_backend. 71 * @ttm: Pointer to a struct ttm_tt.
99 * 72 *
100 * Destroy the backend. 73 * Destroy the backend. This will be call back from ttm_tt_destroy so
74 * don't call ttm_tt_destroy from the callback or infinite loop.
101 */ 75 */
102 void (*destroy) (struct ttm_backend *backend); 76 void (*destroy) (struct ttm_tt *ttm);
103};
104
105/**
106 * struct ttm_backend
107 *
108 * @bdev: Pointer to a struct ttm_bo_device.
109 * @func: Pointer to a struct ttm_backend_func that describes
110 * the backend methods.
111 *
112 */
113
114struct ttm_backend {
115 struct ttm_bo_device *bdev;
116 struct ttm_backend_func *func;
117}; 77};
118 78
119#define TTM_PAGE_FLAG_WRITE (1 << 3) 79#define TTM_PAGE_FLAG_WRITE (1 << 3)
@@ -131,6 +91,9 @@ enum ttm_caching_state {
131/** 91/**
132 * struct ttm_tt 92 * struct ttm_tt
133 * 93 *
94 * @bdev: Pointer to a struct ttm_bo_device.
95 * @func: Pointer to a struct ttm_backend_func that describes
96 * the backend methods.
134 * @dummy_read_page: Page to map where the ttm_tt page array contains a NULL 97 * @dummy_read_page: Page to map where the ttm_tt page array contains a NULL
135 * pointer. 98 * pointer.
136 * @pages: Array of pages backing the data. 99 * @pages: Array of pages backing the data.
@@ -148,6 +111,8 @@ enum ttm_caching_state {
148 */ 111 */
149 112
150struct ttm_tt { 113struct ttm_tt {
114 struct ttm_bo_device *bdev;
115 struct ttm_backend_func *func;
151 struct page *dummy_read_page; 116 struct page *dummy_read_page;
152 struct page **pages; 117 struct page **pages;
153 uint32_t page_flags; 118 uint32_t page_flags;
@@ -336,15 +301,22 @@ struct ttm_mem_type_manager {
336 301
337struct ttm_bo_driver { 302struct ttm_bo_driver {
338 /** 303 /**
339 * struct ttm_bo_driver member create_ttm_backend_entry 304 * ttm_tt_create
340 * 305 *
341 * @bdev: The buffer object device. 306 * @bdev: pointer to a struct ttm_bo_device:
307 * @size: Size of the data needed backing.
308 * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags.
309 * @dummy_read_page: See struct ttm_bo_device.
342 * 310 *
343 * Create a driver specific struct ttm_backend. 311 * Create a struct ttm_tt to back data with system memory pages.
312 * No pages are actually allocated.
313 * Returns:
314 * NULL: Out of memory.
344 */ 315 */
345 316 struct ttm_tt *(*ttm_tt_create)(struct ttm_bo_device *bdev,
346 struct ttm_backend *(*create_ttm_backend_entry) 317 unsigned long size,
347 (struct ttm_bo_device *bdev); 318 uint32_t page_flags,
319 struct page *dummy_read_page);
348 320
349 /** 321 /**
350 * struct ttm_bo_driver member invalidate_caches 322 * struct ttm_bo_driver member invalidate_caches
@@ -585,8 +557,9 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
585} 557}
586 558
587/** 559/**
588 * ttm_tt_create 560 * ttm_tt_init
589 * 561 *
562 * @ttm: The struct ttm_tt.
590 * @bdev: pointer to a struct ttm_bo_device: 563 * @bdev: pointer to a struct ttm_bo_device:
591 * @size: Size of the data needed backing. 564 * @size: Size of the data needed backing.
592 * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. 565 * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags.
@@ -597,10 +570,9 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
597 * Returns: 570 * Returns:
598 * NULL: Out of memory. 571 * NULL: Out of memory.
599 */ 572 */
600extern struct ttm_tt *ttm_tt_create(struct ttm_bo_device *bdev, 573extern int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev,
601 unsigned long size, 574 unsigned long size, uint32_t page_flags,
602 uint32_t page_flags, 575 struct page *dummy_read_page);
603 struct page *dummy_read_page);
604 576
605/** 577/**
606 * ttm_ttm_bind: 578 * ttm_ttm_bind:
@@ -626,7 +598,7 @@ extern int ttm_tt_populate(struct ttm_tt *ttm);
626 * 598 *
627 * @ttm: The struct ttm_tt. 599 * @ttm: The struct ttm_tt.
628 * 600 *
629 * Unbind, unpopulate and destroy a struct ttm_tt. 601 * Unbind, unpopulate and destroy common struct ttm_tt.
630 */ 602 */
631extern void ttm_tt_destroy(struct ttm_tt *ttm); 603extern void ttm_tt_destroy(struct ttm_tt *ttm);
632 604
@@ -1013,17 +985,23 @@ extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
1013#include <linux/agp_backend.h> 985#include <linux/agp_backend.h>
1014 986
1015/** 987/**
1016 * ttm_agp_backend_init 988 * ttm_agp_tt_create
1017 * 989 *
1018 * @bdev: Pointer to a struct ttm_bo_device. 990 * @bdev: Pointer to a struct ttm_bo_device.
1019 * @bridge: The agp bridge this device is sitting on. 991 * @bridge: The agp bridge this device is sitting on.
992 * @size: Size of the data needed backing.
993 * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags.
994 * @dummy_read_page: See struct ttm_bo_device.
995 *
1020 * 996 *
1021 * Create a TTM backend that uses the indicated AGP bridge as an aperture 997 * Create a TTM backend that uses the indicated AGP bridge as an aperture
1022 * for TT memory. This function uses the linux agpgart interface to 998 * for TT memory. This function uses the linux agpgart interface to
1023 * bind and unbind memory backing a ttm_tt. 999 * bind and unbind memory backing a ttm_tt.
1024 */ 1000 */
1025extern struct ttm_backend *ttm_agp_backend_init(struct ttm_bo_device *bdev, 1001extern struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev,
1026 struct agp_bridge_data *bridge); 1002 struct agp_bridge_data *bridge,
1003 unsigned long size, uint32_t page_flags,
1004 struct page *dummy_read_page);
1027#endif 1005#endif
1028 1006
1029#endif 1007#endif