~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to drivers/ata/libata-eh.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
547
547
 
548
548
        /* For new EH, all qcs are finished in one of three ways -
549
549
         * normal completion, error completion, and SCSI timeout.
550
 
         * Both cmpletions can race against SCSI timeout.  When normal
 
550
         * Both completions can race against SCSI timeout.  When normal
551
551
         * completion wins, the qc never reaches EH.  When error
552
552
         * completion wins, the qc has ATA_QCFLAG_FAILED set.
553
553
         *
562
562
                int nr_timedout = 0;
563
563
 
564
564
                spin_lock_irqsave(ap->lock, flags);
 
565
                
 
566
                /* This must occur under the ap->lock as we don't want
 
567
                   a polled recovery to race the real interrupt handler
 
568
                   
 
569
                   The lost_interrupt handler checks for any completed but
 
570
                   non-notified command and completes much like an IRQ handler.
 
571
                   
 
572
                   We then fall into the error recovery code which will treat
 
573
                   this as if normal completion won the race */
565
574
 
 
575
                if (ap->ops->lost_interrupt)
 
576
                        ap->ops->lost_interrupt(ap);
 
577
                        
566
578
                list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) {
567
579
                        struct ata_queued_cmd *qc;
568
580
 
606
618
                ap->eh_tries = ATA_EH_MAX_TRIES;
607
619
        } else
608
620
                spin_unlock_wait(ap->lock);
 
621
                
 
622
        /* If we timed raced normal completion and there is nothing to
 
623
           recover nr_timedout == 0 why exactly are we doing error recovery ? */
609
624
 
610
625
 repeat:
611
626
        /* invoke error handler */
2502
2517
 
2503
2518
                        ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
2504
2519
                        rc = ata_do_reset(link, reset, classes, deadline, true);
 
2520
                        if (rc) {
 
2521
                                failed_link = link;
 
2522
                                goto fail;
 
2523
                        }
2505
2524
                }
2506
2525
        } else {
2507
2526
                if (verbose)
2768
2787
                } else if (dev->class == ATA_DEV_UNKNOWN &&
2769
2788
                           ehc->tries[dev->devno] &&
2770
2789
                           ata_class_enabled(ehc->classes[dev->devno])) {
 
2790
                        /* Temporarily set dev->class, it will be
 
2791
                         * permanently set once all configurations are
 
2792
                         * complete.  This is necessary because new
 
2793
                         * device configuration is done in two
 
2794
                         * separate loops.
 
2795
                         */
2771
2796
                        dev->class = ehc->classes[dev->devno];
2772
2797
 
2773
2798
                        if (dev->class == ATA_DEV_PMP)
2775
2800
                        else
2776
2801
                                rc = ata_dev_read_id(dev, &dev->class,
2777
2802
                                                     readid_flags, dev->id);
 
2803
 
 
2804
                        /* read_id might have changed class, store and reset */
 
2805
                        ehc->classes[dev->devno] = dev->class;
 
2806
                        dev->class = ATA_DEV_UNKNOWN;
 
2807
 
2778
2808
                        switch (rc) {
2779
2809
                        case 0:
2780
2810
                                /* clear error info accumulated during probe */
2784
2814
                        case -ENOENT:
2785
2815
                                /* IDENTIFY was issued to non-existent
2786
2816
                                 * device.  No need to reset.  Just
2787
 
                                 * thaw and kill the device.
 
2817
                                 * thaw and ignore the device.
2788
2818
                                 */
2789
2819
                                ata_eh_thaw_port(ap);
2790
 
                                dev->class = ATA_DEV_UNKNOWN;
2791
2820
                                break;
2792
2821
                        default:
2793
 
                                dev->class = ATA_DEV_UNKNOWN;
2794
2822
                                goto err;
2795
2823
                        }
2796
2824
                }
2811
2839
                    dev->class == ATA_DEV_PMP)
2812
2840
                        continue;
2813
2841
 
 
2842
                dev->class = ehc->classes[dev->devno];
 
2843
 
2814
2844
                ehc->i.flags |= ATA_EHI_PRINTINFO;
2815
2845
                rc = ata_dev_configure(dev);
2816
2846
                ehc->i.flags &= ~ATA_EHI_PRINTINFO;
2817
 
                if (rc)
 
2847
                if (rc) {
 
2848
                        dev->class = ATA_DEV_UNKNOWN;
2818
2849
                        goto err;
 
2850
                }
2819
2851
 
2820
2852
                spin_lock_irqsave(ap->lock, flags);
2821
2853
                ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
2836
2868
/**
2837
2869
 *      ata_set_mode - Program timings and issue SET FEATURES - XFER
2838
2870
 *      @link: link on which timings will be programmed
2839
 
 *      @r_failed_dev: out paramter for failed device
 
2871
 *      @r_failed_dev: out parameter for failed device
2840
2872
 *
2841
2873
 *      Set ATA device disk transfer mode (PIO3, UDMA6, etc.).  If
2842
2874
 *      ata_set_mode() fails, pointer to the failing device is
3479
3511
 */
3480
3512
static void ata_eh_handle_port_resume(struct ata_port *ap)
3481
3513
{
 
3514
        struct ata_link *link;
 
3515
        struct ata_device *dev;
3482
3516
        unsigned long flags;
3483
3517
        int rc = 0;
3484
3518
 
3493
3527
 
3494
3528
        WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
3495
3529
 
 
3530
        /*
 
3531
         * Error timestamps are in jiffies which doesn't run while
 
3532
         * suspended and PHY events during resume isn't too uncommon.
 
3533
         * When the two are combined, it can lead to unnecessary speed
 
3534
         * downs if the machine is suspended and resumed repeatedly.
 
3535
         * Clear error history.
 
3536
         */
 
3537
        ata_for_each_link(link, ap, HOST_FIRST)
 
3538
                ata_for_each_dev(dev, link, ALL)
 
3539
                        ata_ering_clear(&dev->ering);
 
3540
 
3496
3541
        ata_acpi_set_state(ap, PMSG_ON);
3497
3542
 
3498
3543
        if (ap->ops->port_resume)