diff options
author | Christian König <christian.koenig@amd.com> | 2018-02-22 03:23:44 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-03-14 15:38:24 -0400 |
commit | 81f5ec025514865fb930d3a665a10a339b113da8 (patch) | |
tree | 9f18b7de22b2eb0a0ece8b6f21055fd5695ddac1 /include/drm/ttm | |
parent | 963976cfe9c54d4d9e725e61c90c47a4af6b5ea2 (diff) |
drm/ttm: move ttm_tt defines into ttm_tt.h
Let's stop mangling everything in a single header and create one header
per object instead.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Roger He <Hongbo.He@amd.com>
Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'include/drm/ttm')
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 237 | ||||
-rw-r--r-- | include/drm/ttm/ttm_tt.h | 272 |
2 files changed, 273 insertions, 236 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 4312b5326f0b..f8e2515b401f 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -42,111 +42,10 @@ | |||
42 | #include "ttm_memory.h" | 42 | #include "ttm_memory.h" |
43 | #include "ttm_module.h" | 43 | #include "ttm_module.h" |
44 | #include "ttm_placement.h" | 44 | #include "ttm_placement.h" |
45 | #include "ttm_tt.h" | ||
45 | 46 | ||
46 | #define TTM_MAX_BO_PRIORITY 4U | 47 | #define TTM_MAX_BO_PRIORITY 4U |
47 | 48 | ||
48 | struct ttm_backend_func { | ||
49 | /** | ||
50 | * struct ttm_backend_func member bind | ||
51 | * | ||
52 | * @ttm: Pointer to a struct ttm_tt. | ||
53 | * @bo_mem: Pointer to a struct ttm_mem_reg describing the | ||
54 | * memory type and location for binding. | ||
55 | * | ||
56 | * Bind the backend pages into the aperture in the location | ||
57 | * indicated by @bo_mem. This function should be able to handle | ||
58 | * differences between aperture and system page sizes. | ||
59 | */ | ||
60 | int (*bind) (struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem); | ||
61 | |||
62 | /** | ||
63 | * struct ttm_backend_func member unbind | ||
64 | * | ||
65 | * @ttm: Pointer to a struct ttm_tt. | ||
66 | * | ||
67 | * Unbind previously bound backend pages. This function should be | ||
68 | * able to handle differences between aperture and system page sizes. | ||
69 | */ | ||
70 | int (*unbind) (struct ttm_tt *ttm); | ||
71 | |||
72 | /** | ||
73 | * struct ttm_backend_func member destroy | ||
74 | * | ||
75 | * @ttm: Pointer to a struct ttm_tt. | ||
76 | * | ||
77 | * Destroy the backend. This will be call back from ttm_tt_destroy so | ||
78 | * don't call ttm_tt_destroy from the callback or infinite loop. | ||
79 | */ | ||
80 | void (*destroy) (struct ttm_tt *ttm); | ||
81 | }; | ||
82 | |||
83 | #define TTM_PAGE_FLAG_WRITE (1 << 3) | ||
84 | #define TTM_PAGE_FLAG_SWAPPED (1 << 4) | ||
85 | #define TTM_PAGE_FLAG_PERSISTENT_SWAP (1 << 5) | ||
86 | #define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6) | ||
87 | #define TTM_PAGE_FLAG_DMA32 (1 << 7) | ||
88 | #define TTM_PAGE_FLAG_SG (1 << 8) | ||
89 | #define TTM_PAGE_FLAG_NO_RETRY (1 << 9) | ||
90 | |||
91 | enum ttm_caching_state { | ||
92 | tt_uncached, | ||
93 | tt_wc, | ||
94 | tt_cached | ||
95 | }; | ||
96 | |||
97 | /** | ||
98 | * struct ttm_tt | ||
99 | * | ||
100 | * @bdev: Pointer to a struct ttm_bo_device. | ||
101 | * @func: Pointer to a struct ttm_backend_func that describes | ||
102 | * the backend methods. | ||
103 | * pointer. | ||
104 | * @pages: Array of pages backing the data. | ||
105 | * @num_pages: Number of pages in the page array. | ||
106 | * @bdev: Pointer to the current struct ttm_bo_device. | ||
107 | * @be: Pointer to the ttm backend. | ||
108 | * @swap_storage: Pointer to shmem struct file for swap storage. | ||
109 | * @caching_state: The current caching state of the pages. | ||
110 | * @state: The current binding state of the pages. | ||
111 | * | ||
112 | * This is a structure holding the pages, caching- and aperture binding | ||
113 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) | ||
114 | * memory. | ||
115 | */ | ||
116 | |||
117 | struct ttm_tt { | ||
118 | struct ttm_bo_device *bdev; | ||
119 | struct ttm_backend_func *func; | ||
120 | struct page **pages; | ||
121 | uint32_t page_flags; | ||
122 | unsigned long num_pages; | ||
123 | struct sg_table *sg; /* for SG objects via dma-buf */ | ||
124 | struct file *swap_storage; | ||
125 | enum ttm_caching_state caching_state; | ||
126 | enum { | ||
127 | tt_bound, | ||
128 | tt_unbound, | ||
129 | tt_unpopulated, | ||
130 | } state; | ||
131 | }; | ||
132 | |||
133 | /** | ||
134 | * struct ttm_dma_tt | ||
135 | * | ||
136 | * @ttm: Base ttm_tt struct. | ||
137 | * @dma_address: The DMA (bus) addresses of the pages | ||
138 | * @pages_list: used by some page allocation backend | ||
139 | * | ||
140 | * This is a structure holding the pages, caching- and aperture binding | ||
141 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) | ||
142 | * memory. | ||
143 | */ | ||
144 | struct ttm_dma_tt { | ||
145 | struct ttm_tt ttm; | ||
146 | dma_addr_t *dma_address; | ||
147 | struct list_head pages_list; | ||
148 | }; | ||
149 | |||
150 | #define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ | 49 | #define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ |
151 | #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ | 50 | #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ |
152 | #define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ | 51 | #define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ |
@@ -610,117 +509,6 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask) | |||
610 | return *old; | 509 | return *old; |
611 | } | 510 | } |
612 | 511 | ||
613 | /** | ||
614 | * ttm_tt_create | ||
615 | * | ||
616 | * @bo: pointer to a struct ttm_buffer_object | ||
617 | * @zero_alloc: true if allocated pages needs to be zeroed | ||
618 | * | ||
619 | * Make sure we have a TTM structure allocated for the given BO. | ||
620 | * No pages are actually allocated. | ||
621 | */ | ||
622 | int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc); | ||
623 | |||
624 | /** | ||
625 | * ttm_tt_init | ||
626 | * | ||
627 | * @ttm: The struct ttm_tt. | ||
628 | * @bdev: pointer to a struct ttm_bo_device: | ||
629 | * @size: Size of the data needed backing. | ||
630 | * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. | ||
631 | * | ||
632 | * Create a struct ttm_tt to back data with system memory pages. | ||
633 | * No pages are actually allocated. | ||
634 | * Returns: | ||
635 | * NULL: Out of memory. | ||
636 | */ | ||
637 | int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev, | ||
638 | unsigned long size, uint32_t page_flags); | ||
639 | int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, | ||
640 | unsigned long size, uint32_t page_flags); | ||
641 | |||
642 | /** | ||
643 | * ttm_tt_fini | ||
644 | * | ||
645 | * @ttm: the ttm_tt structure. | ||
646 | * | ||
647 | * Free memory of ttm_tt structure | ||
648 | */ | ||
649 | void ttm_tt_fini(struct ttm_tt *ttm); | ||
650 | void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma); | ||
651 | |||
652 | /** | ||
653 | * ttm_ttm_bind: | ||
654 | * | ||
655 | * @ttm: The struct ttm_tt containing backing pages. | ||
656 | * @bo_mem: The struct ttm_mem_reg identifying the binding location. | ||
657 | * | ||
658 | * Bind the pages of @ttm to an aperture location identified by @bo_mem | ||
659 | */ | ||
660 | int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem, | ||
661 | struct ttm_operation_ctx *ctx); | ||
662 | |||
663 | /** | ||
664 | * ttm_ttm_destroy: | ||
665 | * | ||
666 | * @ttm: The struct ttm_tt. | ||
667 | * | ||
668 | * Unbind, unpopulate and destroy common struct ttm_tt. | ||
669 | */ | ||
670 | void ttm_tt_destroy(struct ttm_tt *ttm); | ||
671 | |||
672 | /** | ||
673 | * ttm_ttm_unbind: | ||
674 | * | ||
675 | * @ttm: The struct ttm_tt. | ||
676 | * | ||
677 | * Unbind a struct ttm_tt. | ||
678 | */ | ||
679 | void ttm_tt_unbind(struct ttm_tt *ttm); | ||
680 | |||
681 | /** | ||
682 | * ttm_tt_swapin: | ||
683 | * | ||
684 | * @ttm: The struct ttm_tt. | ||
685 | * | ||
686 | * Swap in a previously swap out ttm_tt. | ||
687 | */ | ||
688 | int ttm_tt_swapin(struct ttm_tt *ttm); | ||
689 | |||
690 | /** | ||
691 | * ttm_tt_set_placement_caching: | ||
692 | * | ||
693 | * @ttm A struct ttm_tt the backing pages of which will change caching policy. | ||
694 | * @placement: Flag indicating the desired caching policy. | ||
695 | * | ||
696 | * This function will change caching policy of any default kernel mappings of | ||
697 | * the pages backing @ttm. If changing from cached to uncached or | ||
698 | * write-combined, | ||
699 | * all CPU caches will first be flushed to make sure the data of the pages | ||
700 | * hit RAM. This function may be very costly as it involves global TLB | ||
701 | * and cache flushes and potential page splitting / combining. | ||
702 | */ | ||
703 | int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement); | ||
704 | int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage); | ||
705 | |||
706 | /** | ||
707 | * ttm_tt_populate - allocate pages for a ttm | ||
708 | * | ||
709 | * @ttm: Pointer to the ttm_tt structure | ||
710 | * | ||
711 | * Calls the driver method to allocate pages for a ttm | ||
712 | */ | ||
713 | int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx); | ||
714 | |||
715 | /** | ||
716 | * ttm_tt_unpopulate - free pages from a ttm | ||
717 | * | ||
718 | * @ttm: Pointer to the ttm_tt structure | ||
719 | * | ||
720 | * Calls the driver method to free all pages from a ttm | ||
721 | */ | ||
722 | void ttm_tt_unpopulate(struct ttm_tt *ttm); | ||
723 | |||
724 | /* | 512 | /* |
725 | * ttm_bo.c | 513 | * ttm_bo.c |
726 | */ | 514 | */ |
@@ -1074,27 +862,4 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); | |||
1074 | 862 | ||
1075 | extern const struct ttm_mem_type_manager_func ttm_bo_manager_func; | 863 | extern const struct ttm_mem_type_manager_func ttm_bo_manager_func; |
1076 | 864 | ||
1077 | #if IS_ENABLED(CONFIG_AGP) | ||
1078 | #include <linux/agp_backend.h> | ||
1079 | |||
1080 | /** | ||
1081 | * ttm_agp_tt_create | ||
1082 | * | ||
1083 | * @bdev: Pointer to a struct ttm_bo_device. | ||
1084 | * @bridge: The agp bridge this device is sitting on. | ||
1085 | * @size: Size of the data needed backing. | ||
1086 | * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. | ||
1087 | * | ||
1088 | * | ||
1089 | * Create a TTM backend that uses the indicated AGP bridge as an aperture | ||
1090 | * for TT memory. This function uses the linux agpgart interface to | ||
1091 | * bind and unbind memory backing a ttm_tt. | ||
1092 | */ | ||
1093 | struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev, | ||
1094 | struct agp_bridge_data *bridge, | ||
1095 | unsigned long size, uint32_t page_flags); | ||
1096 | int ttm_agp_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx); | ||
1097 | void ttm_agp_tt_unpopulate(struct ttm_tt *ttm); | ||
1098 | #endif | ||
1099 | |||
1100 | #endif | 865 | #endif |
diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h new file mode 100644 index 000000000000..9c78556b488e --- /dev/null +++ b/include/drm/ttm/ttm_tt.h | |||
@@ -0,0 +1,272 @@ | |||
1 | /************************************************************************** | ||
2 | * | ||
3 | * Copyright (c) 2006-2009 Vmware, Inc., Palo Alto, CA., USA | ||
4 | * All Rights Reserved. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the | ||
8 | * "Software"), to deal in the Software without restriction, including | ||
9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
10 | * distribute, sub license, and/or sell copies of the Software, and to | ||
11 | * permit persons to whom the Software is furnished to do so, subject to | ||
12 | * the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice (including the | ||
15 | * next paragraph) shall be included in all copies or substantial portions | ||
16 | * of the Software. | ||
17 | * | ||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | ||
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
25 | * | ||
26 | **************************************************************************/ | ||
27 | #ifndef _TTM_TT_H_ | ||
28 | #define _TTM_TT_H_ | ||
29 | |||
30 | #include <linux/types.h> | ||
31 | |||
32 | struct ttm_tt; | ||
33 | struct ttm_mem_reg; | ||
34 | struct ttm_buffer_object; | ||
35 | struct ttm_operation_ctx; | ||
36 | |||
37 | #define TTM_PAGE_FLAG_WRITE (1 << 3) | ||
38 | #define TTM_PAGE_FLAG_SWAPPED (1 << 4) | ||
39 | #define TTM_PAGE_FLAG_PERSISTENT_SWAP (1 << 5) | ||
40 | #define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6) | ||
41 | #define TTM_PAGE_FLAG_DMA32 (1 << 7) | ||
42 | #define TTM_PAGE_FLAG_SG (1 << 8) | ||
43 | #define TTM_PAGE_FLAG_NO_RETRY (1 << 9) | ||
44 | |||
45 | enum ttm_caching_state { | ||
46 | tt_uncached, | ||
47 | tt_wc, | ||
48 | tt_cached | ||
49 | }; | ||
50 | |||
51 | struct ttm_backend_func { | ||
52 | /** | ||
53 | * struct ttm_backend_func member bind | ||
54 | * | ||
55 | * @ttm: Pointer to a struct ttm_tt. | ||
56 | * @bo_mem: Pointer to a struct ttm_mem_reg describing the | ||
57 | * memory type and location for binding. | ||
58 | * | ||
59 | * Bind the backend pages into the aperture in the location | ||
60 | * indicated by @bo_mem. This function should be able to handle | ||
61 | * differences between aperture and system page sizes. | ||
62 | */ | ||
63 | int (*bind) (struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem); | ||
64 | |||
65 | /** | ||
66 | * struct ttm_backend_func member unbind | ||
67 | * | ||
68 | * @ttm: Pointer to a struct ttm_tt. | ||
69 | * | ||
70 | * Unbind previously bound backend pages. This function should be | ||
71 | * able to handle differences between aperture and system page sizes. | ||
72 | */ | ||
73 | int (*unbind) (struct ttm_tt *ttm); | ||
74 | |||
75 | /** | ||
76 | * struct ttm_backend_func member destroy | ||
77 | * | ||
78 | * @ttm: Pointer to a struct ttm_tt. | ||
79 | * | ||
80 | * Destroy the backend. This will be call back from ttm_tt_destroy so | ||
81 | * don't call ttm_tt_destroy from the callback or infinite loop. | ||
82 | */ | ||
83 | void (*destroy) (struct ttm_tt *ttm); | ||
84 | }; | ||
85 | |||
86 | /** | ||
87 | * struct ttm_tt | ||
88 | * | ||
89 | * @bdev: Pointer to a struct ttm_bo_device. | ||
90 | * @func: Pointer to a struct ttm_backend_func that describes | ||
91 | * the backend methods. | ||
92 | * pointer. | ||
93 | * @pages: Array of pages backing the data. | ||
94 | * @num_pages: Number of pages in the page array. | ||
95 | * @bdev: Pointer to the current struct ttm_bo_device. | ||
96 | * @be: Pointer to the ttm backend. | ||
97 | * @swap_storage: Pointer to shmem struct file for swap storage. | ||
98 | * @caching_state: The current caching state of the pages. | ||
99 | * @state: The current binding state of the pages. | ||
100 | * | ||
101 | * This is a structure holding the pages, caching- and aperture binding | ||
102 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) | ||
103 | * memory. | ||
104 | */ | ||
105 | struct ttm_tt { | ||
106 | struct ttm_bo_device *bdev; | ||
107 | struct ttm_backend_func *func; | ||
108 | struct page **pages; | ||
109 | uint32_t page_flags; | ||
110 | unsigned long num_pages; | ||
111 | struct sg_table *sg; /* for SG objects via dma-buf */ | ||
112 | struct file *swap_storage; | ||
113 | enum ttm_caching_state caching_state; | ||
114 | enum { | ||
115 | tt_bound, | ||
116 | tt_unbound, | ||
117 | tt_unpopulated, | ||
118 | } state; | ||
119 | }; | ||
120 | |||
121 | /** | ||
122 | * struct ttm_dma_tt | ||
123 | * | ||
124 | * @ttm: Base ttm_tt struct. | ||
125 | * @dma_address: The DMA (bus) addresses of the pages | ||
126 | * @pages_list: used by some page allocation backend | ||
127 | * | ||
128 | * This is a structure holding the pages, caching- and aperture binding | ||
129 | * status for a buffer object that isn't backed by fixed (VRAM / AGP) | ||
130 | * memory. | ||
131 | */ | ||
132 | struct ttm_dma_tt { | ||
133 | struct ttm_tt ttm; | ||
134 | dma_addr_t *dma_address; | ||
135 | struct list_head pages_list; | ||
136 | }; | ||
137 | |||
138 | /** | ||
139 | * ttm_tt_create | ||
140 | * | ||
141 | * @bo: pointer to a struct ttm_buffer_object | ||
142 | * @zero_alloc: true if allocated pages needs to be zeroed | ||
143 | * | ||
144 | * Make sure we have a TTM structure allocated for the given BO. | ||
145 | * No pages are actually allocated. | ||
146 | */ | ||
147 | int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc); | ||
148 | |||
149 | /** | ||
150 | * ttm_tt_init | ||
151 | * | ||
152 | * @ttm: The struct ttm_tt. | ||
153 | * @bdev: pointer to a struct ttm_bo_device: | ||
154 | * @size: Size of the data needed backing. | ||
155 | * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. | ||
156 | * | ||
157 | * Create a struct ttm_tt to back data with system memory pages. | ||
158 | * No pages are actually allocated. | ||
159 | * Returns: | ||
160 | * NULL: Out of memory. | ||
161 | */ | ||
162 | int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev, | ||
163 | unsigned long size, uint32_t page_flags); | ||
164 | int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, | ||
165 | unsigned long size, uint32_t page_flags); | ||
166 | |||
167 | /** | ||
168 | * ttm_tt_fini | ||
169 | * | ||
170 | * @ttm: the ttm_tt structure. | ||
171 | * | ||
172 | * Free memory of ttm_tt structure | ||
173 | */ | ||
174 | void ttm_tt_fini(struct ttm_tt *ttm); | ||
175 | void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma); | ||
176 | |||
177 | /** | ||
178 | * ttm_ttm_bind: | ||
179 | * | ||
180 | * @ttm: The struct ttm_tt containing backing pages. | ||
181 | * @bo_mem: The struct ttm_mem_reg identifying the binding location. | ||
182 | * | ||
183 | * Bind the pages of @ttm to an aperture location identified by @bo_mem | ||
184 | */ | ||
185 | int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem, | ||
186 | struct ttm_operation_ctx *ctx); | ||
187 | |||
188 | /** | ||
189 | * ttm_ttm_destroy: | ||
190 | * | ||
191 | * @ttm: The struct ttm_tt. | ||
192 | * | ||
193 | * Unbind, unpopulate and destroy common struct ttm_tt. | ||
194 | */ | ||
195 | void ttm_tt_destroy(struct ttm_tt *ttm); | ||
196 | |||
197 | /** | ||
198 | * ttm_ttm_unbind: | ||
199 | * | ||
200 | * @ttm: The struct ttm_tt. | ||
201 | * | ||
202 | * Unbind a struct ttm_tt. | ||
203 | */ | ||
204 | void ttm_tt_unbind(struct ttm_tt *ttm); | ||
205 | |||
206 | /** | ||
207 | * ttm_tt_swapin: | ||
208 | * | ||
209 | * @ttm: The struct ttm_tt. | ||
210 | * | ||
211 | * Swap in a previously swap out ttm_tt. | ||
212 | */ | ||
213 | int ttm_tt_swapin(struct ttm_tt *ttm); | ||
214 | |||
215 | /** | ||
216 | * ttm_tt_set_placement_caching: | ||
217 | * | ||
218 | * @ttm A struct ttm_tt the backing pages of which will change caching policy. | ||
219 | * @placement: Flag indicating the desired caching policy. | ||
220 | * | ||
221 | * This function will change caching policy of any default kernel mappings of | ||
222 | * the pages backing @ttm. If changing from cached to uncached or | ||
223 | * write-combined, | ||
224 | * all CPU caches will first be flushed to make sure the data of the pages | ||
225 | * hit RAM. This function may be very costly as it involves global TLB | ||
226 | * and cache flushes and potential page splitting / combining. | ||
227 | */ | ||
228 | int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement); | ||
229 | int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage); | ||
230 | |||
231 | /** | ||
232 | * ttm_tt_populate - allocate pages for a ttm | ||
233 | * | ||
234 | * @ttm: Pointer to the ttm_tt structure | ||
235 | * | ||
236 | * Calls the driver method to allocate pages for a ttm | ||
237 | */ | ||
238 | int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx); | ||
239 | |||
240 | /** | ||
241 | * ttm_tt_unpopulate - free pages from a ttm | ||
242 | * | ||
243 | * @ttm: Pointer to the ttm_tt structure | ||
244 | * | ||
245 | * Calls the driver method to free all pages from a ttm | ||
246 | */ | ||
247 | void ttm_tt_unpopulate(struct ttm_tt *ttm); | ||
248 | |||
249 | #if IS_ENABLED(CONFIG_AGP) | ||
250 | #include <linux/agp_backend.h> | ||
251 | |||
252 | /** | ||
253 | * ttm_agp_tt_create | ||
254 | * | ||
255 | * @bdev: Pointer to a struct ttm_bo_device. | ||
256 | * @bridge: The agp bridge this device is sitting on. | ||
257 | * @size: Size of the data needed backing. | ||
258 | * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. | ||
259 | * | ||
260 | * | ||
261 | * Create a TTM backend that uses the indicated AGP bridge as an aperture | ||
262 | * for TT memory. This function uses the linux agpgart interface to | ||
263 | * bind and unbind memory backing a ttm_tt. | ||
264 | */ | ||
265 | struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev, | ||
266 | struct agp_bridge_data *bridge, | ||
267 | unsigned long size, uint32_t page_flags); | ||
268 | int ttm_agp_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx); | ||
269 | void ttm_agp_tt_unpopulate(struct ttm_tt *ttm); | ||
270 | #endif | ||
271 | |||
272 | #endif | ||