License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* srmmu.c: SRMMU specific routines for memory management.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
* Copyright (C) 1995,2002 Pete Zaitcev (zaitcev@yahoo.com)
|
|
|
|
* Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
|
|
|
|
* Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
|
|
* Copyright (C) 1999,2000 Anton Blanchard (anton@samba.org)
|
|
|
|
*/
|
|
|
|
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <linux/seq_file.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/spinlock.h>
|
2018-10-31 01:09:49 +03:00
|
|
|
#include <linux/memblock.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/vmalloc.h>
|
2007-05-08 11:27:03 +04:00
|
|
|
#include <linux/kdebug.h>
|
sparc32: make copy_to/from_user_page() usable from modular code
While copy_to/from_user_page() users are uncommon, there is one in
drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c which leads
to the following:
ERROR: "sparc32_cachetlb_ops" [drivers/staging/lustre/lustre/libcfs/libcfs.ko] undefined!
during routine allmodconfig build coverage. The reason this happens
is as follows:
In arch/sparc/include/asm/cacheflush_32.h we have:
#define flush_cache_page(vma,addr,pfn) \
sparc32_cachetlb_ops->cache_page(vma, addr)
#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
do { \
flush_cache_page(vma, vaddr, page_to_pfn(page));\
memcpy(dst, src, len); \
} while (0)
#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
do { \
flush_cache_page(vma, vaddr, page_to_pfn(page));\
memcpy(dst, src, len); \
} while (0)
However, sparc32_cachetlb_ops isn't exported and hence the error.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-14 01:15:01 +04:00
|
|
|
#include <linux/export.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
2009-04-24 07:58:24 +04:00
|
|
|
#include <linux/log2.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/gfp.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mm.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/mmu_context.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
#include <asm/io-unit.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/pgtable.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/bitext.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/vaddrs.h>
|
|
|
|
#include <asm/cache.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/traps.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/oplib.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/mbus.h>
|
|
|
|
#include <asm/page.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/asi.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/smp.h>
|
|
|
|
#include <asm/io.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Now the cpu specific definitions. */
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/turbosparc.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/tsunami.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/viking.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/swift.h>
|
2009-08-17 04:13:33 +04:00
|
|
|
#include <asm/leon.h>
|
2012-07-26 15:02:12 +04:00
|
|
|
#include <asm/mxcc.h>
|
|
|
|
#include <asm/ross.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2014-04-21 23:39:16 +04:00
|
|
|
#include "mm_32.h"
|
2012-05-20 00:02:49 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
enum mbus_module srmmu_modtype;
|
2008-06-05 22:41:51 +04:00
|
|
|
static unsigned int hwbug_bitmask;
|
2005-04-17 02:20:36 +04:00
|
|
|
int vac_cache_size;
|
2017-04-01 23:47:44 +03:00
|
|
|
EXPORT_SYMBOL(vac_cache_size);
|
2005-04-17 02:20:36 +04:00
|
|
|
int vac_line_size;
|
|
|
|
|
|
|
|
extern struct resource sparc_iomap;
|
|
|
|
|
|
|
|
extern unsigned long last_valid_pfn;
|
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static pgd_t *srmmu_swapper_pg_dir;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
const struct sparc32_cachetlb_ops *sparc32_cachetlb_ops;
|
sparc32: make copy_to/from_user_page() usable from modular code
While copy_to/from_user_page() users are uncommon, there is one in
drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c which leads
to the following:
ERROR: "sparc32_cachetlb_ops" [drivers/staging/lustre/lustre/libcfs/libcfs.ko] undefined!
during routine allmodconfig build coverage. The reason this happens
is as follows:
In arch/sparc/include/asm/cacheflush_32.h we have:
#define flush_cache_page(vma,addr,pfn) \
sparc32_cachetlb_ops->cache_page(vma, addr)
#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
do { \
flush_cache_page(vma, vaddr, page_to_pfn(page));\
memcpy(dst, src, len); \
} while (0)
#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
do { \
flush_cache_page(vma, vaddr, page_to_pfn(page));\
memcpy(dst, src, len); \
} while (0)
However, sparc32_cachetlb_ops isn't exported and hence the error.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-14 01:15:01 +04:00
|
|
|
EXPORT_SYMBOL(sparc32_cachetlb_ops);
|
2012-05-14 07:49:31 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef CONFIG_SMP
|
2012-05-14 07:49:31 +04:00
|
|
|
const struct sparc32_cachetlb_ops *local_ops;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#define FLUSH_BEGIN(mm)
|
|
|
|
#define FLUSH_END
|
|
|
|
#else
|
2012-05-14 07:49:31 +04:00
|
|
|
#define FLUSH_BEGIN(mm) if ((mm)->context != NO_CONTEXT) {
|
2005-04-17 02:20:36 +04:00
|
|
|
#define FLUSH_END }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int flush_page_for_dma_global = 1;
|
|
|
|
|
|
|
|
char *srmmu_name;
|
|
|
|
|
|
|
|
ctxd_t *srmmu_ctx_table_phys;
|
2008-06-05 22:41:51 +04:00
|
|
|
static ctxd_t *srmmu_context_table;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
int viking_mxcc_present;
|
|
|
|
static DEFINE_SPINLOCK(srmmu_context_spinlock);
|
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static int is_hypersparc;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static int srmmu_cache_pagetables;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* these will be initialized in srmmu_nocache_calcsize() */
|
2008-06-05 22:41:51 +04:00
|
|
|
static unsigned long srmmu_nocache_size;
|
|
|
|
static unsigned long srmmu_nocache_end;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* 1 bit <=> 256 bytes of nocache <=> 64 PTEs */
|
|
|
|
#define SRMMU_NOCACHE_BITMAP_SHIFT (PAGE_SHIFT - 4)
|
|
|
|
|
|
|
|
/* The context table is a nocache user with the biggest alignment needs. */
|
|
|
|
#define SRMMU_NOCACHE_ALIGN_MAX (sizeof(ctxd_t)*SRMMU_MAX_CONTEXTS)
|
|
|
|
|
|
|
|
void *srmmu_nocache_pool;
|
|
|
|
static struct bit_map srmmu_nocache_map;
|
|
|
|
|
|
|
|
static inline int srmmu_pmd_none(pmd_t pmd)
|
|
|
|
{ return !(pmd_val(pmd) & 0xFFFFFFF); }
|
|
|
|
|
|
|
|
/* XXX should we hyper_flush_whole_icache here - Anton */
|
|
|
|
static inline void srmmu_ctxd_set(ctxd_t *ctxp, pgd_t *pgdp)
|
2016-04-22 20:41:06 +03:00
|
|
|
{
|
|
|
|
pte_t pte;
|
|
|
|
|
|
|
|
pte = __pte((SRMMU_ET_PTD | (__nocache_pa(pgdp) >> 4)));
|
|
|
|
set_pte((pte_t *)ctxp, pte);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-07-24 14:53:04 +03:00
|
|
|
/*
|
|
|
|
* Locations of MSI Registers.
|
|
|
|
*/
|
|
|
|
#define MSI_MBUS_ARBEN 0xe0001008 /* MBus Arbiter Enable register */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Useful bits in the MSI Registers.
|
|
|
|
*/
|
|
|
|
#define MSI_ASYNC_MODE 0x80000000 /* Operate the MSI asynchronously */
|
|
|
|
|
|
|
|
static void msi_set_sync(void)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ ("lda [%0] %1, %%g3\n\t"
|
|
|
|
"andn %%g3, %2, %%g3\n\t"
|
|
|
|
"sta %%g3, [%0] %1\n\t" : :
|
|
|
|
"r" (MSI_MBUS_ARBEN),
|
|
|
|
"i" (ASI_M_CTL), "r" (MSI_ASYNC_MODE) : "g3");
|
|
|
|
}
|
|
|
|
|
2012-05-13 10:40:27 +04:00
|
|
|
void pmd_set(pmd_t *pmdp, pte_t *ptep)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2020-04-15 00:40:09 +03:00
|
|
|
unsigned long ptp = __nocache_pa(ptep) >> 4;
|
|
|
|
set_pte((pte_t *)&pmd_val(*pmdp), __pte(SRMMU_ET_PTD | ptp));
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* size: bytes to allocate in the nocache area.
|
|
|
|
* align: bytes, number to align at.
|
|
|
|
* Returns the virtual address of the allocated area.
|
|
|
|
*/
|
2012-07-26 15:02:14 +04:00
|
|
|
static void *__srmmu_get_nocache(int size, int align)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2020-04-15 00:40:08 +03:00
|
|
|
int offset, minsz = 1 << SRMMU_NOCACHE_BITMAP_SHIFT;
|
2012-07-26 15:02:14 +04:00
|
|
|
unsigned long addr;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2020-04-15 00:40:08 +03:00
|
|
|
if (size < minsz) {
|
2012-07-26 15:02:14 +04:00
|
|
|
printk(KERN_ERR "Size 0x%x too small for nocache request\n",
|
|
|
|
size);
|
2020-04-15 00:40:08 +03:00
|
|
|
size = minsz;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2020-04-15 00:40:08 +03:00
|
|
|
if (size & (minsz - 1)) {
|
|
|
|
printk(KERN_ERR "Size 0x%x unaligned in nocache request\n",
|
2012-07-26 15:02:14 +04:00
|
|
|
size);
|
2020-04-15 00:40:08 +03:00
|
|
|
size += minsz - 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
BUG_ON(align > SRMMU_NOCACHE_ALIGN_MAX);
|
|
|
|
|
|
|
|
offset = bit_map_string_get(&srmmu_nocache_map,
|
2012-07-26 15:02:14 +04:00
|
|
|
size >> SRMMU_NOCACHE_BITMAP_SHIFT,
|
|
|
|
align >> SRMMU_NOCACHE_BITMAP_SHIFT);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (offset == -1) {
|
2012-07-26 15:02:14 +04:00
|
|
|
printk(KERN_ERR "srmmu: out of nocache %d: %d/%d\n",
|
|
|
|
size, (int) srmmu_nocache_size,
|
|
|
|
srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT);
|
2014-04-21 23:39:19 +04:00
|
|
|
return NULL;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:14 +04:00
|
|
|
addr = SRMMU_NOCACHE_VADDR + (offset << SRMMU_NOCACHE_BITMAP_SHIFT);
|
|
|
|
return (void *)addr;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:14 +04:00
|
|
|
void *srmmu_get_nocache(int size, int align)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-07-26 15:02:14 +04:00
|
|
|
void *tmp;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
tmp = __srmmu_get_nocache(size, align);
|
|
|
|
|
|
|
|
if (tmp)
|
2012-07-26 15:02:14 +04:00
|
|
|
memset(tmp, 0, size);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:14 +04:00
|
|
|
void srmmu_free_nocache(void *addr, int size)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-07-26 15:02:14 +04:00
|
|
|
unsigned long vaddr;
|
2005-04-17 02:20:36 +04:00
|
|
|
int offset;
|
|
|
|
|
2012-07-26 15:02:14 +04:00
|
|
|
vaddr = (unsigned long)addr;
|
2005-04-17 02:20:36 +04:00
|
|
|
if (vaddr < SRMMU_NOCACHE_VADDR) {
|
|
|
|
printk("Vaddr %lx is smaller than nocache base 0x%lx\n",
|
|
|
|
vaddr, (unsigned long)SRMMU_NOCACHE_VADDR);
|
|
|
|
BUG();
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
if (vaddr + size > srmmu_nocache_end) {
|
2005-04-17 02:20:36 +04:00
|
|
|
printk("Vaddr %lx is bigger than nocache end 0x%lx\n",
|
|
|
|
vaddr, srmmu_nocache_end);
|
|
|
|
BUG();
|
|
|
|
}
|
2009-04-24 07:58:24 +04:00
|
|
|
if (!is_power_of_2(size)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
printk("Size 0x%x is not a power of 2\n", size);
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
if (size < SRMMU_NOCACHE_BITMAP_SHIFT) {
|
|
|
|
printk("Size 0x%x is too small\n", size);
|
|
|
|
BUG();
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
if (vaddr & (size - 1)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
printk("Vaddr %lx is not aligned to size 0x%x\n", vaddr, size);
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
|
|
|
offset = (vaddr - SRMMU_NOCACHE_VADDR) >> SRMMU_NOCACHE_BITMAP_SHIFT;
|
|
|
|
size = size >> SRMMU_NOCACHE_BITMAP_SHIFT;
|
|
|
|
|
|
|
|
bit_map_clear(&srmmu_nocache_map, offset, size);
|
|
|
|
}
|
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static void srmmu_early_allocate_ptable_skeleton(unsigned long start,
|
|
|
|
unsigned long end);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-07-26 15:02:26 +04:00
|
|
|
/* Return how much physical memory we have. */
|
|
|
|
static unsigned long __init probe_memory(void)
|
|
|
|
{
|
|
|
|
unsigned long total = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; sp_banks[i].num_bytes; i++)
|
|
|
|
total += sp_banks[i].num_bytes;
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reserve nocache dynamically proportionally to the amount of
|
|
|
|
* system RAM. -- Tomas Szepe <szepe@pinerecords.com>, June 2002
|
|
|
|
*/
|
2012-07-26 15:02:11 +04:00
|
|
|
static void __init srmmu_nocache_calcsize(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned long sysmemavail = probe_memory() / 1024;
|
|
|
|
int srmmu_nocache_npages;
|
|
|
|
|
|
|
|
srmmu_nocache_npages =
|
|
|
|
sysmemavail / SRMMU_NOCACHE_ALCRATIO / 1024 * 256;
|
|
|
|
|
|
|
|
/* P3 XXX The 4x overuse: corroborated by /proc/meminfo. */
|
|
|
|
// if (srmmu_nocache_npages < 256) srmmu_nocache_npages = 256;
|
|
|
|
if (srmmu_nocache_npages < SRMMU_MIN_NOCACHE_PAGES)
|
|
|
|
srmmu_nocache_npages = SRMMU_MIN_NOCACHE_PAGES;
|
|
|
|
|
|
|
|
/* anything above 1280 blows up */
|
|
|
|
if (srmmu_nocache_npages > SRMMU_MAX_NOCACHE_PAGES)
|
|
|
|
srmmu_nocache_npages = SRMMU_MAX_NOCACHE_PAGES;
|
|
|
|
|
|
|
|
srmmu_nocache_size = srmmu_nocache_npages * PAGE_SIZE;
|
|
|
|
srmmu_nocache_end = SRMMU_NOCACHE_VADDR + srmmu_nocache_size;
|
|
|
|
}
|
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static void __init srmmu_nocache_init(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2014-04-21 23:39:19 +04:00
|
|
|
void *srmmu_nocache_bitmap;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int bitmap_bits;
|
|
|
|
pgd_t *pgd;
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d_t *p4d;
|
|
|
|
pud_t *pud;
|
2005-04-17 02:20:36 +04:00
|
|
|
pmd_t *pmd;
|
|
|
|
pte_t *pte;
|
|
|
|
unsigned long paddr, vaddr;
|
|
|
|
unsigned long pteval;
|
|
|
|
|
|
|
|
bitmap_bits = srmmu_nocache_size >> SRMMU_NOCACHE_BITMAP_SHIFT;
|
|
|
|
|
2019-03-12 09:29:50 +03:00
|
|
|
srmmu_nocache_pool = memblock_alloc(srmmu_nocache_size,
|
|
|
|
SRMMU_NOCACHE_ALIGN_MAX);
|
2019-03-12 09:30:10 +03:00
|
|
|
if (!srmmu_nocache_pool)
|
|
|
|
panic("%s: Failed to allocate %lu bytes align=0x%x\n",
|
|
|
|
__func__, srmmu_nocache_size, SRMMU_NOCACHE_ALIGN_MAX);
|
2005-04-17 02:20:36 +04:00
|
|
|
memset(srmmu_nocache_pool, 0, srmmu_nocache_size);
|
|
|
|
|
2013-03-29 07:44:43 +04:00
|
|
|
srmmu_nocache_bitmap =
|
2019-03-12 09:29:50 +03:00
|
|
|
memblock_alloc(BITS_TO_LONGS(bitmap_bits) * sizeof(long),
|
|
|
|
SMP_CACHE_BYTES);
|
2019-03-12 09:30:10 +03:00
|
|
|
if (!srmmu_nocache_bitmap)
|
|
|
|
panic("%s: Failed to allocate %zu bytes\n", __func__,
|
|
|
|
BITS_TO_LONGS(bitmap_bits) * sizeof(long));
|
2005-04-17 02:20:36 +04:00
|
|
|
bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits);
|
|
|
|
|
2012-07-26 15:02:14 +04:00
|
|
|
srmmu_swapper_pg_dir = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE);
|
2005-04-17 02:20:36 +04:00
|
|
|
memset(__nocache_fix(srmmu_swapper_pg_dir), 0, SRMMU_PGD_TABLE_SIZE);
|
|
|
|
init_mm.pgd = srmmu_swapper_pg_dir;
|
|
|
|
|
|
|
|
srmmu_early_allocate_ptable_skeleton(SRMMU_NOCACHE_VADDR, srmmu_nocache_end);
|
|
|
|
|
|
|
|
paddr = __pa((unsigned long)srmmu_nocache_pool);
|
|
|
|
vaddr = SRMMU_NOCACHE_VADDR;
|
|
|
|
|
|
|
|
while (vaddr < srmmu_nocache_end) {
|
|
|
|
pgd = pgd_offset_k(vaddr);
|
2020-05-23 22:57:18 +03:00
|
|
|
p4d = p4d_offset(pgd, vaddr);
|
|
|
|
pud = pud_offset(p4d, vaddr);
|
2020-05-23 08:23:09 +03:00
|
|
|
pmd = pmd_offset(__nocache_fix(pud), vaddr);
|
2012-05-13 12:21:25 +04:00
|
|
|
pte = pte_offset_kernel(__nocache_fix(pmd), vaddr);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
pteval = ((paddr >> 4) | SRMMU_ET_PTE | SRMMU_PRIV);
|
|
|
|
|
|
|
|
if (srmmu_cache_pagetables)
|
|
|
|
pteval |= SRMMU_CACHE;
|
|
|
|
|
2012-05-13 00:39:23 +04:00
|
|
|
set_pte(__nocache_fix(pte), __pte(pteval));
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
vaddr += PAGE_SIZE;
|
|
|
|
paddr += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_cache_all();
|
|
|
|
flush_tlb_all();
|
|
|
|
}
|
|
|
|
|
2012-05-13 10:40:27 +04:00
|
|
|
pgd_t *get_pgd_fast(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
pgd_t *pgd = NULL;
|
|
|
|
|
2012-07-26 15:02:14 +04:00
|
|
|
pgd = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (pgd) {
|
|
|
|
pgd_t *init = pgd_offset_k(0);
|
|
|
|
memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
|
|
|
|
memcpy(pgd + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
|
|
|
|
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
return pgd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hardware needs alignment to 256 only, but we align to whole page size
|
|
|
|
* to reduce fragmentation problems due to the buddy principle.
|
|
|
|
* XXX Provide actual fragmentation statistics in /proc.
|
|
|
|
*
|
|
|
|
* Alignments up to the page size are the same for physical and virtual
|
|
|
|
* addresses of the nocache area.
|
|
|
|
*/
|
mm: treewide: remove unused address argument from pte_alloc functions
Patch series "Add support for fast mremap".
This series speeds up the mremap(2) syscall by copying page tables at
the PMD level even for non-THP systems. There is concern that the extra
'address' argument that mremap passes to pte_alloc may do something
subtle architecture related in the future that may make the scheme not
work. Also we find that there is no point in passing the 'address' to
pte_alloc since its unused. This patch therefore removes this argument
tree-wide resulting in a nice negative diff as well. Also ensuring
along the way that the enabled architectures do not do anything funky
with the 'address' argument that goes unnoticed by the optimization.
Build and boot tested on x86-64. Build tested on arm64. The config
enablement patch for arm64 will be posted in the future after more
testing.
The changes were obtained by applying the following Coccinelle script.
(thanks Julia for answering all Coccinelle questions!).
Following fix ups were done manually:
* Removal of address argument from pte_fragment_alloc
* Removal of pte_alloc_one_fast definitions from m68k and microblaze.
// Options: --include-headers --no-includes
// Note: I split the 'identifier fn' line, so if you are manually
// running it, please unsplit it so it runs for you.
virtual patch
@pte_alloc_func_def depends on patch exists@
identifier E2;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
type T2;
@@
fn(...
- , T2 E2
)
{ ... }
@pte_alloc_func_proto_noarg depends on patch exists@
type T1, T2, T3, T4;
identifier fn =~ "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
(
- T3 fn(T1, T2);
+ T3 fn(T1);
|
- T3 fn(T1, T2, T4);
+ T3 fn(T1, T2);
)
@pte_alloc_func_proto depends on patch exists@
identifier E1, E2, E4;
type T1, T2, T3, T4;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
(
- T3 fn(T1 E1, T2 E2);
+ T3 fn(T1 E1);
|
- T3 fn(T1 E1, T2 E2, T4 E4);
+ T3 fn(T1 E1, T2 E2);
)
@pte_alloc_func_call depends on patch exists@
expression E2;
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
@@
fn(...
-, E2
)
@pte_alloc_macro depends on patch exists@
identifier fn =~
"^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
identifier a, b, c;
expression e;
position p;
@@
(
- #define fn(a, b, c) e
+ #define fn(a, b) e
|
- #define fn(a, b) e
+ #define fn(a) e
)
Link: http://lkml.kernel.org/r/20181108181201.88826-2-joelaf@google.com
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Suggested-by: Kirill A. Shutemov <kirill@shutemov.name>
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 02:28:34 +03:00
|
|
|
pgtable_t pte_alloc_one(struct mm_struct *mm)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2020-04-15 00:40:10 +03:00
|
|
|
pte_t *ptep;
|
2008-02-08 15:22:04 +03:00
|
|
|
struct page *page;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2020-11-09 11:06:56 +03:00
|
|
|
if (!(ptep = pte_alloc_one_kernel(mm)))
|
2013-11-15 02:31:42 +04:00
|
|
|
return NULL;
|
2020-04-15 00:40:10 +03:00
|
|
|
page = pfn_to_page(__nocache_pa((unsigned long)ptep) >> PAGE_SHIFT);
|
2020-05-26 20:33:02 +03:00
|
|
|
spin_lock(&mm->page_table_lock);
|
|
|
|
if (page_ref_inc_return(page) == 2 && !pgtable_pte_page_ctor(page)) {
|
|
|
|
page_ref_dec(page);
|
|
|
|
ptep = NULL;
|
2013-11-15 02:31:42 +04:00
|
|
|
}
|
2020-05-26 20:33:02 +03:00
|
|
|
spin_unlock(&mm->page_table_lock);
|
|
|
|
|
2020-04-15 00:40:10 +03:00
|
|
|
return ptep;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2020-04-15 00:40:10 +03:00
|
|
|
void pte_free(struct mm_struct *mm, pgtable_t ptep)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2020-04-15 00:40:10 +03:00
|
|
|
struct page *page;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2020-04-15 00:40:10 +03:00
|
|
|
page = pfn_to_page(__nocache_pa((unsigned long)ptep) >> PAGE_SHIFT);
|
2020-05-26 20:33:02 +03:00
|
|
|
spin_lock(&mm->page_table_lock);
|
|
|
|
if (page_ref_dec_return(page) == 1)
|
|
|
|
pgtable_pte_page_dtor(page);
|
|
|
|
spin_unlock(&mm->page_table_lock);
|
2012-07-26 15:02:14 +04:00
|
|
|
|
2020-04-15 00:40:10 +03:00
|
|
|
srmmu_free_nocache(ptep, SRMMU_PTE_TABLE_SIZE);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:24 +04:00
|
|
|
/* context handling - a dynamically sized pool is used */
|
|
|
|
#define NO_CONTEXT -1
|
|
|
|
|
|
|
|
struct ctx_list {
|
|
|
|
struct ctx_list *next;
|
|
|
|
struct ctx_list *prev;
|
|
|
|
unsigned int ctx_number;
|
|
|
|
struct mm_struct *ctx_mm;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ctx_list *ctx_list_pool;
|
|
|
|
static struct ctx_list ctx_free;
|
|
|
|
static struct ctx_list ctx_used;
|
|
|
|
|
|
|
|
/* At boot time we determine the number of contexts */
|
|
|
|
static int num_contexts;
|
|
|
|
|
|
|
|
static inline void remove_from_ctx_list(struct ctx_list *entry)
|
|
|
|
{
|
|
|
|
entry->next->prev = entry->prev;
|
|
|
|
entry->prev->next = entry->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
|
|
|
|
{
|
|
|
|
entry->next = head;
|
|
|
|
(entry->prev = head->prev)->next = entry;
|
|
|
|
head->prev = entry;
|
|
|
|
}
|
|
|
|
#define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry)
|
|
|
|
#define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry)
|
|
|
|
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static inline void alloc_context(struct mm_struct *old_mm, struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
struct ctx_list *ctxp;
|
|
|
|
|
|
|
|
ctxp = ctx_free.next;
|
2012-07-26 15:02:13 +04:00
|
|
|
if (ctxp != &ctx_free) {
|
2005-04-17 02:20:36 +04:00
|
|
|
remove_from_ctx_list(ctxp);
|
|
|
|
add_to_used_ctxlist(ctxp);
|
|
|
|
mm->context = ctxp->ctx_number;
|
|
|
|
ctxp->ctx_mm = mm;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctxp = ctx_used.next;
|
2012-07-26 15:02:13 +04:00
|
|
|
if (ctxp->ctx_mm == old_mm)
|
2005-04-17 02:20:36 +04:00
|
|
|
ctxp = ctxp->next;
|
2012-07-26 15:02:13 +04:00
|
|
|
if (ctxp == &ctx_used)
|
2005-04-17 02:20:36 +04:00
|
|
|
panic("out of mmu contexts");
|
|
|
|
flush_cache_mm(ctxp->ctx_mm);
|
|
|
|
flush_tlb_mm(ctxp->ctx_mm);
|
|
|
|
remove_from_ctx_list(ctxp);
|
|
|
|
add_to_used_ctxlist(ctxp);
|
|
|
|
ctxp->ctx_mm->context = NO_CONTEXT;
|
|
|
|
ctxp->ctx_mm = mm;
|
|
|
|
mm->context = ctxp->ctx_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void free_context(int context)
|
|
|
|
{
|
|
|
|
struct ctx_list *ctx_old;
|
|
|
|
|
|
|
|
ctx_old = ctx_list_pool + context;
|
|
|
|
remove_from_ctx_list(ctx_old);
|
|
|
|
add_to_free_ctxlist(ctx_old);
|
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:24 +04:00
|
|
|
static void __init sparc_context_init(int numctx)
|
|
|
|
{
|
|
|
|
int ctx;
|
|
|
|
unsigned long size;
|
|
|
|
|
|
|
|
size = numctx * sizeof(struct ctx_list);
|
2019-03-12 09:29:50 +03:00
|
|
|
ctx_list_pool = memblock_alloc(size, SMP_CACHE_BYTES);
|
2019-03-12 09:30:10 +03:00
|
|
|
if (!ctx_list_pool)
|
|
|
|
panic("%s: Failed to allocate %lu bytes\n", __func__, size);
|
2012-07-26 15:02:24 +04:00
|
|
|
|
|
|
|
for (ctx = 0; ctx < numctx; ctx++) {
|
|
|
|
struct ctx_list *clist;
|
|
|
|
|
|
|
|
clist = (ctx_list_pool + ctx);
|
|
|
|
clist->ctx_number = ctx;
|
|
|
|
clist->ctx_mm = NULL;
|
|
|
|
}
|
|
|
|
ctx_free.next = ctx_free.prev = &ctx_free;
|
|
|
|
ctx_used.next = ctx_used.prev = &ctx_used;
|
|
|
|
for (ctx = 0; ctx < numctx; ctx++)
|
|
|
|
add_to_free_ctxlist(ctx_list_pool + ctx);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-05-12 12:04:11 +04:00
|
|
|
void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm,
|
|
|
|
struct task_struct *tsk)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2014-12-18 15:23:23 +03:00
|
|
|
unsigned long flags;
|
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
if (mm->context == NO_CONTEXT) {
|
2014-12-18 15:23:23 +03:00
|
|
|
spin_lock_irqsave(&srmmu_context_spinlock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
alloc_context(old_mm, mm);
|
2014-12-18 15:23:23 +03:00
|
|
|
spin_unlock_irqrestore(&srmmu_context_spinlock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
srmmu_ctxd_set(&srmmu_context_table[mm->context], mm->pgd);
|
|
|
|
}
|
|
|
|
|
2009-08-17 04:13:33 +04:00
|
|
|
if (sparc_cpu_model == sparc_leon)
|
|
|
|
leon_switch_mm();
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (is_hypersparc)
|
|
|
|
hyper_flush_whole_icache();
|
|
|
|
|
|
|
|
srmmu_set_context(mm->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Low level IO area allocation on the SRMMU. */
|
|
|
|
static inline void srmmu_mapioaddr(unsigned long physaddr,
|
2012-07-26 15:02:13 +04:00
|
|
|
unsigned long virt_addr, int bus_type)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
pgd_t *pgdp;
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d_t *p4dp;
|
|
|
|
pud_t *pudp;
|
2005-04-17 02:20:36 +04:00
|
|
|
pmd_t *pmdp;
|
|
|
|
pte_t *ptep;
|
|
|
|
unsigned long tmp;
|
|
|
|
|
|
|
|
physaddr &= PAGE_MASK;
|
|
|
|
pgdp = pgd_offset_k(virt_addr);
|
2019-12-05 03:54:20 +03:00
|
|
|
p4dp = p4d_offset(pgdp, virt_addr);
|
|
|
|
pudp = pud_offset(p4dp, virt_addr);
|
|
|
|
pmdp = pmd_offset(pudp, virt_addr);
|
2012-05-13 12:21:25 +04:00
|
|
|
ptep = pte_offset_kernel(pmdp, virt_addr);
|
2005-04-17 02:20:36 +04:00
|
|
|
tmp = (physaddr >> 4) | SRMMU_ET_PTE;
|
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
/* I need to test whether this is consistent over all
|
2005-04-17 02:20:36 +04:00
|
|
|
* sun4m's. The bus_type represents the upper 4 bits of
|
|
|
|
* 36-bit physical address on the I/O space lines...
|
|
|
|
*/
|
|
|
|
tmp |= (bus_type << 28);
|
|
|
|
tmp |= SRMMU_PRIV;
|
|
|
|
__flush_page_to_ram(virt_addr);
|
2012-05-13 00:39:23 +04:00
|
|
|
set_pte(ptep, __pte(tmp));
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-05-13 12:21:25 +04:00
|
|
|
void srmmu_mapiorange(unsigned int bus, unsigned long xpa,
|
|
|
|
unsigned long xva, unsigned int len)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
while (len != 0) {
|
|
|
|
len -= PAGE_SIZE;
|
|
|
|
srmmu_mapioaddr(xpa, xva, bus);
|
|
|
|
xva += PAGE_SIZE;
|
|
|
|
xpa += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
flush_tlb_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void srmmu_unmapioaddr(unsigned long virt_addr)
|
|
|
|
{
|
|
|
|
pgd_t *pgdp;
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d_t *p4dp;
|
|
|
|
pud_t *pudp;
|
2005-04-17 02:20:36 +04:00
|
|
|
pmd_t *pmdp;
|
|
|
|
pte_t *ptep;
|
|
|
|
|
2019-12-05 03:54:20 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
pgdp = pgd_offset_k(virt_addr);
|
2019-12-05 03:54:20 +03:00
|
|
|
p4dp = p4d_offset(pgdp, virt_addr);
|
|
|
|
pudp = pud_offset(p4dp, virt_addr);
|
|
|
|
pmdp = pmd_offset(pudp, virt_addr);
|
2012-05-13 12:21:25 +04:00
|
|
|
ptep = pte_offset_kernel(pmdp, virt_addr);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* No need to flush uncacheable page. */
|
2012-05-12 23:26:47 +04:00
|
|
|
__pte_clear(ptep);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-05-13 12:21:25 +04:00
|
|
|
void srmmu_unmapiorange(unsigned long virt_addr, unsigned int len)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
while (len != 0) {
|
|
|
|
len -= PAGE_SIZE;
|
|
|
|
srmmu_unmapioaddr(virt_addr);
|
|
|
|
virt_addr += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
flush_tlb_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tsunami.S */
|
|
|
|
extern void tsunami_flush_cache_all(void);
|
|
|
|
extern void tsunami_flush_cache_mm(struct mm_struct *mm);
|
|
|
|
extern void tsunami_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
|
|
|
|
extern void tsunami_flush_cache_page(struct vm_area_struct *vma, unsigned long page);
|
|
|
|
extern void tsunami_flush_page_to_ram(unsigned long page);
|
|
|
|
extern void tsunami_flush_page_for_dma(unsigned long page);
|
|
|
|
extern void tsunami_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr);
|
|
|
|
extern void tsunami_flush_tlb_all(void);
|
|
|
|
extern void tsunami_flush_tlb_mm(struct mm_struct *mm);
|
|
|
|
extern void tsunami_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
|
|
|
|
extern void tsunami_flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
|
|
|
|
extern void tsunami_setup_blockops(void);
|
|
|
|
|
|
|
|
/* swift.S */
|
|
|
|
extern void swift_flush_cache_all(void);
|
|
|
|
extern void swift_flush_cache_mm(struct mm_struct *mm);
|
|
|
|
extern void swift_flush_cache_range(struct vm_area_struct *vma,
|
|
|
|
unsigned long start, unsigned long end);
|
|
|
|
extern void swift_flush_cache_page(struct vm_area_struct *vma, unsigned long page);
|
|
|
|
extern void swift_flush_page_to_ram(unsigned long page);
|
|
|
|
extern void swift_flush_page_for_dma(unsigned long page);
|
|
|
|
extern void swift_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr);
|
|
|
|
extern void swift_flush_tlb_all(void);
|
|
|
|
extern void swift_flush_tlb_mm(struct mm_struct *mm);
|
|
|
|
extern void swift_flush_tlb_range(struct vm_area_struct *vma,
|
|
|
|
unsigned long start, unsigned long end);
|
|
|
|
extern void swift_flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
|
|
|
|
|
|
|
|
#if 0 /* P3: deadwood to debug precise flushes on Swift. */
|
|
|
|
void swift_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
|
|
|
|
{
|
|
|
|
int cctx, ctx1;
|
|
|
|
|
|
|
|
page &= PAGE_MASK;
|
|
|
|
if ((ctx1 = vma->vm_mm->context) != -1) {
|
|
|
|
cctx = srmmu_get_context();
|
|
|
|
/* Is context # ever different from current context? P3 */
|
|
|
|
if (cctx != ctx1) {
|
|
|
|
printk("flush ctx %02x curr %02x\n", ctx1, cctx);
|
|
|
|
srmmu_set_context(ctx1);
|
|
|
|
swift_flush_page(page);
|
|
|
|
__asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
|
|
|
|
"r" (page), "i" (ASI_M_FLUSH_PROBE));
|
|
|
|
srmmu_set_context(cctx);
|
|
|
|
} else {
|
|
|
|
/* Rm. prot. bits from virt. c. */
|
|
|
|
/* swift_flush_cache_all(); */
|
|
|
|
/* swift_flush_cache_page(vma, page); */
|
|
|
|
swift_flush_page(page);
|
|
|
|
|
|
|
|
__asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
|
|
|
|
"r" (page), "i" (ASI_M_FLUSH_PROBE));
|
|
|
|
/* same as above: srmmu_flush_tlb_page() */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following are all MBUS based SRMMU modules, and therefore could
|
|
|
|
* be found in a multiprocessor configuration. On the whole, these
|
|
|
|
* chips seems to be much more touchy about DVMA and page tables
|
|
|
|
* with respect to cache coherency.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* viking.S */
|
|
|
|
extern void viking_flush_cache_all(void);
|
|
|
|
extern void viking_flush_cache_mm(struct mm_struct *mm);
|
|
|
|
extern void viking_flush_cache_range(struct vm_area_struct *vma, unsigned long start,
|
|
|
|
unsigned long end);
|
|
|
|
extern void viking_flush_cache_page(struct vm_area_struct *vma, unsigned long page);
|
|
|
|
extern void viking_flush_page_to_ram(unsigned long page);
|
|
|
|
extern void viking_flush_page_for_dma(unsigned long page);
|
|
|
|
extern void viking_flush_sig_insns(struct mm_struct *mm, unsigned long addr);
|
|
|
|
extern void viking_flush_page(unsigned long page);
|
|
|
|
extern void viking_mxcc_flush_page(unsigned long page);
|
|
|
|
extern void viking_flush_tlb_all(void);
|
|
|
|
extern void viking_flush_tlb_mm(struct mm_struct *mm);
|
|
|
|
extern void viking_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
|
|
|
|
unsigned long end);
|
|
|
|
extern void viking_flush_tlb_page(struct vm_area_struct *vma,
|
|
|
|
unsigned long page);
|
|
|
|
extern void sun4dsmp_flush_tlb_all(void);
|
|
|
|
extern void sun4dsmp_flush_tlb_mm(struct mm_struct *mm);
|
|
|
|
extern void sun4dsmp_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
|
|
|
|
unsigned long end);
|
|
|
|
extern void sun4dsmp_flush_tlb_page(struct vm_area_struct *vma,
|
|
|
|
unsigned long page);
|
|
|
|
|
|
|
|
/* hypersparc.S */
|
|
|
|
extern void hypersparc_flush_cache_all(void);
|
|
|
|
extern void hypersparc_flush_cache_mm(struct mm_struct *mm);
|
|
|
|
extern void hypersparc_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
|
|
|
|
extern void hypersparc_flush_cache_page(struct vm_area_struct *vma, unsigned long page);
|
|
|
|
extern void hypersparc_flush_page_to_ram(unsigned long page);
|
|
|
|
extern void hypersparc_flush_page_for_dma(unsigned long page);
|
|
|
|
extern void hypersparc_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr);
|
|
|
|
extern void hypersparc_flush_tlb_all(void);
|
|
|
|
extern void hypersparc_flush_tlb_mm(struct mm_struct *mm);
|
|
|
|
extern void hypersparc_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
|
|
|
|
extern void hypersparc_flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
|
|
|
|
extern void hypersparc_setup_blockops(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: All of this startup code assumes the low 16mb (approx.) of
|
|
|
|
* kernel mappings are done with one single contiguous chunk of
|
|
|
|
* ram. On small ram machines (classics mainly) we only get
|
|
|
|
* around 8mb mapped for us.
|
|
|
|
*/
|
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static void __init early_pgtable_allocfail(char *type)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
prom_printf("inherit_prom_mappings: Cannot alloc kernel %s.\n", type);
|
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static void __init srmmu_early_allocate_ptable_skeleton(unsigned long start,
|
|
|
|
unsigned long end)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
pgd_t *pgdp;
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d_t *p4dp;
|
|
|
|
pud_t *pudp;
|
2005-04-17 02:20:36 +04:00
|
|
|
pmd_t *pmdp;
|
|
|
|
pte_t *ptep;
|
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
while (start < end) {
|
2005-04-17 02:20:36 +04:00
|
|
|
pgdp = pgd_offset_k(start);
|
2019-12-05 03:54:20 +03:00
|
|
|
p4dp = p4d_offset(pgdp, start);
|
|
|
|
pudp = pud_offset(p4dp, start);
|
2020-06-27 11:16:53 +03:00
|
|
|
if (pud_none(*__nocache_fix(pudp))) {
|
2012-07-26 15:02:14 +04:00
|
|
|
pmdp = __srmmu_get_nocache(
|
2005-04-17 02:20:36 +04:00
|
|
|
SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE);
|
|
|
|
if (pmdp == NULL)
|
|
|
|
early_pgtable_allocfail("pmd");
|
|
|
|
memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE);
|
2019-12-05 03:54:20 +03:00
|
|
|
pud_set(__nocache_fix(pudp), pmdp);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2019-12-05 03:54:20 +03:00
|
|
|
pmdp = pmd_offset(__nocache_fix(pudp), start);
|
2020-06-27 11:16:53 +03:00
|
|
|
if (srmmu_pmd_none(*__nocache_fix(pmdp))) {
|
2012-07-26 15:02:14 +04:00
|
|
|
ptep = __srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (ptep == NULL)
|
|
|
|
early_pgtable_allocfail("pte");
|
|
|
|
memset(__nocache_fix(ptep), 0, PTE_SIZE);
|
2012-05-13 10:40:27 +04:00
|
|
|
pmd_set(__nocache_fix(pmdp), ptep);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
if (start > (0xffffffffUL - PMD_SIZE))
|
|
|
|
break;
|
|
|
|
start = (start + PMD_SIZE) & PMD_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-05 22:41:51 +04:00
|
|
|
static void __init srmmu_allocate_ptable_skeleton(unsigned long start,
|
|
|
|
unsigned long end)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
pgd_t *pgdp;
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d_t *p4dp;
|
|
|
|
pud_t *pudp;
|
2005-04-17 02:20:36 +04:00
|
|
|
pmd_t *pmdp;
|
|
|
|
pte_t *ptep;
|
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
while (start < end) {
|
2005-04-17 02:20:36 +04:00
|
|
|
pgdp = pgd_offset_k(start);
|
2019-12-05 03:54:20 +03:00
|
|
|
p4dp = p4d_offset(pgdp, start);
|
|
|
|
pudp = pud_offset(p4dp, start);
|
|
|
|
if (pud_none(*pudp)) {
|
2012-07-26 15:02:14 +04:00
|
|
|
pmdp = __srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (pmdp == NULL)
|
|
|
|
early_pgtable_allocfail("pmd");
|
|
|
|
memset(pmdp, 0, SRMMU_PMD_TABLE_SIZE);
|
2019-12-05 03:54:20 +03:00
|
|
|
pud_set((pud_t *)pgdp, pmdp);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2019-12-05 03:54:20 +03:00
|
|
|
pmdp = pmd_offset(pudp, start);
|
2012-07-26 15:02:13 +04:00
|
|
|
if (srmmu_pmd_none(*pmdp)) {
|
2012-07-26 15:02:14 +04:00
|
|
|
ptep = __srmmu_get_nocache(PTE_SIZE,
|
2005-04-17 02:20:36 +04:00
|
|
|
PTE_SIZE);
|
|
|
|
if (ptep == NULL)
|
|
|
|
early_pgtable_allocfail("pte");
|
|
|
|
memset(ptep, 0, PTE_SIZE);
|
2012-05-13 10:40:27 +04:00
|
|
|
pmd_set(pmdp, ptep);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
if (start > (0xffffffffUL - PMD_SIZE))
|
|
|
|
break;
|
|
|
|
start = (start + PMD_SIZE) & PMD_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-26 01:20:19 +04:00
|
|
|
/* These flush types are not available on all chips... */
|
|
|
|
static inline unsigned long srmmu_probe(unsigned long vaddr)
|
|
|
|
{
|
|
|
|
unsigned long retval;
|
|
|
|
|
|
|
|
if (sparc_cpu_model != sparc_leon) {
|
|
|
|
|
|
|
|
vaddr &= PAGE_MASK;
|
|
|
|
__asm__ __volatile__("lda [%1] %2, %0\n\t" :
|
|
|
|
"=r" (retval) :
|
|
|
|
"r" (vaddr | 0x400), "i" (ASI_M_FLUSH_PROBE));
|
|
|
|
} else {
|
2014-04-21 23:39:19 +04:00
|
|
|
retval = leon_swprobe(vaddr, NULL);
|
2012-05-26 01:20:19 +04:00
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* This is much cleaner than poking around physical address space
|
|
|
|
* looking at the prom's page table directly which is what most
|
|
|
|
* other OS's do. Yuck... this is much better.
|
|
|
|
*/
|
2008-06-05 22:41:51 +04:00
|
|
|
static void __init srmmu_inherit_prom_mappings(unsigned long start,
|
|
|
|
unsigned long end)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-07-26 15:02:15 +04:00
|
|
|
unsigned long probed;
|
|
|
|
unsigned long addr;
|
2005-04-17 02:20:36 +04:00
|
|
|
pgd_t *pgdp;
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d_t *p4dp;
|
|
|
|
pud_t *pudp;
|
2005-04-17 02:20:36 +04:00
|
|
|
pmd_t *pmdp;
|
|
|
|
pte_t *ptep;
|
2012-07-26 15:02:15 +04:00
|
|
|
int what; /* 0 = normal-pte, 1 = pmd-level pte, 2 = pgd-level pte */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
while (start <= end) {
|
2005-04-17 02:20:36 +04:00
|
|
|
if (start == 0)
|
|
|
|
break; /* probably wrap around */
|
2012-07-26 15:02:13 +04:00
|
|
|
if (start == 0xfef00000)
|
2005-04-17 02:20:36 +04:00
|
|
|
start = KADB_DEBUGGER_BEGVM;
|
2012-07-26 15:02:15 +04:00
|
|
|
probed = srmmu_probe(start);
|
|
|
|
if (!probed) {
|
|
|
|
/* continue probing until we find an entry */
|
2005-04-17 02:20:36 +04:00
|
|
|
start += PAGE_SIZE;
|
|
|
|
continue;
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* A red snapper, see what it really is. */
|
|
|
|
what = 0;
|
2012-07-26 15:02:15 +04:00
|
|
|
addr = start - PAGE_SIZE;
|
2012-07-26 15:02:13 +04:00
|
|
|
|
2020-04-15 00:40:09 +03:00
|
|
|
if (!(start & ~(PMD_MASK))) {
|
|
|
|
if (srmmu_probe(addr + PMD_SIZE) == probed)
|
2005-04-17 02:20:36 +04:00
|
|
|
what = 1;
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
|
2020-04-15 00:40:09 +03:00
|
|
|
if (!(start & ~(PGDIR_MASK))) {
|
|
|
|
if (srmmu_probe(addr + PGDIR_SIZE) == probed)
|
2005-04-17 02:20:36 +04:00
|
|
|
what = 2;
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
pgdp = pgd_offset_k(start);
|
2019-12-05 03:54:20 +03:00
|
|
|
p4dp = p4d_offset(pgdp, start);
|
|
|
|
pudp = pud_offset(p4dp, start);
|
2012-07-26 15:02:13 +04:00
|
|
|
if (what == 2) {
|
2020-06-27 11:16:53 +03:00
|
|
|
*__nocache_fix(pgdp) = __pgd(probed);
|
2020-04-15 00:40:09 +03:00
|
|
|
start += PGDIR_SIZE;
|
2005-04-17 02:20:36 +04:00
|
|
|
continue;
|
|
|
|
}
|
2020-06-27 11:16:53 +03:00
|
|
|
if (pud_none(*__nocache_fix(pudp))) {
|
2012-07-26 15:02:15 +04:00
|
|
|
pmdp = __srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE,
|
|
|
|
SRMMU_PMD_TABLE_SIZE);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (pmdp == NULL)
|
|
|
|
early_pgtable_allocfail("pmd");
|
|
|
|
memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE);
|
2019-12-05 03:54:20 +03:00
|
|
|
pud_set(__nocache_fix(pudp), pmdp);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2020-06-27 11:16:52 +03:00
|
|
|
pmdp = pmd_offset(__nocache_fix(pudp), start);
|
2020-04-15 00:40:09 +03:00
|
|
|
if (what == 1) {
|
|
|
|
*(pmd_t *)__nocache_fix(pmdp) = __pmd(probed);
|
|
|
|
start += PMD_SIZE;
|
|
|
|
continue;
|
|
|
|
}
|
2020-06-27 11:16:53 +03:00
|
|
|
if (srmmu_pmd_none(*__nocache_fix(pmdp))) {
|
2012-07-26 15:02:14 +04:00
|
|
|
ptep = __srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (ptep == NULL)
|
|
|
|
early_pgtable_allocfail("pte");
|
|
|
|
memset(__nocache_fix(ptep), 0, PTE_SIZE);
|
2012-05-13 10:40:27 +04:00
|
|
|
pmd_set(__nocache_fix(pmdp), ptep);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-05-13 12:21:25 +04:00
|
|
|
ptep = pte_offset_kernel(__nocache_fix(pmdp), start);
|
2020-06-27 11:16:53 +03:00
|
|
|
*__nocache_fix(ptep) = __pte(probed);
|
2005-04-17 02:20:36 +04:00
|
|
|
start += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define KERNEL_PTE(page_shifted) ((page_shifted)|SRMMU_CACHE|SRMMU_PRIV|SRMMU_VALID)
|
|
|
|
|
|
|
|
/* Create a third-level SRMMU 16MB page mapping. */
|
|
|
|
static void __init do_large_mapping(unsigned long vaddr, unsigned long phys_base)
|
|
|
|
{
|
|
|
|
pgd_t *pgdp = pgd_offset_k(vaddr);
|
|
|
|
unsigned long big_pte;
|
|
|
|
|
|
|
|
big_pte = KERNEL_PTE(phys_base >> 4);
|
2020-06-27 11:16:53 +03:00
|
|
|
*__nocache_fix(pgdp) = __pgd(big_pte);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Map sp_bank entry SP_ENTRY, starting at virtual address VBASE. */
|
|
|
|
static unsigned long __init map_spbank(unsigned long vbase, int sp_entry)
|
|
|
|
{
|
2020-04-15 00:40:09 +03:00
|
|
|
unsigned long pstart = (sp_banks[sp_entry].base_addr & PGDIR_MASK);
|
|
|
|
unsigned long vstart = (vbase & PGDIR_MASK);
|
|
|
|
unsigned long vend = PGDIR_ALIGN(vbase + sp_banks[sp_entry].num_bytes);
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Map "low" memory only */
|
|
|
|
const unsigned long min_vaddr = PAGE_OFFSET;
|
|
|
|
const unsigned long max_vaddr = PAGE_OFFSET + SRMMU_MAXMEM;
|
|
|
|
|
|
|
|
if (vstart < min_vaddr || vstart >= max_vaddr)
|
|
|
|
return vstart;
|
2012-07-26 15:02:13 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (vend > max_vaddr || vend < min_vaddr)
|
|
|
|
vend = max_vaddr;
|
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
while (vstart < vend) {
|
2005-04-17 02:20:36 +04:00
|
|
|
do_large_mapping(vstart, pstart);
|
2020-04-15 00:40:09 +03:00
|
|
|
vstart += PGDIR_SIZE; pstart += PGDIR_SIZE;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
return vstart;
|
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:11 +04:00
|
|
|
static void __init map_kernel(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (phys_base > 0) {
|
|
|
|
do_large_mapping(PAGE_OFFSET, phys_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; sp_banks[i].num_bytes != 0; i++) {
|
|
|
|
map_spbank((unsigned long)__va(sp_banks[i].base_addr), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-17 23:43:14 +04:00
|
|
|
void (*poke_srmmu)(void) = NULL;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
void __init srmmu_paging_init(void)
|
|
|
|
{
|
2010-10-09 01:18:11 +04:00
|
|
|
int i;
|
|
|
|
phandle cpunode;
|
2005-04-17 02:20:36 +04:00
|
|
|
char node_str[128];
|
|
|
|
pgd_t *pgd;
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d_t *p4d;
|
|
|
|
pud_t *pud;
|
2005-04-17 02:20:36 +04:00
|
|
|
pmd_t *pmd;
|
|
|
|
pte_t *pte;
|
|
|
|
unsigned long pages_avail;
|
|
|
|
|
2012-07-26 15:02:24 +04:00
|
|
|
init_mm.context = (unsigned long) NO_CONTEXT;
|
2005-04-17 02:20:36 +04:00
|
|
|
sparc_iomap.start = SUN4M_IOBASE_VADDR; /* 16MB of IOSPACE on all sun4m's. */
|
|
|
|
|
|
|
|
if (sparc_cpu_model == sun4d)
|
|
|
|
num_contexts = 65536; /* We know it is Viking */
|
|
|
|
else {
|
|
|
|
/* Find the number of contexts on the srmmu. */
|
|
|
|
cpunode = prom_getchild(prom_root_node);
|
|
|
|
num_contexts = 0;
|
2012-07-26 15:02:13 +04:00
|
|
|
while (cpunode != 0) {
|
2005-04-17 02:20:36 +04:00
|
|
|
prom_getstring(cpunode, "device_type", node_str, sizeof(node_str));
|
2012-07-26 15:02:13 +04:00
|
|
|
if (!strcmp(node_str, "cpu")) {
|
2005-04-17 02:20:36 +04:00
|
|
|
num_contexts = prom_getintdefault(cpunode, "mmu-nctx", 0x8);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cpunode = prom_getsibling(cpunode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
if (!num_contexts) {
|
2005-04-17 02:20:36 +04:00
|
|
|
prom_printf("Something wrong, can't find cpu node in paging_init.\n");
|
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
|
|
|
|
pages_avail = 0;
|
|
|
|
last_valid_pfn = bootmem_init(&pages_avail);
|
|
|
|
|
|
|
|
srmmu_nocache_calcsize();
|
|
|
|
srmmu_nocache_init();
|
2012-07-26 15:02:14 +04:00
|
|
|
srmmu_inherit_prom_mappings(0xfe400000, (LINUX_OPPROM_ENDVM - PAGE_SIZE));
|
2005-04-17 02:20:36 +04:00
|
|
|
map_kernel();
|
|
|
|
|
|
|
|
/* ctx table has to be physically aligned to its size */
|
2012-07-26 15:02:14 +04:00
|
|
|
srmmu_context_table = __srmmu_get_nocache(num_contexts * sizeof(ctxd_t), num_contexts * sizeof(ctxd_t));
|
2016-04-22 20:41:07 +03:00
|
|
|
srmmu_ctx_table_phys = (ctxd_t *)__nocache_pa(srmmu_context_table);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
for (i = 0; i < num_contexts; i++)
|
2020-06-27 11:16:53 +03:00
|
|
|
srmmu_ctxd_set(__nocache_fix(&srmmu_context_table[i]), srmmu_swapper_pg_dir);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
flush_cache_all();
|
|
|
|
srmmu_set_ctable_ptr((unsigned long)srmmu_ctx_table_phys);
|
2006-03-24 09:36:19 +03:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Stop from hanging here... */
|
2012-05-14 07:49:31 +04:00
|
|
|
local_ops->tlb_all();
|
2006-03-24 09:36:19 +03:00
|
|
|
#else
|
2005-04-17 02:20:36 +04:00
|
|
|
flush_tlb_all();
|
2006-03-24 09:36:19 +03:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
poke_srmmu();
|
|
|
|
|
|
|
|
srmmu_allocate_ptable_skeleton(sparc_iomap.start, IOBASE_END);
|
|
|
|
srmmu_allocate_ptable_skeleton(DVMA_VADDR, DVMA_END);
|
|
|
|
|
|
|
|
srmmu_allocate_ptable_skeleton(
|
|
|
|
__fix_to_virt(__end_of_fixed_addresses - 1), FIXADDR_TOP);
|
|
|
|
srmmu_allocate_ptable_skeleton(PKMAP_BASE, PKMAP_END);
|
|
|
|
|
|
|
|
pgd = pgd_offset_k(PKMAP_BASE);
|
2019-12-05 03:54:20 +03:00
|
|
|
p4d = p4d_offset(pgd, PKMAP_BASE);
|
|
|
|
pud = pud_offset(p4d, PKMAP_BASE);
|
|
|
|
pmd = pmd_offset(pud, PKMAP_BASE);
|
2012-05-13 12:21:25 +04:00
|
|
|
pte = pte_offset_kernel(pmd, PKMAP_BASE);
|
2005-04-17 02:20:36 +04:00
|
|
|
pkmap_page_table = pte;
|
|
|
|
|
|
|
|
flush_cache_all();
|
|
|
|
flush_tlb_all();
|
|
|
|
|
|
|
|
sparc_context_init(num_contexts);
|
|
|
|
|
|
|
|
{
|
2020-06-04 01:57:41 +03:00
|
|
|
unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2020-06-04 01:57:41 +03:00
|
|
|
max_zone_pfn[ZONE_DMA] = max_low_pfn;
|
|
|
|
max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
|
|
|
|
max_zone_pfn[ZONE_HIGHMEM] = highend_pfn;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2020-06-04 01:57:41 +03:00
|
|
|
free_area_init(max_zone_pfn);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-13 12:21:25 +04:00
|
|
|
void mmu_info(struct seq_file *m)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-07-26 15:02:13 +04:00
|
|
|
seq_printf(m,
|
2005-04-17 02:20:36 +04:00
|
|
|
"MMU type\t: %s\n"
|
|
|
|
"contexts\t: %d\n"
|
|
|
|
"nocache total\t: %ld\n"
|
|
|
|
"nocache used\t: %d\n",
|
|
|
|
srmmu_name,
|
|
|
|
num_contexts,
|
|
|
|
srmmu_nocache_size,
|
|
|
|
srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT);
|
|
|
|
}
|
|
|
|
|
2012-07-26 15:02:24 +04:00
|
|
|
int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
mm->context = NO_CONTEXT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-13 12:30:54 +04:00
|
|
|
void destroy_context(struct mm_struct *mm)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2014-12-18 15:23:23 +03:00
|
|
|
unsigned long flags;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-07-26 15:02:13 +04:00
|
|
|
if (mm->context != NO_CONTEXT) {
|
2005-04-17 02:20:36 +04:00
|
|
|
flush_cache_mm(mm);
|
|
|
|
srmmu_ctxd_set(&srmmu_context_table[mm->context], srmmu_swapper_pg_dir);
|
|
|
|
flush_tlb_mm(mm);
|
2014-12-18 15:23:23 +03:00
|
|
|
spin_lock_irqsave(&srmmu_context_spinlock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
free_context(mm->context);
|
2014-12-18 15:23:23 +03:00
|
|
|
spin_unlock_irqrestore(&srmmu_context_spinlock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
mm->context = NO_CONTEXT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init various srmmu chip types. */
|
|
|
|
static void __init srmmu_is_bad(void)
|
|
|
|
{
|
|
|
|
prom_printf("Could not determine SRMMU chip type.\n");
|
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init init_vac_layout(void)
|
|
|
|
{
|
2010-10-09 01:18:11 +04:00
|
|
|
phandle nd;
|
|
|
|
int cache_lines;
|
2005-04-17 02:20:36 +04:00
|
|
|
char node_str[128];
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int cpu = 0;
|
|
|
|
unsigned long max_size = 0;
|
|
|
|
unsigned long min_line_size = 0x10000000;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nd = prom_getchild(prom_root_node);
|
2012-07-26 15:02:13 +04:00
|
|
|
while ((nd = prom_getsibling(nd)) != 0) {
|
2005-04-17 02:20:36 +04:00
|
|
|
prom_getstring(nd, "device_type", node_str, sizeof(node_str));
|
2012-07-26 15:02:13 +04:00
|
|
|
if (!strcmp(node_str, "cpu")) {
|
2005-04-17 02:20:36 +04:00
|
|
|
vac_line_size = prom_getint(nd, "cache-line-size");
|
|
|
|
if (vac_line_size == -1) {
|
2012-07-26 15:02:13 +04:00
|
|
|
prom_printf("can't determine cache-line-size, halting.\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
cache_lines = prom_getint(nd, "cache-nlines");
|
|
|
|
if (cache_lines == -1) {
|
|
|
|
prom_printf("can't determine cache-nlines, halting.\n");
|
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
|
|
|
|
vac_cache_size = cache_lines * vac_line_size;
|
|
|
|
#ifdef CONFIG_SMP
|
2012-07-26 15:02:13 +04:00
|
|
|
if (vac_cache_size > max_size)
|
2005-04-17 02:20:36 +04:00
|
|
|
max_size = vac_cache_size;
|
2012-07-26 15:02:13 +04:00
|
|
|
if (vac_line_size < min_line_size)
|
2005-04-17 02:20:36 +04:00
|
|
|
min_line_size = vac_line_size;
|
2006-03-24 09:36:19 +03:00
|
|
|
//FIXME: cpus not contiguous!!
|
2005-04-17 02:20:36 +04:00
|
|
|
cpu++;
|
2009-03-16 07:10:24 +03:00
|
|
|
if (cpu >= nr_cpu_ids || !cpu_online(cpu))
|
2005-04-17 02:20:36 +04:00
|
|
|
break;
|
|
|
|
#else
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
if (nd == 0) {
|
2005-04-17 02:20:36 +04:00
|
|
|
prom_printf("No CPU nodes found, halting.\n");
|
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
vac_cache_size = max_size;
|
|
|
|
vac_line_size = min_line_size;
|
|
|
|
#endif
|
|
|
|
printk("SRMMU: Using VAC size of %d bytes, line size %d bytes.\n",
|
|
|
|
(int)vac_cache_size, (int)vac_line_size);
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-17 23:43:14 +04:00
|
|
|
static void poke_hypersparc(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
volatile unsigned long clear;
|
|
|
|
unsigned long mreg = srmmu_get_mmureg();
|
|
|
|
|
|
|
|
hyper_flush_unconditional_combined();
|
|
|
|
|
|
|
|
mreg &= ~(HYPERSPARC_CWENABLE);
|
|
|
|
mreg |= (HYPERSPARC_CENABLE | HYPERSPARC_WBENABLE);
|
|
|
|
mreg |= (HYPERSPARC_CMODE);
|
|
|
|
|
|
|
|
srmmu_set_mmureg(mreg);
|
|
|
|
|
|
|
|
#if 0 /* XXX I think this is bad news... -DaveM */
|
|
|
|
hyper_clear_all_tags();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
put_ross_icr(HYPERSPARC_ICCR_FTD | HYPERSPARC_ICCR_ICE);
|
|
|
|
hyper_flush_whole_icache();
|
|
|
|
clear = srmmu_get_faddr();
|
|
|
|
clear = srmmu_get_fstatus();
|
|
|
|
}
|
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
static const struct sparc32_cachetlb_ops hypersparc_ops = {
|
|
|
|
.cache_all = hypersparc_flush_cache_all,
|
|
|
|
.cache_mm = hypersparc_flush_cache_mm,
|
|
|
|
.cache_page = hypersparc_flush_cache_page,
|
|
|
|
.cache_range = hypersparc_flush_cache_range,
|
|
|
|
.tlb_all = hypersparc_flush_tlb_all,
|
|
|
|
.tlb_mm = hypersparc_flush_tlb_mm,
|
|
|
|
.tlb_page = hypersparc_flush_tlb_page,
|
|
|
|
.tlb_range = hypersparc_flush_tlb_range,
|
|
|
|
.page_to_ram = hypersparc_flush_page_to_ram,
|
|
|
|
.sig_insns = hypersparc_flush_sig_insns,
|
|
|
|
.page_for_dma = hypersparc_flush_page_for_dma,
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static void __init init_hypersparc(void)
|
|
|
|
{
|
|
|
|
srmmu_name = "ROSS HyperSparc";
|
|
|
|
srmmu_modtype = HyperSparc;
|
|
|
|
|
|
|
|
init_vac_layout();
|
|
|
|
|
|
|
|
is_hypersparc = 1;
|
2012-05-14 07:49:31 +04:00
|
|
|
sparc32_cachetlb_ops = &hypersparc_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
poke_srmmu = poke_hypersparc;
|
|
|
|
|
|
|
|
hypersparc_setup_blockops();
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-17 23:43:14 +04:00
|
|
|
static void poke_swift(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned long mreg;
|
|
|
|
|
|
|
|
/* Clear any crap from the cache or else... */
|
|
|
|
swift_flush_cache_all();
|
|
|
|
|
|
|
|
/* Enable I & D caches */
|
|
|
|
mreg = srmmu_get_mmureg();
|
|
|
|
mreg |= (SWIFT_IE | SWIFT_DE);
|
|
|
|
/*
|
|
|
|
* The Swift branch folding logic is completely broken. At
|
|
|
|
* trap time, if things are just right, if can mistakenly
|
|
|
|
* think that a trap is coming from kernel mode when in fact
|
|
|
|
* it is coming from user mode (it mis-executes the branch in
|
|
|
|
* the trap code). So you see things like crashme completely
|
|
|
|
* hosing your machine which is completely unacceptable. Turn
|
|
|
|
* this shit off... nice job Fujitsu.
|
|
|
|
*/
|
|
|
|
mreg &= ~(SWIFT_BF);
|
|
|
|
srmmu_set_mmureg(mreg);
|
|
|
|
}
|
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
static const struct sparc32_cachetlb_ops swift_ops = {
|
|
|
|
.cache_all = swift_flush_cache_all,
|
|
|
|
.cache_mm = swift_flush_cache_mm,
|
|
|
|
.cache_page = swift_flush_cache_page,
|
|
|
|
.cache_range = swift_flush_cache_range,
|
|
|
|
.tlb_all = swift_flush_tlb_all,
|
|
|
|
.tlb_mm = swift_flush_tlb_mm,
|
|
|
|
.tlb_page = swift_flush_tlb_page,
|
|
|
|
.tlb_range = swift_flush_tlb_range,
|
|
|
|
.page_to_ram = swift_flush_page_to_ram,
|
|
|
|
.sig_insns = swift_flush_sig_insns,
|
|
|
|
.page_for_dma = swift_flush_page_for_dma,
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#define SWIFT_MASKID_ADDR 0x10003018
|
|
|
|
static void __init init_swift(void)
|
|
|
|
{
|
|
|
|
unsigned long swift_rev;
|
|
|
|
|
|
|
|
__asm__ __volatile__("lda [%1] %2, %0\n\t"
|
|
|
|
"srl %0, 0x18, %0\n\t" :
|
|
|
|
"=r" (swift_rev) :
|
|
|
|
"r" (SWIFT_MASKID_ADDR), "i" (ASI_M_BYPASS));
|
|
|
|
srmmu_name = "Fujitsu Swift";
|
2012-07-26 15:02:13 +04:00
|
|
|
switch (swift_rev) {
|
2005-04-17 02:20:36 +04:00
|
|
|
case 0x11:
|
|
|
|
case 0x20:
|
|
|
|
case 0x23:
|
|
|
|
case 0x30:
|
|
|
|
srmmu_modtype = Swift_lots_o_bugs;
|
|
|
|
hwbug_bitmask |= (HWBUG_KERN_ACCBROKEN | HWBUG_KERN_CBITBROKEN);
|
|
|
|
/*
|
|
|
|
* Gee george, I wonder why Sun is so hush hush about
|
|
|
|
* this hardware bug... really braindamage stuff going
|
|
|
|
* on here. However I think we can find a way to avoid
|
|
|
|
* all of the workaround overhead under Linux. Basically,
|
|
|
|
* any page fault can cause kernel pages to become user
|
|
|
|
* accessible (the mmu gets confused and clears some of
|
|
|
|
* the ACC bits in kernel ptes). Aha, sounds pretty
|
|
|
|
* horrible eh? But wait, after extensive testing it appears
|
|
|
|
* that if you use pgd_t level large kernel pte's (like the
|
|
|
|
* 4MB pages on the Pentium) the bug does not get tripped
|
|
|
|
* at all. This avoids almost all of the major overhead.
|
|
|
|
* Welcome to a world where your vendor tells you to,
|
|
|
|
* "apply this kernel patch" instead of "sorry for the
|
|
|
|
* broken hardware, send it back and we'll give you
|
|
|
|
* properly functioning parts"
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
case 0x25:
|
|
|
|
case 0x31:
|
|
|
|
srmmu_modtype = Swift_bad_c;
|
|
|
|
hwbug_bitmask |= HWBUG_KERN_CBITBROKEN;
|
|
|
|
/*
|
|
|
|
* You see Sun allude to this hardware bug but never
|
|
|
|
* admit things directly, they'll say things like,
|
|
|
|
* "the Swift chip cache problems" or similar.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
srmmu_modtype = Swift_ok;
|
|
|
|
break;
|
2011-06-03 18:45:23 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
sparc32_cachetlb_ops = &swift_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
flush_page_for_dma_global = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Are you now convinced that the Swift is one of the
|
|
|
|
* biggest VLSI abortions of all time? Bravo Fujitsu!
|
|
|
|
* Fujitsu, the !#?!%$'d up processor people. I bet if
|
|
|
|
* you examined the microcode of the Swift you'd find
|
|
|
|
* XXX's all over the place.
|
|
|
|
*/
|
|
|
|
poke_srmmu = poke_swift;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_cache_all(void)
|
|
|
|
{
|
|
|
|
flush_user_windows();
|
|
|
|
turbosparc_idflash_clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_cache_mm(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
FLUSH_BEGIN(mm)
|
|
|
|
flush_user_windows();
|
|
|
|
turbosparc_idflash_clear();
|
|
|
|
FLUSH_END
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
FLUSH_BEGIN(vma->vm_mm)
|
|
|
|
flush_user_windows();
|
|
|
|
turbosparc_idflash_clear();
|
|
|
|
FLUSH_END
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_cache_page(struct vm_area_struct *vma, unsigned long page)
|
|
|
|
{
|
|
|
|
FLUSH_BEGIN(vma->vm_mm)
|
|
|
|
flush_user_windows();
|
|
|
|
if (vma->vm_flags & VM_EXEC)
|
|
|
|
turbosparc_flush_icache();
|
|
|
|
turbosparc_flush_dcache();
|
|
|
|
FLUSH_END
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TurboSparc is copy-back, if we turn it on, but this does not work. */
|
|
|
|
static void turbosparc_flush_page_to_ram(unsigned long page)
|
|
|
|
{
|
|
|
|
#ifdef TURBOSPARC_WRITEBACK
|
|
|
|
volatile unsigned long clear;
|
|
|
|
|
2012-05-26 01:20:19 +04:00
|
|
|
if (srmmu_probe(page))
|
2005-04-17 02:20:36 +04:00
|
|
|
turbosparc_flush_page_cache(page);
|
|
|
|
clear = srmmu_get_fstatus();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_page_for_dma(unsigned long page)
|
|
|
|
{
|
|
|
|
turbosparc_flush_dcache();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_tlb_all(void)
|
|
|
|
{
|
|
|
|
srmmu_flush_whole_tlb();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_tlb_mm(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
FLUSH_BEGIN(mm)
|
|
|
|
srmmu_flush_whole_tlb();
|
|
|
|
FLUSH_END
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
FLUSH_BEGIN(vma->vm_mm)
|
|
|
|
srmmu_flush_whole_tlb();
|
|
|
|
FLUSH_END
|
|
|
|
}
|
|
|
|
|
|
|
|
static void turbosparc_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
|
|
|
|
{
|
|
|
|
FLUSH_BEGIN(vma->vm_mm)
|
|
|
|
srmmu_flush_whole_tlb();
|
|
|
|
FLUSH_END
|
|
|
|
}
|
|
|
|
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-17 23:43:14 +04:00
|
|
|
static void poke_turbosparc(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned long mreg = srmmu_get_mmureg();
|
|
|
|
unsigned long ccreg;
|
|
|
|
|
|
|
|
/* Clear any crap from the cache or else... */
|
|
|
|
turbosparc_flush_cache_all();
|
2012-07-26 15:02:13 +04:00
|
|
|
/* Temporarily disable I & D caches */
|
|
|
|
mreg &= ~(TURBOSPARC_ICENABLE | TURBOSPARC_DCENABLE);
|
2005-04-17 02:20:36 +04:00
|
|
|
mreg &= ~(TURBOSPARC_PCENABLE); /* Don't check parity */
|
|
|
|
srmmu_set_mmureg(mreg);
|
2012-07-26 15:02:13 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
ccreg = turbosparc_get_ccreg();
|
|
|
|
|
|
|
|
#ifdef TURBOSPARC_WRITEBACK
|
|
|
|
ccreg |= (TURBOSPARC_SNENABLE); /* Do DVMA snooping in Dcache */
|
|
|
|
ccreg &= ~(TURBOSPARC_uS2 | TURBOSPARC_WTENABLE);
|
|
|
|
/* Write-back D-cache, emulate VLSI
|
|
|
|
* abortion number three, not number one */
|
|
|
|
#else
|
|
|
|
/* For now let's play safe, optimize later */
|
|
|
|
ccreg |= (TURBOSPARC_SNENABLE | TURBOSPARC_WTENABLE);
|
|
|
|
/* Do DVMA snooping in Dcache, Write-thru D-cache */
|
|
|
|
ccreg &= ~(TURBOSPARC_uS2);
|
|
|
|
/* Emulate VLSI abortion number three, not number one */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (ccreg & 7) {
|
|
|
|
case 0: /* No SE cache */
|
|
|
|
case 7: /* Test mode */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ccreg |= (TURBOSPARC_SCENABLE);
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
turbosparc_set_ccreg(ccreg);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
mreg |= (TURBOSPARC_ICENABLE | TURBOSPARC_DCENABLE); /* I & D caches on */
|
|
|
|
mreg |= (TURBOSPARC_ICSNOOP); /* Icache snooping on */
|
|
|
|
srmmu_set_mmureg(mreg);
|
|
|
|
}
|
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
static const struct sparc32_cachetlb_ops turbosparc_ops = {
|
|
|
|
.cache_all = turbosparc_flush_cache_all,
|
|
|
|
.cache_mm = turbosparc_flush_cache_mm,
|
|
|
|
.cache_page = turbosparc_flush_cache_page,
|
|
|
|
.cache_range = turbosparc_flush_cache_range,
|
|
|
|
.tlb_all = turbosparc_flush_tlb_all,
|
|
|
|
.tlb_mm = turbosparc_flush_tlb_mm,
|
|
|
|
.tlb_page = turbosparc_flush_tlb_page,
|
|
|
|
.tlb_range = turbosparc_flush_tlb_range,
|
|
|
|
.page_to_ram = turbosparc_flush_page_to_ram,
|
|
|
|
.sig_insns = turbosparc_flush_sig_insns,
|
|
|
|
.page_for_dma = turbosparc_flush_page_for_dma,
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static void __init init_turbosparc(void)
|
|
|
|
{
|
|
|
|
srmmu_name = "Fujitsu TurboSparc";
|
|
|
|
srmmu_modtype = TurboSparc;
|
2012-05-14 07:49:31 +04:00
|
|
|
sparc32_cachetlb_ops = &turbosparc_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
poke_srmmu = poke_turbosparc;
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-17 23:43:14 +04:00
|
|
|
static void poke_tsunami(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned long mreg = srmmu_get_mmureg();
|
|
|
|
|
|
|
|
tsunami_flush_icache();
|
|
|
|
tsunami_flush_dcache();
|
|
|
|
mreg &= ~TSUNAMI_ITD;
|
|
|
|
mreg |= (TSUNAMI_IENAB | TSUNAMI_DENAB);
|
|
|
|
srmmu_set_mmureg(mreg);
|
|
|
|
}
|
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
static const struct sparc32_cachetlb_ops tsunami_ops = {
|
|
|
|
.cache_all = tsunami_flush_cache_all,
|
|
|
|
.cache_mm = tsunami_flush_cache_mm,
|
|
|
|
.cache_page = tsunami_flush_cache_page,
|
|
|
|
.cache_range = tsunami_flush_cache_range,
|
|
|
|
.tlb_all = tsunami_flush_tlb_all,
|
|
|
|
.tlb_mm = tsunami_flush_tlb_mm,
|
|
|
|
.tlb_page = tsunami_flush_tlb_page,
|
|
|
|
.tlb_range = tsunami_flush_tlb_range,
|
|
|
|
.page_to_ram = tsunami_flush_page_to_ram,
|
|
|
|
.sig_insns = tsunami_flush_sig_insns,
|
|
|
|
.page_for_dma = tsunami_flush_page_for_dma,
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static void __init init_tsunami(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Tsunami's pretty sane, Sun and TI actually got it
|
|
|
|
* somewhat right this time. Fujitsu should have
|
|
|
|
* taken some lessons from them.
|
|
|
|
*/
|
|
|
|
|
|
|
|
srmmu_name = "TI Tsunami";
|
|
|
|
srmmu_modtype = Tsunami;
|
2012-05-14 07:49:31 +04:00
|
|
|
sparc32_cachetlb_ops = &tsunami_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
poke_srmmu = poke_tsunami;
|
|
|
|
|
|
|
|
tsunami_setup_blockops();
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-17 23:43:14 +04:00
|
|
|
static void poke_viking(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned long mreg = srmmu_get_mmureg();
|
|
|
|
static int smp_catch;
|
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
if (viking_mxcc_present) {
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long mxcc_control = mxcc_get_creg();
|
|
|
|
|
|
|
|
mxcc_control |= (MXCC_CTL_ECE | MXCC_CTL_PRE | MXCC_CTL_MCE);
|
|
|
|
mxcc_control &= ~(MXCC_CTL_RRC);
|
|
|
|
mxcc_set_creg(mxcc_control);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't need memory parity checks.
|
|
|
|
* XXX This is a mess, have to dig out later. ecd.
|
|
|
|
viking_mxcc_turn_off_parity(&mreg, &mxcc_control);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* We do cache ptables on MXCC. */
|
|
|
|
mreg |= VIKING_TCENABLE;
|
|
|
|
} else {
|
|
|
|
unsigned long bpreg;
|
|
|
|
|
|
|
|
mreg &= ~(VIKING_TCENABLE);
|
2012-07-26 15:02:13 +04:00
|
|
|
if (smp_catch++) {
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Must disable mixed-cmd mode here for other cpu's. */
|
|
|
|
bpreg = viking_get_bpreg();
|
|
|
|
bpreg &= ~(VIKING_ACTION_MIX);
|
|
|
|
viking_set_bpreg(bpreg);
|
|
|
|
|
|
|
|
/* Just in case PROM does something funny. */
|
|
|
|
msi_set_sync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mreg |= VIKING_SPENABLE;
|
|
|
|
mreg |= (VIKING_ICENABLE | VIKING_DCENABLE);
|
|
|
|
mreg |= VIKING_SBENABLE;
|
|
|
|
mreg &= ~(VIKING_ACENABLE);
|
|
|
|
srmmu_set_mmureg(mreg);
|
|
|
|
}
|
|
|
|
|
2017-01-14 15:31:54 +03:00
|
|
|
static struct sparc32_cachetlb_ops viking_ops __ro_after_init = {
|
2012-05-14 07:49:31 +04:00
|
|
|
.cache_all = viking_flush_cache_all,
|
|
|
|
.cache_mm = viking_flush_cache_mm,
|
|
|
|
.cache_page = viking_flush_cache_page,
|
|
|
|
.cache_range = viking_flush_cache_range,
|
|
|
|
.tlb_all = viking_flush_tlb_all,
|
|
|
|
.tlb_mm = viking_flush_tlb_mm,
|
|
|
|
.tlb_page = viking_flush_tlb_page,
|
|
|
|
.tlb_range = viking_flush_tlb_range,
|
|
|
|
.page_to_ram = viking_flush_page_to_ram,
|
|
|
|
.sig_insns = viking_flush_sig_insns,
|
|
|
|
.page_for_dma = viking_flush_page_for_dma,
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* On sun4d the cpu broadcasts local TLB flushes, so we can just
|
|
|
|
* perform the local TLB flush and all the other cpus will see it.
|
|
|
|
* But, unfortunately, there is a bug in the sun4d XBUS backplane
|
|
|
|
* that requires that we add some synchronization to these flushes.
|
|
|
|
*
|
|
|
|
* The bug is that the fifo which keeps track of all the pending TLB
|
|
|
|
* broadcasts in the system is an entry or two too small, so if we
|
|
|
|
* have too many going at once we'll overflow that fifo and lose a TLB
|
|
|
|
* flush resulting in corruption.
|
|
|
|
*
|
|
|
|
* Our workaround is to take a global spinlock around the TLB flushes,
|
|
|
|
* which guarentees we won't ever have too many pending. It's a big
|
|
|
|
* hammer, but a semaphore like system to make sure we only have N TLB
|
|
|
|
* flushes going at once will require SMP locking anyways so there's
|
|
|
|
* no real value in trying any harder than this.
|
|
|
|
*/
|
2017-01-14 15:31:54 +03:00
|
|
|
static struct sparc32_cachetlb_ops viking_sun4d_smp_ops __ro_after_init = {
|
2012-05-14 07:49:31 +04:00
|
|
|
.cache_all = viking_flush_cache_all,
|
|
|
|
.cache_mm = viking_flush_cache_mm,
|
|
|
|
.cache_page = viking_flush_cache_page,
|
|
|
|
.cache_range = viking_flush_cache_range,
|
|
|
|
.tlb_all = sun4dsmp_flush_tlb_all,
|
|
|
|
.tlb_mm = sun4dsmp_flush_tlb_mm,
|
|
|
|
.tlb_page = sun4dsmp_flush_tlb_page,
|
|
|
|
.tlb_range = sun4dsmp_flush_tlb_range,
|
|
|
|
.page_to_ram = viking_flush_page_to_ram,
|
|
|
|
.sig_insns = viking_flush_sig_insns,
|
|
|
|
.page_for_dma = viking_flush_page_for_dma,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static void __init init_viking(void)
|
|
|
|
{
|
|
|
|
unsigned long mreg = srmmu_get_mmureg();
|
|
|
|
|
|
|
|
/* Ahhh, the viking. SRMMU VLSI abortion number two... */
|
2012-07-26 15:02:13 +04:00
|
|
|
if (mreg & VIKING_MMODE) {
|
2005-04-17 02:20:36 +04:00
|
|
|
srmmu_name = "TI Viking";
|
|
|
|
viking_mxcc_present = 0;
|
|
|
|
msi_set_sync();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need this to make sure old viking takes no hits
|
|
|
|
* on it's cache for dma snoops to workaround the
|
|
|
|
* "load from non-cacheable memory" interrupt bug.
|
|
|
|
* This is only necessary because of the new way in
|
|
|
|
* which we use the IOMMU.
|
|
|
|
*/
|
2012-05-14 07:49:31 +04:00
|
|
|
viking_ops.page_for_dma = viking_flush_page;
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
viking_sun4d_smp_ops.page_for_dma = viking_flush_page;
|
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
flush_page_for_dma_global = 0;
|
|
|
|
} else {
|
|
|
|
srmmu_name = "TI Viking/MXCC";
|
|
|
|
viking_mxcc_present = 1;
|
|
|
|
srmmu_cache_pagetables = 1;
|
|
|
|
}
|
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
sparc32_cachetlb_ops = (const struct sparc32_cachetlb_ops *)
|
|
|
|
&viking_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef CONFIG_SMP
|
2012-05-14 07:49:31 +04:00
|
|
|
if (sparc_cpu_model == sun4d)
|
|
|
|
sparc32_cachetlb_ops = (const struct sparc32_cachetlb_ops *)
|
|
|
|
&viking_sun4d_smp_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
poke_srmmu = poke_viking;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Probe for the srmmu chip version. */
|
|
|
|
static void __init get_srmmu_type(void)
|
|
|
|
{
|
|
|
|
unsigned long mreg, psr;
|
|
|
|
unsigned long mod_typ, mod_rev, psr_typ, psr_vers;
|
|
|
|
|
|
|
|
srmmu_modtype = SRMMU_INVAL_MOD;
|
|
|
|
hwbug_bitmask = 0;
|
|
|
|
|
|
|
|
mreg = srmmu_get_mmureg(); psr = get_psr();
|
|
|
|
mod_typ = (mreg & 0xf0000000) >> 28;
|
|
|
|
mod_rev = (mreg & 0x0f000000) >> 24;
|
|
|
|
psr_typ = (psr >> 28) & 0xf;
|
|
|
|
psr_vers = (psr >> 24) & 0xf;
|
|
|
|
|
2009-08-17 04:13:33 +04:00
|
|
|
/* First, check for sparc-leon. */
|
|
|
|
if (sparc_cpu_model == sparc_leon) {
|
|
|
|
init_leon();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Second, check for HyperSparc or Cypress. */
|
2012-07-26 15:02:13 +04:00
|
|
|
if (mod_typ == 1) {
|
|
|
|
switch (mod_rev) {
|
2005-04-17 02:20:36 +04:00
|
|
|
case 7:
|
|
|
|
/* UP or MP Hypersparc */
|
|
|
|
init_hypersparc();
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 2:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
case 12:
|
|
|
|
case 13:
|
|
|
|
case 14:
|
|
|
|
case 15:
|
|
|
|
default:
|
2012-05-15 09:02:08 +04:00
|
|
|
prom_printf("Sparc-Linux Cypress support does not longer exit.\n");
|
|
|
|
prom_halt();
|
2005-04-17 02:20:36 +04:00
|
|
|
break;
|
2011-06-03 18:45:23 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
|
|
|
|
/* Now Fujitsu TurboSparc. It might happen that it is
|
2005-04-17 02:20:36 +04:00
|
|
|
* in Swift emulation mode, so we will check later...
|
|
|
|
*/
|
|
|
|
if (psr_typ == 0 && psr_vers == 5) {
|
|
|
|
init_turbosparc();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Next check for Fujitsu Swift. */
|
2012-07-26 15:02:13 +04:00
|
|
|
if (psr_typ == 0 && psr_vers == 4) {
|
2010-10-09 01:18:11 +04:00
|
|
|
phandle cpunode;
|
2005-04-17 02:20:36 +04:00
|
|
|
char node_str[128];
|
|
|
|
|
|
|
|
/* Look if it is not a TurboSparc emulating Swift... */
|
|
|
|
cpunode = prom_getchild(prom_root_node);
|
2012-07-26 15:02:13 +04:00
|
|
|
while ((cpunode = prom_getsibling(cpunode)) != 0) {
|
2005-04-17 02:20:36 +04:00
|
|
|
prom_getstring(cpunode, "device_type", node_str, sizeof(node_str));
|
2012-07-26 15:02:13 +04:00
|
|
|
if (!strcmp(node_str, "cpu")) {
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!prom_getintdefault(cpunode, "psr-implementation", 1) &&
|
|
|
|
prom_getintdefault(cpunode, "psr-version", 1) == 5) {
|
|
|
|
init_turbosparc();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-07-26 15:02:13 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
init_swift();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now the Viking family of srmmu. */
|
2012-07-26 15:02:13 +04:00
|
|
|
if (psr_typ == 4 &&
|
2005-04-17 02:20:36 +04:00
|
|
|
((psr_vers == 0) ||
|
|
|
|
((psr_vers == 1) && (mod_typ == 0) && (mod_rev == 0)))) {
|
|
|
|
init_viking();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally the Tsunami. */
|
2012-07-26 15:02:13 +04:00
|
|
|
if (psr_typ == 4 && psr_vers == 1 && (mod_typ || mod_rev)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
init_tsunami();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Oh well */
|
|
|
|
srmmu_is_bad();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Local cross-calls. */
|
|
|
|
static void smp_flush_page_for_dma(unsigned long page)
|
|
|
|
{
|
2012-05-14 07:49:31 +04:00
|
|
|
xc1((smpfunc_t) local_ops->page_for_dma, page);
|
|
|
|
local_ops->page_for_dma(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_cache_all(void)
|
|
|
|
{
|
|
|
|
xc0((smpfunc_t) local_ops->cache_all);
|
|
|
|
local_ops->cache_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_tlb_all(void)
|
|
|
|
{
|
|
|
|
xc0((smpfunc_t) local_ops->tlb_all);
|
|
|
|
local_ops->tlb_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_cache_mm(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
if (mm->context != NO_CONTEXT) {
|
|
|
|
cpumask_t cpu_mask;
|
|
|
|
cpumask_copy(&cpu_mask, mm_cpumask(mm));
|
|
|
|
cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
|
|
|
|
if (!cpumask_empty(&cpu_mask))
|
|
|
|
xc1((smpfunc_t) local_ops->cache_mm, (unsigned long) mm);
|
|
|
|
local_ops->cache_mm(mm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_tlb_mm(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
if (mm->context != NO_CONTEXT) {
|
|
|
|
cpumask_t cpu_mask;
|
|
|
|
cpumask_copy(&cpu_mask, mm_cpumask(mm));
|
|
|
|
cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
|
|
|
|
if (!cpumask_empty(&cpu_mask)) {
|
|
|
|
xc1((smpfunc_t) local_ops->tlb_mm, (unsigned long) mm);
|
|
|
|
if (atomic_read(&mm->mm_users) == 1 && current->active_mm == mm)
|
|
|
|
cpumask_copy(mm_cpumask(mm),
|
|
|
|
cpumask_of(smp_processor_id()));
|
|
|
|
}
|
|
|
|
local_ops->tlb_mm(mm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_cache_range(struct vm_area_struct *vma,
|
|
|
|
unsigned long start,
|
|
|
|
unsigned long end)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
|
|
|
|
if (mm->context != NO_CONTEXT) {
|
|
|
|
cpumask_t cpu_mask;
|
|
|
|
cpumask_copy(&cpu_mask, mm_cpumask(mm));
|
|
|
|
cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
|
|
|
|
if (!cpumask_empty(&cpu_mask))
|
|
|
|
xc3((smpfunc_t) local_ops->cache_range,
|
|
|
|
(unsigned long) vma, start, end);
|
|
|
|
local_ops->cache_range(vma, start, end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_tlb_range(struct vm_area_struct *vma,
|
|
|
|
unsigned long start,
|
|
|
|
unsigned long end)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
|
|
|
|
if (mm->context != NO_CONTEXT) {
|
|
|
|
cpumask_t cpu_mask;
|
|
|
|
cpumask_copy(&cpu_mask, mm_cpumask(mm));
|
|
|
|
cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
|
|
|
|
if (!cpumask_empty(&cpu_mask))
|
|
|
|
xc3((smpfunc_t) local_ops->tlb_range,
|
|
|
|
(unsigned long) vma, start, end);
|
|
|
|
local_ops->tlb_range(vma, start, end);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
static void smp_flush_cache_page(struct vm_area_struct *vma, unsigned long page)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
|
|
|
|
if (mm->context != NO_CONTEXT) {
|
|
|
|
cpumask_t cpu_mask;
|
|
|
|
cpumask_copy(&cpu_mask, mm_cpumask(mm));
|
|
|
|
cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
|
|
|
|
if (!cpumask_empty(&cpu_mask))
|
|
|
|
xc2((smpfunc_t) local_ops->cache_page,
|
|
|
|
(unsigned long) vma, page);
|
|
|
|
local_ops->cache_page(vma, page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
|
|
|
|
{
|
|
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
|
|
|
|
if (mm->context != NO_CONTEXT) {
|
|
|
|
cpumask_t cpu_mask;
|
|
|
|
cpumask_copy(&cpu_mask, mm_cpumask(mm));
|
|
|
|
cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
|
|
|
|
if (!cpumask_empty(&cpu_mask))
|
|
|
|
xc2((smpfunc_t) local_ops->tlb_page,
|
|
|
|
(unsigned long) vma, page);
|
|
|
|
local_ops->tlb_page(vma, page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_page_to_ram(unsigned long page)
|
|
|
|
{
|
|
|
|
/* Current theory is that those who call this are the one's
|
|
|
|
* who have just dirtied their cache with the pages contents
|
|
|
|
* in kernel space, therefore we only run this on local cpu.
|
|
|
|
*
|
|
|
|
* XXX This experiment failed, research further... -DaveM
|
|
|
|
*/
|
|
|
|
#if 1
|
|
|
|
xc1((smpfunc_t) local_ops->page_to_ram, page);
|
|
|
|
#endif
|
|
|
|
local_ops->page_to_ram(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr)
|
|
|
|
{
|
|
|
|
cpumask_t cpu_mask;
|
|
|
|
cpumask_copy(&cpu_mask, mm_cpumask(mm));
|
|
|
|
cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
|
|
|
|
if (!cpumask_empty(&cpu_mask))
|
|
|
|
xc2((smpfunc_t) local_ops->sig_insns,
|
|
|
|
(unsigned long) mm, insn_addr);
|
|
|
|
local_ops->sig_insns(mm, insn_addr);
|
|
|
|
}
|
|
|
|
|
2017-01-14 15:31:54 +03:00
|
|
|
static struct sparc32_cachetlb_ops smp_cachetlb_ops __ro_after_init = {
|
2012-05-14 07:49:31 +04:00
|
|
|
.cache_all = smp_flush_cache_all,
|
|
|
|
.cache_mm = smp_flush_cache_mm,
|
|
|
|
.cache_page = smp_flush_cache_page,
|
|
|
|
.cache_range = smp_flush_cache_range,
|
|
|
|
.tlb_all = smp_flush_tlb_all,
|
|
|
|
.tlb_mm = smp_flush_tlb_mm,
|
|
|
|
.tlb_page = smp_flush_tlb_page,
|
|
|
|
.tlb_range = smp_flush_tlb_range,
|
|
|
|
.page_to_ram = smp_flush_page_to_ram,
|
|
|
|
.sig_insns = smp_flush_sig_insns,
|
|
|
|
.page_for_dma = smp_flush_page_for_dma,
|
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Load up routines and constants for sun4m and sun4d mmu */
|
2012-05-12 22:35:52 +04:00
|
|
|
void __init load_mmu(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
/* Functions */
|
|
|
|
get_srmmu_type();
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* El switcheroo... */
|
2012-05-14 07:49:31 +04:00
|
|
|
local_ops = sparc32_cachetlb_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-05-14 07:49:31 +04:00
|
|
|
if (sparc_cpu_model == sun4d || sparc_cpu_model == sparc_leon) {
|
|
|
|
smp_cachetlb_ops.tlb_all = local_ops->tlb_all;
|
|
|
|
smp_cachetlb_ops.tlb_mm = local_ops->tlb_mm;
|
|
|
|
smp_cachetlb_ops.tlb_range = local_ops->tlb_range;
|
|
|
|
smp_cachetlb_ops.tlb_page = local_ops->tlb_page;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2008-11-26 12:00:58 +03:00
|
|
|
|
|
|
|
if (poke_srmmu == poke_viking) {
|
|
|
|
/* Avoid unnecessary cross calls. */
|
2012-05-14 07:49:31 +04:00
|
|
|
smp_cachetlb_ops.cache_all = local_ops->cache_all;
|
|
|
|
smp_cachetlb_ops.cache_mm = local_ops->cache_mm;
|
|
|
|
smp_cachetlb_ops.cache_range = local_ops->cache_range;
|
|
|
|
smp_cachetlb_ops.cache_page = local_ops->cache_page;
|
|
|
|
|
|
|
|
smp_cachetlb_ops.page_to_ram = local_ops->page_to_ram;
|
|
|
|
smp_cachetlb_ops.sig_insns = local_ops->sig_insns;
|
|
|
|
smp_cachetlb_ops.page_for_dma = local_ops->page_for_dma;
|
2008-11-26 12:00:58 +03:00
|
|
|
}
|
2012-05-14 07:49:31 +04:00
|
|
|
|
|
|
|
/* It really is const after this point. */
|
|
|
|
sparc32_cachetlb_ops = (const struct sparc32_cachetlb_ops *)
|
|
|
|
&smp_cachetlb_ops;
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
2020-03-23 11:43:42 +03:00
|
|
|
if (sparc_cpu_model != sun4d)
|
2005-04-17 02:20:36 +04:00
|
|
|
ld_mmu_iommu();
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
if (sparc_cpu_model == sun4d)
|
|
|
|
sun4d_init_smp();
|
2009-09-01 02:08:13 +04:00
|
|
|
else if (sparc_cpu_model == sparc_leon)
|
|
|
|
leon_init_smp();
|
2005-04-17 02:20:36 +04:00
|
|
|
else
|
|
|
|
sun4m_init_smp();
|
|
|
|
#endif
|
|
|
|
}
|