ata: make use of ata_port_is_frozen() helper

Clean up the code by making use of the newly introduced
ata_port_is_frozen() helper function.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
This commit is contained in:
Niklas Cassel 2022-10-07 15:23:38 +02:00 committed by Damien Le Moal
parent fddb1a6424
commit 4cb7c6f1ef
9 changed files with 22 additions and 23 deletions

View file

@ -2120,7 +2120,7 @@ void ahci_error_handler(struct ata_port *ap)
{ {
struct ahci_host_priv *hpriv = ap->host->private_data; struct ahci_host_priv *hpriv = ap->host->private_data;
if (!(ap->pflags & ATA_PFLAG_FROZEN)) { if (!ata_port_is_frozen(ap)) {
/* restart engine */ /* restart engine */
hpriv->stop_engine(ap); hpriv->stop_engine(ap);
hpriv->start_engine(ap); hpriv->start_engine(ap);
@ -2311,7 +2311,7 @@ static void ahci_pmp_attach(struct ata_port *ap)
* Note that during initialization, the port is marked as * Note that during initialization, the port is marked as
* frozen since the irq handler is not yet registered. * frozen since the irq handler is not yet registered.
*/ */
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
} }
@ -2330,7 +2330,7 @@ static void ahci_pmp_detach(struct ata_port *ap)
pp->intr_mask &= ~PORT_IRQ_BAD_PMP; pp->intr_mask &= ~PORT_IRQ_BAD_PMP;
/* see comment above in ahci_pmp_attach() */ /* see comment above in ahci_pmp_attach() */
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
} }

View file

@ -992,7 +992,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
acpi_err: acpi_err:
/* ignore evaluation failure if we can continue safely */ /* ignore evaluation failure if we can continue safely */
if (rc == -EINVAL && !nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) if (rc == -EINVAL && !nr_executed && !ata_port_is_frozen(ap))
return 0; return 0;
/* fail and let EH retry once more for unknown IO errors */ /* fail and let EH retry once more for unknown IO errors */
@ -1007,7 +1007,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
/* We can safely continue if no _GTF command has been executed /* We can safely continue if no _GTF command has been executed
* and port is not frozen. * and port is not frozen.
*/ */
if (!nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) if (!nr_executed && !ata_port_is_frozen(ap))
return 0; return 0;
return rc; return rc;

View file

@ -1489,7 +1489,7 @@ static unsigned ata_exec_internal_sg(struct ata_device *dev,
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
/* no internal command while frozen */ /* no internal command while frozen */
if (ap->pflags & ATA_PFLAG_FROZEN) { if (ata_port_is_frozen(ap)) {
spin_unlock_irqrestore(ap->lock, flags); spin_unlock_irqrestore(ap->lock, flags);
return AC_ERR_SYSTEM; return AC_ERR_SYSTEM;
} }
@ -4721,7 +4721,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
return; return;
} }
WARN_ON_ONCE(ap->pflags & ATA_PFLAG_FROZEN); WARN_ON_ONCE(ata_port_is_frozen(ap));
/* read result TF if requested */ /* read result TF if requested */
if (qc->flags & ATA_QCFLAG_RESULT_TF) if (qc->flags & ATA_QCFLAG_RESULT_TF)

View file

