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

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

[PATCH] libata: move err_mask to ata_queued_cmd



  - remove err_mask from the parameter list of the complete functions
  - move err_mask to ata_queued_cmd
  - initialize qc->err_mask when needed
  - for each function call to ata_qc_complete(), replace the err_mask parameter with qc->err_mask.

Signed-off-by: default avatarAlbert Lee <albertcc@tw.ibm.com>

===============
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent c14b8331
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -643,7 +643,8 @@ static void ahci_eng_timeout(struct ata_port *ap)
	 	 * not being called from the SCSI EH.
	 	 */
		qc->scsidone = scsi_finish_command;
		ata_qc_complete(qc, AC_ERR_OTHER);
		qc->err_mask |= AC_ERR_OTHER;
		ata_qc_complete(qc);
	}

	spin_unlock_irqrestore(&host_set->lock, flags);
@@ -664,7 +665,8 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
	ci = readl(port_mmio + PORT_CMD_ISSUE);
	if (likely((ci & 0x1) == 0)) {
		if (qc) {
			ata_qc_complete(qc, 0);
			assert(qc->err_mask == 0);
			ata_qc_complete(qc);
			qc = NULL;
		}
	}
@@ -681,8 +683,10 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
		/* command processing has stopped due to error; restart */
		ahci_restart_port(ap, status);

		if (qc)
			ata_qc_complete(qc, err_mask);
		if (qc) {
			qc->err_mask |= AC_ERR_OTHER;
			ata_qc_complete(qc);
		}
	}

	return 1;
+19 −13
Original line number Diff line number Diff line
@@ -1053,9 +1053,9 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc,

	if (wait_for_completion_timeout(wait, 30 * HZ) < 1) {
		/* timeout handling */
		unsigned int err_mask = ac_err_mask(ata_chk_status(qc->ap));
		qc->err_mask |= ac_err_mask(ata_chk_status(qc->ap));

		if (!err_mask) {
		if (!qc->err_mask) {
			printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n",
			       qc->ap->id, qc->tf.command);
		} else {
@@ -1064,7 +1064,7 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc,
			rc = -EIO;
		}

		ata_qc_complete(qc, err_mask);
		ata_qc_complete(qc);
	}

	return rc;
@@ -1175,6 +1175,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
				qc->cursg_ofs = 0;
				qc->cursect = 0;
				qc->nsect = 1;
				qc->err_mask = 0;
				goto retry;
			}
		}
@@ -2777,7 +2778,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
 *	None.  (grabs host lock)
 */

void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
void ata_poll_qc_complete(struct ata_queued_cmd *qc)
{
	struct ata_port *ap = qc->ap;
	unsigned long flags;
@@ -2785,7 +2786,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
	spin_lock_irqsave(&ap->host_set->lock, flags);
	ap->flags &= ~ATA_FLAG_NOINTR;
	ata_irq_on(ap);
	ata_qc_complete(qc, err_mask);
	ata_qc_complete(qc);
	spin_unlock_irqrestore(&ap->host_set->lock, flags);
}

@@ -2885,7 +2886,8 @@ static int ata_pio_complete (struct ata_port *ap)

	ap->hsm_task_state = HSM_ST_IDLE;

	ata_poll_qc_complete(qc, 0);
	assert(qc->err_mask == 0);
	ata_poll_qc_complete(qc);

	/* another command may start at this point */

@@ -3261,7 +3263,8 @@ static void ata_pio_error(struct ata_port *ap)

	ap->hsm_task_state = HSM_ST_IDLE;

	ata_poll_qc_complete(qc, AC_ERR_ATA_BUS);
	qc->err_mask |= AC_ERR_ATA_BUS;
	ata_poll_qc_complete(qc);
}

static void ata_pio_task(void *_data)
@@ -3363,7 +3366,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
		       ap->id, qc->tf.command, drv_stat, host_stat);

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

@@ -3462,7 +3466,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
	return qc;
}

