Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/frv/mm/cache-page.c
10817 views
1
/* cache-page.c: whole-page cache wrangling functions for MMU linux
2
*
3
* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4
* Written by David Howells ([email protected])
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version
9
* 2 of the License, or (at your option) any later version.
10
*/
11
#include <linux/sched.h>
12
#include <linux/mm.h>
13
#include <linux/highmem.h>
14
#include <linux/module.h>
15
#include <asm/pgalloc.h>
16
17
/*****************************************************************************/
18
/*
19
* DCF takes a virtual address and the page may not currently have one
20
* - temporarily hijack a kmap_atomic() slot and attach the page to it
21
*/
22
void flush_dcache_page(struct page *page)
23
{
24
unsigned long dampr2;
25
void *vaddr;
26
27
dampr2 = __get_DAMPR(2);
28
29
vaddr = kmap_atomic_primary(page, __KM_CACHE);
30
31
frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE);
32
33
kunmap_atomic_primary(vaddr, __KM_CACHE);
34
35
if (dampr2) {
36
__set_DAMPR(2, dampr2);
37
__set_IAMPR(2, dampr2);
38
}
39
40
} /* end flush_dcache_page() */
41
42
EXPORT_SYMBOL(flush_dcache_page);
43
44
/*****************************************************************************/
45
/*
46
* ICI takes a virtual address and the page may not currently have one
47
* - so we temporarily attach the page to a bit of virtual space so that is can be flushed
48
*/
49
void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
50
unsigned long start, unsigned long len)
51
{
52
unsigned long dampr2;
53
void *vaddr;
54
55
dampr2 = __get_DAMPR(2);
56
57
vaddr = kmap_atomic_primary(page, __KM_CACHE);
58
59
start = (start & ~PAGE_MASK) | (unsigned long) vaddr;
60
frv_cache_wback_inv(start, start + len);
61
62
kunmap_atomic_primary(vaddr, __KM_CACHE);
63
64
if (dampr2) {
65
__set_DAMPR(2, dampr2);
66
__set_IAMPR(2, dampr2);
67
}
68
69
} /* end flush_icache_user_range() */
70
71
EXPORT_SYMBOL(flush_icache_user_range);
72
73