cache.c 16.7 KB
Newer Older
1
/*
L
Linus Torvalds 已提交
2 3 4 5
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
H
Helge Deller 已提交
6
 * Copyright (C) 1999-2006 Helge Deller <deller@gmx.de> (07-13-1999)
L
Linus Torvalds 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19
 * Copyright (C) 1999 SuSE GmbH Nuernberg
 * Copyright (C) 2000 Philipp Rumpf (prumpf@tux.org)
 *
 * Cache and TLB management
 *
 */
 
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/pagemap.h>
A
Alexey Dobriyan 已提交
20
#include <linux/sched.h>
L
Linus Torvalds 已提交
21 22 23 24 25 26 27
#include <asm/pdc.h>
#include <asm/cache.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
#include <asm/page.h>
#include <asm/pgalloc.h>
#include <asm/processor.h>
28
#include <asm/sections.h>
29
#include <asm/shmparam.h>
L
Linus Torvalds 已提交
30

31 32 33
int split_tlb __read_mostly;
int dcache_stride __read_mostly;
int icache_stride __read_mostly;
L
Linus Torvalds 已提交
34 35
EXPORT_SYMBOL(dcache_stride);

36 37 38 39
void flush_dcache_page_asm(unsigned long phys_addr, unsigned long vaddr);
EXPORT_SYMBOL(flush_dcache_page_asm);
void flush_icache_page_asm(unsigned long phys_addr, unsigned long vaddr);

L
Linus Torvalds 已提交
40 41 42 43 44 45 46 47

/* On some machines (e.g. ones with the Merced bus), there can be
 * only a single PxTLB broadcast at a time; this must be guaranteed
 * by software.  We put a spinlock around all TLB flushes  to
 * ensure this.
 */
DEFINE_SPINLOCK(pa_tlb_lock);

48
struct pdc_cache_info cache_info __read_mostly;
L
Linus Torvalds 已提交
49
#ifndef CONFIG_PA20
50
static struct pdc_btlb_info btlb_info __read_mostly;
L
Linus Torvalds 已提交
51 52 53 54 55 56
#endif

#ifdef CONFIG_SMP
void
flush_data_cache(void)
{
57
	on_each_cpu(flush_data_cache_local, NULL, 1);
L
Linus Torvalds 已提交
58 59 60 61
}
void 
flush_instruction_cache(void)
{
62
	on_each_cpu(flush_instruction_cache_local, NULL, 1);
L
Linus Torvalds 已提交
63 64 65 66 67 68
}
#endif

void
flush_cache_all_local(void)
{
69 70
	flush_instruction_cache_local(NULL);
	flush_data_cache_local(NULL);
L
Linus Torvalds 已提交
71 72 73
}
EXPORT_SYMBOL(flush_cache_all_local);

74 75 76
/* Virtual address of pfn.  */
#define pfn_va(pfn)	__va(PFN_PHYS(pfn))

L
Linus Torvalds 已提交
77
void
78
update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
L
Linus Torvalds 已提交
79
{
80 81
	unsigned long pfn = pte_pfn(*ptep);
	struct page *page;
L
Linus Torvalds 已提交
82

83 84 85 86 87
	/* We don't have pte special.  As a result, we can be called with
	   an invalid pfn and we don't need to flush the kernel dcache page.
	   This occurs with FireGL card in C8000.  */
	if (!pfn_valid(pfn))
		return;
L
Linus Torvalds 已提交
88

89 90 91
	page = pfn_to_page(pfn);
	if (page_mapping(page) && test_bit(PG_dcache_dirty, &page->flags)) {
		flush_kernel_dcache_page_addr(pfn_va(pfn));
L
Linus Torvalds 已提交
92
		clear_bit(PG_dcache_dirty, &page->flags);
93
	} else if (parisc_requires_coherency())
94
		flush_kernel_dcache_page_addr(pfn_va(pfn));
L
Linus Torvalds 已提交
95 96 97 98 99
}

