mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
OpenRISC updates for v4.15
Small Things:
- Move OpenRISC docs into Documentation and clean them up
- Document previously undocumented devicetree bindings
- Update the or1ksim dts to use stdout-path
OpenRISC SMP support details:
- First the "use shadow registers" and "define CPU_BIG_ENDIAN as true"
get the architecture ready for SMP.
- The "add 1 and 2 byte cmpxchg support" and "use qspinlocks and
qrwlocks" add the SMP locking infrastructure as needed. Using the
qspinlocks and qrwlocks as suggested by Peter Z while reviewing the
original spinlocks implementation.
- The "support for ompic" adds a new irqchip device which is used for
IPI communication to support SMP.
- The "initial SMP support" adds smp.c and makes changes to all of the
necessary data-structures to be per-cpu.
- The remaining patches are bug fixes and debug helpers which I wanted
to keep separate from the "initial SMP support" in order to allow them
to be reviewed on their own. This includes:
- add cacheflush support to fix icache aliasing
- fix initial preempt state for secondary cpu tasks
- sleep instead of spin on secondary wait
- support framepointers and STACKTRACE_SUPPORT
- enable LOCKDEP_SUPPORT and irqflags tracing
- timer sync: Add tick timer sync logic
- fix possible deadlock in timer sync, pointed out by mips guys
Note: the irqchip patch was reviewed with Marc and we agreed to push it
together with these patches.
-----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJaCaO/AAoJEMOzHC1eZifkwyUQAIwp5q242D5P0Mo8gvpmNZ7s
Lc7XBe1+dahbW8OIh0b8XhufkwFHY614bnrDBAr8GOcbaOXgxk8LbhTmkwbFO9z7
fm5YKr7il0dunCWfw278sQcZsCRQ9sQkXIei0gJL/56Uq6dbJhIREcOgjHBjDW5r
tblrbv70fPmTCP/7cw08y4QwXIAf+8zEhECJcDKqFZ2nhQkWQUd3BAppxdCOWSDa
aV9qOa/koP9lAKg8aWOCwCuS+WK386KNCCowsTxpyWdl9tMWsebeBh1odxteKiiB
KpAENfEvbjuYMWH3CQ+XdSDDdIdGnIP6l5KDzBkhF1USXwS7AlaMUpbPHcLXVRFi
1S2zcO9i6WfTnaDpNZc+L8oHqgyLUDJ6RgC6juLEmbfnCVmzNkLKCYa3d3JRI/oC
6qxpHYkLKWsJoOHDcs0fiMOLhkJZrzPYkIv0fW+uwTM10onxhm48fm6RNWuwqXWd
4FoH8ufqeACxWEotv6pcL7RUYrmX1gmvxby8CCHiUBIBoRM3bGmqTVvgX64nULgB
QIn/74R3J6GDPKicHDcq8ZOnMWvE6nbpXXbX73PqjXMf80HVjejV3Fg2su8m7LR0
+ni1ndKYB3V+t0+m1m5eMvpKMQ2HrMIMdx0M4xL+Z0fT8B3lcZWpb4wBsG7E+C49
pyf9xEk34Fe7HR+7KBO9
=euP7
-----END PGP SIGNATURE-----
Merge tag 'for-linus' of git://github.com/openrisc/linux
Pull OpenRISC updates from Stafford Horne:
"The OpenRISC work is a bit more interesting this time, adding SMP
support and a few general cleanups.
Small Things:
- Move OpenRISC docs into Documentation and clean them up
- Document previously undocumented devicetree bindings
- Update the or1ksim dts to use stdout-path
OpenRISC SMP support details:
- First the "use shadow registers" and "define CPU_BIG_ENDIAN as
true" get the architecture ready for SMP.
- The "add 1 and 2 byte cmpxchg support" and "use qspinlocks and
qrwlocks" add the SMP locking infrastructure as needed. Using the
qspinlocks and qrwlocks as suggested by Peter Z while reviewing the
original spinlocks implementation.
- The "support for ompic" adds a new irqchip device which is used for
IPI communication to support SMP.
- The "initial SMP support" adds smp.c and makes changes to all of
the necessary data-structures to be per-cpu.
The remaining patches are bug fixes and debug helpers which I wanted
to keep separate from the "initial SMP support" in order to allow them
to be reviewed on their own. This includes:
- add cacheflush support to fix icache aliasing
- fix initial preempt state for secondary cpu tasks
- sleep instead of spin on secondary wait
- support framepointers and STACKTRACE_SUPPORT
- enable LOCKDEP_SUPPORT and irqflags tracing
- timer sync: Add tick timer sync logic
- fix possible deadlock in timer sync, pointed out by mips guys
Note: the irqchip patch was reviewed with Marc and we agreed to push
it together with these patches"
* tag 'for-linus' of git://github.com/openrisc/linux:
openrisc: fix possible deadlock scenario during timer sync
openrisc: pass endianness info to sparse
openrisc: add tick timer multi-core sync logic
openrisc: enable LOCKDEP_SUPPORT and irqflags tracing
openrisc: support framepointers and STACKTRACE_SUPPORT
openrisc: add simple_smp dts and defconfig for simulators
openrisc: add cacheflush support to fix icache aliasing
openrisc: sleep instead of spin on secondary wait
openrisc: fix initial preempt state for secondary cpu tasks
openrisc: initial SMP support
irqchip: add initial support for ompic
dt-bindings: add openrisc to vendor prefixes list
openrisc: use qspinlocks and qrwlocks
openrisc: add 1 and 2 byte cmpxchg support
openrisc: use shadow registers to save regs on exception
dt-bindings: openrisc: Add OpenRISC platform SoC
Documentation: openrisc: Updates to README
Documentation: Move OpenRISC docs out of arch/
MAINTAINERS: Add OpenRISC pic maintainer
openrisc: dts: or1ksim: Add stdout-path
This commit is contained in:
commit
f3573b8f90
46 changed files with 1940 additions and 262 deletions
|
|
@ -151,6 +151,9 @@ config CLPS711X_IRQCHIP
|
|||
select SPARSE_IRQ
|
||||
default y
|
||||
|
||||
config OMPIC
|
||||
bool
|
||||
|
||||
config OR1K_PIC
|
||||
bool
|
||||
select IRQ_DOMAIN
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ obj-$(CONFIG_DW_APB_ICTL) += irq-dw-apb-ictl.o
|
|||
obj-$(CONFIG_METAG) += irq-metag-ext.o
|
||||
obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o
|
||||
obj-$(CONFIG_CLPS711X_IRQCHIP) += irq-clps711x.o
|
||||
obj-$(CONFIG_OMPIC) += irq-ompic.o
|
||||
obj-$(CONFIG_OR1K_PIC) += irq-or1k-pic.o
|
||||
obj-$(CONFIG_ORION_IRQCHIP) += irq-orion.o
|
||||
obj-$(CONFIG_OMAP_IRQCHIP) += irq-omap-intc.o
|
||||
|
|
|
|||
202
drivers/irqchip/irq-ompic.c
Normal file
202
drivers/irqchip/irq-ompic.c
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* Open Multi-Processor Interrupt Controller driver
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
|
||||
* Copyright (C) 2017 Stafford Horne <shorne@gmail.com>
|
||||
*
|
||||
* This file is licensed under the terms of the GNU General Public License
|
||||
* version 2. This program is licensed "as is" without any warranty of any
|
||||
* kind, whether express or implied.
|
||||
*
|
||||
* The ompic device handles IPI communication between cores in multi-core
|
||||
* OpenRISC systems.
|
||||
*
|
||||
* Registers
|
||||
*
|
||||
* For each CPU the ompic has 2 registers. The control register for sending
|
||||
* and acking IPIs and the status register for receiving IPIs. The register
|
||||
* layouts are as follows:
|
||||
*
|
||||
* Control register
|
||||
* +---------+---------+----------+---------+
|
||||
* | 31 | 30 | 29 .. 16 | 15 .. 0 |
|
||||
* ----------+---------+----------+----------
|
||||
* | IRQ ACK | IRQ GEN | DST CORE | DATA |
|
||||
* +---------+---------+----------+---------+
|
||||
*
|
||||
* Status register
|
||||
* +----------+-------------+----------+---------+
|
||||
* | 31 | 30 | 29 .. 16 | 15 .. 0 |
|
||||
* -----------+-------------+----------+---------+
|
||||
* | Reserved | IRQ Pending | SRC CORE | DATA |
|
||||
* +----------+-------------+----------+---------+
|
||||
*
|
||||
* Architecture
|
||||
*
|
||||
* - The ompic generates a level interrupt to the CPU PIC when a message is
|
||||
* ready. Messages are delivered via the memory bus.
|
||||
* - The ompic does not have any interrupt input lines.
|
||||
* - The ompic is wired to the same irq line on each core.
|
||||
* - Devices are wired to the same irq line on each core.
|
||||
*
|
||||
* +---------+ +---------+
|
||||
* | CPU | | CPU |
|
||||
* | Core 0 |<==\ (memory access) /==>| Core 1 |
|
||||
* | [ PIC ]| | | | [ PIC ]|
|
||||
* +----^-^--+ | | +----^-^--+
|
||||
* | | v v | |
|
||||
* <====|=|=================================|=|==> (memory bus)
|
||||
* | | ^ ^ | |
|
||||
* (ipi | +------|---------+--------|-------|-+ (device irq)
|
||||
* irq | | | | |
|
||||
* core0)| +------|---------|--------|-------+ (ipi irq core1)
|
||||
* | | | | |
|
||||
* +----o-o-+ | +--------+ |
|
||||
* | ompic |<===/ | Device |<===/
|
||||
* | IPI | +--------+
|
||||
* +--------+*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/io.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/of_address.h>
|
||||
|
||||
#include <linux/irqchip.h>
|
||||
|
||||
#define OMPIC_CPUBYTES 8
|
||||
#define OMPIC_CTRL(cpu) (0x0 + (cpu * OMPIC_CPUBYTES))
|
||||
#define OMPIC_STAT(cpu) (0x4 + (cpu * OMPIC_CPUBYTES))
|
||||
|
||||
#define OMPIC_CTRL_IRQ_ACK (1 << 31)
|
||||
#define OMPIC_CTRL_IRQ_GEN (1 << 30)
|
||||
#define OMPIC_CTRL_DST(cpu) (((cpu) & 0x3fff) << 16)
|
||||
|
||||
#define OMPIC_STAT_IRQ_PENDING (1 << 30)
|
||||
|
||||
#define OMPIC_DATA(x) ((x) & 0xffff)
|
||||
|
||||
DEFINE_PER_CPU(unsigned long, ops);
|
||||
|
||||
static void __iomem *ompic_base;
|
||||
|
||||
static inline u32 ompic_readreg(void __iomem *base, loff_t offset)
|
||||
{
|
||||
return ioread32be(base + offset);
|
||||
}
|
||||
|
||||
static void ompic_writereg(void __iomem *base, loff_t offset, u32 data)
|
||||
{
|
||||
iowrite32be(data, base + offset);
|
||||
}
|
||||
|
||||
static void ompic_raise_softirq(const struct cpumask *mask,
|
||||
unsigned int ipi_msg)
|
||||
{
|
||||
unsigned int dst_cpu;
|
||||
unsigned int src_cpu = smp_processor_id();
|
||||
|
||||
for_each_cpu(dst_cpu, mask) {
|
||||
set_bit(ipi_msg, &per_cpu(ops, dst_cpu));
|
||||
|
||||
/*
|
||||
* On OpenRISC the atomic set_bit() call implies a memory
|
||||
* barrier. Otherwise we would need: smp_wmb(); paired
|
||||
* with the read in ompic_ipi_handler.
|
||||
*/
|
||||
|
||||
ompic_writereg(ompic_base, OMPIC_CTRL(src_cpu),
|
||||
OMPIC_CTRL_IRQ_GEN |
|
||||
OMPIC_CTRL_DST(dst_cpu) |
|
||||
OMPIC_DATA(1));
|
||||
}
|
||||
}
|
||||
|
||||
static irqreturn_t ompic_ipi_handler(int irq, void *dev_id)
|
||||
{
|
||||
unsigned int cpu = smp_processor_id();
|
||||
unsigned long *pending_ops = &per_cpu(ops, cpu);
|
||||
unsigned long ops;
|
||||
|
||||
ompic_writereg(ompic_base, OMPIC_CTRL(cpu), OMPIC_CTRL_IRQ_ACK);
|
||||
while ((ops = xchg(pending_ops, 0)) != 0) {
|
||||
|
||||
/*
|
||||
* On OpenRISC the atomic xchg() call implies a memory
|
||||
* barrier. Otherwise we may need an smp_rmb(); paired
|
||||
* with the write in ompic_raise_softirq.
|
||||
*/
|
||||
|
||||
do {
|
||||
unsigned long ipi_msg;
|
||||
|
||||
ipi_msg = __ffs(ops);
|
||||
ops &= ~(1UL << ipi_msg);
|
||||
|
||||
handle_IPI(ipi_msg);
|
||||
} while (ops);
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int __init ompic_of_init(struct device_node *node,
|
||||
struct device_node *parent)
|
||||
{
|
||||
struct resource res;
|
||||
int irq;
|
||||
int ret;
|
||||
|
||||
/* Validate the DT */
|
||||
if (ompic_base) {
|
||||
pr_err("ompic: duplicate ompic's are not supported");
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
if (of_address_to_resource(node, 0, &res)) {
|
||||
pr_err("ompic: reg property requires an address and size");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (resource_size(&res) < (num_possible_cpus() * OMPIC_CPUBYTES)) {
|
||||
pr_err("ompic: reg size, currently %d must be at least %d",
|
||||
resource_size(&res),
|
||||
(num_possible_cpus() * OMPIC_CPUBYTES));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Setup the device */
|
||||
ompic_base = ioremap(res.start, resource_size(&res));
|
||||
if (IS_ERR(ompic_base)) {
|
||||
pr_err("ompic: unable to map registers");
|
||||
return PTR_ERR(ompic_base);
|
||||
}
|
||||
|
||||
irq = irq_of_parse_and_map(node, 0);
|
||||
if (irq <= 0) {
|
||||
pr_err("ompic: unable to parse device irq");
|
||||
ret = -EINVAL;
|
||||
goto out_unmap;
|
||||
}
|
||||
|
||||
ret = request_irq(irq, ompic_ipi_handler, IRQF_PERCPU,
|
||||
"ompic_ipi", NULL);
|
||||
if (ret)
|
||||
goto out_irq_disp;
|
||||
|
||||
set_smp_cross_call(ompic_raise_softirq);
|
||||
|
||||
return 0;
|
||||
|
||||
out_irq_disp:
|
||||
irq_dispose_mapping(irq);
|
||||
out_unmap:
|
||||
iounmap(ompic_base);
|
||||
ompic_base = NULL;
|
||||
return ret;
|
||||
}
|
||||
IRQCHIP_DECLARE(ompic, "openrisc,ompic", ompic_of_init);
|
||||
Loading…
Reference in a new issue