aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-12-11 18:27:41 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-12-15 19:10:11 -0500
commit8e609d5e7bc032ab220d47c841c992bd8544d0e1 (patch)
tree24c90442699e1ed47605e58a019c43db52bde9fd /arch
parenta79dd5ae5a8f49688d65b89a859f2b98a7ee5538 (diff)
powerpc/pmac: Simplify old pmac PIC interrupt handling
In the old days, we treated all interrupts from the legacy Apple home made interrupt controllers as level, with a trick reading the "level" register along with the "event" register to work arounds bugs where it would occasionally fail to latch some events. Doing so appeared to work fine for both level and edge interrupts. Later on, we discovered in Darwin source the magic masks that define which interrupts are actually level and which are edge, and implemented a different algorithm, more similar to what Apple does, that treats those differently. I recently discovered however that this caused problems (including loss of interrupts) with an old Wallstreet PowerBook when trying to use the internal modem (connected to a cascaded controller). It looks like some interrupts are treated as edge while they are really level and I'm starting to seriously doubt the correctness of the Darwin code (which has other obvious bugs when you read it, so ...) This patch reverts to our original behaviour of treating everything as a level interrupt. It appears to solve the problems with the modem on the Wallstreet and everything else seems to be working properly as well. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/powermac/pic.c34
1 files changed, 6 insertions, 28 deletions
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index d8aedf135bb6..7761aabfc293 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -52,13 +52,8 @@ struct device_node *of_irq_dflt_pic;
52/* Default addresses */ 52/* Default addresses */
53static volatile struct pmac_irq_hw __iomem *pmac_irq_hw[4]; 53static volatile struct pmac_irq_hw __iomem *pmac_irq_hw[4];
54 54
55#define GC_LEVEL_MASK 0x3ff00000
56#define OHARE_LEVEL_MASK 0x1ff00000
57#define HEATHROW_LEVEL_MASK 0x1ff00000
58
59static int max_irqs; 55static int max_irqs;
60static int max_real_irqs; 56static int max_real_irqs;
61static u32 level_mask[4];
62 57
63static DEFINE_RAW_SPINLOCK(pmac_pic_lock); 58static DEFINE_RAW_SPINLOCK(pmac_pic_lock);
64 59
@@ -217,8 +212,7 @@ static irqreturn_t gatwick_action(int cpl, void *dev_id)
217 for (irq = max_irqs; (irq -= 32) >= max_real_irqs; ) { 212 for (irq = max_irqs; (irq -= 32) >= max_real_irqs; ) {
218 int i = irq >> 5; 213 int i = irq >> 5;
219 bits = in_le32(&pmac_irq_hw[i]->event) | ppc_lost_interrupts[i]; 214 bits = in_le32(&pmac_irq_hw[i]->event) | ppc_lost_interrupts[i];
220 /* We must read level interrupts from the level register */ 215 bits |= in_le32(&pmac_irq_hw[i]->level);
221 bits |= (in_le32(&pmac_irq_hw[i]->level) & level_mask[i]);
222 bits &= ppc_cached_irq_mask[i]; 216 bits &= ppc_cached_irq_mask[i];
223 if (bits == 0) 217 if (bits == 0)
224 continue; 218 continue;
@@ -248,8 +242,7 @@ static unsigned int pmac_pic_get_irq(void)
248 for (irq = max_real_irqs; (irq -= 32) >= 0; ) { 242 for (irq = max_real_irqs; (irq -= 32) >= 0; ) {
249 int i = irq >> 5; 243 int i = irq >> 5;
250 bits = in_le32(&pmac_irq_hw[i]->event) | ppc_lost_interrupts[i]; 244 bits = in_le32(&pmac_irq_hw[i]->event) | ppc_lost_interrupts[i];
251 /* We must read level interrupts from the level register */ 245 bits |= in_le32(&pmac_irq_hw[i]->level);
252 bits |= (in_le32(&pmac_irq_hw[i]->level) & level_mask[i]);
253 bits &= ppc_cached_irq_mask[i]; 246 bits &= ppc_cached_irq_mask[i];
254 if (bits == 0) 247 if (bits == 0)
255 continue; 248 continue;
@@ -284,19 +277,14 @@ static int pmac_pic_host_match(struct irq_host *h, struct device_node *node)
284static int pmac_pic_host_map(struct irq_host *h, unsigned int virq, 277static int pmac_pic_host_map(struct irq_host *h, unsigned int virq,
285 irq_hw_number_t hw) 278 irq_hw_number_t hw)
286{ 279{
287 int level;
288
289 if (hw >= max_irqs) 280 if (hw >= max_irqs)
290 return -EINVAL; 281 return -EINVAL;
291 282
292 /* Mark level interrupts, set delayed disable for edge ones and set 283 /* Mark level interrupts, set delayed disable for edge ones and set
293 * handlers 284 * handlers
294 */ 285 */
295 level = !!(level_mask[hw >> 5] & (1UL << (hw & 0x1f))); 286 irq_set_status_flags(virq, IRQ_LEVEL);
296 if (level) 287 irq_set_chip_and_handler(virq, &pmac_pic, handle_level_irq);
297 irq_set_status_flags(virq, IRQ_LEVEL);
298 irq_set_chip_and_handler(virq, &pmac_pic,
299 level ? handle_level_irq : handle_edge_irq);
300 return 0; 288 return 0;
301} 289}
302 290
@@ -334,21 +322,14 @@ static void __init pmac_pic_probe_oldstyle(void)
334 322
335 if ((master = of_find_node_by_name(NULL, "gc")) != NULL) { 323 if ((master = of_find_node_by_name(NULL, "gc")) != NULL) {
336 max_irqs = max_real_irqs = 32; 324 max_irqs = max_real_irqs = 32;
337 level_mask[0] = GC_LEVEL_MASK;
338 } else if ((master = of_find_node_by_name(NULL, "ohare")) != NULL) { 325 } else if ((master = of_find_node_by_name(NULL, "ohare")) != NULL) {
339 max_irqs = max_real_irqs = 32; 326 max_irqs = max_real_irqs = 32;
340 level_mask[0] = OHARE_LEVEL_MASK;
341
342 /* We might have a second cascaded ohare */ 327 /* We might have a second cascaded ohare */
343 slave = of_find_node_by_name(NULL, "pci106b,7"); 328 slave = of_find_node_by_name(NULL, "pci106b,7");
344 if (slave) { 329 if (slave)
345 max_irqs = 64; 330 max_irqs = 64;
346 level_mask[1] = OHARE_LEVEL_MASK;
347 }
348 } else if ((master = of_find_node_by_name(NULL, "mac-io")) != NULL) { 331 } else if ((master = of_find_node_by_name(NULL, "mac-io")) != NULL) {
349 max_irqs = max_real_irqs = 64; 332 max_irqs = max_real_irqs = 64;
350 level_mask[0] = HEATHROW_LEVEL_MASK;
351 level_mask[1] = 0;
352 333
353 /* We might have a second cascaded heathrow */ 334 /* We might have a second cascaded heathrow */
354 slave = of_find_node_by_name(master, "mac-io"); 335 slave = of_find_node_by_name(master, "mac-io");
@@ -363,11 +344,8 @@ static void __init pmac_pic_probe_oldstyle(void)
363 } 344 }
364 345
365 /* We found a slave */ 346 /* We found a slave */
366 if (slave) { 347 if (slave)
367 max_irqs = 128; 348 max_irqs = 128;
368 level_mask[2] = HEATHROW_LEVEL_MASK;
369 level_mask[3] = 0;
370 }
371 } 349 }
372 BUG_ON(master == NULL); 350 BUG_ON(master == NULL);
373 351