void
show_cache_info(struct seq_file *m)
{
100 101
	char buf[32];

L
Linus Torvalds 已提交
102 103
	seq_printf(m, "I-cache\t\t: %ld KB\n", 
		cache_info.ic_size/1024 );
104
	if (cache_info.dc_loop != 1)
105 106
		snprintf(buf, 32, "%lu-way associative", cache_info.dc_loop);
	seq_printf(m, "D-cache\t\t: %ld KB (%s%s, %s)\n",
L
Linus Torvalds 已提交
107 108 109
		cache_info.dc_size/1024,
		(cache_info.dc_conf.cc_wt ? "WT":"WB"),
		(cache_info.dc_conf.cc_sh ? ", shared I/D":""),
110
		((cache_info.dc_loop == 1) ? "direct mapped" : buf));
L
Linus Torvalds 已提交
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
	seq_printf(m, "ITLB entries\t: %ld\n" "DTLB entries\t: %ld%s\n",
		cache_info.it_size,
		cache_info.dt_size,
		cache_info.dt_conf.tc_sh ? " - shared with ITLB":""
	);
		
#ifndef CONFIG_PA20
	/* BTLB - Block TLB */
	if (btlb_info.max_size==0) {
		seq_printf(m, "BTLB\t\t: not supported\n" );
	} else {
		seq_printf(m, 
		"BTLB fixed\t: max. %d pages, pagesize=%d (%dMB)\n"
		"BTLB fix-entr.\t: %d instruction, %d data (%d combined)\n"
		"BTLB var-entr.\t: %d instruction, %d data (%d combined)\n",
		btlb_info.max_size, (int)4096,
		btlb_info.max_size>>8,
		btlb_info.fixed_range_info.num_i,
		btlb_info.fixed_range_info.num_d,
		btlb_info.fixed_range_info.num_comb, 
		btlb_info.variable_range_info.num_i,
		btlb_info.variable_range_info.num_d,
		btlb_info.variable_range_info.num_comb
		);
	}
#endif
}

void __init 
parisc_cache_init(void)
{
	if (pdc_cache_info(&cache_info) < 0)
		panic("parisc_cache_init: pdc_cache_info failed");

#if 0
	printk("ic_size %lx dc_size %lx it_size %lx\n",
		cache_info.ic_size,
		cache_info.dc_size,
		cache_info.it_size);

	printk("DC  base 0x%lx stride 0x%lx count 0x%lx loop 0x%lx\n",
		cache_info.dc_base,
		cache_info.dc_stride,
		cache_info.dc_count,
		cache_info.dc_loop);

	printk("dc_conf = 0x%lx  alias %d blk %d line %d shift %d\n",
		*(unsigned long *) (&cache_info.dc_conf),
		cache_info.dc_conf.cc_alias,
		cache_info.dc_conf.cc_block,
		cache_info.dc_conf.cc_line,
		cache_info.dc_conf.cc_shift);
163
	printk("	wt %d sh %d cst %d hv %d\n",
L
Linus Torvalds 已提交
164 165 166
		cache_info.dc_conf.cc_wt,
		cache_info.dc_conf.cc_sh,
		cache_info.dc_conf.cc_cst,
167
		cache_info.dc_conf.cc_hv);
L
Linus Torvalds 已提交
168 169 170 171 172 173 174 175 176 177 178 179 180

	printk("IC  base 0x%lx stride 0x%lx count 0x%lx loop 0x%lx\n",
		cache_info.ic_base,
		cache_info.ic_stride,
		cache_info.ic_count,
		cache_info.ic_loop);

	printk("ic_conf = 0x%lx  alias %d blk %d line %d shift %d\n",
		*(unsigned long *) (&cache_info.ic_conf),
		cache_info.ic_conf.cc_alias,
		cache_info.ic_conf.cc_block,
		cache_info.ic_conf.cc_line,
		cache_info.ic_conf.cc_shift);
181
	printk("	wt %d sh %d cst %d hv %d\n",
L
Linus Torvalds 已提交
182 183 184
		cache_info.ic_conf.cc_wt,
		cache_info.ic_conf.cc_sh,
		cache_info.ic_conf.cc_cst,
185
		cache_info.ic_conf.cc_hv);
L
Linus Torvalds 已提交
186

187
	printk("D-TLB conf: sh %d page %d cst %d aid %d pad1 %d\n",
L
Linus Torvalds 已提交
188 189 190 191 192 193
		cache_info.dt_conf.tc_sh,
		cache_info.dt_conf.tc_page,
		cache_info.dt_conf.tc_cst,
		cache_info.dt_conf.tc_aid,
		cache_info.dt_conf.tc_pad1);

194
	printk("I-TLB conf: sh %d page %d cst %d aid %d pad1 %d\n",
L
Linus Torvalds 已提交
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
		cache_info.it_conf.tc_sh,
		cache_info.it_conf.tc_page,
		cache_info.it_conf.tc_cst,
		cache_info.it_conf.tc_aid,
		cache_info.it_conf.tc_pad1);
#endif

	split_tlb = 0;
	if (cache_info.dt_conf.tc_sh == 0 || cache_info.dt_conf.tc_sh == 2) {
		if (cache_info.dt_conf.tc_sh == 2)
			printk(KERN_WARNING "Unexpected TLB configuration. "
			"Will flush I/D separately (could be optimized).\n");

		split_tlb = 1;
	}

	/* "New and Improved" version from Jim Hull 
	 *	(1 << (cc_block-1)) * (cc_line << (4 + cnf.cc_shift))
213 214 215
	 * The following CAFL_STRIDE is an optimized version, see
	 * http://lists.parisc-linux.org/pipermail/parisc-linux/2004-June/023625.html
	 * http://lists.parisc-linux.org/pipermail/parisc-linux/2004-June/023671.html
L
Linus Torvalds 已提交
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
	 */
#define CAFL_STRIDE(cnf) (cnf.cc_line << (3 + cnf.cc_block + cnf.cc_shift))
	dcache_stride = CAFL_STRIDE(cache_info.dc_conf);
	icache_stride = CAFL_STRIDE(cache_info.ic_conf);
#undef CAFL_STRIDE

#ifndef CONFIG_PA20
	if (pdc_btlb_info(&btlb_info) < 0) {
		memset(&btlb_info, 0, sizeof btlb_info);
	}
#endif

	if ((boot_cpu_data.pdc.capabilities & PDC_MODEL_NVA_MASK) ==
						PDC_MODEL_NVA_UNSUPPORTED) {
		printk(KERN_WARNING "parisc_cache_init: Only equivalent aliasing supported!\n");
#if 0
		panic("SMP kernel required to avoid non-equivalent aliasing");
#endif
	}
}

