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

Commit 3e4ec344 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik
Browse files

libata: kill ATA_FLAG_DISABLED



ATA_FLAG_DISABLED is only used by drivers which don't use
->error_handler framework and is largely broken.  Its only meaningful
function is to make irq handlers skip processing if the flag is set,
which is largely useless and even harmful as it makes those ports more
likely to cause IRQ storms.

Kill ATA_FLAG_DISABLED and makes the callers disable attached devices
instead.  ata_port_probe() and ata_port_disable() which manipulate the
flag are also killed.

This simplifies condition check in IRQ handlers.  While updating IRQ
handlers, remove ap NULL check as libata guarantees consecutive port
allocation (unoccupied ports are initialized with dummies) and
long-obsolete ATA_QCFLAG_ACTIVE check (checked by ata_qc_from_tag()).

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent c7a8209f
Loading
Loading
Loading
Loading
+1 −65
Original line number Original line Diff line number Diff line
@@ -1907,22 +1907,6 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
	ap->qc_active = preempted_qc_active;
	ap->qc_active = preempted_qc_active;
	ap->nr_active_links = preempted_nr_active_links;
	ap->nr_active_links = preempted_nr_active_links;


	/* XXX - Some LLDDs (sata_mv) disable port on command failure.
	 * Until those drivers are fixed, we detect the condition
	 * here, fail the command with AC_ERR_SYSTEM and reenable the
	 * port.
	 *
	 * Note that this doesn't change any behavior as internal
	 * command failure results in disabling the device in the
	 * higher layer for LLDDs without new reset/EH callbacks.
	 *
	 * Kill the following code as soon as those drivers are fixed.
	 */
	if (ap->flags & ATA_FLAG_DISABLED) {
		err_mask |= AC_ERR_SYSTEM;
		ata_port_probe(ap);
	}

	spin_unlock_irqrestore(ap->lock, flags);
	spin_unlock_irqrestore(ap->lock, flags);


	if ((err_mask & AC_ERR_TIMEOUT) && auto_timeout)
	if ((err_mask & AC_ERR_TIMEOUT) && auto_timeout)
@@ -2768,8 +2752,6 @@ int ata_bus_probe(struct ata_port *ap)
	int rc;
	int rc;
	struct ata_device *dev;
	struct ata_device *dev;


	ata_port_probe(ap);

	ata_for_each_dev(dev, &ap->link, ALL)
	ata_for_each_dev(dev, &ap->link, ALL)
		tries[dev->devno] = ATA_PROBE_MAX_TRIES;
		tries[dev->devno] = ATA_PROBE_MAX_TRIES;


@@ -2797,8 +2779,7 @@ int ata_bus_probe(struct ata_port *ap)
	ap->ops->phy_reset(ap);
	ap->ops->phy_reset(ap);


	ata_for_each_dev(dev, &ap->link, ALL) {
	ata_for_each_dev(dev, &ap->link, ALL) {
		if (!(ap->flags & ATA_FLAG_DISABLED) &&
		if (dev->class != ATA_DEV_UNKNOWN)
		    dev->class != ATA_DEV_UNKNOWN)
			classes[dev->devno] = dev->class;
			classes[dev->devno] = dev->class;
		else
		else
			classes[dev->devno] = ATA_DEV_NONE;
			classes[dev->devno] = ATA_DEV_NONE;
@@ -2806,8 +2787,6 @@ int ata_bus_probe(struct ata_port *ap)
		dev->class = ATA_DEV_UNKNOWN;
		dev->class = ATA_DEV_UNKNOWN;
	}
	}


	ata_port_probe(ap);

	/* read IDENTIFY page and configure devices. We have to do the identify
	/* read IDENTIFY page and configure devices. We have to do the identify
	   specific sequence bass-ackwards so that PDIAG- is released by
	   specific sequence bass-ackwards so that PDIAG- is released by
	   the slave device */
	   the slave device */
@@ -2857,8 +2836,6 @@ int ata_bus_probe(struct ata_port *ap)
	ata_for_each_dev(dev, &ap->link, ENABLED)
	ata_for_each_dev(dev, &ap->link, ENABLED)
		return 0;
		return 0;


	/* no device present, disable port */
	ata_port_disable(ap);
	return -ENODEV;
	return -ENODEV;


 fail:
 fail:
@@ -2889,22 +2866,6 @@ int ata_bus_probe(struct ata_port *ap)
	goto retry;
	goto retry;
}
}


/**
 *	ata_port_probe - Mark port as enabled
 *	@ap: Port for which we indicate enablement
 *
 *	Modify @ap data structure such that the system
 *	thinks that the entire port is enabled.
 *
 *	LOCKING: host lock, or some other form of
 *	serialization.
 */

void ata_port_probe(struct ata_port *ap)
{
	ap->flags &= ~ATA_FLAG_DISABLED;
}

