mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
OpenRISC updates for 6.15
This is a bit late as I was on holiday, but as there are no huge structural changes I hope it's OK to include mid release cycle. - Support for cacheinfo API to expose OpenRISC cache info via sysfs, this also translated to some cleanups to OpenRISC cache flush and invalidate API's - Documentation updates for new mailing list and toolchain binaries -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE2cRzVK74bBA6Je/xw7McLV5mJ+QFAmgMeH8ACgkQw7McLV5m J+SkoQ//ZACMeDCXqNVbOg8dHmh1fVw5o+wbTS4kf7dBbDKvOniL5QS9s+Q9VjJi lm9xHNTcmB6lv6dPsX8mgOJear9PO0YChiSvMwuwMU8QnUkyXUZqMcMUJbGJvObh M73BYAq+2d7cQgOj4tvQ0+npX1EPmiHD0al+MTolSrqH3UcCxcFdJoeuGowQ5GUJ iWCmy6WeRSvmidsTxp+daQ5VVEz5bGHa2pvjdPp6pD0cDS+QjPvr1XIXAmELCDxO R9dy1BrRm7igw3/ACpGRiIpwGX42ut4luw2ZjXd2iuuTqFBu8S7N3Lwf+jQP6CA9 G7PD7Tn1PG6JFM9Fbohr6HjwZgcJ1YonyiLUoUzKBDdJaFoIewg4BO0iLujBfdTo +IZ7NyesRyksDv5uov1hYTTv0N3IFsdORfBt0OparvWvuHb9uqSaZzHEHXPDb16R PTrJson/n+Qkc10dcOtyu4gi8xnyrCybNOTTJH4cz6SWMGaWUJV0n1VEE0dNGzm+ jBKQ1Bf1PXOUk95Ll8MUj/1oYrrBH3IGUrh6ucprvvAGY92B81ca1DNyFPlUa/TR 8gdhVofhhG9h3NRAN1ulhR8JZNGwa+FhnhlT4D6ikLySw5j3aq5dQZbqIquRl3/P 2RvO7lpUpGQ4zVaQLIekiDQB/+CBJjK4DsNrNDiTePwYXvVcYGc= =FxHM -----END PGP SIGNATURE----- Merge tag 'for-linus' of https://github.com/openrisc/linux Pull OpenRISC updates from Stafford Horne: - Support for cacheinfo API to expose OpenRISC cache info via sysfs, this also translated to some cleanups to OpenRISC cache flush and invalidate API's - Documentation updates for new mailing list and toolchain binaries * tag 'for-linus' of https://github.com/openrisc/linux: Documentation: openrisc: Update toolchain binaries URL Documentation: openrisc: Update mailing list openrisc: Add cacheinfo support openrisc: Introduce new utility functions to flush and invalidate caches openrisc: Refactor struct cpuinfo_or1k to reduce duplication
This commit is contained in:
commit
ec0c2d5359
11 changed files with 214 additions and 93 deletions
|
@ -7,10 +7,10 @@ target architecture, specifically, is the 32-bit OpenRISC 1000 family (or1k).
|
|||
|
||||
For information about OpenRISC processors and ongoing development:
|
||||
|
||||
======= =============================
|
||||
======= ==============================
|
||||
website https://openrisc.io
|
||||
email openrisc@lists.librecores.org
|
||||
======= =============================
|
||||
email linux-openrisc@vger.kernel.org
|
||||
======= ==============================
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -27,11 +27,11 @@ Toolchain binaries can be obtained from openrisc.io or our github releases page.
|
|||
Instructions for building the different toolchains can be found on openrisc.io
|
||||
or Stafford's toolchain build and release scripts.
|
||||
|
||||
========== =================================================
|
||||
binaries https://github.com/openrisc/or1k-gcc/releases
|
||||
========== ==========================================================
|
||||
binaries https://github.com/stffrdhrn/or1k-toolchain-build/releases
|
||||
toolchains https://openrisc.io/software
|
||||
building https://github.com/stffrdhrn/or1k-toolchain-build
|
||||
========== =================================================
|
||||
========== ==========================================================
|
||||
|
||||
2) Building
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ OpenRISC 1000系列(或1k)。
|
|||
|
||||
关于OpenRISC处理器和正在进行中的开发的信息:
|
||||
|
||||
======= =============================
|
||||
======= ==============================
|
||||
网站 https://openrisc.io
|
||||
邮箱 openrisc@lists.librecores.org
|
||||
======= =============================
|
||||
邮箱 linux-openrisc@vger.kernel.org
|
||||
======= ==============================
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -36,11 +36,11 @@ OpenRISC工具链和Linux的构建指南
|
|||
工具链的构建指南可以在openrisc.io或Stafford的工具链构建和发布脚本
|
||||
中找到。
|
||||
|
||||
====== =================================================
|
||||
二进制 https://github.com/openrisc/or1k-gcc/releases
|
||||
====== ==========================================================
|
||||
二进制 https://github.com/stffrdhrn/or1k-toolchain-build/releases
|
||||
工具链 https://openrisc.io/software
|
||||
构建 https://github.com/stffrdhrn/or1k-toolchain-build
|
||||
====== =================================================
|
||||
====== ==========================================================
|
||||
|
||||
2) 构建
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ OpenRISC 1000系列(或1k)。
|
|||
|
||||
關於OpenRISC處理器和正在進行中的開發的信息:
|
||||
|
||||
======= =============================
|
||||
======= ==============================
|
||||
網站 https://openrisc.io
|
||||
郵箱 openrisc@lists.librecores.org
|
||||
======= =============================
|
||||
郵箱 linux-openrisc@vger.kernel.org
|
||||
======= ==============================
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -36,11 +36,11 @@ OpenRISC工具鏈和Linux的構建指南
|
|||
工具鏈的構建指南可以在openrisc.io或Stafford的工具鏈構建和發佈腳本
|
||||
中找到。
|
||||
|
||||
====== =================================================
|
||||
二進制 https://github.com/openrisc/or1k-gcc/releases
|
||||
====== ==========================================================
|
||||
二進制 https://github.com/stffrdhrn/or1k-toolchain-build/releases
|
||||
工具鏈 https://openrisc.io/software
|
||||
構建 https://github.com/stffrdhrn/or1k-toolchain-build
|
||||
====== =================================================
|
||||
====== ==========================================================
|
||||
|
||||
2) 構建
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
*/
|
||||
extern void local_dcache_page_flush(struct page *page);
|
||||
extern void local_icache_page_inv(struct page *page);
|
||||
extern void local_dcache_range_flush(unsigned long start, unsigned long end);
|
||||
extern void local_dcache_range_inv(unsigned long start, unsigned long end);
|
||||
extern void local_icache_range_inv(unsigned long start, unsigned long end);
|
||||
|
||||
/*
|
||||
* Data cache flushing always happen on the local cpu. Instruction cache
|
||||
|
@ -38,6 +41,20 @@ extern void local_icache_page_inv(struct page *page);
|
|||
extern void smp_icache_page_inv(struct page *page);
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
/*
|
||||
* Even if the actual block size is larger than L1_CACHE_BYTES, paddr
|
||||
* can be incremented by L1_CACHE_BYTES. When paddr is written to the
|
||||
* invalidate register, the entire cache line encompassing this address
|
||||
* is invalidated. Each subsequent reference to the same cache line will
|
||||
* not affect the invalidation process.
|
||||
*/
|
||||
#define local_dcache_block_flush(addr) \
|
||||
local_dcache_range_flush(addr, addr + L1_CACHE_BYTES)
|
||||
#define local_dcache_block_inv(addr) \
|
||||
local_dcache_range_inv(addr, addr + L1_CACHE_BYTES)
|
||||
#define local_icache_block_inv(addr) \
|
||||
local_icache_range_inv(addr, addr + L1_CACHE_BYTES)
|
||||
|
||||
/*
|
||||
* Synchronizes caches. Whenever a cpu writes executable code to memory, this
|
||||
* should be called to make sure the processor sees the newly written code.
|
||||
|
|
|
@ -15,16 +15,21 @@
|
|||
#ifndef __ASM_OPENRISC_CPUINFO_H
|
||||
#define __ASM_OPENRISC_CPUINFO_H
|
||||
|
||||
#include <asm/spr.h>
|
||||
#include <asm/spr_defs.h>
|
||||
|
||||
struct cache_desc {
|
||||
u32 size;
|
||||
u32 sets;
|
||||
u32 block_size;
|
||||
u32 ways;
|
||||
};
|
||||
|
||||
struct cpuinfo_or1k {
|
||||
u32 clock_frequency;
|
||||
|
||||
u32 icache_size;
|
||||
u32 icache_block_size;
|
||||
u32 icache_ways;
|
||||
|
||||
u32 dcache_size;
|
||||
u32 dcache_block_size;
|
||||
u32 dcache_ways;
|
||||
struct cache_desc icache;
|
||||
struct cache_desc dcache;
|
||||
|
||||
u16 coreid;
|
||||
};
|
||||
|
@ -32,4 +37,9 @@ struct cpuinfo_or1k {
|
|||
extern struct cpuinfo_or1k cpuinfo_or1k[NR_CPUS];
|
||||
extern void setup_cpuinfo(void);
|
||||
|
||||
/*
|
||||
* Check if the cache component exists.
|
||||
*/
|
||||
extern bool cpu_cache_is_present(const unsigned int cache_type);
|
||||
|
||||
#endif /* __ASM_OPENRISC_CPUINFO_H */
|
||||
|
|
|
@ -7,7 +7,7 @@ extra-y := vmlinux.lds
|
|||
|
||||
obj-y := head.o setup.o or32_ksyms.o process.o dma.o \
|
||||
traps.o time.o irq.o entry.o ptrace.o signal.o \
|
||||
sys_call_table.o unwinder.o
|
||||
sys_call_table.o unwinder.o cacheinfo.o
|
||||
|
||||
obj-$(CONFIG_SMP) += smp.o sync-timer.o
|
||||
obj-$(CONFIG_STACKTRACE) += stacktrace.o
|
||||
|
|
104
arch/openrisc/kernel/cacheinfo.c
Normal file
104
arch/openrisc/kernel/cacheinfo.c
Normal file
|
@ -0,0 +1,104 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* OpenRISC cacheinfo support
|
||||
*
|
||||
* Based on work done for MIPS and LoongArch. All original copyrights
|
||||
* apply as per the original source declaration.
|
||||
*
|
||||
* OpenRISC implementation:
|
||||
* Copyright (C) 2025 Sahil Siddiq <sahilcdq@proton.me>
|
||||
*/
|
||||
|
||||
#include <linux/cacheinfo.h>
|
||||
#include <asm/cpuinfo.h>
|
||||
#include <asm/spr.h>
|
||||
#include <asm/spr_defs.h>
|
||||
|
||||
static inline void ci_leaf_init(struct cacheinfo *this_leaf, enum cache_type type,
|
||||
unsigned int level, struct cache_desc *cache, int cpu)
|
||||
{
|
||||
this_leaf->type = type;
|
||||
this_leaf->level = level;
|
||||
this_leaf->coherency_line_size = cache->block_size;
|
||||
this_leaf->number_of_sets = cache->sets;
|
||||
this_leaf->ways_of_associativity = cache->ways;
|
||||
this_leaf->size = cache->size;
|
||||
cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map);
|
||||
}
|
||||
|
||||
int init_cache_level(unsigned int cpu)
|
||||
{
|
||||
struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[smp_processor_id()];
|
||||
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
|
||||
int leaves = 0, levels = 0;
|
||||
unsigned long upr = mfspr(SPR_UPR);
|
||||
unsigned long iccfgr, dccfgr;
|
||||
|
||||
if (!(upr & SPR_UPR_UP)) {
|
||||
printk(KERN_INFO
|
||||
"-- no UPR register... unable to detect configuration\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (cpu_cache_is_present(SPR_UPR_DCP)) {
|
||||
dccfgr = mfspr(SPR_DCCFGR);
|
||||
cpuinfo->dcache.ways = 1 << (dccfgr & SPR_DCCFGR_NCW);
|
||||
cpuinfo->dcache.sets = 1 << ((dccfgr & SPR_DCCFGR_NCS) >> 3);
|
||||
cpuinfo->dcache.block_size = 16 << ((dccfgr & SPR_DCCFGR_CBS) >> 7);
|
||||
cpuinfo->dcache.size =
|
||||
cpuinfo->dcache.sets * cpuinfo->dcache.ways * cpuinfo->dcache.block_size;
|
||||
leaves += 1;
|
||||
printk(KERN_INFO
|
||||
"-- dcache: %d bytes total, %d bytes/line, %d set(s), %d way(s)\n",
|
||||
cpuinfo->dcache.size, cpuinfo->dcache.block_size,
|
||||
cpuinfo->dcache.sets, cpuinfo->dcache.ways);
|
||||
} else
|
||||
printk(KERN_INFO "-- dcache disabled\n");
|
||||
|
||||
if (cpu_cache_is_present(SPR_UPR_ICP)) {
|
||||
iccfgr = mfspr(SPR_ICCFGR);
|
||||
cpuinfo->icache.ways = 1 << (iccfgr & SPR_ICCFGR_NCW);
|
||||
cpuinfo->icache.sets = 1 << ((iccfgr & SPR_ICCFGR_NCS) >> 3);
|
||||
cpuinfo->icache.block_size = 16 << ((iccfgr & SPR_ICCFGR_CBS) >> 7);
|
||||
cpuinfo->icache.size =
|
||||
cpuinfo->icache.sets * cpuinfo->icache.ways * cpuinfo->icache.block_size;
|
||||
leaves += 1;
|
||||
printk(KERN_INFO
|
||||
"-- icache: %d bytes total, %d bytes/line, %d set(s), %d way(s)\n",
|
||||
cpuinfo->icache.size, cpuinfo->icache.block_size,
|
||||
cpuinfo->icache.sets, cpuinfo->icache.ways);
|
||||
} else
|
||||
printk(KERN_INFO "-- icache disabled\n");
|
||||
|
||||
if (!leaves)
|
||||
return -ENOENT;
|
||||
|
||||
levels = 1;
|
||||
|
||||
this_cpu_ci->num_leaves = leaves;
|
||||
this_cpu_ci->num_levels = levels;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int populate_cache_leaves(unsigned int cpu)
|
||||
{
|
||||
struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[smp_processor_id()];
|
||||
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
|
||||
struct cacheinfo *this_leaf = this_cpu_ci->info_list;
|
||||
int level = 1;
|
||||
|
||||
if (cpu_cache_is_present(SPR_UPR_DCP)) {
|
||||
ci_leaf_init(this_leaf, CACHE_TYPE_DATA, level, &cpuinfo->dcache, cpu);
|
||||
this_leaf->attributes = ((mfspr(SPR_DCCFGR) & SPR_DCCFGR_CWS) >> 8) ?
|
||||
CACHE_WRITE_BACK : CACHE_WRITE_THROUGH;
|
||||
this_leaf++;
|
||||
}
|
||||
|
||||
if (cpu_cache_is_present(SPR_UPR_ICP))
|
||||
ci_leaf_init(this_leaf, CACHE_TYPE_INST, level, &cpuinfo->icache, cpu);
|
||||
|
||||
this_cpu_ci->cpu_map_populated = true;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
#include <linux/pagewalk.h>
|
||||
|
||||
#include <asm/cpuinfo.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/spr_defs.h>
|
||||
#include <asm/tlbflush.h>
|
||||
|
||||
|
@ -24,9 +25,6 @@ static int
|
|||
page_set_nocache(pte_t *pte, unsigned long addr,
|
||||
unsigned long next, struct mm_walk *walk)
|
||||
{
|
||||
unsigned long cl;
|
||||
struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[smp_processor_id()];
|
||||
|
||||
pte_val(*pte) |= _PAGE_CI;
|
||||
|
||||
/*
|
||||
|
@ -36,8 +34,7 @@ page_set_nocache(pte_t *pte, unsigned long addr,
|
|||
flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
|
||||
|
||||
/* Flush page out of dcache */
|
||||
for (cl = __pa(addr); cl < __pa(next); cl += cpuinfo->dcache_block_size)
|
||||
mtspr(SPR_DCBFR, cl);
|
||||
local_dcache_range_flush(__pa(addr), __pa(next));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -98,21 +95,14 @@ void arch_dma_clear_uncached(void *cpu_addr, size_t size)
|
|||
void arch_sync_dma_for_device(phys_addr_t addr, size_t size,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
unsigned long cl;
|
||||
struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[smp_processor_id()];
|
||||
|
||||
switch (dir) {
|
||||
case DMA_TO_DEVICE:
|
||||
/* Flush the dcache for the requested range */
|
||||
for (cl = addr; cl < addr + size;
|
||||
cl += cpuinfo->dcache_block_size)
|
||||
mtspr(SPR_DCBFR, cl);
|
||||
local_dcache_range_flush(addr, addr + size);
|
||||
break;
|
||||
case DMA_FROM_DEVICE:
|
||||
/* Invalidate the dcache for the requested range */
|
||||
for (cl = addr; cl < addr + size;
|
||||
cl += cpuinfo->dcache_block_size)
|
||||
mtspr(SPR_DCBIR, cl);
|
||||
local_dcache_range_inv(addr, addr + size);
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
|
|
|
@ -113,21 +113,6 @@ static void print_cpuinfo(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (upr & SPR_UPR_DCP)
|
||||
printk(KERN_INFO
|
||||
"-- dcache: %4d bytes total, %2d bytes/line, %d way(s)\n",
|
||||
cpuinfo->dcache_size, cpuinfo->dcache_block_size,
|
||||
cpuinfo->dcache_ways);
|
||||
else
|
||||
printk(KERN_INFO "-- dcache disabled\n");
|
||||
if (upr & SPR_UPR_ICP)
|
||||
printk(KERN_INFO
|
||||
"-- icache: %4d bytes total, %2d bytes/line, %d way(s)\n",
|
||||
cpuinfo->icache_size, cpuinfo->icache_block_size,
|
||||
cpuinfo->icache_ways);
|
||||
else
|
||||
printk(KERN_INFO "-- icache disabled\n");
|
||||
|
||||
if (upr & SPR_UPR_DMP)
|
||||
printk(KERN_INFO "-- dmmu: %4d entries, %lu way(s)\n",
|
||||
1 << ((mfspr(SPR_DMMUCFGR) & SPR_DMMUCFGR_NTS) >> 2),
|
||||
|
@ -155,8 +140,6 @@ static void print_cpuinfo(void)
|
|||
void __init setup_cpuinfo(void)
|
||||
{
|
||||
struct device_node *cpu;
|
||||
unsigned long iccfgr, dccfgr;
|
||||
unsigned long cache_set_size;
|
||||
int cpu_id = smp_processor_id();
|
||||
struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[cpu_id];
|
||||
|
||||
|
@ -164,20 +147,6 @@ void __init setup_cpuinfo(void)
|
|||
if (!cpu)
|
||||
panic("Couldn't find CPU%d in device tree...\n", cpu_id);
|
||||
|
||||
iccfgr = mfspr(SPR_ICCFGR);
|
||||
cpuinfo->icache_ways = 1 << (iccfgr & SPR_ICCFGR_NCW);
|
||||
cache_set_size = 1 << ((iccfgr & SPR_ICCFGR_NCS) >> 3);
|
||||
cpuinfo->icache_block_size = 16 << ((iccfgr & SPR_ICCFGR_CBS) >> 7);
|
||||
cpuinfo->icache_size =
|
||||
cache_set_size * cpuinfo->icache_ways * cpuinfo->icache_block_size;
|
||||
|
||||
dccfgr = mfspr(SPR_DCCFGR);
|
||||
cpuinfo->dcache_ways = 1 << (dccfgr & SPR_DCCFGR_NCW);
|
||||
cache_set_size = 1 << ((dccfgr & SPR_DCCFGR_NCS) >> 3);
|
||||
cpuinfo->dcache_block_size = 16 << ((dccfgr & SPR_DCCFGR_CBS) >> 7);
|
||||
cpuinfo->dcache_size =
|
||||
cache_set_size * cpuinfo->dcache_ways * cpuinfo->dcache_block_size;
|
||||
|
||||
if (of_property_read_u32(cpu, "clock-frequency",
|
||||
&cpuinfo->clock_frequency)) {
|
||||
printk(KERN_WARNING
|
||||
|
@ -294,14 +263,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)
|
|||
unsigned int vr, cpucfgr;
|
||||
unsigned int avr;
|
||||
unsigned int version;
|
||||
#ifdef CONFIG_SMP
|
||||
struct cpuinfo_or1k *cpuinfo = v;
|
||||
seq_printf(m, "processor\t\t: %d\n", cpuinfo->coreid);
|
||||
#endif
|
||||
|
||||
vr = mfspr(SPR_VR);
|
||||
cpucfgr = mfspr(SPR_CPUCFGR);
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
seq_printf(m, "processor\t\t: %d\n", cpuinfo->coreid);
|
||||
#endif
|
||||
if (vr & SPR_VR_UVRP) {
|
||||
vr = mfspr(SPR_VR2);
|
||||
version = vr & SPR_VR2_VER;
|
||||
|
@ -320,14 +289,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
|
|||
seq_printf(m, "revision\t\t: %d\n", vr & SPR_VR_REV);
|
||||
}
|
||||
seq_printf(m, "frequency\t\t: %ld\n", loops_per_jiffy * HZ);
|
||||
seq_printf(m, "dcache size\t\t: %d bytes\n", cpuinfo->dcache_size);
|
||||
seq_printf(m, "dcache block size\t: %d bytes\n",
|
||||
cpuinfo->dcache_block_size);
|
||||
seq_printf(m, "dcache ways\t\t: %d\n", cpuinfo->dcache_ways);
|
||||
seq_printf(m, "icache size\t\t: %d bytes\n", cpuinfo->icache_size);
|
||||
seq_printf(m, "icache block size\t: %d bytes\n",
|
||||
cpuinfo->icache_block_size);
|
||||
seq_printf(m, "icache ways\t\t: %d\n", cpuinfo->icache_ways);
|
||||
seq_printf(m, "immu\t\t\t: %d entries, %lu ways\n",
|
||||
1 << ((mfspr(SPR_DMMUCFGR) & SPR_DMMUCFGR_NTS) >> 2),
|
||||
1 + (mfspr(SPR_DMMUCFGR) & SPR_DMMUCFGR_NTW));
|
||||
|
|
|
@ -14,31 +14,70 @@
|
|||
#include <asm/spr_defs.h>
|
||||
#include <asm/cache.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/cpuinfo.h>
|
||||
#include <asm/tlbflush.h>
|
||||
|
||||
static __always_inline void cache_loop(struct page *page, const unsigned int reg)
|
||||
/*
|
||||
* Check if the cache component exists.
|
||||
*/
|
||||
bool cpu_cache_is_present(const unsigned int cache_type)
|
||||
{
|
||||
unsigned long upr = mfspr(SPR_UPR);
|
||||
unsigned long mask = SPR_UPR_UP | cache_type;
|
||||
|
||||
return !((upr & mask) ^ mask);
|
||||
}
|
||||
|
||||
static __always_inline void cache_loop(unsigned long paddr, unsigned long end,
|
||||
const unsigned short reg, const unsigned int cache_type)
|
||||
{
|
||||
if (!cpu_cache_is_present(cache_type))
|
||||
return;
|
||||
|
||||
while (paddr < end) {
|
||||
mtspr(reg, paddr);
|
||||
paddr += L1_CACHE_BYTES;
|
||||
}
|
||||
}
|
||||
|
||||
static __always_inline void cache_loop_page(struct page *page, const unsigned short reg,
|
||||
const unsigned int cache_type)
|
||||
{
|
||||
unsigned long paddr = page_to_pfn(page) << PAGE_SHIFT;
|
||||
unsigned long line = paddr & ~(L1_CACHE_BYTES - 1);
|
||||
unsigned long end = paddr + PAGE_SIZE;
|
||||
|
||||
while (line < paddr + PAGE_SIZE) {
|
||||
mtspr(reg, line);
|
||||
line += L1_CACHE_BYTES;
|
||||
}
|
||||
paddr &= ~(L1_CACHE_BYTES - 1);
|
||||
|
||||
cache_loop(paddr, end, reg, cache_type);
|
||||
}
|
||||
|
||||
void local_dcache_page_flush(struct page *page)
|
||||
{
|
||||
cache_loop(page, SPR_DCBFR);
|
||||
cache_loop_page(page, SPR_DCBFR, SPR_UPR_DCP);
|
||||
}
|
||||
EXPORT_SYMBOL(local_dcache_page_flush);
|
||||
|
||||
void local_icache_page_inv(struct page *page)
|
||||
{
|
||||
cache_loop(page, SPR_ICBIR);
|
||||
cache_loop_page(page, SPR_ICBIR, SPR_UPR_ICP);
|
||||
}
|
||||
EXPORT_SYMBOL(local_icache_page_inv);
|
||||
|
||||
void local_dcache_range_flush(unsigned long start, unsigned long end)
|
||||
{
|
||||
cache_loop(start, end, SPR_DCBFR, SPR_UPR_DCP);
|
||||
}
|
||||
|
||||
void local_dcache_range_inv(unsigned long start, unsigned long end)
|
||||
{
|
||||
cache_loop(start, end, SPR_DCBIR, SPR_UPR_DCP);
|
||||
}
|
||||
|
||||
void local_icache_range_inv(unsigned long start, unsigned long end)
|
||||
{
|
||||
cache_loop(start, end, SPR_ICBIR, SPR_UPR_ICP);
|
||||
}
|
||||
|
||||
void update_cache(struct vm_area_struct *vma, unsigned long address,
|
||||
pte_t *pte)
|
||||
{
|
||||
|
@ -58,4 +97,3 @@ void update_cache(struct vm_area_struct *vma, unsigned long address,
|
|||
sync_icache_dcache(folio_page(folio, nr));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <asm/fixmap.h>
|
||||
#include <asm/tlbflush.h>
|
||||
#include <asm/sections.h>
|
||||
#include <asm/cacheflush.h>
|
||||
|
||||
int mem_init_done;
|
||||
|
||||
|
@ -176,8 +177,8 @@ void __init paging_init(void)
|
|||
barrier();
|
||||
|
||||
/* Invalidate instruction caches after code modification */
|
||||
mtspr(SPR_ICBIR, 0x900);
|
||||
mtspr(SPR_ICBIR, 0xa00);
|
||||
local_icache_block_inv(0x900);
|
||||
local_icache_block_inv(0xa00);
|
||||
|
||||
/* New TLB miss handlers and kernel page tables are in now place.
|
||||
* Make sure that page flags get updated for all pages in TLB by
|
||||
|
|
Loading…
Add table
Reference in a new issue