linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: Tejun Heo <htejun@gmail.com>
Cc: albertcc@tw.ibm.com, liml@rtr.ca, linux-ide@vger.kernel.org
Subject: Re: [PATCH 02/14] libata: implement new reset mechanism
Date: Mon, 19 Dec 2005 00:31:37 -0500	[thread overview]
Message-ID: <43A645B9.8050009@pobox.com> (raw)
In-Reply-To: <20051218133833.GC31571@htj.dyndns.org>

Tejun Heo wrote:
> +int ata_reset(struct ata_port *ap, unsigned int flags, unsigned int *r_classes)
> +{
> +	const unsigned int unknown[2] = { ATA_DEV_UNKNOWN, ATA_DEV_UNKNOWN };
> +	unsigned int classes[2];
> +	int ret = 0;
> +
> +	DPRINTK("ENTER\n");
> +
> +	if (ap->ops->soft_reset == NULL)
> +		flags &= ~ATA_RESET_SOFT;
> +	if (ap->ops->hard_reset == NULL)
> +		flags &= ~ATA_RESET_HARD;
> +
> +	if (!(flags & (ATA_RESET_SOFT | ATA_RESET_HARD))) {
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> + retry:
> +	if (flags & ATA_RESET_SOFT) {
> +		memcpy(classes, unknown, sizeof(classes));
> +		ret = ap->ops->soft_reset(ap, classes);
> +		if (ret == 0) {
> +			if (!(flags & ATA_RESET_CLASSIFY) ||
> +			    classes[0] != ATA_DEV_UNKNOWN)
> +				goto success;
> +			/* no signature on SRST, try HRST */
> +			flags &= ~ATA_RESET_SOFT;
> +			ret = -ENODEV;	/* no sigature */
> +		}
> +		/* SRST failed, try HRST */
> +	}
> +
> +	if (flags & ATA_RESET_HARD) {
> +		memcpy(classes, unknown, sizeof(classes));
> +		ret = ap->ops->hard_reset(ap, classes);
> +		if (ret == 0) {
> +			if (!(flags & ATA_RESET_CLASSIFY) ||
> +			    classes[0] != ATA_DEV_UNKNOWN)
> +				goto success;
> +			/* no signature on HRST, retry SRST */
> +			flags &= ~ATA_RESET_HARD;
> +			ret = -ENODEV;	/* no sigature */
> +			goto retry;
> +		}
> +		/* HRST failed, give up */
> +	}
> +
> +	goto out;

Fundamental problem:  you should not hard code this execution order. 
Each controller has a different way it likes to handle global and port 
resets.  Sometimes COMRESET is automatically executed for you, when you 
do a controller reset (AHCI does this).

Looking at the bigger picture of error handling, we will want to 
basically run the entire probe sequence, after we reset.  I would look 
into a few key areas:

* figuring out how to safely stop SCSI from submitting commands, while 
you are doing the reset (important!).  SCSI errors are delivered to SATA 
ports -- thus if you are doing a global reset in the EH path, only one 
port's command submission is frozen, and the SCSI layer is happily 
sending commands to the other ports.

* get libata error handlers to start using scsi_eh_flush_done_q() and 
scsi_eh_finish_cmd(), which enables retrying of commands.

* making sure ata_bus_probe() can be called again and again

* implementing srst and hard-reset as taskfile protocols, and supporting 
them via qc_prep/qc_issue

	Jeff



  reply	other threads:[~2005-12-19  5:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-18 13:33 [RFC/PATCHSET] libata: new reset mechanism Tejun Heo
2005-12-18 13:36 ` [PATCH 01/14] libata: modify ata_dev_try_classify Tejun Heo
2005-12-18 13:38 ` [PATCH 02/14] libata: implement new reset mechanism Tejun Heo
2005-12-19  5:31   ` Jeff Garzik [this message]
2005-12-19  6:33     ` Tejun Heo
2005-12-18 13:40 ` [PATCH 03/14] libata: implement standard reset methods Tejun Heo
2005-12-18 13:41 ` [PATCH 04/14] libata: export ata_busy_sleep() Tejun Heo
2005-12-18 13:42 ` [PATCH 05/14] sata_sil: convert to new reset mechanism Tejun Heo
2005-12-18 13:43 ` [PATCH 06/14] sata_sil24: " Tejun Heo
2005-12-18 13:44 ` [PATCH 07/14] sata_sil24: add hardreset Tejun Heo
2005-12-18 13:46 ` [PATCH 08/14] ata_piix: convert pata to new reset mechanism Tejun Heo
2005-12-18 13:47 ` [PATCH 09/14] ata_piix: convert sata " Tejun Heo
2005-12-18 13:48 ` [PATCH 10/14] ahci: separate out ahci_stop/start_engine() Tejun Heo
2005-12-19  5:33   ` Jeff Garzik
2005-12-19  6:05     ` Tejun Heo
2005-12-18 13:49 ` [PATCH 11/14] ahci: convert to new reset mechanism Tejun Heo
2005-12-19  5:33   ` Jeff Garzik
2005-12-19  6:07     ` Tejun Heo
2005-12-18 13:50 ` [PATCH 12/14] ahci: separate out ahci_cmd_prep() Tejun Heo
2005-12-19  5:34   ` Jeff Garzik
2005-12-18 13:51 ` [PATCH 13/14] ahci: add constants for SRST Tejun Heo
2005-12-19  5:35   ` Jeff Garzik
2005-12-18 13:51 ` [PATCH 14/14] ahci: add softreset Tejun Heo
2005-12-19  5:36   ` Jeff Garzik
2005-12-19  6:12     ` Tejun Heo
2005-12-19  6:40       ` Jeff Garzik
2005-12-19  7:13         ` Tejun Heo
2006-01-29  5:11           ` Jeff Garzik
2005-12-19  5:20 ` [RFC/PATCHSET] libata: new reset mechanism Jeff Garzik
2005-12-19  6:03   ` Tejun Heo
2006-01-29  5:20     ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43A645B9.8050009@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=albertcc@tw.ibm.com \
    --cc=htejun@gmail.com \
    --cc=liml@rtr.ca \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).