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

+184 -27
+98
Documentation/devicetree/bindings/open-pic.txt
··· 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 +
+4
arch/powerpc/include/asm/mpic.h
··· 367 367 #define MPIC_SINGLE_DEST_CPU 0x00001000 368 368 /* Enable CoreInt delivery of interrupts */ 369 369 #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 370 374 371 375 /* MPIC HW modification ID */ 372 376 #define MPIC_REGSET_MASK 0xf0000000
+2
arch/powerpc/include/asm/ptrace.h
··· 125 125 #endif /* ! __powerpc64__ */ 126 126 #define TRAP(regs) ((regs)->trap & ~0xF) 127 127 #ifdef __powerpc64__ 128 + #define NV_REG_POISON 0xdeadbeefdeadbeefUL 128 129 #define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1) 129 130 #else 131 + #define NV_REG_POISON 0xdeadbeef 130 132 #define CHECK_FULL_REGS(regs) \ 131 133 do { \ 132 134 if ((regs)->trap & 1) \
+5 -2
arch/powerpc/kernel/pci_dn.c
··· 176 176 */ 177 177 struct device_node *fetch_dev_dn(struct pci_dev *dev) 178 178 { 179 - struct device_node *orig_dn = dev->dev.of_node; 179 + struct pci_controller *phb = dev->sysdata; 180 180 struct device_node *dn; 181 181 unsigned long searchval = (dev->bus->number << 8) | dev->devfn; 182 182 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); 184 187 if (dn) 185 188 dev->dev.of_node = dn; 186 189 return dn;
+12 -3
arch/powerpc/kernel/ptrace.c
··· 229 229 unsigned int pos, unsigned int count, 230 230 void *kbuf, void __user *ubuf) 231 231 { 232 - int ret; 232 + int i, ret; 233 233 234 234 if (target->thread.regs == NULL) 235 235 return -EIO; 236 236 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 + } 238 242 239 243 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 240 244 target->thread.regs, ··· 645 641 compat_ulong_t *k = kbuf; 646 642 compat_ulong_t __user *u = ubuf; 647 643 compat_ulong_t reg; 644 + int i; 648 645 649 646 if (target->thread.regs == NULL) 650 647 return -EIO; 651 648 652 - CHECK_FULL_REGS(target->thread.regs); 649 + if (!FULL_REGS(target->thread.regs)) { 650 + /* We have a partial register set. Fill 14-31 with bogus values */ 651 + for (i = 14; i < 32; i++) 652 + target->thread.regs->gpr[i] = NV_REG_POISON; 653 + } 653 654 654 655 pos /= sizeof(reg); 655 656 count /= sizeof(reg);
+63 -22
arch/powerpc/sysdev/mpic.c
··· 147 147 148 148 #endif /* CONFIG_MPIC_WEIRD */ 149 149 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 + 150 160 /* 151 161 * Register accessor functions 152 162 */ ··· 220 210 221 211 static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg) 222 212 { 223 - unsigned int cpu = 0; 213 + unsigned int cpu = mpic_processor_id(mpic); 224 214 225 - if (mpic->flags & MPIC_PRIMARY) 226 - cpu = hard_smp_processor_id(); 227 215 return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg); 228 216 } 229 217 230 218 static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value) 231 219 { 232 - unsigned int cpu = 0; 233 - 234 - if (mpic->flags & MPIC_PRIMARY) 235 - cpu = hard_smp_processor_id(); 220 + unsigned int cpu = mpic_processor_id(mpic); 236 221 237 222 _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value); 238 223 } ··· 918 913 mpic_irq_write(src, MPIC_INFO(IRQ_VECTOR_PRI), vecpri); 919 914 } 920 915 916 + void mpic_set_destination(unsigned int virq, unsigned int cpuid) 917 + { 918 + struct mpic *mpic = mpic_from_irq(virq); 919 + unsigned int src = mpic_irq_to_hw(virq); 920 + 921 + DBG("mpic: set_destination(mpic:@%p,virq:%d,src:%d,cpuid:0x%x)\n", 922 + mpic, virq, src, cpuid); 923 + 924 + if (src >= mpic->irq_count) 925 + return; 926 + 927 + mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid); 928 + } 929 + 921 930 static struct irq_chip mpic_irq_chip = { 922 931 .irq_mask = mpic_mask_irq, 923 932 .irq_unmask = mpic_unmask_irq, ··· 1012 993 /* Set default irq type */ 1013 994 set_irq_type(virq, IRQ_TYPE_NONE); 1014 995 996 + /* If the MPIC was reset, then all vectors have already been 997 + * initialized. Otherwise, a per source lazy initialization 998 + * is done here. 999 + */ 1000 + if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) { 1001 + mpic_set_vector(virq, hw); 1002 + mpic_set_destination(virq, mpic_processor_id(mpic)); 1003 + mpic_irq_set_priority(virq, 8); 1004 + } 1005 + 1015 1006 return 0; 1016 1007 } 1017 1008 ··· 1068 1039 .map = mpic_host_map, 1069 1040 .xlate = mpic_host_xlate, 1070 1041 }; 1042 + 1043 + static int mpic_reset_prohibited(struct device_node *node) 1044 + { 1045 + return node && of_get_property(node, "pic-no-reset", NULL); 1046 + } 1071 1047 1072 1048 /* 1073 1049 * Exported functions ··· 1194 1160 mpic_map(mpic, node, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); 1195 1161 1196 1162 /* Reset */ 1197 - if (flags & MPIC_WANTS_RESET) { 1163 + 1164 + /* When using a device-node, reset requests are only honored if the MPIC 1165 + * is allowed to reset. 1166 + */ 1167 + if (mpic_reset_prohibited(node)) 1168 + mpic->flags |= MPIC_NO_RESET; 1169 + 1170 + if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) { 1171 + printk(KERN_DEBUG "mpic: Resetting\n"); 1198 1172 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), 1199 1173 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) 1200 1174 | MPIC_GREG_GCONF_RESET); ··· 1362 1320 1363 1321 mpic_pasemi_msi_init(mpic); 1364 1322 1365 - if (mpic->flags & MPIC_PRIMARY) 1366 - cpu = hard_smp_processor_id(); 1367 - else 1368 - cpu = 0; 1323 + cpu = mpic_processor_id(mpic); 1369 1324 1370 - for (i = 0; i < mpic->num_sources; i++) { 1371 - /* start with vector = source number, and masked */ 1372 - u32 vecpri = MPIC_VECPRI_MASK | i | 1373 - (8 << MPIC_VECPRI_PRIORITY_SHIFT); 1325 + if (!(mpic->flags & MPIC_NO_RESET)) { 1326 + for (i = 0; i < mpic->num_sources; i++) { 1327 + /* start with vector = source number, and masked */ 1328 + u32 vecpri = MPIC_VECPRI_MASK | i | 1329 + (8 << MPIC_VECPRI_PRIORITY_SHIFT); 1374 1330 1375 - /* check if protected */ 1376 - if (mpic->protected && test_bit(i, mpic->protected)) 1377 - continue; 1378 - /* init hw */ 1379 - mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri); 1380 - mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu); 1331 + /* check if protected */ 1332 + if (mpic->protected && test_bit(i, mpic->protected)) 1333 + continue; 1334 + /* init hw */ 1335 + mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri); 1336 + mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu); 1337 + } 1381 1338 } 1382 1339 1383 1340 /* Init spurious vector */