提交 1ac2f7d5 编写于 作者: S Shaohua Li 提交者: Ingo Molnar

introduce two APIs for page attribute

Introduce two APIs for page attribute. flushing tlb/cache in every page
attribute is expensive. AGP gart usually will do a lot of operations to
change a page to uc, new APIs can reduce flush.
Signed-off-by: NShaohua Li <shaohua.li@intel.com>
Cc: airlied@linux.ie
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 012f09e7
...@@ -752,12 +752,12 @@ static inline int cache_attr(pgprot_t attr) ...@@ -752,12 +752,12 @@ static inline int cache_attr(pgprot_t attr)
(_PAGE_PAT | _PAGE_PAT_LARGE | _PAGE_PWT | _PAGE_PCD); (_PAGE_PAT | _PAGE_PAT_LARGE | _PAGE_PWT | _PAGE_PCD);
} }
static int change_page_attr_set_clr(unsigned long addr, int numpages, static int do_change_page_attr_set_clr(unsigned long addr, int numpages,
pgprot_t mask_set, pgprot_t mask_clr, pgprot_t mask_set, pgprot_t mask_clr,
int force_split) int force_split, int *tlb_flush)
{ {
struct cpa_data cpa; struct cpa_data cpa;
int ret, cache, checkalias; int ret, checkalias;
/* /*
* Check, if we are requested to change a not supported * Check, if we are requested to change a not supported
...@@ -792,9 +792,22 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages, ...@@ -792,9 +792,22 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
/* /*
* Check whether we really changed something: * Check whether we really changed something:
*/ */
if (!cpa.flushtlb) *tlb_flush = cpa.flushtlb;
goto out; cpa_fill_pool(NULL);
return ret;
}
static int change_page_attr_set_clr(unsigned long addr, int numpages,
pgprot_t mask_set, pgprot_t mask_clr,
int force_split)
{
int cache, flush_cache = 0, ret;
ret = do_change_page_attr_set_clr(addr, numpages, mask_set, mask_clr,
force_split, &flush_cache);
if (!flush_cache)
goto out;
/* /*
* No need to flush, when we did not set any of the caching * No need to flush, when we did not set any of the caching
* attributes: * attributes:
...@@ -811,10 +824,7 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages, ...@@ -811,10 +824,7 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
cpa_flush_range(addr, numpages, cache); cpa_flush_range(addr, numpages, cache);
else else
cpa_flush_all(cache); cpa_flush_all(cache);
out: out:
cpa_fill_pool(NULL);
return ret; return ret;
} }
...@@ -852,6 +862,30 @@ int set_memory_uc(unsigned long addr, int numpages) ...@@ -852,6 +862,30 @@ int set_memory_uc(unsigned long addr, int numpages)
} }
EXPORT_SYMBOL(set_memory_uc); EXPORT_SYMBOL(set_memory_uc);
int set_memory_uc_noflush(unsigned long addr, int numpages)
{
int flush;
/*
* for now UC MINUS. see comments in ioremap_nocache()
*/
if (reserve_memtype(addr, addr + numpages * PAGE_SIZE,
_PAGE_CACHE_UC_MINUS, NULL))
return -EINVAL;
/*
* for now UC MINUS. see comments in ioremap_nocache()
*/
return do_change_page_attr_set_clr(addr, numpages,
__pgprot(_PAGE_CACHE_UC_MINUS),
__pgprot(0), 0, &flush);
}
EXPORT_SYMBOL(set_memory_uc_noflush);
void set_memory_flush_all(void)
{
cpa_flush_all(1);
}
EXPORT_SYMBOL(set_memory_flush_all);
int _set_memory_wc(unsigned long addr, int numpages) int _set_memory_wc(unsigned long addr, int numpages)
{ {
return change_page_attr_set(addr, numpages, return change_page_attr_set(addr, numpages,
...@@ -926,6 +960,14 @@ int set_pages_uc(struct page *page, int numpages) ...@@ -926,6 +960,14 @@ int set_pages_uc(struct page *page, int numpages)
} }
EXPORT_SYMBOL(set_pages_uc); EXPORT_SYMBOL(set_pages_uc);
int set_pages_uc_noflush(struct page *page, int numpages)
{
unsigned long addr = (unsigned long)page_address(page);
return set_memory_uc_noflush(addr, numpages);
}
EXPORT_SYMBOL(set_pages_uc_noflush);
int set_pages_wb(struct page *page, int numpages) int set_pages_wb(struct page *page, int numpages)
{ {
unsigned long addr = (unsigned long)page_address(page); unsigned long addr = (unsigned long)page_address(page);
......
...@@ -57,6 +57,8 @@ int _set_memory_uc(unsigned long addr, int numpages); ...@@ -57,6 +57,8 @@ int _set_memory_uc(unsigned long addr, int numpages);
int _set_memory_wc(unsigned long addr, int numpages); int _set_memory_wc(unsigned long addr, int numpages);
int _set_memory_wb(unsigned long addr, int numpages); int _set_memory_wb(unsigned long addr, int numpages);
int set_memory_uc(unsigned long addr, int numpages); int set_memory_uc(unsigned long addr, int numpages);
int set_memory_uc_noflush(unsigned long addr, int numpages);
void set_memory_flush_all(void);
int set_memory_wc(unsigned long addr, int numpages); int set_memory_wc(unsigned long addr, int numpages);
int set_memory_wb(unsigned long addr, int numpages); int set_memory_wb(unsigned long addr, int numpages);
int set_memory_x(unsigned long addr, int numpages); int set_memory_x(unsigned long addr, int numpages);
...@@ -87,6 +89,7 @@ int set_memory_4k(unsigned long addr, int numpages); ...@@ -87,6 +89,7 @@ int set_memory_4k(unsigned long addr, int numpages);
*/ */
int set_pages_uc(struct page *page, int numpages); int set_pages_uc(struct page *page, int numpages);
int set_pages_uc_noflush(struct page *page, int numpages);
int set_pages_wb(struct page *page, int numpages); int set_pages_wb(struct page *page, int numpages);
int set_pages_x(struct page *page, int numpages); int set_pages_x(struct page *page, int numpages);
int set_pages_nx(struct page *page, int numpages); int set_pages_nx(struct page *page, int numpages);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册