void disable_sr_hashing(void)
{
239 240
	int srhash_type, retval;
	unsigned long space_bits;
L
Linus Torvalds 已提交
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

	switch (boot_cpu_data.cpu_type) {
	case pcx: /* We shouldn't get this far.  setup.c should prevent it. */
		BUG();
		return;

	case pcxs:
	case pcxt:
	case pcxt_:
		srhash_type = SRHASH_PCXST;
		break;

	case pcxl:
		srhash_type = SRHASH_PCXL;
		break;

	case pcxl2: /* pcxl2 doesn't support space register hashing */
		return;

	default: /* Currently all PA2.0 machines use the same ins. sequence */
		srhash_type = SRHASH_PA20;
		break;
	}

	disable_sr_hashing_asm(srhash_type);
266 267 268 269 270 271 272

	retval = pdc_spaceid_bits(&space_bits);
	/* If this procedure isn't implemented, don't panic. */
	if (retval < 0 && retval != PDC_BAD_OPTION)
		panic("pdc_spaceid_bits call failed.\n");
	if (space_bits != 0)
		panic("SpaceID hashing is still on!\n");
L
Linus Torvalds 已提交
273 274
}

275
static inline void
276 277
__flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr,
		   unsigned long physaddr)
278
{
279
	preempt_disable();
280 281 282
	flush_dcache_page_asm(physaddr, vmaddr);
	if (vma->vm_flags & VM_EXEC)
		flush_icache_page_asm(physaddr, vmaddr);
283
	preempt_enable();
284 285
}

