forked from mirrors/linux
documented (hopefully adequately) in the respective changelogs. Notable
series include:
- Lucas Stach has provided some page-mapping
cleanup/consolidation/maintainability work in the series "mm/treewide:
Remove pXd_huge() API".
- In the series "Allow migrate on protnone reference with
MPOL_PREFERRED_MANY policy", Donet Tom has optimized mempolicy's
MPOL_PREFERRED_MANY mode, yielding almost doubled performance in one
test.
- In their series "Memory allocation profiling" Kent Overstreet and
Suren Baghdasaryan have contributed a means of determining (via
/proc/allocinfo) whereabouts in the kernel memory is being allocated:
number of calls and amount of memory.
- Matthew Wilcox has provided the series "Various significant MM
patches" which does a number of rather unrelated things, but in largely
similar code sites.
- In his series "mm: page_alloc: freelist migratetype hygiene" Johannes
Weiner has fixed the page allocator's handling of migratetype requests,
with resulting improvements in compaction efficiency.
- In the series "make the hugetlb migration strategy consistent" Baolin
Wang has fixed a hugetlb migration issue, which should improve hugetlb
allocation reliability.
- Liu Shixin has hit an I/O meltdown caused by readahead in a
memory-tight memcg. Addressed in the series "Fix I/O high when memory
almost met memcg limit".
- In the series "mm/filemap: optimize folio adding and splitting" Kairui
Song has optimized pagecache insertion, yielding ~10% performance
improvement in one test.
- Baoquan He has cleaned up and consolidated the early zone
initialization code in the series "mm/mm_init.c: refactor
free_area_init_core()".
- Baoquan has also redone some MM initializatio code in the series
"mm/init: minor clean up and improvement".
- MM helper cleanups from Christoph Hellwig in his series "remove
follow_pfn".
- More cleanups from Matthew Wilcox in the series "Various page->flags
cleanups".
- Vlastimil Babka has contributed maintainability improvements in the
series "memcg_kmem hooks refactoring".
- More folio conversions and cleanups in Matthew Wilcox's series
"Convert huge_zero_page to huge_zero_folio"
"khugepaged folio conversions"
"Remove page_idle and page_young wrappers"
"Use folio APIs in procfs"
"Clean up __folio_put()"
"Some cleanups for memory-failure"
"Remove page_mapping()"
"More folio compat code removal"
- David Hildenbrand chipped in with "fs/proc/task_mmu: convert hugetlb
functions to work on folis".
- Code consolidation and cleanup work related to GUP's handling of
hugetlbs in Peter Xu's series "mm/gup: Unify hugetlb, part 2".
- Rick Edgecombe has developed some fixes to stack guard gaps in the
series "Cover a guard gap corner case".
- Jinjiang Tu has fixed KSM's behaviour after a fork+exec in the series
"mm/ksm: fix ksm exec support for prctl".
- Baolin Wang has implemented NUMA balancing for multi-size THPs. This
is a simple first-cut implementation for now. The series is "support
multi-size THP numa balancing".
- Cleanups to vma handling helper functions from Matthew Wilcox in the
series "Unify vma_address and vma_pgoff_address".
- Some selftests maintenance work from Dev Jain in the series
"selftests/mm: mremap_test: Optimizations and style fixes".
- Improvements to the swapping of multi-size THPs from Ryan Roberts in
the series "Swap-out mTHP without splitting".
- Kefeng Wang has significantly optimized the handling of arm64's
permission page faults in the series
"arch/mm/fault: accelerate pagefault when badaccess"
"mm: remove arch's private VM_FAULT_BADMAP/BADACCESS"
- GUP cleanups from David Hildenbrand in "mm/gup: consistently call it
GUP-fast".
- hugetlb fault code cleanups from Vishal Moola in "Hugetlb fault path to
use struct vm_fault".
- selftests build fixes from John Hubbard in the series "Fix
selftests/mm build without requiring "make headers"".
- Memory tiering fixes/improvements from Ho-Ren (Jack) Chuang in the
series "Improved Memory Tier Creation for CPUless NUMA Nodes". Fixes
the initialization code so that migration between different memory types
works as intended.
- David Hildenbrand has improved follow_pte() and fixed an errant driver
in the series "mm: follow_pte() improvements and acrn follow_pte()
fixes".
- David also did some cleanup work on large folio mapcounts in his
series "mm: mapcount for large folios + page_mapcount() cleanups".
- Folio conversions in KSM in Alex Shi's series "transfer page to folio
in KSM".
- Barry Song has added some sysfs stats for monitoring multi-size THP's
in the series "mm: add per-order mTHP alloc and swpout counters".
- Some zswap cleanups from Yosry Ahmed in the series "zswap same-filled
and limit checking cleanups".
- Matthew Wilcox has been looking at buffer_head code and found the
documentation to be lacking. The series is "Improve buffer head
documentation".
- Multi-size THPs get more work, this time from Lance Yang. His series
"mm/madvise: enhance lazyfreeing with mTHP in madvise_free" optimizes
the freeing of these things.
- Kemeng Shi has added more userspace-visible writeback instrumentation
in the series "Improve visibility of writeback".
- Kemeng Shi then sent some maintenance work on top in the series "Fix
and cleanups to page-writeback".
- Matthew Wilcox reduces mmap_lock traffic in the anon vma code in the
series "Improve anon_vma scalability for anon VMAs". Intel's test bot
reported an improbable 3x improvement in one test.
- SeongJae Park adds some DAMON feature work in the series
"mm/damon: add a DAMOS filter type for page granularity access recheck"
"selftests/damon: add DAMOS quota goal test"
- Also some maintenance work in the series
"mm/damon/paddr: simplify page level access re-check for pageout"
"mm/damon: misc fixes and improvements"
- David Hildenbrand has disabled some known-to-fail selftests ni the
series "selftests: mm: cow: flag vmsplice() hugetlb tests as XFAIL".
- memcg metadata storage optimizations from Shakeel Butt in "memcg:
reduce memory consumption by memcg stats".
- DAX fixes and maintenance work from Vishal Verma in the series
"dax/bus.c: Fixups for dax-bus locking".
-----BEGIN PGP SIGNATURE-----
iHUEABYIAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCZkgQYwAKCRDdBJ7gKXxA
jrdKAP9WVJdpEcXxpoub/vVE0UWGtffr8foifi9bCwrQrGh5mgEAx7Yf0+d/oBZB
nvA4E0DcPrUAFy144FNM0NTCb7u9vAw=
=V3R/
-----END PGP SIGNATURE-----
Merge tag 'mm-stable-2024-05-17-19-19' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull mm updates from Andrew Morton:
"The usual shower of singleton fixes and minor series all over MM,
documented (hopefully adequately) in the respective changelogs.
Notable series include:
- Lucas Stach has provided some page-mapping cleanup/consolidation/
maintainability work in the series "mm/treewide: Remove pXd_huge()
API".
- In the series "Allow migrate on protnone reference with
MPOL_PREFERRED_MANY policy", Donet Tom has optimized mempolicy's
MPOL_PREFERRED_MANY mode, yielding almost doubled performance in
one test.
- In their series "Memory allocation profiling" Kent Overstreet and
Suren Baghdasaryan have contributed a means of determining (via
/proc/allocinfo) whereabouts in the kernel memory is being
allocated: number of calls and amount of memory.
- Matthew Wilcox has provided the series "Various significant MM
patches" which does a number of rather unrelated things, but in
largely similar code sites.
- In his series "mm: page_alloc: freelist migratetype hygiene"
Johannes Weiner has fixed the page allocator's handling of
migratetype requests, with resulting improvements in compaction
efficiency.
- In the series "make the hugetlb migration strategy consistent"
Baolin Wang has fixed a hugetlb migration issue, which should
improve hugetlb allocation reliability.
- Liu Shixin has hit an I/O meltdown caused by readahead in a
memory-tight memcg. Addressed in the series "Fix I/O high when
memory almost met memcg limit".
- In the series "mm/filemap: optimize folio adding and splitting"
Kairui Song has optimized pagecache insertion, yielding ~10%
performance improvement in one test.
- Baoquan He has cleaned up and consolidated the early zone
initialization code in the series "mm/mm_init.c: refactor
free_area_init_core()".
- Baoquan has also redone some MM initializatio code in the series
"mm/init: minor clean up and improvement".
- MM helper cleanups from Christoph Hellwig in his series "remove
follow_pfn".
- More cleanups from Matthew Wilcox in the series "Various
page->flags cleanups".
- Vlastimil Babka has contributed maintainability improvements in the
series "memcg_kmem hooks refactoring".
- More folio conversions and cleanups in Matthew Wilcox's series:
"Convert huge_zero_page to huge_zero_folio"
"khugepaged folio conversions"
"Remove page_idle and page_young wrappers"
"Use folio APIs in procfs"
"Clean up __folio_put()"
"Some cleanups for memory-failure"
"Remove page_mapping()"
"More folio compat code removal"
- David Hildenbrand chipped in with "fs/proc/task_mmu: convert
hugetlb functions to work on folis".
- Code consolidation and cleanup work related to GUP's handling of
hugetlbs in Peter Xu's series "mm/gup: Unify hugetlb, part 2".
- Rick Edgecombe has developed some fixes to stack guard gaps in the
series "Cover a guard gap corner case".
- Jinjiang Tu has fixed KSM's behaviour after a fork+exec in the
series "mm/ksm: fix ksm exec support for prctl".
- Baolin Wang has implemented NUMA balancing for multi-size THPs.
This is a simple first-cut implementation for now. The series is
"support multi-size THP numa balancing".
- Cleanups to vma handling helper functions from Matthew Wilcox in
the series "Unify vma_address and vma_pgoff_address".
- Some selftests maintenance work from Dev Jain in the series
"selftests/mm: mremap_test: Optimizations and style fixes".
- Improvements to the swapping of multi-size THPs from Ryan Roberts
in the series "Swap-out mTHP without splitting".
- Kefeng Wang has significantly optimized the handling of arm64's
permission page faults in the series
"arch/mm/fault: accelerate pagefault when badaccess"
"mm: remove arch's private VM_FAULT_BADMAP/BADACCESS"
- GUP cleanups from David Hildenbrand in "mm/gup: consistently call
it GUP-fast".
- hugetlb fault code cleanups from Vishal Moola in "Hugetlb fault
path to use struct vm_fault".
- selftests build fixes from John Hubbard in the series "Fix
selftests/mm build without requiring "make headers"".
- Memory tiering fixes/improvements from Ho-Ren (Jack) Chuang in the
series "Improved Memory Tier Creation for CPUless NUMA Nodes".
Fixes the initialization code so that migration between different
memory types works as intended.
- David Hildenbrand has improved follow_pte() and fixed an errant
driver in the series "mm: follow_pte() improvements and acrn
follow_pte() fixes".
- David also did some cleanup work on large folio mapcounts in his
series "mm: mapcount for large folios + page_mapcount() cleanups".
- Folio conversions in KSM in Alex Shi's series "transfer page to
folio in KSM".
- Barry Song has added some sysfs stats for monitoring multi-size
THP's in the series "mm: add per-order mTHP alloc and swpout
counters".
- Some zswap cleanups from Yosry Ahmed in the series "zswap
same-filled and limit checking cleanups".
- Matthew Wilcox has been looking at buffer_head code and found the
documentation to be lacking. The series is "Improve buffer head
documentation".
- Multi-size THPs get more work, this time from Lance Yang. His
series "mm/madvise: enhance lazyfreeing with mTHP in madvise_free"
optimizes the freeing of these things.
- Kemeng Shi has added more userspace-visible writeback
instrumentation in the series "Improve visibility of writeback".
- Kemeng Shi then sent some maintenance work on top in the series
"Fix and cleanups to page-writeback".
- Matthew Wilcox reduces mmap_lock traffic in the anon vma code in
the series "Improve anon_vma scalability for anon VMAs". Intel's
test bot reported an improbable 3x improvement in one test.
- SeongJae Park adds some DAMON feature work in the series
"mm/damon: add a DAMOS filter type for page granularity access recheck"
"selftests/damon: add DAMOS quota goal test"
- Also some maintenance work in the series
"mm/damon/paddr: simplify page level access re-check for pageout"
"mm/damon: misc fixes and improvements"
- David Hildenbrand has disabled some known-to-fail selftests ni the
series "selftests: mm: cow: flag vmsplice() hugetlb tests as
XFAIL".
- memcg metadata storage optimizations from Shakeel Butt in "memcg:
reduce memory consumption by memcg stats".
- DAX fixes and maintenance work from Vishal Verma in the series
"dax/bus.c: Fixups for dax-bus locking""
* tag 'mm-stable-2024-05-17-19-19' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (426 commits)
memcg, oom: cleanup unused memcg_oom_gfp_mask and memcg_oom_order
selftests/mm: hugetlb_madv_vs_map: avoid test skipping by querying hugepage size at runtime
mm/hugetlb: add missing VM_FAULT_SET_HINDEX in hugetlb_wp
mm/hugetlb: add missing VM_FAULT_SET_HINDEX in hugetlb_fault
selftests: cgroup: add tests to verify the zswap writeback path
mm: memcg: make alloc_mem_cgroup_per_node_info() return bool
mm/damon/core: fix return value from damos_wmark_metric_value
mm: do not update memcg stats for NR_{FILE/SHMEM}_PMDMAPPED
selftests: cgroup: remove redundant enabling of memory controller
Docs/mm/damon/maintainer-profile: allow posting patches based on damon/next tree
Docs/mm/damon/maintainer-profile: change the maintainer's timezone from PST to PT
Docs/mm/damon/design: use a list for supported filters
Docs/admin-guide/mm/damon/usage: fix wrong schemes effective quota update command
Docs/admin-guide/mm/damon/usage: fix wrong example of DAMOS filter matching sysfs file
selftests/damon: classify tests for functionalities and regressions
selftests/damon/_damon_sysfs: use 'is' instead of '==' for 'None'
selftests/damon/_damon_sysfs: find sysfs mount point from /proc/mounts
selftests/damon/_damon_sysfs: check errors from nr_schemes file reads
mm/damon/core: initialize ->esz_bp from damos_quota_init_priv()
selftests/damon: add a test for DAMOS quota goal
...
354 lines
9.3 KiB
C
354 lines
9.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* arch/sh/mm/cache.c
|
|
*
|
|
* Copyright (C) 1999, 2000, 2002 Niibe Yutaka
|
|
* Copyright (C) 2002 - 2010 Paul Mundt
|
|
*/
|
|
#include <linux/mm.h>
|
|
#include <linux/init.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/module.h>
|
|
#include <asm/mmu_context.h>
|
|
#include <asm/cacheflush.h>
|
|
|
|
void (*local_flush_cache_all)(void *args) = cache_noop;
|
|
void (*local_flush_cache_mm)(void *args) = cache_noop;
|
|
void (*local_flush_cache_dup_mm)(void *args) = cache_noop;
|
|
void (*local_flush_cache_page)(void *args) = cache_noop;
|
|
void (*local_flush_cache_range)(void *args) = cache_noop;
|
|
void (*local_flush_dcache_folio)(void *args) = cache_noop;
|
|
void (*local_flush_icache_range)(void *args) = cache_noop;
|
|
void (*local_flush_icache_folio)(void *args) = cache_noop;
|
|
void (*local_flush_cache_sigtramp)(void *args) = cache_noop;
|
|
|
|
void (*__flush_wback_region)(void *start, int size);
|
|
EXPORT_SYMBOL(__flush_wback_region);
|
|
void (*__flush_purge_region)(void *start, int size);
|
|
EXPORT_SYMBOL(__flush_purge_region);
|
|
void (*__flush_invalidate_region)(void *start, int size);
|
|
EXPORT_SYMBOL(__flush_invalidate_region);
|
|
|
|
static inline void noop__flush_region(void *start, int size)
|
|
{
|
|
}
|
|
|
|
static inline void cacheop_on_each_cpu(void (*func) (void *info), void *info,
|
|
int wait)
|
|
{
|
|
preempt_disable();
|
|
|
|
/* Needing IPI for cross-core flush is SHX3-specific. */
|
|
#ifdef CONFIG_CPU_SHX3
|
|
/*
|
|
* It's possible that this gets called early on when IRQs are
|
|
* still disabled due to ioremapping by the boot CPU, so don't
|
|
* even attempt IPIs unless there are other CPUs online.
|
|
*/
|
|
if (num_online_cpus() > 1)
|
|
smp_call_function(func, info, wait);
|
|
#endif
|
|
|
|
func(info);
|
|
|
|
preempt_enable();
|
|
}
|
|
|
|
void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
|
|
unsigned long vaddr, void *dst, const void *src,
|
|
unsigned long len)
|
|
{
|
|
struct folio *folio = page_folio(page);
|
|
|
|
if (boot_cpu_data.dcache.n_aliases && folio_mapped(folio) &&
|
|
test_bit(PG_dcache_clean, &folio->flags)) {
|
|
void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
|
|
memcpy(vto, src, len);
|
|
kunmap_coherent(vto);
|
|
} else {
|
|
memcpy(dst, src, len);
|
|
if (boot_cpu_data.dcache.n_aliases)
|
|
clear_bit(PG_dcache_clean, &folio->flags);
|
|
}
|
|
|
|
if (vma->vm_flags & VM_EXEC)
|
|
flush_cache_page(vma, vaddr, page_to_pfn(page));
|
|
}
|
|
|
|
void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
|
|
unsigned long vaddr, void *dst, const void *src,
|
|
unsigned long len)
|
|
{
|
|
struct folio *folio = page_folio(page);
|
|
|
|
if (boot_cpu_data.dcache.n_aliases && folio_mapped(folio) &&
|
|
test_bit(PG_dcache_clean, &folio->flags)) {
|
|
void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
|
|
memcpy(dst, vfrom, len);
|
|
kunmap_coherent(vfrom);
|
|
} else {
|
|
memcpy(dst, src, len);
|
|
if (boot_cpu_data.dcache.n_aliases)
|
|
clear_bit(PG_dcache_clean, &folio->flags);
|
|
}
|
|
}
|
|
|
|
void copy_user_highpage(struct page *to, struct page *from,
|
|
unsigned long vaddr, struct vm_area_struct *vma)
|
|
{
|
|
struct folio *src = page_folio(from);
|
|
void *vfrom, *vto;
|
|
|
|
vto = kmap_atomic(to);
|
|
|
|
if (boot_cpu_data.dcache.n_aliases && folio_mapped(src) &&
|
|
test_bit(PG_dcache_clean, &src->flags)) {
|
|
vfrom = kmap_coherent(from, vaddr);
|
|
copy_page(vto, vfrom);
|
|
kunmap_coherent(vfrom);
|
|
} else {
|
|
vfrom = kmap_atomic(from);
|
|
copy_page(vto, vfrom);
|
|
kunmap_atomic(vfrom);
|
|
}
|
|
|
|
if (pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK) ||
|
|
(vma->vm_flags & VM_EXEC))
|
|
__flush_purge_region(vto, PAGE_SIZE);
|
|
|
|
kunmap_atomic(vto);
|
|
/* Make sure this page is cleared on other CPU's too before using it */
|
|
smp_wmb();
|
|
}
|
|
EXPORT_SYMBOL(copy_user_highpage);
|
|
|
|
void clear_user_highpage(struct page *page, unsigned long vaddr)
|
|
{
|
|
void *kaddr = kmap_atomic(page);
|
|
|
|
clear_page(kaddr);
|
|
|
|
if (pages_do_alias((unsigned long)kaddr, vaddr & PAGE_MASK))
|
|
__flush_purge_region(kaddr, PAGE_SIZE);
|
|
|
|
kunmap_atomic(kaddr);
|
|
}
|
|
EXPORT_SYMBOL(clear_user_highpage);
|
|
|
|
void __update_cache(struct vm_area_struct *vma,
|
|
unsigned long address, pte_t pte)
|
|
{
|
|
unsigned long pfn = pte_pfn(pte);
|
|
|
|
if (!boot_cpu_data.dcache.n_aliases)
|
|
return;
|
|
|
|
if (pfn_valid(pfn)) {
|
|
struct folio *folio = page_folio(pfn_to_page(pfn));
|
|
int dirty = !test_and_set_bit(PG_dcache_clean, &folio->flags);
|
|
if (dirty)
|
|
__flush_purge_region(folio_address(folio),
|
|
folio_size(folio));
|
|
}
|
|
}
|
|
|
|
void __flush_anon_page(struct page *page, unsigned long vmaddr)
|
|
{
|
|
struct folio *folio = page_folio(page);
|
|
unsigned long addr = (unsigned long) page_address(page);
|
|
|
|
if (pages_do_alias(addr, vmaddr)) {
|
|
if (boot_cpu_data.dcache.n_aliases && folio_mapped(folio) &&
|
|
test_bit(PG_dcache_clean, &folio->flags)) {
|
|
void *kaddr;
|
|
|
|
kaddr = kmap_coherent(page, vmaddr);
|
|
/* XXX.. For now kunmap_coherent() does a purge */
|
|
/* __flush_purge_region((void *)kaddr, PAGE_SIZE); */
|
|
kunmap_coherent(kaddr);
|
|
} else
|
|
__flush_purge_region(folio_address(folio),
|
|
folio_size(folio));
|
|
}
|
|
}
|
|
|
|
void flush_cache_all(void)
|
|
{
|
|
cacheop_on_each_cpu(local_flush_cache_all, NULL, 1);
|
|
}
|
|
EXPORT_SYMBOL(flush_cache_all);
|
|
|
|
void flush_cache_mm(struct mm_struct *mm)
|
|
{
|
|
if (boot_cpu_data.dcache.n_aliases == 0)
|
|
return;
|
|
|
|
cacheop_on_each_cpu(local_flush_cache_mm, mm, 1);
|
|
}
|
|
|
|
void flush_cache_dup_mm(struct mm_struct *mm)
|
|
{
|
|
if (boot_cpu_data.dcache.n_aliases == 0)
|
|
return;
|
|
|
|
cacheop_on_each_cpu(local_flush_cache_dup_mm, mm, 1);
|
|
}
|
|
|
|
void flush_cache_page(struct vm_area_struct *vma, unsigned long addr,
|
|
unsigned long pfn)
|
|
{
|
|
struct flusher_data data;
|
|
|
|
data.vma = vma;
|
|
data.addr1 = addr;
|
|
data.addr2 = pfn;
|
|
|
|
cacheop_on_each_cpu(local_flush_cache_page, (void *)&data, 1);
|
|
}
|
|
|
|
void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
|
|
unsigned long end)
|
|
{
|
|
struct flusher_data data;
|
|
|
|
data.vma = vma;
|
|
data.addr1 = start;
|
|
data.addr2 = end;
|
|
|
|
cacheop_on_each_cpu(local_flush_cache_range, (void *)&data, 1);
|
|
}
|
|
EXPORT_SYMBOL(flush_cache_range);
|
|
|
|
void flush_dcache_folio(struct folio *folio)
|
|
{
|
|
cacheop_on_each_cpu(local_flush_dcache_folio, folio, 1);
|
|
}
|
|
EXPORT_SYMBOL(flush_dcache_folio);
|
|
|
|
void flush_icache_range(unsigned long start, unsigned long end)
|
|
{
|
|
struct flusher_data data;
|
|
|
|
data.vma = NULL;
|
|
data.addr1 = start;
|
|
data.addr2 = end;
|
|
|
|
cacheop_on_each_cpu(local_flush_icache_range, (void *)&data, 1);
|
|
}
|
|
EXPORT_SYMBOL(flush_icache_range);
|
|
|
|
void flush_icache_pages(struct vm_area_struct *vma, struct page *page,
|
|
unsigned int nr)
|
|
{
|
|
/* Nothing uses the VMA, so just pass the folio along */
|
|
cacheop_on_each_cpu(local_flush_icache_folio, page_folio(page), 1);
|
|
}
|
|
|
|
void flush_cache_sigtramp(unsigned long address)
|
|
{
|
|
cacheop_on_each_cpu(local_flush_cache_sigtramp, (void *)address, 1);
|
|
}
|
|
|
|
static void compute_alias(struct cache_info *c)
|
|
{
|
|
#ifdef CONFIG_MMU
|
|
c->alias_mask = ((c->sets - 1) << c->entry_shift) & ~(PAGE_SIZE - 1);
|
|
#else
|
|
c->alias_mask = 0;
|
|
#endif
|
|
c->n_aliases = c->alias_mask ? (c->alias_mask >> PAGE_SHIFT) + 1 : 0;
|
|
}
|
|
|
|
static void __init emit_cache_params(void)
|
|
{
|
|
printk(KERN_NOTICE "I-cache : n_ways=%d n_sets=%d way_incr=%d\n",
|
|
boot_cpu_data.icache.ways,
|
|
boot_cpu_data.icache.sets,
|
|
boot_cpu_data.icache.way_incr);
|
|
printk(KERN_NOTICE "I-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
|
|
boot_cpu_data.icache.entry_mask,
|
|
boot_cpu_data.icache.alias_mask,
|
|
boot_cpu_data.icache.n_aliases);
|
|
printk(KERN_NOTICE "D-cache : n_ways=%d n_sets=%d way_incr=%d\n",
|
|
boot_cpu_data.dcache.ways,
|
|
boot_cpu_data.dcache.sets,
|
|
boot_cpu_data.dcache.way_incr);
|
|
printk(KERN_NOTICE "D-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
|
|
boot_cpu_data.dcache.entry_mask,
|
|
boot_cpu_data.dcache.alias_mask,
|
|
boot_cpu_data.dcache.n_aliases);
|
|
|
|
/*
|
|
* Emit Secondary Cache parameters if the CPU has a probed L2.
|
|
*/
|
|
if (boot_cpu_data.flags & CPU_HAS_L2_CACHE) {
|
|
printk(KERN_NOTICE "S-cache : n_ways=%d n_sets=%d way_incr=%d\n",
|
|
boot_cpu_data.scache.ways,
|
|
boot_cpu_data.scache.sets,
|
|
boot_cpu_data.scache.way_incr);
|
|
printk(KERN_NOTICE "S-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
|
|
boot_cpu_data.scache.entry_mask,
|
|
boot_cpu_data.scache.alias_mask,
|
|
boot_cpu_data.scache.n_aliases);
|
|
}
|
|
}
|
|
|
|
void __init cpu_cache_init(void)
|
|
{
|
|
unsigned int cache_disabled = 0;
|
|
|
|
#ifdef SH_CCR
|
|
cache_disabled = !(__raw_readl(SH_CCR) & CCR_CACHE_ENABLE);
|
|
#endif
|
|
|
|
compute_alias(&boot_cpu_data.icache);
|
|
compute_alias(&boot_cpu_data.dcache);
|
|
compute_alias(&boot_cpu_data.scache);
|
|
|
|
__flush_wback_region = noop__flush_region;
|
|
__flush_purge_region = noop__flush_region;
|
|
__flush_invalidate_region = noop__flush_region;
|
|
|
|
/*
|
|
* No flushing is necessary in the disabled cache case so we can
|
|
* just keep the noop functions in local_flush_..() and __flush_..()
|
|
*/
|
|
if (unlikely(cache_disabled))
|
|
goto skip;
|
|
|
|
if (boot_cpu_data.type == CPU_J2) {
|
|
j2_cache_init();
|
|
} else if (boot_cpu_data.family == CPU_FAMILY_SH2) {
|
|
sh2_cache_init();
|
|
}
|
|
|
|
if (boot_cpu_data.family == CPU_FAMILY_SH2A) {
|
|
sh2a_cache_init();
|
|
}
|
|
|
|
if (boot_cpu_data.family == CPU_FAMILY_SH3) {
|
|
sh3_cache_init();
|
|
|
|
if ((boot_cpu_data.type == CPU_SH7705) &&
|
|
(boot_cpu_data.dcache.sets == 512)) {
|
|
sh7705_cache_init();
|
|
}
|
|
}
|
|
|
|
if ((boot_cpu_data.family == CPU_FAMILY_SH4) ||
|
|
(boot_cpu_data.family == CPU_FAMILY_SH4A) ||
|
|
(boot_cpu_data.family == CPU_FAMILY_SH4AL_DSP)) {
|
|
sh4_cache_init();
|
|
|
|
if ((boot_cpu_data.type == CPU_SH7786) ||
|
|
(boot_cpu_data.type == CPU_SHX3)) {
|
|
shx3_cache_init();
|
|
}
|
|
}
|
|
|
|
skip:
|
|
emit_cache_params();
|
|
}
|