Skip to content

Commit 111f426

Browse files
committed
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: powerpc/ptrace: Remove BUG_ON when full register set not available powerpc: Factoring mpic cpu id fetching into a function powerpc: Make MPIC honor the "pic-no-reset" device tree property powerpc: Document the Open PIC device tree binding powerpc/pci: Fix crash in PCI code on ppc64 when matching device nodes
2 parents a44f99c + a71f5d5 commit 111f426

6 files changed

Lines changed: 184 additions & 27 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
* Open PIC Binding
2+
3+
This binding specifies what properties must be available in the device tree
4+
representation of an Open PIC compliant interrupt controller. This binding is
5+
based on the binding defined for Open PIC in [1] and is a superset of that
6+
binding.
7+
8+
Required properties:
9+
10+
NOTE: Many of these descriptions were paraphrased here from [1] to aid
11+
readability.
12+
13+
- compatible: Specifies the compatibility list for the PIC. The type
14+
shall be <string> and the value shall include "open-pic".
15+
16+
- reg: Specifies the base physical address(s) and size(s) of this
17+
PIC's addressable register space. The type shall be <prop-encoded-array>.
18+
19+
- interrupt-controller: The presence of this property identifies the node
20+
as an Open PIC. No property value shall be defined.
21+
22+
- #interrupt-cells: Specifies the number of cells needed to encode an
23+
interrupt source. The type shall be a <u32> and the value shall be 2.
24+
25+
- #address-cells: Specifies the number of cells needed to encode an
26+
address. The type shall be <u32> and the value shall be 0. As such,
27+
'interrupt-map' nodes do not have to specify a parent unit address.
28+
29+
Optional properties:
30+
31+
- pic-no-reset: The presence of this property indicates that the PIC
32+
shall not be reset during runtime initialization. No property value shall
33+
be defined. The presence of this property also mandates that any
34+
initialization related to interrupt sources shall be limited to sources
35+
explicitly referenced in the device tree.
36+
37+
* Interrupt Specifier Definition
38+
39+
Interrupt specifiers consists of 2 cells encoded as
40+
follows:
41+
42+
- <1st-cell>: The interrupt-number that identifies the interrupt source.
43+
44+
- <2nd-cell>: The level-sense information, encoded as follows:
45+
0 = low-to-high edge triggered
46+
1 = active low level-sensitive
47+
2 = active high level-sensitive
48+
3 = high-to-low edge triggered
49+
50+
* Examples
51+
52+
Example 1:
53+
54+
/*
55+
* An Open PIC interrupt controller
56+
*/
57+
mpic: pic@40000 {
58+
// This is an interrupt controller node.
59+
interrupt-controller;
60+
61+
// No address cells so that 'interrupt-map' nodes which reference
62+
// this Open PIC node do not need a parent address specifier.
63+
#address-cells = <0>;
64+
65+
// Two cells to encode interrupt sources.
66+
#interrupt-cells = <2>;
67+
68+
// Offset address of 0x40000 and size of 0x40000.
69+
reg = <0x40000 0x40000>;
70+
71+
// Compatible with Open PIC.
72+
compatible = "open-pic";
73+
74+
// The PIC shall not be reset.
75+
pic-no-reset;
76+
};
77+
78+
Example 2:
79+
80+
/*
81+
* An interrupt generating device that is wired to an Open PIC.
82+
*/
83+
serial0: serial@4500 {
84+
// Interrupt source '42' that is active high level-sensitive.
85+
// Note that there are only two cells as specified in the interrupt
86+
// parent's '#interrupt-cells' property.
87+
interrupts = <42 2>;
88+
89+
// The interrupt controller that this device is wired to.
90+
interrupt-parent = <&mpic>;
91+
};
92+
93+
* References
94+
95+
[1] Power.org (TM) Standard for Embedded Power Architecture (TM) Platform
96+
Requirements (ePAPR), Version 1.0, July 2008.
97+
(http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf)
98+

‎arch/powerpc/include/asm/mpic.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ struct mpic
367367
#define MPIC_SINGLE_DEST_CPU 0x00001000
368368
/* Enable CoreInt delivery of interrupts */
369369
#define MPIC_ENABLE_COREINT 0x00002000
370+
/* Disable resetting of the MPIC.
371+
* NOTE: This flag trumps MPIC_WANTS_RESET.
372+
*/
373+
#define MPIC_NO_RESET 0x00004000
370374

