Merge tag 'iommu-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux/fpc-iii.git] / include / drm / ttm / ttm_pool.h
blob4321728bdd11f86a69b5e0672175a9337e2898c6
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /*
3 * Copyright 2020 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
23 * Authors: Christian König
26 #ifndef _TTM_PAGE_POOL_H_
27 #define _TTM_PAGE_POOL_H_
29 #include <linux/mmzone.h>
30 #include <linux/llist.h>
31 #include <linux/spinlock.h>
32 #include <drm/ttm/ttm_caching.h>
34 struct device;
35 struct ttm_tt;
36 struct ttm_pool;
37 struct ttm_operation_ctx;
39 /**
40 * ttm_pool_type - Pool for a certain memory type
42 * @pool: the pool we belong to, might be NULL for the global ones
43 * @order: the allocation order our pages have
44 * @caching: the caching type our pages have
45 * @shrinker_list: our place on the global shrinker list
46 * @lock: protection of the page list
47 * @pages: the list of pages in the pool
49 struct ttm_pool_type {
50 struct ttm_pool *pool;
51 unsigned int order;
52 enum ttm_caching caching;
54 struct list_head shrinker_list;
56 spinlock_t lock;
57 struct list_head pages;
60 /**
61 * ttm_pool - Pool for all caching and orders
63 * @use_dma_alloc: if coherent DMA allocations should be used
64 * @use_dma32: if GFP_DMA32 should be used
65 * @caching: pools for each caching/order
67 struct ttm_pool {
68 struct device *dev;
70 bool use_dma_alloc;
71 bool use_dma32;
73 struct {
74 struct ttm_pool_type orders[MAX_ORDER];
75 } caching[TTM_NUM_CACHING_TYPES];
78 int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt,
79 struct ttm_operation_ctx *ctx);
80 void ttm_pool_free(struct ttm_pool *pool, struct ttm_tt *tt);
82 void ttm_pool_init(struct ttm_pool *pool, struct device *dev,
83 bool use_dma_alloc, bool use_dma32);
84 void ttm_pool_fini(struct ttm_pool *pool);
86 int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m);
88 int ttm_pool_mgr_init(unsigned long num_pages);
89 void ttm_pool_mgr_fini(void);
91 #endif