L
Linus Torvalds 已提交
286 287 288 289 290
void flush_dcache_page(struct page *page)
{
	struct address_space *mapping = page_mapping(page);
	struct vm_area_struct *mpnt;
	unsigned long offset;
291
	unsigned long addr, old_addr = 0;
L
Linus Torvalds 已提交
292 293 294 295 296 297 298
	pgoff_t pgoff;

	if (mapping && !mapping_mapped(mapping)) {
		set_bit(PG_dcache_dirty, &page->flags);
		return;
	}

299
	flush_kernel_dcache_page(page);
L
Linus Torvalds 已提交
300 301 302 303 304 305 306 307 308 309 310 311

	if (!mapping)
		return;

	pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);

	/* We have carefully arranged in arch_get_unmapped_area() that
	 * *any* mappings of a file are always congruently mapped (whether
	 * declared as MAP_PRIVATE or MAP_SHARED), so we only need
	 * to flush one address here for them all to become coherent */

	flush_dcache_mmap_lock(mapping);
312
	vma_interval_tree_foreach(mpnt, &mapping->i_mmap, pgoff, pgoff) {
L
Linus Torvalds 已提交
313 314 315
		offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT;
		addr = mpnt->vm_start + offset;

316 317 318 319 320 321 322 323 324 325
		/* The TLB is the engine of coherence on parisc: The
		 * CPU is entitled to speculate any page with a TLB
		 * mapping, so here we kill the mapping then flush the
		 * page along a special flush only alias mapping.
		 * This guarantees that the page is no-longer in the
		 * cache for any process and nor may it be
		 * speculatively read in (until the user or kernel
		 * specifically accesses it, of course) */

		flush_tlb_page(mpnt, addr);
326 327 328
		if (old_addr == 0 || (old_addr & (SHMLBA - 1)) != (addr & (SHMLBA - 1))) {
			__flush_cache_page(mpnt, addr, page_to_phys(page));
			if (old_addr)
329
				printk(KERN_ERR "INEQUIVALENT ALIASES 0x%lx and 0x%lx in file %s\n", old_addr, addr, mpnt->vm_file ? (char *)mpnt->vm_file->f_path.dentry->d_name.name : "(null)");
330
			old_addr = addr;
H
Hugh Dickins 已提交
331
		}
L
Linus Torvalds 已提交
332 333 334 335 336 337 338
	}
	flush_dcache_mmap_unlock(mapping);
}
EXPORT_SYMBOL(flush_dcache_page);

/* Defined in arch/parisc/kernel/pacache.S */
EXPORT_SYMBOL(flush_kernel_dcache_range_asm);
339
EXPORT_SYMBOL(flush_kernel_dcache_page_asm);
L
Linus Torvalds 已提交
340 341 342 343
EXPORT_SYMBOL(flush_data_cache_local);
EXPORT_SYMBOL(flush_kernel_icache_range_asm);

#define FLUSH_THRESHOLD 0x80000 /* 0.5MB */
344
int parisc_cache_flush_threshold __read_mostly = FLUSH_THRESHOLD;
L
Linus Torvalds 已提交
345

346
void __init parisc_setup_cache_timing(void)
L
Linus Torvalds 已提交
347 348 349 350 351 352 353 354
{
	unsigned long rangetime, alltime;
	unsigned long size;

	alltime = mfctl(16);
	flush_data_cache();
	alltime = mfctl(16) - alltime;

355
	size = (unsigned long)(_end - _text);
L
Linus Torvalds 已提交
356
	rangetime = mfctl(16);
357
	flush_kernel_dcache_range((unsigned long)_text, size);
L
Linus Torvalds 已提交
358 359 360 361 362 363 364 365 366 367 368 369
	rangetime = mfctl(16) - rangetime;

	printk(KERN_DEBUG "Whole cache flush %lu cycles, flushing %lu bytes %lu cycles\n",
		alltime, size, rangetime);

	/* Racy, but if we see an intermediate value, it's ok too... */
	parisc_cache_flush_threshold = size * alltime / rangetime;

	parisc_cache_flush_threshold = (parisc_cache_flush_threshold + L1_CACHE_BYTES - 1) &~ (L1_CACHE_BYTES - 1); 
	if (!parisc_cache_flush_threshold)
		parisc_cache_flush_threshold = FLUSH_THRESHOLD;

370 371 372
	if (parisc_cache_flush_threshold > cache_info.dc_size)
		parisc_cache_flush_threshold = cache_info.dc_size;

H
Helge Deller 已提交
373
	printk(KERN_INFO "Setting cache flush threshold to %x (%d CPUs online)\n", parisc_cache_flush_threshold, num_online_cpus());
L
Linus Torvalds 已提交
374
}
375