/**
/**
 *	sata_print_link_status - Print SATA link status
 *	sata_print_link_status - Print SATA link status
 *	@link: SATA link to printk link status about
 *	@link: SATA link to printk link status about
@@ -2951,26 +2912,6 @@ struct ata_device *ata_dev_pair(struct ata_device *adev)
	return pair;
	return pair;
}
}


/**
 *	ata_port_disable - Disable port.
 *	@ap: Port to be disabled.
 *
 *	Modify @ap data structure such that the system
 *	thinks that the entire port is disabled, and should
 *	never attempt to probe or communicate with devices
 *	on this port.
 *
 *	LOCKING: host lock, or some other form of
 *	serialization.
 */

void ata_port_disable(struct ata_port *ap)
{
	ap->link.device[0].class = ATA_DEV_NONE;
	ap->link.device[1].class = ATA_DEV_NONE;
	ap->flags |= ATA_FLAG_DISABLED;
}

/**
/**
 *	sata_down_spd_limit - adjust SATA spd limit downward
 *	sata_down_spd_limit - adjust SATA spd limit downward
 *	@link: Link to adjust SATA spd limit for
 *	@link: Link to adjust SATA spd limit for
@@ -5716,7 +5657,6 @@ struct ata_port *ata_port_alloc(struct ata_host *host)


	ap->pflags |= ATA_PFLAG_INITIALIZING;
	ap->pflags |= ATA_PFLAG_INITIALIZING;
	ap->lock = &host->lock;
	ap->lock = &host->lock;
	ap->flags = ATA_FLAG_DISABLED;
	ap->print_id = -1;
	ap->print_id = -1;
	ap->ctl = ATA_DEVCTL_OBS;
	ap->ctl = ATA_DEVCTL_OBS;
	ap->host = host;
	ap->host = host;
@@ -6145,8 +6085,6 @@ static void async_port_probe(void *data, async_cookie_t cookie)
		struct ata_eh_info *ehi = &ap->link.eh_info;
		struct ata_eh_info *ehi = &ap->link.eh_info;
		unsigned long flags;
		unsigned long flags;


		ata_port_probe(ap);

		/* kick EH for boot probing */
		/* kick EH for boot probing */
		spin_lock_irqsave(ap->lock, flags);
		spin_lock_irqsave(ap->lock, flags);


