1*592ffb21SWarner Losh /*
2*592ffb21SWarner Losh * Copyright (c) Red Hat Inc.
3*592ffb21SWarner Losh
4*592ffb21SWarner Losh * Permission is hereby granted, free of charge, to any person obtaining a
5*592ffb21SWarner Losh * copy of this software and associated documentation files (the "Software"),
6*592ffb21SWarner Losh * to deal in the Software without restriction, including without limitation
7*592ffb21SWarner Losh * the rights to use, copy, modify, merge, publish, distribute, sub license,
8*592ffb21SWarner Losh * and/or sell copies of the Software, and to permit persons to whom the
9*592ffb21SWarner Losh * Software is furnished to do so, subject to the following conditions:
10*592ffb21SWarner Losh *
11*592ffb21SWarner Losh * The above copyright notice and this permission notice (including the
12*592ffb21SWarner Losh * next paragraph) shall be included in all copies or substantial portions
13*592ffb21SWarner Losh * of the Software.
14*592ffb21SWarner Losh *
15*592ffb21SWarner Losh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*592ffb21SWarner Losh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*592ffb21SWarner Losh * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18*592ffb21SWarner Losh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*592ffb21SWarner Losh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*592ffb21SWarner Losh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21*592ffb21SWarner Losh * DEALINGS IN THE SOFTWARE.
22*592ffb21SWarner Losh *
23*592ffb21SWarner Losh * Authors: Dave Airlie <airlied@redhat.com>
24*592ffb21SWarner Losh * Jerome Glisse <jglisse@redhat.com>
25*592ffb21SWarner Losh */
26*592ffb21SWarner Losh #ifndef TTM_PAGE_ALLOC
27*592ffb21SWarner Losh #define TTM_PAGE_ALLOC
28*592ffb21SWarner Losh
29*592ffb21SWarner Losh #include <dev/drm2/ttm/ttm_bo_driver.h>
30*592ffb21SWarner Losh #include <dev/drm2/ttm/ttm_memory.h>
31*592ffb21SWarner Losh
32*592ffb21SWarner Losh /**
33*592ffb21SWarner Losh * Initialize pool allocator.
34*592ffb21SWarner Losh */
35*592ffb21SWarner Losh int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages);
36*592ffb21SWarner Losh /**
37*592ffb21SWarner Losh * Free pool allocator.
38*592ffb21SWarner Losh */
39*592ffb21SWarner Losh void ttm_page_alloc_fini(void);
40*592ffb21SWarner Losh
41*592ffb21SWarner Losh /**
42*592ffb21SWarner Losh * ttm_pool_populate:
43*592ffb21SWarner Losh *
44*592ffb21SWarner Losh * @ttm: The struct ttm_tt to contain the backing pages.
45*592ffb21SWarner Losh *
46*592ffb21SWarner Losh * Add backing pages to all of @ttm
47*592ffb21SWarner Losh */
48*592ffb21SWarner Losh extern int ttm_pool_populate(struct ttm_tt *ttm);
49*592ffb21SWarner Losh
50*592ffb21SWarner Losh /**
51*592ffb21SWarner Losh * ttm_pool_unpopulate:
52*592ffb21SWarner Losh *
53*592ffb21SWarner Losh * @ttm: The struct ttm_tt which to free backing pages.
54*592ffb21SWarner Losh *
55*592ffb21SWarner Losh * Free all pages of @ttm
56*592ffb21SWarner Losh */
57*592ffb21SWarner Losh extern void ttm_pool_unpopulate(struct ttm_tt *ttm);
58*592ffb21SWarner Losh
59*592ffb21SWarner Losh /**
60*592ffb21SWarner Losh * Output the state of pools to debugfs file
61*592ffb21SWarner Losh */
62*592ffb21SWarner Losh /* XXXKIB
63*592ffb21SWarner Losh extern int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
64*592ffb21SWarner Losh */
65*592ffb21SWarner Losh
66*592ffb21SWarner Losh #ifdef CONFIG_SWIOTLB
67*592ffb21SWarner Losh /**
68*592ffb21SWarner Losh * Initialize pool allocator.
69*592ffb21SWarner Losh */
70*592ffb21SWarner Losh int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages);
71*592ffb21SWarner Losh
72*592ffb21SWarner Losh /**
73*592ffb21SWarner Losh * Free pool allocator.
74*592ffb21SWarner Losh */
75*592ffb21SWarner Losh void ttm_dma_page_alloc_fini(void);
76*592ffb21SWarner Losh
77*592ffb21SWarner Losh /**
78*592ffb21SWarner Losh * Output the state of pools to debugfs file
79*592ffb21SWarner Losh */
80*592ffb21SWarner Losh extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
81*592ffb21SWarner Losh
82*592ffb21SWarner Losh extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
83*592ffb21SWarner Losh extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
84*592ffb21SWarner Losh
85*592ffb21SWarner Losh #else
ttm_dma_page_alloc_init(struct ttm_mem_global * glob,unsigned max_pages)86*592ffb21SWarner Losh static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
87*592ffb21SWarner Losh unsigned max_pages)
88*592ffb21SWarner Losh {
89*592ffb21SWarner Losh return -ENODEV;
90*592ffb21SWarner Losh }
91*592ffb21SWarner Losh
ttm_dma_page_alloc_fini(void)92*592ffb21SWarner Losh static inline void ttm_dma_page_alloc_fini(void) { return; }
93*592ffb21SWarner Losh
94*592ffb21SWarner Losh /* XXXKIB
95*592ffb21SWarner Losh static inline int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data)
96*592ffb21SWarner Losh {
97*592ffb21SWarner Losh return 0;
98*592ffb21SWarner Losh }
99*592ffb21SWarner Losh */
100*592ffb21SWarner Losh #endif
101*592ffb21SWarner Losh
102*592ffb21SWarner Losh #endif
103