371375
/* MPIC HW modification ID */
372376
#define MPIC_REGSET_MASK 0xf0000000

‎arch/powerpc/include/asm/ptrace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ extern int ptrace_put_reg(struct task_struct *task, int regno,
125125
#endif /* ! __powerpc64__ */
126126
#define TRAP(regs) ((regs)->trap & ~0xF)
127127
#ifdef __powerpc64__
128+
#define NV_REG_POISON 0xdeadbeefdeadbeefUL
128129
#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
129130
#else
131+
#define NV_REG_POISON 0xdeadbeef
130132
#define CHECK_FULL_REGS(regs) \
131133
do { \
132134
if ((regs)->trap & 1) \

‎arch/powerpc/kernel/pci_dn.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,14 @@ static void *is_devfn_node(struct device_node *dn, void *data)
176176
*/
177177
struct device_node *fetch_dev_dn(struct pci_dev *dev)
178178
{
179-
struct device_node *orig_dn = dev->dev.of_node;
179+
struct pci_controller *phb = dev->sysdata;
180180
struct device_node *dn;
181181
unsigned long searchval = (dev->bus->number << 8) | dev->devfn;
182182

183-
dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval);
183+
if (WARN_ON(!phb))
184+
return NULL;
185+
186+
dn = traverse_pci_devices(phb->dn, is_devfn_node, (void *)searchval);
184187
if (dn)
185188
dev->dev.of_node = dn;
186189
return dn;

‎arch/powerpc/kernel/ptrace.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,16 @@ static int gpr_get(struct task_struct *target, const struct user_regset *regset,
229229
unsigned int pos, unsigned int count,
230230
void *kbuf, void __user *ubuf)
231231
{
232-
int ret;
232+
int i, ret;
233233

234234
if (target->thread.regs == NULL)
235235
return -EIO;
236236

237-
CHECK_FULL_REGS(target->thread.regs);
237+
if (!FULL_REGS(target->thread.regs)) {
238+
/* We have a partial register set. Fill 14-31 with bogus values */
239+
for (i = 14; i < 32; i++)
240+
target->thread.regs->gpr[i] = NV_REG_POISON;
241+
}
238242

239243
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
240244
target->thread.regs,
@@ -641,11 +645,16 @@ static int gpr32_get(struct task_struct *target,
641645
compat_ulong_t *k = kbuf;
642646
compat_ulong_t __user *u = ubuf;
643647
compat_ulong_t reg;
648+
int i;
644649

645650
if (target->thread.regs == NULL)
646651
return -EIO;
647652

648-
CHECK_FULL_REGS(target->thread.regs);
653+
if (!FULL_REGS(target->thread.regs)) {
654+
/* We have a partial register set. Fill 14-31 with bogus values */
655+
for (i = 14; i < 32; i++)
656+
target->thread.regs->gpr[i] = NV_REG_POISON;
657+
}
649658

650659
pos /= sizeof(reg);
651660
count /= sizeof(reg);

‎arch/powerpc/sysdev/mpic.c‎

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ static u32 mpic_infos[][MPIC_IDX_END] = {
147147

148148
#endif /* CONFIG_MPIC_WEIRD */
149149

150+
static inline unsigned int mpic_processor_id(struct mpic *mpic)
151+
{
152+
unsigned int cpu = 0;
153+
154+
if (mpic->flags & MPIC_PRIMARY)
155+
cpu = hard_smp_processor_id();
156+
157+
return cpu;
158+
}
159+
150160
/*
151161
* Register accessor functions
152162
*/
@@ -210,19 +220,14 @@ static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 valu
210220

211221
static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
212222
{
213-
unsigned int cpu = 0;
223+
unsigned int cpu = mpic_processor_id(mpic);
214224

215-
if (mpic->flags & MPIC_PRIMARY)
216-
cpu = hard_smp_processor_id();
217225
return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg);
218226
}
219227

220228
static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value)
221229
{
222-
unsigned int cpu = 0;
223-
224-
if (mpic->flags & MPIC_PRIMARY)
225-
cpu = hard_smp_processor_id();
230+
unsigned int cpu = mpic_processor_id(mpic);
226231

227232
_mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value);
228233
}
@@ -913,6 +918,20 @@ void mpic_set_vector(unsigned int virq, unsigned int vector)
913918
mpic_irq_write(src, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
914919
}
915920

921+
void mpic_set_destination(unsigned int virq, unsigned int cpuid)
922+
{
923+
struct mpic *mpic = mpic_from_irq(virq);
924+
unsigned int src = mpic_irq_to_hw(virq);
925+
926+
DBG("mpic: set_destination(mpic:@%p,virq:%d,src:%d,cpuid:0x%x)\n",
927+
mpic, virq, src, cpuid);
928+
929+
if (src >= mpic->irq_count)
930+
return;
931+
932+
mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid);
933+
}
934+
916935
static struct irq_chip mpic_irq_chip = {
917936
.irq_mask = mpic_mask_irq,
918937
.irq_unmask = mpic_unmask_irq,
@@ -993,6 +1012,16 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
9931012
/* Set default irq type */
9941013
set_irq_type(virq, IRQ_TYPE_NONE);
9951014

1015+
/* If the MPIC was reset, then all vectors have already been
1016+
* initialized. Otherwise, a per source lazy initialization
1017+
* is done here.
1018+
*/
1019+
if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
1020+
mpic_set_vector(virq, hw);
1021+
mpic_set_destination(virq, mpic_processor_id(mpic));
1022+
mpic_irq_set_priority(virq, 8);
1023+
}
1024+
9961025
return 0;
9971026
}
9981027

