Skip to content

Commit 2ac305b

Browse files
huangruialexdeucher
authored andcommitted
drm/ttm: add ttm_set_memory header (v2)
This patch moves all non-x86 abstraction to the ttm_set_memory header. It is to make function calling more clearly. (v2): add ttm_ prefix. Suggested-by: Christian König <christian.koenig@amd.com> Signed-off-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent f1e582e commit 2ac305b

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

‎include/drm/ttm/ttm_set_memory.h‎

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/**************************************************************************
2+
*
3+
* Copyright (c) 2018 Advanced Micro Devices, Inc.
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+
/*
28+
* Authors: Huang Rui <ray.huang@amd.com>
29+
*/
30+
31+
#ifndef TTM_SET_MEMORY
32+
#define TTM_SET_MEMORY
33+
34+
#include <linux/mm.h>
35+
36+
#ifdef CONFIG_X86
37+
38+
#include <asm/set_memory.h>
39+
40+
static inline int ttm_set_pages_array_wb(struct page **pages, int addrinarray)
41+
{
42+
return set_pages_array_wb(pages, addrinarray);
43+
}
44+
45+
static inline int ttm_set_pages_array_wc(struct page **pages, int addrinarray)
46+
{
47+
return set_pages_array_wc(pages, addrinarray);
48+
}
49+
50+
static inline int ttm_set_pages_array_uc(struct page **pages, int addrinarray)
51+
{
52+
return set_pages_array_uc(pages, addrinarray);
53+
}
54+
55+
static inline int ttm_set_pages_wb(struct page *page, int numpages)
56+
{
57+
return set_pages_wb(page, numpages);
58+
}
59+
60+
#else /* for CONFIG_X86 */
61+
62+
#if IS_ENABLED(CONFIG_AGP)
63+
64+
#include <asm/agp.h>
65+
66+
static inline int ttm_set_pages_array_wb(struct page **pages, int addrinarray)
67+
{
68+
int i;
69+
70+
for (i = 0; i < addrinarray; i++)
71+
unmap_page_from_agp(pages[i]);
72+
return 0;
73+
}
74+
75+
static inline int ttm_set_pages_array_wc(struct page **pages, int addrinarray)
76+
{
77+
int i;
78+
79+
for (i = 0; i < addrinarray; i++)
80+
map_page_into_agp(pages[i]);
81+
return 0;
82+
}
83+
84+
static inline int ttm_set_pages_array_uc(struct page **pages, int addrinarray)
85+
{
86+
int i;
87+
88+
for (i = 0; i < addrinarray; i++)
89+
map_page_into_agp(pages[i]);
90+
return 0;
91+
}
92+
93+
static inline int ttm_set_pages_wb(struct page *page, int numpages)
94+
{
95+
int i;
96+
97+
for (i = 0; i < numpages; i++)
98+
unmap_page_from_agp(page++);
99+
return 0;
100+
}
101+
102+
#else /* for CONFIG_AGP */
103+
104+
static inline int ttm_set_pages_array_wb(struct page **pages, int addrinarray)
105+
{
106+
return 0;
107+
}
108+
109+
static inline int ttm_set_pages_array_wc(struct page **pages, int addrinarray)
110+
{
111+
return 0;
112+
}
113+
114+
static inline int ttm_set_pages_array_uc(struct page **pages, int addrinarray)
115+
{
116+
return 0;
117+
}
118+
119+
static inline int ttm_set_pages_wb(struct page *page, int numpages)
120+
{
121+
return 0;
122+
}
123+
124+
#endif /* for CONFIG_AGP */
125+
126+
#endif /* for CONFIG_X86 */
127+
128+
#endif

0 commit comments

Comments
 (0)