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

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

libata: move reset freeze/thaw handling into ata_eh_reset()



Previously reset freeze/thaw handling lived outside of ata_eh_reset()
mainly because the original PMP reset code needed the port frozen
while resetting all the fan-out ports, which is no longer the case.

This patch moves freeze/thaw handling into ata_eh_reset().
@prereset() and @postreset() are now called w/o freezing the port
although @prereset() an be called frozen if the port is frozen prior
to entering ata_eh_reset().

This makes code simpler and will help removing hotplug event related
races.

Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 932648b0
Loading
Loading
Loading
Loading
+18 −28
Original line number Original line Diff line number Diff line
@@ -2170,6 +2170,9 @@ int ata_eh_reset(struct ata_link *link, int classify,
	/*
	/*
	 * Perform reset
	 * Perform reset
	 */
	 */
	if (ata_is_host_link(link))
		ata_eh_freeze_port(ap);

	deadline = jiffies + ata_eh_reset_timeouts[try++];
	deadline = jiffies + ata_eh_reset_timeouts[try++];


	if (reset) {
	if (reset) {
@@ -2238,6 +2241,10 @@ int ata_eh_reset(struct ata_link *link, int classify,
	if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
	if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
		link->sata_spd = (sstatus >> 4) & 0xf;
		link->sata_spd = (sstatus >> 4) & 0xf;


	/* thaw the port */
	if (ata_is_host_link(link))
		ata_eh_thaw_port(ap);

	if (postreset)
	if (postreset)
		postreset(link, classes);
		postreset(link, classes);


@@ -2589,7 +2596,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
	struct ata_link *link;
	struct ata_link *link;
	struct ata_device *dev;
	struct ata_device *dev;
	int nr_failed_devs, nr_disabled_devs;
	int nr_failed_devs, nr_disabled_devs;
	int reset, rc;
	int rc;
	unsigned long flags;
	unsigned long flags;


	DPRINTK("ENTER\n");
	DPRINTK("ENTER\n");
@@ -2632,7 +2639,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
	rc = 0;
	rc = 0;
	nr_failed_devs = 0;
	nr_failed_devs = 0;
	nr_disabled_devs = 0;
	nr_disabled_devs = 0;
	reset = 0;


	/* if UNLOADING, finish immediately */
	/* if UNLOADING, finish immediately */
	if (ap->pflags & ATA_PFLAG_UNLOADING)
	if (ap->pflags & ATA_PFLAG_UNLOADING)
@@ -2646,22 +2652,11 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
		if (ata_eh_skip_recovery(link))
		if (ata_eh_skip_recovery(link))
			ehc->i.action = 0;
			ehc->i.action = 0;


		/* do we need to reset? */
		if (ehc->i.action & ATA_EH_RESET)
			reset = 1;

		ata_link_for_each_dev(dev, link)
		ata_link_for_each_dev(dev, link)
			ehc->classes[dev->devno] = ATA_DEV_UNKNOWN;
			ehc->classes[dev->devno] = ATA_DEV_UNKNOWN;
	}
	}


	/* reset */
	/* reset */
	if (reset) {
		/* if PMP is attached, this function only deals with
		 * downstream links, port should stay thawed.
		 */
		if (!sata_pmp_attached(ap))
			ata_eh_freeze_port(ap);

	ata_port_for_each_link(link, ap) {
	ata_port_for_each_link(link, ap) {
		struct ata_eh_context *ehc = &link->eh_context;
		struct ata_eh_context *ehc = &link->eh_context;


@@ -2669,8 +2664,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
			continue;
			continue;


		rc = ata_eh_reset(link, ata_link_nr_vacant(link),
		rc = ata_eh_reset(link, ata_link_nr_vacant(link),
					  prereset, softreset, hardreset,
				  prereset, softreset, hardreset, postreset);
					  postreset);
		if (rc) {
		if (rc) {
			ata_link_printk(link, KERN_ERR,
			ata_link_printk(link, KERN_ERR,
					"reset failed, giving up\n");
					"reset failed, giving up\n");
@@ -2678,10 +2672,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
		}
		}
	}
	}


		if (!sata_pmp_attached(ap))
			ata_eh_thaw_port(ap);
	}

	/* the rest */
	/* the rest */
	ata_port_for_each_link(link, ap) {
	ata_port_for_each_link(link, ap) {
		struct ata_eh_context *ehc = &link->eh_context;
		struct ata_eh_context *ehc = &link->eh_context;
+0 −4
Original line number Original line Diff line number Diff line
@@ -700,8 +700,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
	if (ehc->i.action & ATA_EH_RESET) {
	if (ehc->i.action & ATA_EH_RESET) {
		struct ata_link *tlink;
		struct ata_link *tlink;


		ata_eh_freeze_port(ap);

		/* reset */
		/* reset */
		rc = ata_eh_reset(link, 0, prereset, softreset, hardreset,
		rc = ata_eh_reset(link, 0, prereset, softreset, hardreset,
				  postreset);
				  postreset);
@@ -711,8 +709,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
			goto fail;
			goto fail;
		}
		}


		ata_eh_thaw_port(ap);

		/* PMP is reset, SErrors cannot be trusted, scan all */
		/* PMP is reset, SErrors cannot be trusted, scan all */
		ata_port_for_each_link(tlink, ap) {
		ata_port_for_each_link(tlink, ap) {
			struct ata_eh_context *ehc = &tlink->eh_context;
			struct ata_eh_context *ehc = &tlink->eh_context;