int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask)
int ata_qc_complete_noop(struct ata_queued_cmd *qc)
{
	return 0;
}
@@ -3521,7 +3525,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
 *	spin_lock_irqsave(host_set lock)
 */

void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
void ata_qc_complete(struct ata_queued_cmd *qc)
{
	int rc;

@@ -3538,7 +3542,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
	qc->flags &= ~ATA_QCFLAG_ACTIVE;

	/* call completion callback */
	rc = qc->complete_fn(qc, err_mask);
	rc = qc->complete_fn(qc);

	/* if callback indicates not to complete command (non-zero),
	 * return immediately
@@ -3976,7 +3980,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
		ap->ops->irq_clear(ap);

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

	default:
@@ -4111,7 +4116,8 @@ static void atapi_packet_task(void *_data)
err_out_status:
	status = ata_chk_status(ap);
err_out:
	ata_poll_qc_complete(qc, __ac_err_mask(status));
	qc->err_mask |= __ac_err_mask(status);
	ata_poll_qc_complete(qc);
}


+10 −8
Original line number Diff line number Diff line
@@ -1203,12 +1203,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
	return 1;
}

static int ata_scsi_qc_complete(struct ata_queued_cmd *qc,
				unsigned int err_mask)
static int ata_scsi_qc_complete(struct ata_queued_cmd *qc)
{
	struct scsi_cmnd *cmd = qc->scsicmd;
	u8 *cdb = cmd->cmnd;
 	int need_sense = (err_mask != 0);
 	int need_sense = (qc->err_mask != 0);

	/* For ATA pass thru (SAT) commands, generate a sense block if
	 * user mandated it or if there's an error.  Note that if we
@@ -1955,9 +1954,9 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8
	done(cmd);
}

static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask)
static int atapi_sense_complete(struct ata_queued_cmd *qc)
{
	if (err_mask && ((err_mask & AC_ERR_DEV) == 0))
	if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0))
		/* FIXME: not quite right; we don't want the
		 * translation of taskfile registers into
		 * a sense descriptors, since that's only
@@ -2015,15 +2014,18 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)

	qc->complete_fn = atapi_sense_complete;

	if (ata_qc_issue(qc))
		ata_qc_complete(qc, AC_ERR_OTHER);
	if (ata_qc_issue(qc)) {
		qc->err_mask |= AC_ERR_OTHER;
		ata_qc_complete(qc);
	}

	DPRINTK("EXIT\n");
}

static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
static int atapi_qc_complete(struct ata_queued_cmd *qc)
{
	struct scsi_cmnd *cmd = qc->scsicmd;
	unsigned int err_mask = qc->err_mask;

	VPRINTK("ENTER, err_mask 0x%X\n", err_mask);

+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ struct ata_scsi_args {

/* libata-core.c */
extern int atapi_enabled;
extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask);
extern int ata_qc_complete_noop(struct ata_queued_cmd *qc);
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
				      struct ata_device *dev);
extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc);
+5 −6
Original line number Diff line number Diff line
@@ -464,14 +464,12 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
			continue;
		qc = ata_qc_from_tag(ap, ap->active_tag);
		if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
			unsigned int err_mask = 0;

			if ((status & (aPERR | aPSD | aUIRQ)))
				err_mask = AC_ERR_OTHER;
				qc->err_mask |= AC_ERR_OTHER;
			else if (pp->pkt[0] != cDONE)
				err_mask = AC_ERR_OTHER;
				qc->err_mask |= AC_ERR_OTHER;

			ata_qc_complete(qc, err_mask);
			ata_qc_complete(qc);
		}
	}
	return handled;
@@ -501,7 +499,8 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
		
				/* complete taskfile transaction */
				pp->state = adma_state_idle;
				ata_qc_complete(qc, ac_err_mask(status));
				qc->err_mask |= ac_err_mask(status);
				ata_qc_complete(qc);
				handled = 1;
			}
		}
Loading