1 /**************************************************************************
3 * Copyright (c) 2018 Advanced Micro Devices, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 * Authors: Huang Rui <ray.huang@amd.com>
31 #ifndef TTM_SET_MEMORY
32 #define TTM_SET_MEMORY
38 #include <asm/set_memory.h>
40 static inline int ttm_set_pages_array_wb(struct page
**pages
, int addrinarray
)
42 return set_pages_array_wb(pages
, addrinarray
);
45 static inline int ttm_set_pages_array_wc(struct page
**pages
, int addrinarray
)
47 return set_pages_array_wc(pages
, addrinarray
);
50 static inline int ttm_set_pages_array_uc(struct page
**pages
, int addrinarray
)
52 return set_pages_array_uc(pages
, addrinarray
);
55 static inline int ttm_set_pages_wb(struct page
*page
, int numpages
)
57 return set_pages_wb(page
, numpages
);
60 static inline int ttm_set_pages_wc(struct page
*page
, int numpages
)
62 unsigned long addr
= (unsigned long)page_address(page
);
64 return set_memory_wc(addr
, numpages
);
67 static inline int ttm_set_pages_uc(struct page
*page
, int numpages
)
69 return set_pages_uc(page
, numpages
);
72 #else /* for CONFIG_X86 */
74 #if IS_ENABLED(CONFIG_AGP)
78 static inline int ttm_set_pages_array_wb(struct page
**pages
, int addrinarray
)
82 for (i
= 0; i
< addrinarray
; i
++)
83 unmap_page_from_agp(pages
[i
]);
87 static inline int ttm_set_pages_array_wc(struct page
**pages
, int addrinarray
)
91 for (i
= 0; i
< addrinarray
; i
++)
92 map_page_into_agp(pages
[i
]);
96 static inline int ttm_set_pages_array_uc(struct page
**pages
, int addrinarray
)
100 for (i
= 0; i
< addrinarray
; i
++)
101 map_page_into_agp(pages
[i
]);
105 static inline int ttm_set_pages_wb(struct page
*page
, int numpages
)
109 for (i
= 0; i
< numpages
; i
++)
110 unmap_page_from_agp(page
++);
114 #else /* for CONFIG_AGP */
116 static inline int ttm_set_pages_array_wb(struct page
**pages
, int addrinarray
)
121 static inline int ttm_set_pages_array_wc(struct page
**pages
, int addrinarray
)
126 static inline int ttm_set_pages_array_uc(struct page
**pages
, int addrinarray
)
131 static inline int ttm_set_pages_wb(struct page
*page
, int numpages
)
136 #endif /* for CONFIG_AGP */
138 static inline int ttm_set_pages_wc(struct page
*page
, int numpages
)
143 static inline int ttm_set_pages_uc(struct page
*page
, int numpages
)
148 #endif /* for CONFIG_X86 */