diff options
author | Alexandre Bounine <alexandre.bounine@idt.com> | 2010-10-27 18:34:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 21:03:15 -0400 |
commit | 6429cd49f45450cd77a57b70b0dfa98fe2794da0 (patch) | |
tree | 1d17827eb9d7163855e8836e4835b32475d72a95 /drivers/rapidio/rio.c | |
parent | ac38d7232dfa3c71b129bab3318ba327bbcf8405 (diff) |
rapidio: add handling of orphan port-write message
Add check for access to port-write (PW) message source device before
processing the PW message. If source RIO device is not available (power
down or RIO link failure) trace back to a last available switch/port on
the PW message route and service failure at that point.
Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Thomas Moll <thomas.moll@sysgo.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Li Yang <leoli@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Micha Nelissen <micha@neli.hopto.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio/rio.c')
-rw-r--r-- | drivers/rapidio/rio.c | 113 |
1 files changed, 108 insertions, 5 deletions
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index 77bd4165238f..aefc2a0004d4 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c | |||
@@ -495,6 +495,92 @@ int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock) | |||
495 | } | 495 | } |
496 | 496 | ||
497 | /** | 497 | /** |
498 | * rio_chk_dev_route - Validate route to the specified device. | ||
499 | * @rdev: RIO device failed to respond | ||
500 | * @nrdev: Last active device on the route to rdev | ||
501 | * @npnum: nrdev's port number on the route to rdev | ||
502 | * | ||
503 | * Follows a route to the specified RIO device to determine the last available | ||
504 | * device (and corresponding RIO port) on the route. | ||
505 | */ | ||
506 | static int | ||
507 | rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum) | ||
508 | { | ||
509 | u32 result; | ||
510 | int p_port, rc = -EIO; | ||
511 | struct rio_dev *prev = NULL; | ||
512 | |||
513 | /* Find switch with failed RIO link */ | ||
514 | while (rdev->prev && (rdev->prev->pef & RIO_PEF_SWITCH)) { | ||
515 | if (!rio_read_config_32(rdev->prev, RIO_DEV_ID_CAR, &result)) { | ||
516 | prev = rdev->prev; | ||
517 | break; | ||
518 | } | ||
519 | rdev = rdev->prev; | ||
520 | } | ||
521 | |||
522 | if (prev == NULL) | ||
523 | goto err_out; | ||
524 | |||
525 | /* Find port with failed RIO link */ | ||
526 | for (p_port = 0; | ||
527 | p_port < RIO_GET_TOTAL_PORTS(prev->swpinfo); p_port++) | ||
528 | if (prev->rswitch->nextdev[p_port] == rdev) | ||
529 | break; | ||
530 | |||
531 | if (p_port < RIO_GET_TOTAL_PORTS(prev->swpinfo)) { | ||
532 | pr_debug("RIO: link failed on [%s]-P%d\n", | ||
533 | rio_name(prev), p_port); | ||
534 | *nrdev = prev; | ||
535 | *npnum = p_port; | ||
536 | rc = 0; | ||
537 | } else | ||
538 | pr_debug("RIO: failed to trace route to %s\n", rio_name(prev)); | ||
539 | err_out: | ||
540 | return rc; | ||
541 | } | ||
542 | |||
543 | /** | ||
544 | * rio_mport_chk_dev_access - Validate access to the specified device. | ||
545 | * @mport: Master port to send transactions | ||
546 | * @destid: Device destination ID in network | ||
547 | * @hopcount: Number of hops into the network | ||
548 | */ | ||
549 | static int | ||
550 | rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, u8 hopcount) | ||
551 | { | ||
552 | int i = 0; | ||
553 | u32 tmp; | ||
554 | |||
555 | while (rio_mport_read_config_32(mport, destid, hopcount, | ||
556 | RIO_DEV_ID_CAR, &tmp)) { | ||
557 | i++; | ||
558 | if (i == RIO_MAX_CHK_RETRY) | ||
559 | return -EIO; | ||
560 | mdelay(1); | ||
561 | } | ||
562 | |||
563 | return 0; | ||
564 | } | ||
565 | |||
566 | /** | ||
567 | * rio_chk_dev_access - Validate access to the specified device. | ||
568 | * @rdev: Pointer to RIO device control structure | ||
569 | */ | ||
570 | static int rio_chk_dev_access(struct rio_dev *rdev) | ||
571 | { | ||
572 | u8 hopcount = 0xff; | ||
573 | u16 destid = rdev->destid; | ||
574 | |||
575 | if (rdev->rswitch) { | ||
576 | destid = rdev->rswitch->destid; | ||
577 | hopcount = rdev->rswitch->hopcount; | ||
578 | } | ||
579 | |||
580 | return rio_mport_chk_dev_access(rdev->net->hport, destid, hopcount); | ||
581 | } | ||
582 | |||
583 | /** | ||
498 | * rio_get_input_status - Sends a Link-Request/Input-Status control symbol and | 584 | * rio_get_input_status - Sends a Link-Request/Input-Status control symbol and |
499 | * returns link-response (if requested). | 585 | * returns link-response (if requested). |
500 | * @rdev: RIO devive to issue Input-status command | 586 | * @rdev: RIO devive to issue Input-status command |
@@ -654,8 +740,8 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
654 | 740 | ||
655 | rdev = rio_get_comptag(pw_msg->em.comptag, NULL); | 741 | rdev = rio_get_comptag(pw_msg->em.comptag, NULL); |
656 | if (rdev == NULL) { | 742 | if (rdev == NULL) { |
657 | /* Someting bad here (probably enumeration error) */ | 743 | /* Device removed or enumeration error */ |
658 | pr_err("RIO: %s No matching device for CTag 0x%08x\n", | 744 | pr_debug("RIO: %s No matching device for CTag 0x%08x\n", |
659 | __func__, pw_msg->em.comptag); | 745 | __func__, pw_msg->em.comptag); |
660 | return -EIO; | 746 | return -EIO; |
661 | } | 747 | } |
@@ -686,6 +772,26 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
686 | return 0; | 772 | return 0; |
687 | } | 773 | } |
688 | 774 | ||
775 | portnum = pw_msg->em.is_port & 0xFF; | ||
776 | |||
777 | /* Check if device and route to it are functional: | ||
778 | * Sometimes devices may send PW message(s) just before being | ||
779 | * powered down (or link being lost). | ||
780 | */ | ||
781 | if (rio_chk_dev_access(rdev)) { | ||
782 | pr_debug("RIO: device access failed - get link partner\n"); | ||
783 | /* Scan route to the device and identify failed link. | ||
784 | * This will replace device and port reported in PW message. | ||
785 | * PW message should not be used after this point. | ||
786 | */ | ||
787 | if (rio_chk_dev_route(rdev, &rdev, &portnum)) { | ||
788 | pr_err("RIO: Route trace for %s failed\n", | ||
789 | rio_name(rdev)); | ||
790 | return -EIO; | ||
791 | } | ||
792 | pw_msg = NULL; | ||
793 | } | ||
794 | |||
689 | /* For End-point devices processing stops here */ | 795 | /* For End-point devices processing stops here */ |
690 | if (!(rdev->pef & RIO_PEF_SWITCH)) | 796 | if (!(rdev->pef & RIO_PEF_SWITCH)) |
691 | return 0; | 797 | return 0; |
@@ -703,9 +809,6 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
703 | /* | 809 | /* |
704 | * Process the port-write notification from switch | 810 | * Process the port-write notification from switch |
705 | */ | 811 | */ |
706 | |||
707 | portnum = pw_msg->em.is_port & 0xFF; | ||
708 | |||
709 | if (rdev->rswitch->em_handle) | 812 | if (rdev->rswitch->em_handle) |
710 | rdev->rswitch->em_handle(rdev, portnum); | 813 | rdev->rswitch->em_handle(rdev, portnum); |
711 | 814 | ||