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 15:07:57 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2011-01-28 23:08:21 +01:00
|
|
|
/* Sparc SS1000/SC2000 SMP support.
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
|
|
*
|
|
|
|
* Based on sun4m's smp.c, which is:
|
|
|
|
* Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
*/
|
|
|
|
|
2012-04-04 21:49:26 +02:00
|
|
|
#include <linux/clockchips.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/profile.h>
|
2008-02-06 10:37:51 +01:00
|
|
|
#include <linux/delay.h>
|
2017-02-01 19:08:20 +01:00
|
|
|
#include <linux/sched/mm.h>
|
2008-10-13 05:52:26 +02:00
|
|
|
#include <linux/cpu.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-04-04 21:49:26 +02:00
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/switch_to.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
#include <asm/timer.h>
|
2012-05-14 05:49:31 +02:00
|
|
|
#include <asm/oplib.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/sbi.h>
|
2011-01-28 23:08:21 +01:00
|
|
|
#include <asm/mmu.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-01-28 23:08:21 +01:00
|
|
|
#include "kernel.h"
|
2007-07-22 04:18:57 +02:00
|
|
|
#include "irq.h"
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-01-28 23:08:21 +01:00
|
|
|
#define IRQ_CROSS_CALL 15
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-01-28 23:08:21 +01:00
|
|
|
static volatile int smp_processors_ready;
|
2005-04-17 00:20:36 +02:00
|
|
|
static int smp_highest_cpu;
|
|
|
|
|
2009-01-09 01:47:17 +01:00
|
|
|
static inline unsigned long sun4d_swap(volatile unsigned long *ptr, unsigned long val)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__asm__ __volatile__("swap [%1], %0\n\t" :
|
|
|
|
"=&r" (val), "=&r" (ptr) :
|
|
|
|
"0" (val), "1" (ptr));
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2011-05-02 02:08:54 +02:00
|
|
|
static void smp4d_ipi_init(void);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-09-02 10:17:41 +02:00
|
|
|
static unsigned char cpu_leds[32];
|
|
|
|
|
|
|
|
static inline void show_leds(int cpuid)
|
|
|
|
{
|
|
|
|
cpuid &= 0x1e;
|
|
|
|
__asm__ __volatile__ ("stba %0, [%1] %2" : :
|
|
|
|
"r" ((cpu_leds[cpuid] << 4) | cpu_leds[cpuid+1]),
|
|
|
|
"r" (ECSR_BASE(cpuid) | BB_LEDS),
|
|
|
|
"i" (ASI_M_CTL));
|
|
|
|
}
|
|
|
|
|
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 21:43:14 +02:00
|
|
|
void sun4d_cpu_pre_starting(void *arg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2012-05-14 08:09:04 +02:00
|
|
|
int cpuid = hard_smp_processor_id();
|
2011-01-28 23:08:21 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Show we are alive */
|
|
|
|
cpu_leds[cpuid] = 0x6;
|
|
|
|
show_leds(cpuid);
|
|
|
|
|
|
|
|
/* Enable level15 interrupt, disable level14 interrupt for now */
|
|
|
|
cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000);
|
2013-02-15 15:52:06 +01:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
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 21:43:14 +02:00
|
|
|
void sun4d_cpu_pre_online(void *arg)
|
2013-02-15 15:52:06 +01:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int cpuid;
|
|
|
|
|
|
|
|
cpuid = hard_smp_processor_id();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2013-02-15 15:52:06 +01:00
|
|
|
/* Unblock the master CPU _only_ when the scheduler state
|
2005-04-17 00:20:36 +02:00
|
|
|
* of all secondary CPUs will be up-to-date, so after
|
|
|
|
* the SMP initialization the master will be just allowed
|
|
|
|
* to call the scheduler code.
|
|
|
|
*/
|
2009-01-09 01:47:17 +01:00
|
|
|
sun4d_swap((unsigned long *)&cpu_callin_map[cpuid], 1);
|
2012-05-14 05:49:31 +02:00
|
|
|
local_ops->cache_all();
|
|
|
|
local_ops->tlb_all();
|
2011-01-28 23:08:21 +01:00
|
|
|
|
|
|
|
while ((unsigned long)current_set[cpuid] < PAGE_OFFSET)
|
2005-04-17 00:20:36 +02:00
|
|
|
barrier();
|
2011-01-28 23:08:21 +01:00
|
|
|
|
|
|
|
while (current_set[cpuid]->cpu != cpuid)
|
2005-04-17 00:20:36 +02:00
|
|
|
barrier();
|
2011-01-28 23:08:21 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Fix idle thread fields. */
|
|
|
|
__asm__ __volatile__("ld [%0], %%g6\n\t"
|
|
|
|
: : "r" (¤t_set[cpuid])
|
|
|
|
: "memory" /* paranoid */);
|
|
|
|
|
|
|
|
cpu_leds[cpuid] = 0x9;
|
|
|
|
show_leds(cpuid);
|
2011-01-28 23:08:21 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Attach to the address space of init_task. */
|
2017-02-27 23:30:07 +01:00
|
|
|
mmgrab(&init_mm);
|
2005-04-17 00:20:36 +02:00
|
|
|
current->active_mm = &init_mm;
|
|
|
|
|
2012-05-14 05:49:31 +02:00
|
|
|
local_ops->cache_all();
|
|
|
|
local_ops->tlb_all();
|
2011-01-28 23:08:21 +01:00
|
|
|
|
2011-05-16 22:38:07 +02:00
|
|
|
while (!cpumask_test_cpu(cpuid, &smp_commenced_mask))
|
2005-04-17 00:20:36 +02:00
|
|
|
barrier();
|
|
|
|
|
|
|
|
spin_lock_irqsave(&sun4d_imsk_lock, flags);
|
|
|
|
cc_set_imsk(cc_get_imsk() & ~0x4000); /* Allow PIL 14 as well */
|
|
|
|
spin_unlock_irqrestore(&sun4d_imsk_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cycle through the processors asking the PROM to start each one.
|
|
|
|
*/
|
|
|
|
void __init smp4d_boot_cpus(void)
|
|
|
|
{
|
2011-05-02 02:08:54 +02:00
|
|
|
smp4d_ipi_init();
|
2005-04-17 00:20:36 +02:00
|
|
|
if (boot_cpu_id)
|
|
|
|
current_set[0] = NULL;
|
2012-05-14 05:49:31 +02:00
|
|
|
local_ops->cache_all();
|
2006-07-18 06:57:09 +02:00
|
|
|
}
|
|
|
|
|
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 21:43:14 +02:00
|
|
|
int smp4d_boot_one_cpu(int i, struct task_struct *idle)
|
2006-07-18 06:57:09 +02:00
|
|
|
{
|
2011-01-28 23:08:21 +01:00
|
|
|
unsigned long *entry = &sun4d_cpu_startup;
|
|
|
|
int timeout;
|
|
|
|
int cpu_node;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-01-28 23:08:21 +01:00
|
|
|
cpu_find_by_instance(i, &cpu_node, NULL);
|
2012-04-20 15:05:56 +02:00
|
|
|
current_set[i] = task_thread_info(idle);
|
2011-01-28 23:08:21 +01:00
|
|
|
/*
|
|
|
|
* Initialize the contexts table
|
|
|
|
* Since the call to prom_startcpu() trashes the structure,
|
|
|
|
* we need to re-initialize it for each cpu
|
|
|
|
*/
|
|
|
|
smp_penguin_ctable.which_io = 0;
|
|
|
|
smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys;
|
|
|
|
smp_penguin_ctable.reg_size = 0;
|
|
|
|
|
|
|
|
/* whirrr, whirrr, whirrrrrrrrr... */
|
|
|
|
printk(KERN_INFO "Starting CPU %d at %p\n", i, entry);
|
2012-05-14 05:49:31 +02:00
|
|
|
local_ops->cache_all();
|
2011-01-28 23:08:21 +01:00
|
|
|
prom_startcpu(cpu_node,
|
|
|
|
&smp_penguin_ctable, 0, (char *)entry);
|
|
|
|
|
|
|
|
printk(KERN_INFO "prom_startcpu returned :)\n");
|
|
|
|
|
|
|
|
/* wheee... it's going... */
|
|
|
|
for (timeout = 0; timeout < 10000; timeout++) {
|
|
|
|
if (cpu_callin_map[i])
|
|
|
|
break;
|
|
|
|
udelay(200);
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-07-18 06:57:09 +02:00
|
|
|
if (!(cpu_callin_map[i])) {
|
2011-01-28 23:08:21 +01:00
|
|
|
printk(KERN_ERR "Processor %d is stuck.\n", i);
|
2006-07-18 06:57:09 +02:00
|
|
|
return -ENODEV;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2012-05-14 05:49:31 +02:00
|
|
|
local_ops->cache_all();
|
2006-07-18 06:57:09 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init smp4d_smp_done(void)
|
|
|
|
{
|
|
|
|
int i, first;
|
|
|
|
int *prev;
|
|
|
|
|
|
|
|
/* setup cpu list for irq rotation */
|
|
|
|
first = 0;
|
|
|
|
prev = &first;
|
2009-03-16 05:10:24 +01:00
|
|
|
for_each_online_cpu(i) {
|
|
|
|
*prev = i;
|
|
|
|
prev = &cpu_data(i).next;
|
|
|
|
}
|
2006-07-18 06:57:09 +02:00
|
|
|
*prev = first;
|
2012-05-14 05:49:31 +02:00
|
|
|
local_ops->cache_all();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Ok, they are spinning and ready to go. */
|
|
|
|
smp_processors_ready = 1;
|
|
|
|
sun4d_distribute_irqs();
|
|
|
|
}
|
|
|
|
|
2011-05-02 02:08:54 +02:00
|
|
|
/* Memory structure giving interrupt handler information about IPI generated */
|
|
|
|
struct sun4d_ipi_work {
|
|
|
|
int single;
|
|
|
|
int msk;
|
|
|
|
int resched;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DEFINE_PER_CPU_SHARED_ALIGNED(struct sun4d_ipi_work, sun4d_ipi_work);
|
|
|
|
|
|
|
|
/* Initialize IPIs on the SUN4D SMP machine */
|
|
|
|
static void __init smp4d_ipi_init(void)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
struct sun4d_ipi_work *work;
|
|
|
|
|
|
|
|
printk(KERN_INFO "smp4d: setup IPI at IRQ %d\n", SUN4D_IPI_IRQ);
|
|
|
|
|
|
|
|
for_each_possible_cpu(cpu) {
|
|
|
|
work = &per_cpu(sun4d_ipi_work, cpu);
|
|
|
|
work->single = work->msk = work->resched = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sun4d_ipi_interrupt(void)
|
|
|
|
{
|
sparc: Replace __get_cpu_var uses
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: sparclinux@vger.kernel.org
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2014-08-17 19:30:54 +02:00
|
|
|
struct sun4d_ipi_work *work = this_cpu_ptr(&sun4d_ipi_work);
|
2011-05-02 02:08:54 +02:00
|
|
|
|
|
|
|
if (work->single) {
|
|
|
|
work->single = 0;
|
|
|
|
smp_call_function_single_interrupt();
|
|
|
|
}
|
|
|
|
if (work->msk) {
|
|
|
|
work->msk = 0;
|
|
|
|
smp_call_function_interrupt();
|
|
|
|
}
|
|
|
|
if (work->resched) {
|
|
|
|
work->resched = 0;
|
|
|
|
smp_resched_interrupt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-14 15:14:36 +02:00
|
|
|
/* +-------+-------------+-----------+------------------------------------+
|
|
|
|
* | bcast | devid | sid | levels mask |
|
|
|
|
* +-------+-------------+-----------+------------------------------------+
|
|
|
|
* 31 30 23 22 15 14 0
|
|
|
|
*/
|
|
|
|
#define IGEN_MESSAGE(bcast, devid, sid, levels) \
|
|
|
|
(((bcast) << 31) | ((devid) << 23) | ((sid) << 15) | (levels))
|
|
|
|
|
|
|
|
static void sun4d_send_ipi(int cpu, int level)
|
|
|
|
{
|
|
|
|
cc_set_igen(IGEN_MESSAGE(0, cpu << 3, 6 + ((level >> 1) & 7), 1 << (level - 1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sun4d_ipi_single(int cpu)
|
2011-05-02 02:08:54 +02:00
|
|
|
{
|
|
|
|
struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu);
|
|
|
|
|
|
|
|
/* Mark work */
|
|
|
|
work->single = 1;
|
|
|
|
|
|
|
|
/* Generate IRQ on the CPU */
|
|
|
|
sun4d_send_ipi(cpu, SUN4D_IPI_IRQ);
|
|
|
|
}
|
|
|
|
|
2012-05-14 15:14:36 +02:00
|
|
|
static void sun4d_ipi_mask_one(int cpu)
|
2011-05-02 02:08:54 +02:00
|
|
|
{
|
|
|
|
struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu);
|
|
|
|
|
|
|
|
/* Mark work */
|
|
|
|
work->msk = 1;
|
|
|
|
|
|
|
|
/* Generate IRQ on the CPU */
|
|
|
|
sun4d_send_ipi(cpu, SUN4D_IPI_IRQ);
|
|
|
|
}
|
|
|
|
|
2012-05-14 15:14:36 +02:00
|
|
|
static void sun4d_ipi_resched(int cpu)
|
2011-05-02 02:08:54 +02:00
|
|
|
{
|
|
|
|
struct sun4d_ipi_work *work = &per_cpu(sun4d_ipi_work, cpu);
|
|
|
|
|
|
|
|
/* Mark work */
|
|
|
|
work->resched = 1;
|
|
|
|
|
|
|
|
/* Generate IRQ on the CPU (any IRQ will cause resched) */
|
|
|
|
sun4d_send_ipi(cpu, SUN4D_IPI_IRQ);
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static struct smp_funcall {
|
|
|
|
smpfunc_t func;
|
|
|
|
unsigned long arg1;
|
|
|
|
unsigned long arg2;
|
|
|
|
unsigned long arg3;
|
|
|
|
unsigned long arg4;
|
|
|
|
unsigned long arg5;
|
|
|
|
unsigned char processors_in[NR_CPUS]; /* Set when ipi entered. */
|
|
|
|
unsigned char processors_out[NR_CPUS]; /* Set when ipi exited. */
|
|
|
|
} ccall_info __attribute__((aligned(8)));
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(cross_call_lock);
|
|
|
|
|
|
|
|
/* Cross calls must be serialized, at least currently. */
|
2012-05-14 15:14:36 +02:00
|
|
|
static void sun4d_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1,
|
2008-08-28 05:03:22 +02:00
|
|
|
unsigned long arg2, unsigned long arg3,
|
|
|
|
unsigned long arg4)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2011-01-28 23:08:21 +01:00
|
|
|
if (smp_processors_ready) {
|
2005-04-17 00:20:36 +02:00
|
|
|
register int high = smp_highest_cpu;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&cross_call_lock, flags);
|
|
|
|
|
|
|
|
{
|
2011-01-28 23:08:21 +01:00
|
|
|
/*
|
|
|
|
* If you make changes here, make sure
|
|
|
|
* gcc generates proper code...
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
register smpfunc_t f asm("i0") = func;
|
|
|
|
register unsigned long a1 asm("i1") = arg1;
|
|
|
|
register unsigned long a2 asm("i2") = arg2;
|
|
|
|
register unsigned long a3 asm("i3") = arg3;
|
|
|
|
register unsigned long a4 asm("i4") = arg4;
|
2008-08-28 05:03:22 +02:00
|
|
|
register unsigned long a5 asm("i5") = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"std %0, [%6]\n\t"
|
|
|
|
"std %2, [%6 + 8]\n\t"
|
|
|
|
"std %4, [%6 + 16]\n\t" : :
|
|
|
|
"r"(f), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5),
|
|
|
|
"r" (&ccall_info.func));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init receive/complete mapping, plus fire the IPI's off. */
|
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
2011-05-16 22:38:07 +02:00
|
|
|
cpumask_clear_cpu(smp_processor_id(), &mask);
|
|
|
|
cpumask_and(&mask, cpu_online_mask, &mask);
|
2011-01-28 23:08:21 +01:00
|
|
|
for (i = 0; i <= high; i++) {
|
2011-05-16 22:38:07 +02:00
|
|
|
if (cpumask_test_cpu(i, &mask)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
ccall_info.processors_in[i] = 0;
|
|
|
|
ccall_info.processors_out[i] = 0;
|
|
|
|
sun4d_send_ipi(i, IRQ_CROSS_CALL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
do {
|
2011-05-16 22:38:07 +02:00
|
|
|
if (!cpumask_test_cpu(i, &mask))
|
2008-08-28 05:03:22 +02:00
|
|
|
continue;
|
2011-01-28 23:08:21 +01:00
|
|
|
while (!ccall_info.processors_in[i])
|
2005-04-17 00:20:36 +02:00
|
|
|
barrier();
|
2011-01-28 23:08:21 +01:00
|
|
|
} while (++i <= high);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
do {
|
2011-05-16 22:38:07 +02:00
|
|
|
if (!cpumask_test_cpu(i, &mask))
|
2008-08-28 05:03:22 +02:00
|
|
|
continue;
|
2011-01-28 23:08:21 +01:00
|
|
|
while (!ccall_info.processors_out[i])
|
2005-04-17 00:20:36 +02:00
|
|
|
barrier();
|
2011-01-28 23:08:21 +01:00
|
|
|
} while (++i <= high);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&cross_call_lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Running cross calls. */
|
|
|
|
void smp4d_cross_call_irq(void)
|
|
|
|
{
|
2012-05-14 08:09:04 +02:00
|
|
|
int i = hard_smp_processor_id();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
ccall_info.processors_in[i] = 1;
|
|
|
|
ccall_info.func(ccall_info.arg1, ccall_info.arg2, ccall_info.arg3,
|
|
|
|
ccall_info.arg4, ccall_info.arg5);
|
|
|
|
ccall_info.processors_out[i] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void smp4d_percpu_timer_interrupt(struct pt_regs *regs)
|
|
|
|
{
|
2006-10-08 15:30:44 +02:00
|
|
|
struct pt_regs *old_regs;
|
2012-05-14 08:09:04 +02:00
|
|
|
int cpu = hard_smp_processor_id();
|
2012-04-04 21:49:26 +02:00
|
|
|
struct clock_event_device *ce;
|
2005-04-17 00:20:36 +02:00
|
|
|
static int cpu_tick[NR_CPUS];
|
|
|
|
static char led_mask[] = { 0xe, 0xd, 0xb, 0x7, 0xb, 0xd };
|
|
|
|
|
2006-10-08 15:30:44 +02:00
|
|
|
old_regs = set_irq_regs(regs);
|
2011-01-28 23:08:21 +01:00
|
|
|
bw_get_prof_limit(cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
bw_clear_intr_mask(0, 1); /* INTR_TABLE[0] & 1 is Profile IRQ */
|
|
|
|
|
|
|
|
cpu_tick[cpu]++;
|
|
|
|
if (!(cpu_tick[cpu] & 15)) {
|
|
|
|
if (cpu_tick[cpu] == 0x60)
|
|
|
|
cpu_tick[cpu] = 0;
|
|
|
|
cpu_leds[cpu] = led_mask[cpu_tick[cpu] >> 4];
|
|
|
|
show_leds(cpu);
|
|
|
|
}
|
|
|
|
|
2012-04-04 21:49:26 +02:00
|
|
|
ce = &per_cpu(sparc32_clockevent, cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-04-04 21:49:26 +02:00
|
|
|
irq_enter();
|
|
|
|
ce->event_handler(ce);
|
|
|
|
irq_exit();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-10-08 15:30:44 +02:00
|
|
|
set_irq_regs(old_regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2012-05-14 15:14:36 +02:00
|
|
|
static const struct sparc32_ipi_ops sun4d_ipi_ops = {
|
|
|
|
.cross_call = sun4d_cross_call,
|
|
|
|
.resched = sun4d_ipi_resched,
|
|
|
|
.single = sun4d_ipi_single,
|
|
|
|
.mask_one = sun4d_ipi_mask_one,
|
|
|
|
};
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
void __init sun4d_init_smp(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Patch ipi15 trap table */
|
|
|
|
t_nmi[1] = t_nmi[1] + (linux_trap_ipi15_sun4d - linux_trap_ipi15_sun4m);
|
2011-01-28 23:08:21 +01:00
|
|
|
|
2012-05-14 15:14:36 +02:00
|
|
|
sparc32_ipi_ops = &sun4d_ipi_ops;
|
2011-01-28 23:08:21 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
for (i = 0; i < NR_CPUS; i++) {
|
|
|
|
ccall_info.processors_in[i] = 1;
|
|
|
|
ccall_info.processors_out[i] = 1;
|
|
|
|
}
|
|
|
|
}
|