376 377 378
extern void purge_kernel_dcache_page_asm(unsigned long);
extern void clear_user_page_asm(void *, unsigned long);
extern void copy_user_page_asm(void *, void *, unsigned long);
379 380 381

void flush_kernel_dcache_page_addr(void *addr)
{
382 383
	unsigned long flags;

384
	flush_kernel_dcache_page_asm(addr);
385
	purge_tlb_start(flags);
386
	pdtlb_kernel(addr);
387
	purge_tlb_end(flags);
388 389 390
}
EXPORT_SYMBOL(flush_kernel_dcache_page_addr);

391 392 393 394 395 396 397 398
void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
{
	unsigned long flags;

	/* Note: purge_tlb_entries can be called at startup with
	   no context.  */

	purge_tlb_start(flags);
399
	mtsp(mm->context, 1);
400 401 402 403 404 405
	pdtlb(addr);
	pitlb(addr);
	purge_tlb_end(flags);
}
EXPORT_SYMBOL(purge_tlb_entries);

406 407 408 409 410 411 412 413 414
void __flush_tlb_range(unsigned long sid, unsigned long start,
		       unsigned long end)
{
	unsigned long npages;

	npages = ((end - (start & PAGE_MASK)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
	if (npages >= 512)  /* 2MB of space: arbitrary, should be tuned */
		flush_tlb_all();
	else {
415 416 417
		unsigned long flags;

		purge_tlb_start(flags);
418
		mtsp(sid, 1);
419 420 421 422 423 424 425 426 427 428 429 430
		if (split_tlb) {
			while (npages--) {
				pdtlb(start);
				pitlb(start);
				start += PAGE_SIZE;
			}
		} else {
			while (npages--) {
				pdtlb(start);
				start += PAGE_SIZE;
			}
		}
431
		purge_tlb_end(flags);
432 433 434 435 436 437 438 439 440 441
	}
}

static void cacheflush_h_tmp_function(void *dummy)
{
	flush_cache_all_local();
}

void flush_cache_all(void)
{
442
	on_each_cpu(cacheflush_h_tmp_function, NULL, 1);
443 444
}

445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
static inline unsigned long mm_total_size(struct mm_struct *mm)
{
	struct vm_area_struct *vma;
	unsigned long usize = 0;

	for (vma = mm->mmap; vma; vma = vma->vm_next)
		usize += vma->vm_end - vma->vm_start;
	return usize;
}

static inline pte_t *get_ptep(pgd_t *pgd, unsigned long addr)
{
	pte_t *ptep = NULL;

	if (!pgd_none(*pgd)) {
		pud_t *pud = pud_offset(pgd, addr);
		if (!pud_none(*pud)) {
			pmd_t *pmd = pmd_offset(pud, addr);
			if (!pmd_none(*pmd))
				ptep = pte_offset_map(pmd, addr);
		}
	}
	return ptep;
}

470 471
void flush_cache_mm(struct mm_struct *mm)
{
472 473 474
	struct vm_area_struct *vma;
	pgd_t *pgd;

475 476
	/* Flushing the whole cache on each cpu takes forever on
	   rp3440, etc.  So, avoid it if the mm isn't too big.  */
477 478 479 480 481 482 483 484 485 486 487
	if (mm_total_size(mm) >= parisc_cache_flush_threshold) {
		flush_cache_all();
		return;
	}

	if (mm->context == mfsp(3)) {
		for (vma = mm->mmap; vma; vma = vma->vm_next) {
			flush_user_dcache_range_asm(vma->vm_start, vma->vm_end);
			if ((vma->vm_flags & VM_EXEC) == 0)
				continue;
			flush_user_icache_range_asm(vma->vm_start, vma->vm_end);
488 489 490 491
		}
		return;
	}

492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
	pgd = mm->pgd;
	for (vma = mm->mmap; vma; vma = vma->vm_next) {
		unsigned long addr;

		for (addr = vma->vm_start; addr < vma->vm_end;
		     addr += PAGE_SIZE) {
			unsigned long pfn;
			pte_t *ptep = get_ptep(pgd, addr);
			if (!ptep)
				continue;
			pfn = pte_pfn(*ptep);
			if (!pfn_valid(pfn))
				continue;
			__flush_cache_page(vma, addr, PFN_PHYS(pfn));
		}
	}
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
}

void
flush_user_dcache_range(unsigned long start, unsigned long end)
{
	if ((end - start) < parisc_cache_flush_threshold)
		flush_user_dcache_range_asm(start,end);
	else
		flush_data_cache();
}

void
flush_user_icache_range(unsigned long start, unsigned long end)
{
	if ((end - start) < parisc_cache_flush_threshold)
		flush_user_icache_range_asm(start,end);
	else
		flush_instruction_cache();
}

void flush_cache_range(struct vm_area_struct *vma,
		unsigned long start, unsigned long end)
{
531 532 533
	unsigned long addr;
	pgd_t *pgd;

H
Helge Deller 已提交
534
	BUG_ON(!vma->vm_mm->context);
535

536
	if ((end - start) >= parisc_cache_flush_threshold) {
537
		flush_cache_all();
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
		return;
	}

	if (vma->vm_mm->context == mfsp(3)) {
		flush_user_dcache_range_asm(start, end);
		if (vma->vm_flags & VM_EXEC)
			flush_user_icache_range_asm(start, end);
		return;
	}

	pgd = vma->vm_mm->pgd;
	for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) {
		unsigned long pfn;
		pte_t *ptep = get_ptep(pgd, addr);
		if (!ptep)
			continue;
		pfn = pte_pfn(*ptep);
		if (pfn_valid(pfn))
			__flush_cache_page(vma, addr, PFN_PHYS(pfn));
557 558 559 560 561 562 563 564
	}
}

void
flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn)
{
	BUG_ON(!vma->vm_mm->context);

565 566 567 568
	if (pfn_valid(pfn)) {
		flush_tlb_page(vma, vmaddr);
		__flush_cache_page(vma, vmaddr, PFN_PHYS(pfn));
	}
569
}
570 571 572 573 574 575 576 577 578 579 580