@@ -1040,6 +1069,11 @@ static struct irq_host_ops mpic_host_ops = {
10401069
.xlate = mpic_host_xlate,
10411070
};
10421071

1072+
static int mpic_reset_prohibited(struct device_node *node)
1073+
{
1074+
return node && of_get_property(node, "pic-no-reset", NULL);
1075+
}
1076+
10431077
/*
10441078
* Exported functions
10451079
*/
@@ -1160,7 +1194,15 @@ struct mpic * __init mpic_alloc(struct device_node *node,
11601194
mpic_map(mpic, node, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
11611195

11621196
/* Reset */
1163-
if (flags & MPIC_WANTS_RESET) {
1197+
1198+
/* When using a device-node, reset requests are only honored if the MPIC
1199+
* is allowed to reset.
1200+
*/
1201+
if (mpic_reset_prohibited(node))
1202+
mpic->flags |= MPIC_NO_RESET;
1203+
1204+
if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) {
1205+
printk(KERN_DEBUG "mpic: Resetting\n");
11641206
mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0),
11651207
mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0))
11661208
| MPIC_GREG_GCONF_RESET);
@@ -1320,22 +1362,21 @@ void __init mpic_init(struct mpic *mpic)
13201362

13211363
mpic_pasemi_msi_init(mpic);
13221364

1323-
if (mpic->flags & MPIC_PRIMARY)
1324-
cpu = hard_smp_processor_id();
1325-
else
1326-
cpu = 0;
1365+
cpu = mpic_processor_id(mpic);
13271366

1328-
for (i = 0; i < mpic->num_sources; i++) {
1329-
/* start with vector = source number, and masked */
1330-
u32 vecpri = MPIC_VECPRI_MASK | i |
1331-
(8 << MPIC_VECPRI_PRIORITY_SHIFT);
1367+
if (!(mpic->flags & MPIC_NO_RESET)) {
1368+
for (i = 0; i < mpic->num_sources; i++) {
1369+
/* start with vector = source number, and masked */
1370+
u32 vecpri = MPIC_VECPRI_MASK | i |
1371+
(8 << MPIC_VECPRI_PRIORITY_SHIFT);
13321372

1333-
/* check if protected */
1334-
if (mpic->protected && test_bit(i, mpic->protected))
1335-
continue;
1336-
/* init hw */
1337-
mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
1338-
mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu);
1373+
/* check if protected */
1374+
if (mpic->protected && test_bit(i, mpic->protected))
1375+
continue;
1376+
/* init hw */
1377+
mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
1378+
mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu);
1379+
}
13391380
}
13401381

13411382
/* Init spurious vector */

0 commit comments

Comments
 (0)