@@ -6823,7 +6761,6 @@ EXPORT_SYMBOL_GPL(ata_port_start);
EXPORT_SYMBOL_GPL(ata_do_set_mode);
EXPORT_SYMBOL_GPL(ata_do_set_mode);
EXPORT_SYMBOL_GPL(ata_std_qc_defer);
EXPORT_SYMBOL_GPL(ata_std_qc_defer);
EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
EXPORT_SYMBOL_GPL(ata_port_probe);
EXPORT_SYMBOL_GPL(ata_dev_disable);
EXPORT_SYMBOL_GPL(ata_dev_disable);
EXPORT_SYMBOL_GPL(sata_set_spd);
EXPORT_SYMBOL_GPL(sata_set_spd);
EXPORT_SYMBOL_GPL(ata_wait_after_reset);
EXPORT_SYMBOL_GPL(ata_wait_after_reset);
@@ -6835,7 +6772,6 @@ EXPORT_SYMBOL_GPL(sata_std_hardreset);
EXPORT_SYMBOL_GPL(ata_std_postreset);
EXPORT_SYMBOL_GPL(ata_std_postreset);
EXPORT_SYMBOL_GPL(ata_dev_classify);
EXPORT_SYMBOL_GPL(ata_dev_classify);
EXPORT_SYMBOL_GPL(ata_dev_pair);
EXPORT_SYMBOL_GPL(ata_dev_pair);
EXPORT_SYMBOL_GPL(ata_port_disable);
EXPORT_SYMBOL_GPL(ata_ratelimit);
EXPORT_SYMBOL_GPL(ata_ratelimit);
EXPORT_SYMBOL_GPL(ata_wait_register);
EXPORT_SYMBOL_GPL(ata_wait_register);
EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
+0 −3
Original line number Original line Diff line number Diff line
@@ -3345,9 +3345,6 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
	struct ata_link *link;
	struct ata_link *link;
	struct ata_device *dev;
	struct ata_device *dev;


	if (ap->flags & ATA_FLAG_DISABLED)
		return;

 repeat:
 repeat:
	ata_for_each_link(link, ap, EDGE) {
	ata_for_each_link(link, ap, EDGE) {
		ata_for_each_dev(dev, link, ENABLED) {
		ata_for_each_dev(dev, link, ENABLED) {
+2 −8
Original line number Original line Diff line number Diff line
@@ -1807,9 +1807,6 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
		struct ata_port *ap = host->ports[i];
		struct ata_port *ap = host->ports[i];
		struct ata_queued_cmd *qc;
		struct ata_queued_cmd *qc;


		if (unlikely(ap->flags & ATA_FLAG_DISABLED))
			continue;

		qc = ata_qc_from_tag(ap, ap->link.active_tag);
		qc = ata_qc_from_tag(ap, ap->link.active_tag);
		if (qc) {
		if (qc) {
			if (!(qc->tf.flags & ATA_TFLAG_POLLING))
			if (!(qc->tf.flags & ATA_TFLAG_POLLING))
@@ -1884,11 +1881,8 @@ void ata_sff_lost_interrupt(struct ata_port *ap)


	/* Only one outstanding command per SFF channel */
	/* Only one outstanding command per SFF channel */
	qc = ata_qc_from_tag(ap, ap->link.active_tag);
	qc = ata_qc_from_tag(ap, ap->link.active_tag);
	/* Check we have a live one.. */
	/* We cannot lose an interrupt on a non-existent or polled command */
	if (qc == NULL ||  !(qc->flags & ATA_QCFLAG_ACTIVE))
	if (!qc || qc->tf.flags & ATA_TFLAG_POLLING)
		return;
	/* We cannot lose an interrupt on a polled command */
	if (qc->tf.flags & ATA_TFLAG_POLLING)
		return;
		return;
	/* See if the controller thinks it is still busy - if so the command
	/* See if the controller thinks it is still busy - if so the command
	   isn't a lost IRQ but is still in progress */
	   isn't a lost IRQ but is still in progress */
+5 −11
Original line number Original line Diff line number Diff line
@@ -1400,19 +1400,13 @@ static irqreturn_t bfin_ata_interrupt(int irq, void *dev_instance)
	spin_lock_irqsave(&host->lock, flags);
	spin_lock_irqsave(&host->lock, flags);


	for (i = 0; i < host->n_ports; i++) {
	for (i = 0; i < host->n_ports; i++) {
		struct ata_port *ap;
		struct ata_port *ap = host->ports[i];

		ap = host->ports[i];
		if (ap &&
		    !(ap->flags & ATA_FLAG_DISABLED)) {
		struct ata_queued_cmd *qc;
		struct ata_queued_cmd *qc;


		qc = ata_qc_from_tag(ap, ap->link.active_tag);
		qc = ata_qc_from_tag(ap, ap->link.active_tag);
			if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
		if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
			    (qc->flags & ATA_QCFLAG_ACTIVE))
			handled |= bfin_ata_host_intr(ap, qc);
			handled |= bfin_ata_host_intr(ap, qc);
	}
	}
	}


	spin_unlock_irqrestore(&host->lock, flags);
	spin_unlock_irqrestore(&host->lock, flags);


+2 −7
Original line number Original line Diff line number Diff line
@@ -654,9 +654,6 @@ static irqreturn_t octeon_cf_interrupt(int irq, void *dev_instance)
		ap = host->ports[i];
		ap = host->ports[i];
		ocd = ap->dev->platform_data;
		ocd = ap->dev->platform_data;


		if (ap->flags & ATA_FLAG_DISABLED)
			continue;

		ocd = ap->dev->platform_data;
		ocd = ap->dev->platform_data;
		cf_port = ap->private_data;
		cf_port = ap->private_data;
		dma_int.u64 =
		dma_int.u64 =
@@ -666,8 +663,7 @@ static irqreturn_t octeon_cf_interrupt(int irq, void *dev_instance)


		qc = ata_qc_from_tag(ap, ap->link.active_tag);
		qc = ata_qc_from_tag(ap, ap->link.active_tag);


		if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
		if (qc && !(qc->tf.flags & ATA_TFLAG_POLLING)) {
		    (qc->flags & ATA_QCFLAG_ACTIVE)) {
			if (dma_int.s.done && !dma_cfg.s.en) {
			if (dma_int.s.done && !dma_cfg.s.en) {
				if (!sg_is_last(qc->cursg)) {
				if (!sg_is_last(qc->cursg)) {
					qc->cursg = sg_next(qc->cursg);
					qc->cursg = sg_next(qc->cursg);
@@ -737,8 +733,7 @@ static void octeon_cf_delayed_finish(struct work_struct *work)
		goto out;
		goto out;
	}
	}
	qc = ata_qc_from_tag(ap, ap->link.active_tag);
	qc = ata_qc_from_tag(ap, ap->link.active_tag);
	if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
	if (qc && !(qc->tf.flags & ATA_TFLAG_POLLING))
	    (qc->flags & ATA_QCFLAG_ACTIVE))
		octeon_cf_dma_finished(ap, qc);
		octeon_cf_dma_finished(ap, qc);
out:
out:
	spin_unlock_irqrestore(&host->lock, flags);
	spin_unlock_irqrestore(&host->lock, flags);
Loading