#ifdef CONFIG_PARISC_TMPALIAS

void clear_user_highpage(struct page *page, unsigned long vaddr)
{
	void *vto;
	unsigned long flags;

	/* Clear using TMPALIAS region.  The page doesn't need to
	   be flushed but the kernel mapping needs to be purged.  */

581
	vto = kmap_atomic(page);
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615

	/* The PA-RISC 2.0 Architecture book states on page F-6:
	   "Before a write-capable translation is enabled, *all*
	   non-equivalently-aliased translations must be removed
	   from the page table and purged from the TLB.  (Note
	   that the caches are not required to be flushed at this
	   time.)  Before any non-equivalent aliased translation
	   is re-enabled, the virtual address range for the writeable
	   page (the entire page) must be flushed from the cache,
	   and the write-capable translation removed from the page
	   table and purged from the TLB."  */

	purge_kernel_dcache_page_asm((unsigned long)vto);
	purge_tlb_start(flags);
	pdtlb_kernel(vto);
	purge_tlb_end(flags);
	preempt_disable();
	clear_user_page_asm(vto, vaddr);
	preempt_enable();

	pagefault_enable();		/* kunmap_atomic(addr, KM_USER0); */
}

void copy_user_highpage(struct page *to, struct page *from,
	unsigned long vaddr, struct vm_area_struct *vma)
{
	void *vfrom, *vto;
	unsigned long flags;

	/* Copy using TMPALIAS region.  This has the advantage
	   that the `from' page doesn't need to be flushed.  However,
	   the `to' page must be flushed in copy_user_page_asm since
	   it can be used to bring in executable code.  */

616 617
	vfrom = kmap_atomic(from);
	vto = kmap_atomic(to);
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633

	purge_kernel_dcache_page_asm((unsigned long)vto);
	purge_tlb_start(flags);
	pdtlb_kernel(vto);
	pdtlb_kernel(vfrom);
	purge_tlb_end(flags);
	preempt_disable();
	copy_user_page_asm(vto, vfrom, vaddr);
	flush_dcache_page_asm(__pa(vto), vaddr);
	preempt_enable();

	pagefault_enable();		/* kunmap_atomic(addr, KM_USER1); */
	pagefault_enable();		/* kunmap_atomic(addr, KM_USER0); */
}

#endif /* CONFIG_PARISC_TMPALIAS */