@ -1406,7 +1406,7 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc)
struct ata_taskfile tf; struct ata_taskfile tf;
unsigned int err_mask; unsigned int err_mask;
if (qc->ap->pflags & ATA_PFLAG_FROZEN) { if (ata_port_is_frozen(qc->ap)) {
ata_dev_warn(dev, "sense data available but port frozen\n"); ata_dev_warn(dev, "sense data available but port frozen\n");
return; return;
} }
@ -1596,7 +1596,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc)
break; break;
case ATA_DEV_ATAPI: case ATA_DEV_ATAPI:
if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { if (!ata_port_is_frozen(qc->ap)) {
tmp = atapi_eh_request_sense(qc->dev, tmp = atapi_eh_request_sense(qc->dev,
qc->scsicmd->sense_buffer, qc->scsicmd->sense_buffer,
qc->result_tf.error >> 4); qc->result_tf.error >> 4);
@ -2003,7 +2003,7 @@ static void ata_eh_link_autopsy(struct ata_link *link)
ehc->i.flags |= ATA_EHI_QUIET; ehc->i.flags |= ATA_EHI_QUIET;
/* enforce default EH actions */ /* enforce default EH actions */
if (ap->pflags & ATA_PFLAG_FROZEN || if (ata_port_is_frozen(ap) ||
all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT)) all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT))
ehc->i.action |= ATA_EH_RESET; ehc->i.action |= ATA_EH_RESET;
else if (((eflags & ATA_EFLAG_IS_IO) && all_err_mask) || else if (((eflags & ATA_EFLAG_IS_IO) && all_err_mask) ||
@ -2246,7 +2246,7 @@ static void ata_eh_link_report(struct ata_link *link)
return; return;
frozen = ""; frozen = "";
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
frozen = " frozen"; frozen = " frozen";
if (ap->eh_tries < ATA_EH_MAX_TRIES) if (ap->eh_tries < ATA_EH_MAX_TRIES)
@ -2567,8 +2567,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
if (reset && !(ehc->i.action & ATA_EH_RESET)) { if (reset && !(ehc->i.action & ATA_EH_RESET)) {
ata_for_each_dev(dev, link, ALL) ata_for_each_dev(dev, link, ALL)
classes[dev->devno] = ATA_DEV_NONE; classes[dev->devno] = ATA_DEV_NONE;
if ((ap->pflags & ATA_PFLAG_FROZEN) && if (ata_port_is_frozen(ap) && ata_is_host_link(link))
ata_is_host_link(link))
ata_eh_thaw_port(ap); ata_eh_thaw_port(ap);
rc = 0; rc = 0;
goto out; goto out;
@ -2726,7 +2725,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
ap->pflags &= ~ATA_PFLAG_EH_PENDING; ap->pflags &= ~ATA_PFLAG_EH_PENDING;
spin_unlock_irqrestore(link->ap->lock, flags); spin_unlock_irqrestore(link->ap->lock, flags);
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
ata_eh_thaw_port(ap); ata_eh_thaw_port(ap);
/* /*
@ -3233,7 +3232,7 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev)
if (err_mask & AC_ERR_DEV) { if (err_mask & AC_ERR_DEV) {
qc->err_mask |= AC_ERR_DEV; qc->err_mask |= AC_ERR_DEV;
qc->result_tf = tf; qc->result_tf = tf;
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
rc = 0; rc = 0;
} }
} }
@ -3410,7 +3409,7 @@ static int ata_eh_skip_recovery(struct ata_link *link)
return 1; return 1;
/* thaw frozen port and recover failed devices */ /* thaw frozen port and recover failed devices */
if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) if (ata_port_is_frozen(ap) || ata_link_nr_enabled(link))
return 0; return 0;
/* reset at least once if reset is requested */ /* reset at least once if reset is requested */
@ -3765,7 +3764,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
if (dev) if (dev)
ata_eh_handle_dev_fail(dev, rc); ata_eh_handle_dev_fail(dev, rc);
if (ap->pflags & ATA_PFLAG_FROZEN) { if (ata_port_is_frozen(ap)) {
/* PMP reset requires working host port. /* PMP reset requires working host port.
* Can't retry if it's frozen. * Can't retry if it's frozen.
*/ */
@ -3939,7 +3938,7 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
ap->pflags &= ~ATA_PFLAG_PM_PENDING; ap->pflags &= ~ATA_PFLAG_PM_PENDING;
if (rc == 0) if (rc == 0)
ap->pflags |= ATA_PFLAG_SUSPENDED; ap->pflags |= ATA_PFLAG_SUSPENDED;
else if (ap->pflags & ATA_PFLAG_FROZEN) else if (ata_port_is_frozen(ap))
ata_port_schedule_eh(ap); ata_port_schedule_eh(ap);
spin_unlock_irqrestore(ap->lock, flags); spin_unlock_irqrestore(ap->lock, flags);

View file

@ -1420,7 +1420,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
int tag, rc; int tag, rc;
/* if frozen, we can't do much */ /* if frozen, we can't do much */
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
return; return;
/* is it NCQ device error? */ /* is it NCQ device error? */

View file

@ -658,7 +658,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
int tag; int tag;
if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) if (unlikely(ata_port_is_frozen(ap)))
goto fail; goto fail;
if (ap->flags & ATA_FLAG_SAS_HOST) { if (ap->flags & ATA_FLAG_SAS_HOST) {

View file

@ -2185,7 +2185,7 @@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis)
if (!fis) if (!fis)
return; return;
if (ap->pflags & ATA_PFLAG_FROZEN) if (ata_port_is_frozen(ap))
return; return;
if (fis & NV_SWNCQ_IRQ_HOTPLUG) { if (fis & NV_SWNCQ_IRQ_HOTPLUG) {

View file

@ -817,7 +817,7 @@ static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class,
static void pdc_error_handler(struct ata_port *ap) static void pdc_error_handler(struct ata_port *ap)
{ {
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
pdc_reset_port(ap); pdc_reset_port(ap);
ata_sff_error_handler(ap); ata_sff_error_handler(ap);

View file

@ -855,7 +855,7 @@ static int pdc_softreset(struct ata_link *link, unsigned int *class,
static void pdc_error_handler(struct ata_port *ap) static void pdc_error_handler(struct ata_port *ap)
{ {
if (!(ap->pflags & ATA_PFLAG_FROZEN)) if (!ata_port_is_frozen(ap))
pdc_reset_port(ap); pdc_reset_port(ap);
ata_sff_error_handler(ap); ata_sff_error_handler(ap);