1247835Skib/*
2247835Skib * Copyright (c) Red Hat Inc.
3247835Skib
4247835Skib * Permission is hereby granted, free of charge, to any person obtaining a
5247835Skib * copy of this software and associated documentation files (the "Software"),
6247835Skib * to deal in the Software without restriction, including without limitation
7247835Skib * the rights to use, copy, modify, merge, publish, distribute, sub license,
8247835Skib * and/or sell copies of the Software, and to permit persons to whom the
9247835Skib * Software is furnished to do so, subject to the following conditions:
10247835Skib *
11247835Skib * The above copyright notice and this permission notice (including the
12247835Skib * next paragraph) shall be included in all copies or substantial portions
13247835Skib * of the Software.
14247835Skib *
15247835Skib * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16247835Skib * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17247835Skib * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18247835Skib * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19247835Skib * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20247835Skib * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21247835Skib * DEALINGS IN THE SOFTWARE.
22247835Skib *
23247835Skib * Authors: Dave Airlie <airlied@redhat.com>
24247835Skib *          Jerome Glisse <jglisse@redhat.com>
25247835Skib */
26247835Skib/* $FreeBSD: releng/10.2/sys/dev/drm2/ttm/ttm_page_alloc.h 247835 2013-03-05 09:49:34Z kib $ */
27247835Skib#ifndef TTM_PAGE_ALLOC
28247835Skib#define TTM_PAGE_ALLOC
29247835Skib
30247835Skib#include <dev/drm2/ttm/ttm_bo_driver.h>
31247835Skib#include <dev/drm2/ttm/ttm_memory.h>
32247835Skib
33247835Skib/**
34247835Skib * Initialize pool allocator.
35247835Skib */
36247835Skibint ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages);
37247835Skib/**
38247835Skib * Free pool allocator.
39247835Skib */
40247835Skibvoid ttm_page_alloc_fini(void);
41247835Skib
42247835Skib/**
43247835Skib * ttm_pool_populate:
44247835Skib *
45247835Skib * @ttm: The struct ttm_tt to contain the backing pages.
46247835Skib *
47247835Skib * Add backing pages to all of @ttm
48247835Skib */
49247835Skibextern int ttm_pool_populate(struct ttm_tt *ttm);
50247835Skib
51247835Skib/**
52247835Skib * ttm_pool_unpopulate:
53247835Skib *
54247835Skib * @ttm: The struct ttm_tt which to free backing pages.
55247835Skib *
56247835Skib * Free all pages of @ttm
57247835Skib */
58247835Skibextern void ttm_pool_unpopulate(struct ttm_tt *ttm);
59247835Skib
60247835Skib/**
61247835Skib * Output the state of pools to debugfs file
62247835Skib */
63247835Skib/* XXXKIB
64247835Skibextern int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
65247835Skib*/
66247835Skib
67247835Skib#ifdef CONFIG_SWIOTLB
68247835Skib/**
69247835Skib * Initialize pool allocator.
70247835Skib */
71247835Skibint ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages);
72247835Skib
73247835Skib/**
74247835Skib * Free pool allocator.
75247835Skib */
76247835Skibvoid ttm_dma_page_alloc_fini(void);
77247835Skib
78247835Skib/**
79247835Skib * Output the state of pools to debugfs file
80247835Skib */
81247835Skibextern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
82247835Skib
83247835Skibextern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
84247835Skibextern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
85247835Skib
86247835Skib#else
87247835Skibstatic inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
88247835Skib					  unsigned max_pages)
89247835Skib{
90247835Skib	return -ENODEV;
91247835Skib}
92247835Skib
93247835Skibstatic inline void ttm_dma_page_alloc_fini(void) { return; }
94247835Skib
95247835Skib/* XXXKIB
96247835Skibstatic inline int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data)
97247835Skib{
98247835Skib	return 0;
99247835Skib}
100247835Skib*/
101247835Skib#endif
102247835Skib
103247835Skib#endif
104