1 the current ssb irq setup (in ssb_mipscore_init) have some problem :
2 it configure some device on some irq without checking that the irq is not taken by an other device.
4 For example in my case PCI host is on irq 0 and IPSEC on irq 3.
6 - store in dev->irq that IPSEC irq is 3+2
7 - do a set_irq 0->3 on PCI host
9 But now IPSEC irq is not routed anymore to the mips code and dev->irq is wrong. This cause problem described in [1].
11 This patch try to solve the problem by making set_irq configure the device we want to take the irq on the shared irq0.
12 The previous example become :
13 - store in dev->irq that IPSEC irq is 3+2
14 - do a set_irq 0->3 on PCI host :
15 - irq 3 is already taken by IPSEC. do a set_irq 3->0 on IPSEC
18 I also added some code to print the irq configuration before and after irq setup to allow easier debugging. And I add extra checking in ssb_mips_irq to report device without irq or device with not routed irq.
21 [1] http://www.danm.de/files/src/bcm5365p/REPORTED_DEVICES
23 Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
24 --- a/drivers/ssb/driver_mipscore.c
25 +++ b/drivers/ssb/driver_mipscore.c
26 @@ -49,29 +49,54 @@ static const u32 ipsflag_irq_shift[] = {
28 static inline u32 ssb_irqflag(struct ssb_device *dev)
30 - return ssb_read32(dev, SSB_TPSFLAG) & SSB_TPSFLAG_BPFLAG;
31 + u32 tpsflag = ssb_read32(dev, SSB_TPSFLAG);
33 + return ssb_read32(dev, SSB_TPSFLAG) & SSB_TPSFLAG_BPFLAG;
35 + /* not irq supported */
39 +static struct ssb_device *find_device(struct ssb_device *rdev, int irqflag)
41 + struct ssb_bus *bus = rdev->bus;
43 + for (i = 0; i < bus->nr_devices; i++) {
44 + struct ssb_device *dev;
45 + dev = &(bus->devices[i]);
46 + if (ssb_irqflag(dev) == irqflag)
52 /* Get the MIPS IRQ assignment for a specified device.
53 * If unassigned, 0 is returned.
54 + * If disabled, 5 is returned.
55 + * If not supported, 6 is returned.
57 unsigned int ssb_mips_irq(struct ssb_device *dev)
59 struct ssb_bus *bus = dev->bus;
60 + struct ssb_device *mdev = bus->mipscore.dev;
66 irqflag = ssb_irqflag(dev);
67 + if (irqflag == 0x3f)
69 ipsflag = ssb_read32(bus->mipscore.dev, SSB_IPSFLAG);
70 for (irq = 1; irq <= 4; irq++) {
71 tmp = ((ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq]);
78 + if ((1 << irqflag) & ssb_read32(mdev, SSB_INTVEC))
84 @@ -97,25 +122,56 @@ static void set_irq(struct ssb_device *d
85 struct ssb_device *mdev = bus->mipscore.dev;
86 u32 irqflag = ssb_irqflag(dev);
88 + BUG_ON(oldirq == 6);
92 - ssb_dprintk(KERN_INFO PFX
93 - "set_irq: core 0x%04x, irq %d => %d\n",
94 - dev->id.coreid, oldirq, irq);
95 /* clear the old irq */
97 ssb_write32(mdev, SSB_INTVEC, (~(1 << irqflag) & ssb_read32(mdev, SSB_INTVEC)));
99 + else if (oldirq != 5)
100 clear_irq(bus, oldirq);
102 /* assign the new one */
104 ssb_write32(mdev, SSB_INTVEC, ((1 << irqflag) | ssb_read32(mdev, SSB_INTVEC)));
106 + u32 ipsflag = ssb_read32(mdev, SSB_IPSFLAG);
107 + if ((ipsflag & ipsflag_irq_mask[irq]) != ipsflag_irq_mask[irq]) {
108 + u32 oldipsflag = (ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq];
109 + struct ssb_device *olddev = find_device(dev, oldipsflag);
111 + set_irq(olddev, 0);
113 irqflag <<= ipsflag_irq_shift[irq];
114 - irqflag |= (ssb_read32(mdev, SSB_IPSFLAG) & ~ipsflag_irq_mask[irq]);
115 + irqflag |= (ipsflag & ~ipsflag_irq_mask[irq]);
116 ssb_write32(mdev, SSB_IPSFLAG, irqflag);
118 + ssb_dprintk(KERN_INFO PFX
119 + "set_irq: core 0x%04x, irq %d => %d\n",
120 + dev->id.coreid, oldirq+2, irq+2);
123 +static void print_irq(struct ssb_device *dev, unsigned int irq)
126 + static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
127 + ssb_dprintk(KERN_INFO PFX
128 + "core 0x%04x, irq :", dev->id.coreid);
129 + for (i = 0; i <= 6; i++) {
130 + ssb_dprintk(" %s%s", irq_name[i], i==irq?"*":" ");
135 +static void dump_irq(struct ssb_bus *bus)
138 + for (i = 0; i < bus->nr_devices; i++) {
139 + struct ssb_device *dev;
140 + dev = &(bus->devices[i]);
141 + print_irq(dev, ssb_mips_irq(dev));
145 static void ssb_mips_serial_init(struct ssb_mipscore *mcore)
146 @@ -197,18 +253,26 @@ void ssb_mipscore_init(struct ssb_mipsco
147 else if (bus->chipco.dev)
148 ssb_chipco_timing_init(&bus->chipco, ns);
151 /* Assign IRQs to all cores on the bus, start with irq line 2, because serial usually takes 1 */
152 for (irq = 2, i = 0; i < bus->nr_devices; i++) {
154 dev = &(bus->devices[i]);
155 - dev->irq = ssb_mips_irq(dev) + 2;
156 + mips_irq = ssb_mips_irq(dev);
160 + dev->irq = mips_irq + 2;
163 switch (dev->id.coreid) {
164 case SSB_DEV_USB11_HOST:
165 /* shouldn't need a separate irq line for non-4710, most of them have a proper
166 * external usb controller on the pci */
167 if ((bus->chip_id == 0x4710) && (irq <= 4)) {
174 case SSB_DEV_ETHERNET:
175 @@ -222,6 +286,8 @@ void ssb_mipscore_init(struct ssb_mipsco
179 + ssb_dprintk(KERN_INFO PFX "after irq reconfiguration\n");
182 ssb_mips_serial_init(mcore);
183 ssb_mips_flash_detect(mcore);