Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6912ccd5 authored by Albert Lee's avatar Albert Lee Committed by Jeff Garzik
Browse files

[PATCH] libata-dev: Minor fix for ata_hsm_move() to work with ata_host_intr()



Minor fix for ata_hsm_move() to work with ata_host_intr().
Changes:
- WARN_ON() and comment fix
- Make the HSM_ST_LAST device status checking more rigid.
- Treat unknown HSM state as BUG().

Signed-off-by: default avatarAlbert Lee <albertcc@tw.ibm.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent e2cec771
Loading
Loading
Loading
Loading
+13 −11
Original line number Original line Diff line number Diff line
@@ -3808,6 +3808,8 @@ static void ata_pio_error(struct ata_port *ap)
static void ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
static void ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
			 u8 status)
			 u8 status)
{
{
	WARN_ON((qc->flags & ATA_QCFLAG_ACTIVE) == 0);

	/* check error */
	/* check error */
	if (unlikely(status & (ATA_ERR | ATA_DF))) {
	if (unlikely(status & (ATA_ERR | ATA_DF))) {
		qc->err_mask |= AC_ERR_DEV;
		qc->err_mask |= AC_ERR_DEV;
@@ -3817,10 +3819,6 @@ static void ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
fsm_start:
fsm_start:
	switch (ap->hsm_task_state) {
	switch (ap->hsm_task_state) {
	case HSM_ST_FIRST:
	case HSM_ST_FIRST:
		/* Some pre-ATAPI-4 devices assert INTRQ
		 * at this state when ready to receive CDB.
		 */

		/* check device status */
		/* check device status */
		if (unlikely((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)) {
		if (unlikely((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)) {
			/* Wrong status. Let EH handle this */
			/* Wrong status. Let EH handle this */
@@ -3873,9 +3871,8 @@ static void ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
		break;
		break;


	case HSM_ST_LAST:
	case HSM_ST_LAST:
		if (unlikely(status & ATA_DRQ)) {
		if (unlikely(!ata_ok(status))) {
			/* handle DRQ=1 as error */
			qc->err_mask |= __ac_err_mask(status);
			qc->err_mask |= AC_ERR_HSM;
			ap->hsm_task_state = HSM_ST_ERR;
			ap->hsm_task_state = HSM_ST_ERR;
			goto fsm_start;
			goto fsm_start;
		}
		}
@@ -3884,17 +3881,18 @@ static void ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
		DPRINTK("ata%u: command complete, drv_stat 0x%x\n",
		DPRINTK("ata%u: command complete, drv_stat 0x%x\n",
			ap->id, status);
			ap->id, status);


		WARN_ON(qc->err_mask);

		ap->hsm_task_state = HSM_ST_IDLE;
		ap->hsm_task_state = HSM_ST_IDLE;


		/* complete taskfile transaction */
		/* complete taskfile transaction */
		qc->err_mask |= ac_err_mask(status);
		ata_qc_complete(qc);
		ata_qc_complete(qc);
		break;
		break;


	case HSM_ST_ERR:
	case HSM_ST_ERR:
		if (qc->tf.command != ATA_CMD_PACKET)
		if (qc->tf.command != ATA_CMD_PACKET)
			printk(KERN_ERR "ata%u: command error, drv_stat 0x%x host_stat 0x%x\n",
			printk(KERN_ERR "ata%u: command error, drv_stat 0x%x\n",
			       ap->id, status, host_stat);
			       ap->id, status);


		/* make sure qc->err_mask is available to
		/* make sure qc->err_mask is available to
		 * know what's wrong and recover
		 * know what's wrong and recover
@@ -3905,7 +3903,7 @@ static void ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
		ata_qc_complete(qc);
		ata_qc_complete(qc);
		break;
		break;
	default:
	default:
		goto idle_irq;
		BUG();
	}
	}


}
}
@@ -4371,6 +4369,10 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
	/* Check whether we are expecting interrupt in this state */
	/* Check whether we are expecting interrupt in this state */
	switch (ap->hsm_task_state) {
	switch (ap->hsm_task_state) {
	case HSM_ST_FIRST:
	case HSM_ST_FIRST:
		/* Some pre-ATAPI-4 devices assert INTRQ
		 * at this state when ready to receive CDB.
		 */

		/* Check the ATA_DFLAG_CDB_INTR flag is enough here.
		/* Check the ATA_DFLAG_CDB_INTR flag is enough here.
		 * The flag was turned on only for atapi devices.
		 * The flag was turned on only for atapi devices.
		 * No need to check is_atapi_taskfile(&qc->tf) again.
		 * No need to check is_atapi_taskfile(&qc->tf) again.