Skip to content

Commit

Permalink
[PATCH] libata: clean up debounce parameters and improve parameter se…
Browse files Browse the repository at this point in the history
…lection

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>
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Jul 6, 2006
1 parent 2832430 commit e9c8391
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
25 changes: 11 additions & 14 deletions drivers/scsi/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
#include "libata.h"

/* debounce timing parameters in msecs { interval, duration, timeout } */
const unsigned long sata_deb_timing_boot[] = { 5, 100, 2000 };
const unsigned long sata_deb_timing_eh[] = { 25, 500, 2000 };
const unsigned long sata_deb_timing_before_fsrst[] = { 100, 2000, 5000 };
const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 };
const unsigned long sata_deb_timing_hotplug[] = { 25, 500, 2000 };
const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 };

static unsigned int ata_dev_init_params(struct ata_device *dev,
u16 heads, u16 sectors);
Expand Down Expand Up @@ -2588,7 +2588,7 @@ static void ata_wait_spinup(struct ata_port *ap)

/* first, debounce phy if SATA */
if (ap->cbl == ATA_CBL_SATA) {
rc = sata_phy_debounce(ap, sata_deb_timing_eh);
rc = sata_phy_debounce(ap, sata_deb_timing_hotplug);

/* if debounced successfully and offline, no need to wait */
if ((rc == 0 || rc == -EOPNOTSUPP) && ata_port_offline(ap))
Expand Down Expand Up @@ -2624,7 +2624,7 @@ static void ata_wait_spinup(struct ata_port *ap)
int ata_std_prereset(struct ata_port *ap)
{
struct ata_eh_context *ehc = &ap->eh_context;
const unsigned long *timing;
const unsigned long *timing = sata_ehc_deb_timing(ehc);
int rc;

/* handle link resume & hotplug spinup */
Expand All @@ -2642,11 +2642,6 @@ int ata_std_prereset(struct ata_port *ap)

/* if SATA, resume phy */
if (ap->cbl == ATA_CBL_SATA) {
if (ap->pflags & ATA_PFLAG_LOADING)
timing = sata_deb_timing_boot;
else
timing = sata_deb_timing_eh;

rc = sata_phy_resume(ap, timing);
if (rc && rc != -EOPNOTSUPP) {
/* phy resume failed */
Expand Down Expand Up @@ -2734,6 +2729,8 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes)
*/
int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
{
struct ata_eh_context *ehc = &ap->eh_context;
const unsigned long *timing = sata_ehc_deb_timing(ehc);
u32 scontrol;
int rc;

Expand Down Expand Up @@ -2771,7 +2768,7 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
msleep(1);

/* bring phy back */
sata_phy_resume(ap, sata_deb_timing_eh);
sata_phy_resume(ap, timing);

/* TODO: phy layer with polling, timeouts, etc. */
if (ata_port_offline(ap)) {
Expand Down Expand Up @@ -5852,9 +5849,9 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
* Do not depend on ABI/API stability.
*/

EXPORT_SYMBOL_GPL(sata_deb_timing_boot);
EXPORT_SYMBOL_GPL(sata_deb_timing_eh);
EXPORT_SYMBOL_GPL(sata_deb_timing_before_fsrst);
EXPORT_SYMBOL_GPL(sata_deb_timing_normal);
EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
EXPORT_SYMBOL_GPL(sata_deb_timing_long);
EXPORT_SYMBOL_GPL(ata_std_bios_param);
EXPORT_SYMBOL_GPL(ata_std_ports);
EXPORT_SYMBOL_GPL(ata_device_add);
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/sata_sil24.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ static int sil24_hardreset(struct ata_port *ap, unsigned int *class)
/* SStatus oscillates between zero and valid status after
* DEV_RST, debounce it.
*/
rc = sata_phy_debounce(ap, sata_deb_timing_before_fsrst);
rc = sata_phy_debounce(ap, sata_deb_timing_long);
if (rc) {
reason = "PHY debouncing failed";
goto err;
Expand Down
15 changes: 12 additions & 3 deletions include/linux/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,18 @@ struct ata_timing {

#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin)

extern const unsigned long sata_deb_timing_boot[];
extern const unsigned long sata_deb_timing_eh[];
extern const unsigned long sata_deb_timing_before_fsrst[];
extern const unsigned long sata_deb_timing_normal[];
extern const unsigned long sata_deb_timing_hotplug[];
extern const unsigned long sata_deb_timing_long[];

static inline const unsigned long *
sata_ehc_deb_timing(struct ata_eh_context *ehc)
{
if (ehc->i.flags & ATA_EHI_HOTPLUGGED)
return sata_deb_timing_hotplug;
else
return sata_deb_timing_normal;
}

extern void ata_port_probe(struct ata_port *);
extern void __sata_phy_reset(struct ata_port *ap);
Expand Down

0 comments on commit e9c8391

Please sign in to comment.