blob: cab14324242bf75d0e276847aba8f2744823c60b [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001/* SPDX-License-Identifier: GPL-2.0-or-later */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * vDSO provided cache flush routines
4 *
5 * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
6 * IBM Corp.
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00007 */
8#include <asm/processor.h>
9#include <asm/ppc_asm.h>
10#include <asm/vdso.h>
Olivier Deprez157378f2022-04-04 15:47:50 +020011#include <asm/vdso_datapage.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000012#include <asm/asm-offsets.h>
13
14 .text
15
16/*
17 * Default "generic" version of __kernel_sync_dicache.
18 *
19 * void __kernel_sync_dicache(unsigned long start, unsigned long end)
20 *
21 * Flushes the data cache & invalidate the instruction cache for the
22 * provided range [start, end[
23 */
24V_FUNCTION_BEGIN(__kernel_sync_dicache)
25 .cfi_startproc
26 mflr r12
27 .cfi_register lr,r12
Olivier Deprez157378f2022-04-04 15:47:50 +020028 get_datapage r10, r0
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000029 mtlr r12
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000030
31 lwz r7,CFG_DCACHE_BLOCKSZ(r10)
32 addi r5,r7,-1
Olivier Deprez157378f2022-04-04 15:47:50 +020033 andc r6,r3,r5 /* round low to line bdy */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000034 subf r8,r6,r4 /* compute length */
35 add r8,r8,r5 /* ensure we get enough */
36 lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
Olivier Deprez0e641232021-09-23 10:07:05 +020037 srd. r8,r8,r9 /* compute line count */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000038 crclr cr0*4+so
39 beqlr /* nothing to do? */
40 mtctr r8
411: dcbst 0,r6
42 add r6,r6,r7
43 bdnz 1b
44 sync
45
46/* Now invalidate the instruction cache */
47
48 lwz r7,CFG_ICACHE_BLOCKSZ(r10)
49 addi r5,r7,-1
Olivier Deprez157378f2022-04-04 15:47:50 +020050 andc r6,r3,r5 /* round low to line bdy */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000051 subf r8,r6,r4 /* compute length */
52 add r8,r8,r5
53 lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
Olivier Deprez0e641232021-09-23 10:07:05 +020054 srd. r8,r8,r9 /* compute line count */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000055 crclr cr0*4+so
56 beqlr /* nothing to do? */
57 mtctr r8
582: icbi 0,r6
59 add r6,r6,r7
60 bdnz 2b
61 isync
62 li r3,0
63 blr
64 .cfi_endproc
65V_FUNCTION_END(__kernel_sync_dicache)
66
67
68/*
69 * POWER5 version of __kernel_sync_dicache
70 */
71V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
72 .cfi_startproc
73 crclr cr0*4+so
74 sync
75 isync
76 li r3,0
77 blr
78 .cfi_endproc
79V_FUNCTION_END(__kernel_sync_dicache_p5)