18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_AGP_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_AGP_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/pgtable.h>
68c2ecf20Sopenharmony_ci#include <asm/cacheflush.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci * Functions to keep the agpgart mappings coherent with the MMU. The
108c2ecf20Sopenharmony_ci * GART gives the CPU a physical alias of pages in memory. The alias
118c2ecf20Sopenharmony_ci * region is mapped uncacheable. Make sure there are no conflicting
128c2ecf20Sopenharmony_ci * mappings with different cachability attributes for the same
138c2ecf20Sopenharmony_ci * page. This avoids data corruption on some CPUs.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define map_page_into_agp(page) set_pages_uc(page, 1)
178c2ecf20Sopenharmony_ci#define unmap_page_from_agp(page) set_pages_wb(page, 1)
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci/*
208c2ecf20Sopenharmony_ci * Could use CLFLUSH here if the cpu supports it. But then it would
218c2ecf20Sopenharmony_ci * need to be called for each cacheline of the whole page so it may
228c2ecf20Sopenharmony_ci * not be worth it. Would need a page for it.
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci#define flush_agp_cache() wbinvd()
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* GATT allocation. Returns/accepts GATT kernel virtual address. */
278c2ecf20Sopenharmony_ci#define alloc_gatt_pages(order)		\
288c2ecf20Sopenharmony_ci	((char *)__get_free_pages(GFP_KERNEL, (order)))
298c2ecf20Sopenharmony_ci#define free_gatt_pages(table, order)	\
308c2ecf20Sopenharmony_ci	free_pages((unsigned long)(table), (order))
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#endif /* _ASM_X86_AGP_H */
33