diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2006-07-10 07:44:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-10 16:24:20 -0400 |
commit | 6e99e4582861578fb00d84d085f8f283569f51dd (patch) | |
tree | 8890d540932f02fa47e49248adcc918b42c335b8 /arch/powerpc/kernel | |
parent | 50099328e4fe7c9f8981f408071a1ff82d59ddf8 (diff) |
[PATCH] powerpc: fix trigger handling in the new irq code
This patch slightly reworks the new irq code to fix a small design error. I
removed the passing of the trigger to the map() calls entirely, it was not a
good idea to have one call do two different things. It also fixes a couple of
corner cases.
Mapping a linux virtual irq to a physical irq now does only that. Setting the
trigger is a different action which has a different call.
The main changes are:
- I no longer call host->ops->map() for an already mapped irq, I just return
the virtual number that was already mapped. It was called before to give an
opportunity to change the trigger, but that was causing issues as that could
happen while the interrupt was in use by a device, and because of the
trigger change, map would potentially muck around with things in a racy way.
That was causing much burden on a given's controller implementation of
map() to get it right. This is much simpler now. map() is only called on
the initial mapping of an irq, meaning that you know that this irq is _not_
being used. You can initialize the hardware if you want (though you don't
have to).
- Controllers that can handle different type of triggers (level/edge/etc...)
now implement the standard irq_chip->set_type() call as defined by the
generic code. That means that you can use the standard set_irq_type() to
configure an irq line manually if you wish or (though I don't like that
interface), pass explicit trigger flags to request_irq() as defined by the
generic kernel interfaces. Also, using those interfaces guarantees that
your controller set_type callback is called with the descriptor lock held,
thus providing locking against activity on the same interrupt (including
mask/unmask/etc...) automatically. A result is that, for example, MPIC's
own map() implementation calls irq_set_type(NONE) to configure the hardware
to the default triggers.
- To allow the above, the irq_map array entry for the new mapped interrupt
is now set before map() callback is called for the controller.
- The irq_create_of_mapping() (also used by irq_of_parse_and_map()) function
for mapping interrupts from the device-tree now also call the separate
set_irq_type(), and only does so if there is a change in the trigger type.
- While I was at it, I changed pci_read_irq_line() (which is the helper I
would expect most archs to use in their pcibios_fixup() to get the PCI
interrupt routing from the device tree) to also handle a fallback when the
DT mapping fails consisting of reading the PCI_INTERRUPT_PIN to know wether
the device has an interrupt at all, and the the PCI_INTERRUPT_LINE to get an
interrupt number from the device. That number is then mapped using the
default controller, and the trigger is set to level low. That default
behaviour works for several platforms that don't have a proper interrupt
tree like Pegasos. If it doesn't work for your platform, then either
provide a proper interrupt tree from the firmware so that fallback isn't
needed, or don't call pci_read_irq_line()
- Add back a bit that got dropped by my main rework patch for properly
clearing pending IPIs on pSeries when using a kexec
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/ibmebus.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/irq.c | 47 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_32.c | 36 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_64.c | 36 |
4 files changed, 87 insertions, 34 deletions
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c index 97ddc02a3d42..68e5ab0443d2 100644 --- a/arch/powerpc/kernel/ibmebus.c +++ b/arch/powerpc/kernel/ibmebus.c | |||
@@ -323,7 +323,7 @@ int ibmebus_request_irq(struct ibmebus_dev *dev, | |||
323 | unsigned long irq_flags, const char * devname, | 323 | unsigned long irq_flags, const char * devname, |
324 | void *dev_id) | 324 | void *dev_id) |
325 | { | 325 | { |
326 | unsigned int irq = irq_create_mapping(NULL, ist, 0); | 326 | unsigned int irq = irq_create_mapping(NULL, ist); |
327 | 327 | ||
328 | if (irq == NO_IRQ) | 328 | if (irq == NO_IRQ) |
329 | return -EINVAL; | 329 | return -EINVAL; |
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 8cf987809c66..01bdae35cb55 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c | |||
@@ -391,15 +391,14 @@ struct irq_host *irq_alloc_host(unsigned int revmap_type, | |||
391 | irq_map[i].host = host; | 391 | irq_map[i].host = host; |
392 | smp_wmb(); | 392 | smp_wmb(); |
393 | 393 | ||
394 | /* Clear some flags */ | 394 | /* Clear norequest flags */ |
395 | get_irq_desc(i)->status | 395 | get_irq_desc(i)->status &= ~IRQ_NOREQUEST; |
396 | &= ~(IRQ_NOREQUEST | IRQ_LEVEL); | ||
397 | 396 | ||
398 | /* Legacy flags are left to default at this point, | 397 | /* Legacy flags are left to default at this point, |
399 | * one can then use irq_create_mapping() to | 398 | * one can then use irq_create_mapping() to |
400 | * explicitely change them | 399 | * explicitely change them |
401 | */ | 400 | */ |
402 | ops->map(host, i, i, 0); | 401 | ops->map(host, i, i); |
403 | } | 402 | } |
404 | break; | 403 | break; |
405 | case IRQ_HOST_MAP_LINEAR: | 404 | case IRQ_HOST_MAP_LINEAR: |
@@ -457,13 +456,11 @@ void irq_set_virq_count(unsigned int count) | |||
457 | } | 456 | } |
458 | 457 | ||
459 | unsigned int irq_create_mapping(struct irq_host *host, | 458 | unsigned int irq_create_mapping(struct irq_host *host, |
460 | irq_hw_number_t hwirq, | 459 | irq_hw_number_t hwirq) |
461 | unsigned int flags) | ||
462 | { | 460 | { |
463 | unsigned int virq, hint; | 461 | unsigned int virq, hint; |
464 | 462 | ||
465 | pr_debug("irq: irq_create_mapping(0x%p, 0x%lx, 0x%x)\n", | 463 | pr_debug("irq: irq_create_mapping(0x%p, 0x%lx)\n", host, hwirq); |
466 | host, hwirq, flags); | ||
467 | 464 | ||
468 | /* Look for default host if nececssary */ | 465 | /* Look for default host if nececssary */ |
469 | if (host == NULL) | 466 | if (host == NULL) |
@@ -482,7 +479,6 @@ unsigned int irq_create_mapping(struct irq_host *host, | |||
482 | virq = irq_find_mapping(host, hwirq); | 479 | virq = irq_find_mapping(host, hwirq); |
483 | if (virq != IRQ_NONE) { | 480 | if (virq != IRQ_NONE) { |
484 | pr_debug("irq: -> existing mapping on virq %d\n", virq); | 481 | pr_debug("irq: -> existing mapping on virq %d\n", virq); |
485 | host->ops->map(host, virq, hwirq, flags); | ||
486 | return virq; | 482 | return virq; |
487 | } | 483 | } |
488 | 484 | ||
@@ -504,18 +500,18 @@ unsigned int irq_create_mapping(struct irq_host *host, | |||
504 | } | 500 | } |
505 | pr_debug("irq: -> obtained virq %d\n", virq); | 501 | pr_debug("irq: -> obtained virq %d\n", virq); |
506 | 502 | ||
507 | /* Clear some flags */ | 503 | /* Clear IRQ_NOREQUEST flag */ |
508 | get_irq_desc(virq)->status &= ~(IRQ_NOREQUEST | IRQ_LEVEL); | 504 | get_irq_desc(virq)->status &= ~IRQ_NOREQUEST; |
509 | 505 | ||
510 | /* map it */ | 506 | /* map it */ |
511 | if (host->ops->map(host, virq, hwirq, flags)) { | 507 | smp_wmb(); |
508 | irq_map[virq].hwirq = hwirq; | ||
509 | smp_mb(); | ||
510 | if (host->ops->map(host, virq, hwirq)) { | ||
512 | pr_debug("irq: -> mapping failed, freeing\n"); | 511 | pr_debug("irq: -> mapping failed, freeing\n"); |
513 | irq_free_virt(virq, 1); | 512 | irq_free_virt(virq, 1); |
514 | return NO_IRQ; | 513 | return NO_IRQ; |
515 | } | 514 | } |
516 | smp_wmb(); | ||
517 | irq_map[virq].hwirq = hwirq; | ||
518 | smp_mb(); | ||
519 | return virq; | 515 | return virq; |
520 | } | 516 | } |
521 | EXPORT_SYMBOL_GPL(irq_create_mapping); | 517 | EXPORT_SYMBOL_GPL(irq_create_mapping); |
@@ -525,25 +521,38 @@ extern unsigned int irq_create_of_mapping(struct device_node *controller, | |||
525 | { | 521 | { |
526 | struct irq_host *host; | 522 | struct irq_host *host; |
527 | irq_hw_number_t hwirq; | 523 | irq_hw_number_t hwirq; |
528 | unsigned int flags = IRQ_TYPE_NONE; | 524 | unsigned int type = IRQ_TYPE_NONE; |
525 | unsigned int virq; | ||
529 | 526 | ||
530 | if (controller == NULL) | 527 | if (controller == NULL) |
531 | host = irq_default_host; | 528 | host = irq_default_host; |
532 | else | 529 | else |
533 | host = irq_find_host(controller); | 530 | host = irq_find_host(controller); |
534 | if (host == NULL) | 531 | if (host == NULL) { |
532 | printk(KERN_WARNING "irq: no irq host found for %s !\n", | ||
533 | controller->full_name); | ||
535 | return NO_IRQ; | 534 | return NO_IRQ; |
535 | } | ||
536 | 536 | ||
537 | /* If host has no translation, then we assume interrupt line */ | 537 | /* If host has no translation, then we assume interrupt line */ |
538 | if (host->ops->xlate == NULL) | 538 | if (host->ops->xlate == NULL) |
539 | hwirq = intspec[0]; | 539 | hwirq = intspec[0]; |
540 | else { | 540 | else { |
541 | if (host->ops->xlate(host, controller, intspec, intsize, | 541 | if (host->ops->xlate(host, controller, intspec, intsize, |
542 | &hwirq, &flags)) | 542 | &hwirq, &type)) |
543 | return NO_IRQ; | 543 | return NO_IRQ; |
544 | } | 544 | } |
545 | 545 | ||
546 | return irq_create_mapping(host, hwirq, flags); | 546 | /* Create mapping */ |
547 | virq = irq_create_mapping(host, hwirq); | ||
548 | if (virq == NO_IRQ) | ||
549 | return virq; | ||
550 | |||
551 | /* Set type if specified and different than the current one */ | ||
552 | if (type != IRQ_TYPE_NONE && | ||
553 | type != (get_irq_desc(virq)->status & IRQF_TRIGGER_MASK)) | ||
554 | set_irq_type(virq, type); | ||
555 | return virq; | ||
547 | } | 556 | } |
548 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); | 557 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); |
549 | 558 | ||
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index 898dae8ab6d9..09b1e1bbb29b 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
12 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
13 | #include <linux/bootmem.h> | 13 | #include <linux/bootmem.h> |
14 | #include <linux/irq.h> | ||
14 | 15 | ||
15 | #include <asm/processor.h> | 16 | #include <asm/processor.h> |
16 | #include <asm/io.h> | 17 | #include <asm/io.h> |
@@ -18,7 +19,6 @@ | |||
18 | #include <asm/sections.h> | 19 | #include <asm/sections.h> |
19 | #include <asm/pci-bridge.h> | 20 | #include <asm/pci-bridge.h> |
20 | #include <asm/byteorder.h> | 21 | #include <asm/byteorder.h> |
21 | #include <asm/irq.h> | ||
22 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
23 | #include <asm/machdep.h> | 23 | #include <asm/machdep.h> |
24 | 24 | ||
@@ -1420,15 +1420,37 @@ int pci_read_irq_line(struct pci_dev *pci_dev) | |||
1420 | 1420 | ||
1421 | DBG("Try to map irq for %s...\n", pci_name(pci_dev)); | 1421 | DBG("Try to map irq for %s...\n", pci_name(pci_dev)); |
1422 | 1422 | ||
1423 | /* Try to get a mapping from the device-tree */ | ||
1423 | if (of_irq_map_pci(pci_dev, &oirq)) { | 1424 | if (of_irq_map_pci(pci_dev, &oirq)) { |
1424 | DBG(" -> failed !\n"); | 1425 | u8 line, pin; |
1425 | return -1; | 1426 | |
1426 | } | 1427 | /* If that fails, lets fallback to what is in the config |
1428 | * space and map that through the default controller. We | ||
1429 | * also set the type to level low since that's what PCI | ||
1430 | * interrupts are. If your platform does differently, then | ||
1431 | * either provide a proper interrupt tree or don't use this | ||
1432 | * function. | ||
1433 | */ | ||
1434 | if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin)) | ||
1435 | return -1; | ||
1436 | if (pin == 0) | ||
1437 | return -1; | ||
1438 | if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) || | ||
1439 | line == 0xff) { | ||
1440 | return -1; | ||
1441 | } | ||
1442 | DBG(" -> no map ! Using irq line %d from PCI config\n", line); | ||
1427 | 1443 | ||
1428 | DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", | 1444 | virq = irq_create_mapping(NULL, line); |
1429 | oirq.size, oirq.specifier[0], oirq.controller->full_name); | 1445 | if (virq != NO_IRQ) |
1446 | set_irq_type(virq, IRQ_TYPE_LEVEL_LOW); | ||
1447 | } else { | ||
1448 | DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", | ||
1449 | oirq.size, oirq.specifier[0], oirq.controller->full_name); | ||
1430 | 1450 | ||
1431 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); | 1451 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, |
1452 | oirq.size); | ||
1453 | } | ||
1432 | if(virq == NO_IRQ) { | 1454 | if(virq == NO_IRQ) { |
1433 | DBG(" -> failed to map !\n"); | 1455 | DBG(" -> failed to map !\n"); |
1434 | return -1; | 1456 | return -1; |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index efc0b5559ee0..2fce7738e9e2 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -21,13 +21,13 @@ | |||
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/list.h> | 22 | #include <linux/list.h> |
23 | #include <linux/syscalls.h> | 23 | #include <linux/syscalls.h> |
24 | #include <linux/irq.h> | ||
24 | 25 | ||
25 | #include <asm/processor.h> | 26 | #include <asm/processor.h> |
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
27 | #include <asm/prom.h> | 28 | #include <asm/prom.h> |
28 | #include <asm/pci-bridge.h> | 29 | #include <asm/pci-bridge.h> |
29 | #include <asm/byteorder.h> | 30 | #include <asm/byteorder.h> |
30 | #include <asm/irq.h> | ||
31 | #include <asm/machdep.h> | 31 | #include <asm/machdep.h> |
32 | #include <asm/ppc-pci.h> | 32 | #include <asm/ppc-pci.h> |
33 | 33 | ||
@@ -1289,15 +1289,37 @@ int pci_read_irq_line(struct pci_dev *pci_dev) | |||
1289 | 1289 | ||
1290 | DBG("Try to map irq for %s...\n", pci_name(pci_dev)); | 1290 | DBG("Try to map irq for %s...\n", pci_name(pci_dev)); |
1291 | 1291 | ||
1292 | /* Try to get a mapping from the device-tree */ | ||
1292 | if (of_irq_map_pci(pci_dev, &oirq)) { | 1293 | if (of_irq_map_pci(pci_dev, &oirq)) { |
1293 | DBG(" -> failed !\n"); | 1294 | u8 line, pin; |
1294 | return -1; | 1295 | |
1295 | } | 1296 | /* If that fails, lets fallback to what is in the config |
1297 | * space and map that through the default controller. We | ||
1298 | * also set the type to level low since that's what PCI | ||
1299 | * interrupts are. If your platform does differently, then | ||
1300 | * either provide a proper interrupt tree or don't use this | ||
1301 | * function. | ||
1302 | */ | ||
1303 | if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin)) | ||
1304 | return -1; | ||
1305 | if (pin == 0) | ||
1306 | return -1; | ||
1307 | if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) || | ||
1308 | line == 0xff) { | ||
1309 | return -1; | ||
1310 | } | ||
1311 | DBG(" -> no map ! Using irq line %d from PCI config\n", line); | ||
1296 | 1312 | ||
1297 | DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", | 1313 | virq = irq_create_mapping(NULL, line); |
1298 | oirq.size, oirq.specifier[0], oirq.controller->full_name); | 1314 | if (virq != NO_IRQ) |
1315 | set_irq_type(virq, IRQ_TYPE_LEVEL_LOW); | ||
1316 | } else { | ||
1317 | DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", | ||
1318 | oirq.size, oirq.specifier[0], oirq.controller->full_name); | ||
1299 | 1319 | ||
1300 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); | 1320 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, |
1321 | oirq.size); | ||
1322 | } | ||
1301 | if(virq == NO_IRQ) { | 1323 | if(virq == NO_IRQ) { |
1302 | DBG(" -> failed to map !\n"); | 1324 | DBG(" -> failed to map !\n"); |
1303 | return -1; | 1325 | return -1; |