[PATCH] libata: clean up debounce parameters and improve parameter selection

The names of predefined debounce timing parameters didn't exactly
match their usages. Rename to more generic names and implement param
selection helper sata_ehc_deb_timing() which uses EHI_HOTPLUGGED to
select params.

Combined with the previous EHI_RESUME_LINK differentiation, this makes
parameter selection accurate. e.g. user scan resumes link but normal
deb param is used instead of hotplug param.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Tejun Heo and committed by Jeff Garzik e9c83914 28324304

+24 -18
+11 -14
drivers/scsi/libata-core.c
··· 61 61 #include "libata.h" 62 62 63 63 /* debounce timing parameters in msecs { interval, duration, timeout } */ 64 - const unsigned long sata_deb_timing_boot[] = { 5, 100, 2000 }; 65 - const unsigned long sata_deb_timing_eh[] = { 25, 500, 2000 }; 66 - const unsigned long sata_deb_timing_before_fsrst[] = { 100, 2000, 5000 }; 64 + const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 }; 65 + const unsigned long sata_deb_timing_hotplug[] = { 25, 500, 2000 }; 66 + const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 }; 67 67 68 68 static unsigned int ata_dev_init_params(struct ata_device *dev, 69 69 u16 heads, u16 sectors); ··· 2588 2588 2589 2589 /* first, debounce phy if SATA */ 2590 2590 if (ap->cbl == ATA_CBL_SATA) { 2591 - rc = sata_phy_debounce(ap, sata_deb_timing_eh); 2591 + rc = sata_phy_debounce(ap, sata_deb_timing_hotplug); 2592 2592 2593 2593 /* if debounced successfully and offline, no need to wait */ 2594 2594 if ((rc == 0 || rc == -EOPNOTSUPP) && ata_port_offline(ap)) ··· 2624 2624 int ata_std_prereset(struct ata_port *ap) 2625 2625 { 2626 2626 struct ata_eh_context *ehc = &ap->eh_context; 2627 - const unsigned long *timing; 2627 + const unsigned long *timing = sata_ehc_deb_timing(ehc); 2628 2628 int rc; 2629 2629 2630 2630 /* handle link resume & hotplug spinup */ ··· 2642 2642 2643 2643 /* if SATA, resume phy */ 2644 2644 if (ap->cbl == ATA_CBL_SATA) { 2645 - if (ap->pflags & ATA_PFLAG_LOADING) 2646 - timing = sata_deb_timing_boot; 2647 - else 2648 - timing = sata_deb_timing_eh; 2649 - 2650 2645 rc = sata_phy_resume(ap, timing); 2651 2646 if (rc && rc != -EOPNOTSUPP) { 2652 2647 /* phy resume failed */ ··· 2729 2734 */ 2730 2735 int sata_std_hardreset(struct ata_port *ap, unsigned int *class) 2731 2736 { 2737 + struct ata_eh_context *ehc = &ap->eh_context; 2738 + const unsigned long *timing = sata_ehc_deb_timing(ehc); 2732 2739 u32 scontrol; 2733 2740 int rc; 2734 2741 ··· 2768 2771 msleep(1); 2769 2772 2770 2773 /* bring phy back */ 2771 - sata_phy_resume(ap, sata_deb_timing_eh); 2774 + sata_phy_resume(ap, timing); 2772 2775 2773 2776 /* TODO: phy layer with polling, timeouts, etc. */ 2774 2777 if (ata_port_offline(ap)) { ··· 5849 5852 * Do not depend on ABI/API stability. 5850 5853 */ 5851 5854 5852 - EXPORT_SYMBOL_GPL(sata_deb_timing_boot); 5853 - EXPORT_SYMBOL_GPL(sata_deb_timing_eh); 5854 - EXPORT_SYMBOL_GPL(sata_deb_timing_before_fsrst); 5855 + EXPORT_SYMBOL_GPL(sata_deb_timing_normal); 5856 + EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug); 5857 + EXPORT_SYMBOL_GPL(sata_deb_timing_long); 5855 5858 EXPORT_SYMBOL_GPL(ata_std_bios_param); 5856 5859 EXPORT_SYMBOL_GPL(ata_std_ports); 5857 5860 EXPORT_SYMBOL_GPL(ata_device_add);
+1 -1
drivers/scsi/sata_sil24.c
··· 607 607 /* SStatus oscillates between zero and valid status after 608 608 * DEV_RST, debounce it. 609 609 */ 610 - rc = sata_phy_debounce(ap, sata_deb_timing_before_fsrst); 610 + rc = sata_phy_debounce(ap, sata_deb_timing_long); 611 611 if (rc) { 612 612 reason = "PHY debouncing failed"; 613 613 goto err;
+12 -3
include/linux/libata.h
··· 629 629 630 630 #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) 631 631 632 - extern const unsigned long sata_deb_timing_boot[]; 633 - extern const unsigned long sata_deb_timing_eh[]; 634 - extern const unsigned long sata_deb_timing_before_fsrst[]; 632 + extern const unsigned long sata_deb_timing_normal[]; 633 + extern const unsigned long sata_deb_timing_hotplug[]; 634 + extern const unsigned long sata_deb_timing_long[]; 635 + 636 + static inline const unsigned long * 637 + sata_ehc_deb_timing(struct ata_eh_context *ehc) 638 + { 639 + if (ehc->i.flags & ATA_EHI_HOTPLUGGED) 640 + return sata_deb_timing_hotplug; 641 + else 642 + return sata_deb_timing_normal; 643 + } 635 644 636 645 extern void ata_port_probe(struct ata_port *); 637 646 extern void __sata_phy_reset(struct ata_port *ap);