提交 0260731f 编写于 作者: T Tejun Heo 提交者: Jeff Garzik

libata-link: linkify config/EH related functions

Make the following functions deal with ata_link instead of ata_port.

* ata_set_mode()
* ata_eh_autopsy() and related functions
* ata_eh_report() and related functions
* suspend/resume related functions
* ata_eh_recover() and related functions
Signed-off-by: NTejun Heo <htejun@gmail.com>
Signed-off-by: NJeff Garzik <jeff@garzik.org>
上级 cc0680a5
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
/** /**
* generic_set_mode - mode setting * generic_set_mode - mode setting
* @ap: interface to set up * @link: link to set up
* @unused: returned device on error * @unused: returned device on error
* *
* Use a non standard set_mode function. We don't want to be tuned. * Use a non standard set_mode function. We don't want to be tuned.
...@@ -43,8 +43,9 @@ ...@@ -43,8 +43,9 @@
* and respect them. * and respect them.
*/ */
static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) static int generic_set_mode(struct ata_link *link, struct ata_device **unused)
{ {
struct ata_port *ap = link->ap;
int dma_enabled = 0; int dma_enabled = 0;
struct ata_device *dev; struct ata_device *dev;
...@@ -52,7 +53,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) ...@@ -52,7 +53,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)
if (ap->ioaddr.bmdma_addr) if (ap->ioaddr.bmdma_addr)
dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (ata_dev_enabled(dev)) { if (ata_dev_enabled(dev)) {
/* We don't really care */ /* We don't really care */
dev->pio_mode = XFER_PIO_0; dev->pio_mode = XFER_PIO_0;
......
...@@ -2171,7 +2171,7 @@ int ata_bus_probe(struct ata_port *ap) ...@@ -2171,7 +2171,7 @@ int ata_bus_probe(struct ata_port *ap)
} }
/* configure transfer mode */ /* configure transfer mode */
rc = ata_set_mode(ap, &dev); rc = ata_set_mode(&ap->link, &dev);
if (rc) if (rc)
goto fail; goto fail;
...@@ -2782,7 +2782,7 @@ static int ata_dev_set_mode(struct ata_device *dev) ...@@ -2782,7 +2782,7 @@ static int ata_dev_set_mode(struct ata_device *dev)
/** /**
* ata_do_set_mode - Program timings and issue SET FEATURES - XFER * ata_do_set_mode - Program timings and issue SET FEATURES - XFER
* @ap: port on which timings will be programmed * @link: link on which timings will be programmed
* @r_failed_dev: out paramter for failed device * @r_failed_dev: out paramter for failed device
* *
* Standard implementation of the function used to tune and set * Standard implementation of the function used to tune and set
...@@ -2797,9 +2797,9 @@ static int ata_dev_set_mode(struct ata_device *dev) ...@@ -2797,9 +2797,9 @@ static int ata_dev_set_mode(struct ata_device *dev)
* 0 on success, negative errno otherwise * 0 on success, negative errno otherwise
*/ */
int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
{ {
struct ata_link *link = &ap->link; struct ata_port *ap = link->ap;
struct ata_device *dev; struct ata_device *dev;
int rc = 0, used_dma = 0, found = 0; int rc = 0, used_dma = 0, found = 0;
...@@ -2877,7 +2877,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) ...@@ -2877,7 +2877,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
/** /**
* ata_set_mode - Program timings and issue SET FEATURES - XFER * ata_set_mode - Program timings and issue SET FEATURES - XFER
* @ap: port on which timings will be programmed * @link: link on which timings will be programmed
* @r_failed_dev: out paramter for failed device * @r_failed_dev: out paramter for failed device
* *
* Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If
...@@ -2890,12 +2890,14 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) ...@@ -2890,12 +2890,14 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
* RETURNS: * RETURNS:
* 0 on success, negative errno otherwise * 0 on success, negative errno otherwise
*/ */
int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
{ {
struct ata_port *ap = link->ap;
/* has private set_mode? */ /* has private set_mode? */
if (ap->ops->set_mode) if (ap->ops->set_mode)
return ap->ops->set_mode(ap, r_failed_dev); return ap->ops->set_mode(link, r_failed_dev);
return ata_do_set_mode(ap, r_failed_dev); return ata_do_set_mode(link, r_failed_dev);
} }
/** /**
......
...@@ -1201,7 +1201,7 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc) ...@@ -1201,7 +1201,7 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
/** /**
* ata_eh_analyze_serror - analyze SError for a failed port * ata_eh_analyze_serror - analyze SError for a failed port
* @ap: ATA port to analyze SError for * @link: ATA link to analyze SError for
* *
* Analyze SError if available and further determine cause of * Analyze SError if available and further determine cause of
* failure. * failure.
...@@ -1209,9 +1209,9 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc) ...@@ -1209,9 +1209,9 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
* LOCKING: * LOCKING:
* None. * None.
*/ */
static void ata_eh_analyze_serror(struct ata_port *ap) static void ata_eh_analyze_serror(struct ata_link *link)
{ {
struct ata_eh_context *ehc = &ap->link.eh_context; struct ata_eh_context *ehc = &link->eh_context;
u32 serror = ehc->i.serror; u32 serror = ehc->i.serror;
unsigned int err_mask = 0, action = 0; unsigned int err_mask = 0, action = 0;
...@@ -1241,7 +1241,7 @@ static void ata_eh_analyze_serror(struct ata_port *ap) ...@@ -1241,7 +1241,7 @@ static void ata_eh_analyze_serror(struct ata_port *ap)
/** /**
* ata_eh_analyze_ncq_error - analyze NCQ error * ata_eh_analyze_ncq_error - analyze NCQ error
* @ap: ATA port to analyze NCQ error for * @link: ATA link to analyze NCQ error for
* *
* Read log page 10h, determine the offending qc and acquire * Read log page 10h, determine the offending qc and acquire
* error status TF. For NCQ device errors, all LLDDs have to do * error status TF. For NCQ device errors, all LLDDs have to do
...@@ -1251,10 +1251,11 @@ static void ata_eh_analyze_serror(struct ata_port *ap) ...@@ -1251,10 +1251,11 @@ static void ata_eh_analyze_serror(struct ata_port *ap)
* LOCKING: * LOCKING:
* Kernel thread context (may sleep). * Kernel thread context (may sleep).
*/ */
static void ata_eh_analyze_ncq_error(struct ata_port *ap) static void ata_eh_analyze_ncq_error(struct ata_link *link)
{ {
struct ata_eh_context *ehc = &ap->link.eh_context; struct ata_port *ap = link->ap;
struct ata_device *dev = ap->link.device; struct ata_eh_context *ehc = &link->eh_context;
struct ata_device *dev = link->device;
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
struct ata_taskfile tf; struct ata_taskfile tf;
int tag, rc; int tag, rc;
...@@ -1264,7 +1265,7 @@ static void ata_eh_analyze_ncq_error(struct ata_port *ap) ...@@ -1264,7 +1265,7 @@ static void ata_eh_analyze_ncq_error(struct ata_port *ap)
return; return;
/* is it NCQ device error? */ /* is it NCQ device error? */
if (!ap->link.sactive || !(ehc->i.err_mask & AC_ERR_DEV)) if (!link->sactive || !(ehc->i.err_mask & AC_ERR_DEV))
return; return;
/* has LLDD analyzed already? */ /* has LLDD analyzed already? */
...@@ -1281,13 +1282,13 @@ static void ata_eh_analyze_ncq_error(struct ata_port *ap) ...@@ -1281,13 +1282,13 @@ static void ata_eh_analyze_ncq_error(struct ata_port *ap)
/* okay, this error is ours */ /* okay, this error is ours */
rc = ata_eh_read_log_10h(dev, &tag, &tf); rc = ata_eh_read_log_10h(dev, &tag, &tf);
if (rc) { if (rc) {
ata_port_printk(ap, KERN_ERR, "failed to read log page 10h " ata_link_printk(link, KERN_ERR, "failed to read log page 10h "
"(errno=%d)\n", rc); "(errno=%d)\n", rc);
return; return;
} }
if (!(ap->link.sactive & (1 << tag))) { if (!(link->sactive & (1 << tag))) {
ata_port_printk(ap, KERN_ERR, "log page 10h reported " ata_link_printk(link, KERN_ERR, "log page 10h reported "
"inactive tag %d\n", tag); "inactive tag %d\n", tag);
return; return;
} }
...@@ -1551,18 +1552,18 @@ static unsigned int ata_eh_speed_down(struct ata_device *dev, int is_io, ...@@ -1551,18 +1552,18 @@ static unsigned int ata_eh_speed_down(struct ata_device *dev, int is_io,
/** /**
* ata_eh_autopsy - analyze error and determine recovery action * ata_eh_autopsy - analyze error and determine recovery action
* @ap: ATA port to perform autopsy on * @link: ATA link to perform autopsy on
* *
* Analyze why @ap failed and determine which recovery action is * Analyze why @link failed and determine which recovery actions
* needed. This function also sets more detailed AC_ERR_* values * are needed. This function also sets more detailed AC_ERR_*
* and fills sense data for ATAPI CHECK SENSE. * values and fills sense data for ATAPI CHECK SENSE.
* *
* LOCKING: * LOCKING:
* Kernel thread context (may sleep). * Kernel thread context (may sleep).
*/ */
static void ata_eh_autopsy(struct ata_port *ap) static void ata_eh_autopsy(struct ata_link *link)
{ {
struct ata_link *link = &ap->link; struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context; struct ata_eh_context *ehc = &link->eh_context;
unsigned int all_err_mask = 0; unsigned int all_err_mask = 0;
int tag, is_io = 0; int tag, is_io = 0;
...@@ -1578,7 +1579,7 @@ static void ata_eh_autopsy(struct ata_port *ap) ...@@ -1578,7 +1579,7 @@ static void ata_eh_autopsy(struct ata_port *ap)
rc = sata_scr_read(link, SCR_ERROR, &serror); rc = sata_scr_read(link, SCR_ERROR, &serror);
if (rc == 0) { if (rc == 0) {
ehc->i.serror |= serror; ehc->i.serror |= serror;
ata_eh_analyze_serror(ap); ata_eh_analyze_serror(link);
} else if (rc != -EOPNOTSUPP) { } else if (rc != -EOPNOTSUPP) {
/* SError read failed, force hardreset and probing */ /* SError read failed, force hardreset and probing */
ata_ehi_schedule_probe(&ehc->i); ata_ehi_schedule_probe(&ehc->i);
...@@ -1587,7 +1588,7 @@ static void ata_eh_autopsy(struct ata_port *ap) ...@@ -1587,7 +1588,7 @@ static void ata_eh_autopsy(struct ata_port *ap)
} }
/* analyze NCQ failure */ /* analyze NCQ failure */
ata_eh_analyze_ncq_error(ap); ata_eh_analyze_ncq_error(link);
/* any real error trumps AC_ERR_OTHER */ /* any real error trumps AC_ERR_OTHER */
if (ehc->i.err_mask & ~AC_ERR_OTHER) if (ehc->i.err_mask & ~AC_ERR_OTHER)
...@@ -1598,7 +1599,7 @@ static void ata_eh_autopsy(struct ata_port *ap) ...@@ -1598,7 +1599,7 @@ static void ata_eh_autopsy(struct ata_port *ap)
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
if (!(qc->flags & ATA_QCFLAG_FAILED)) if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link)
continue; continue;
/* inherit upper level err_mask */ /* inherit upper level err_mask */
...@@ -1653,16 +1654,17 @@ static void ata_eh_autopsy(struct ata_port *ap) ...@@ -1653,16 +1654,17 @@ static void ata_eh_autopsy(struct ata_port *ap)
/** /**
* ata_eh_report - report error handling to user * ata_eh_report - report error handling to user
* @ap: ATA port EH is going on * @link: ATA link EH is going on
* *
* Report EH to user. * Report EH to user.
* *
* LOCKING: * LOCKING:
* None. * None.
*/ */
static void ata_eh_report(struct ata_port *ap) static void ata_eh_report(struct ata_link *link)
{ {
struct ata_eh_context *ehc = &ap->link.eh_context; struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context;
const char *frozen, *desc; const char *frozen, *desc;
int tag, nr_failed = 0; int tag, nr_failed = 0;
...@@ -1673,7 +1675,7 @@ static void ata_eh_report(struct ata_port *ap) ...@@ -1673,7 +1675,7 @@ static void ata_eh_report(struct ata_port *ap)
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
if (!(qc->flags & ATA_QCFLAG_FAILED)) if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link)
continue; continue;
if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask) if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask)
continue; continue;
...@@ -1691,17 +1693,17 @@ static void ata_eh_report(struct ata_port *ap) ...@@ -1691,17 +1693,17 @@ static void ata_eh_report(struct ata_port *ap)
if (ehc->i.dev) { if (ehc->i.dev) {
ata_dev_printk(ehc->i.dev, KERN_ERR, "exception Emask 0x%x " ata_dev_printk(ehc->i.dev, KERN_ERR, "exception Emask 0x%x "
"SAct 0x%x SErr 0x%x action 0x%x%s\n", "SAct 0x%x SErr 0x%x action 0x%x%s\n",
ehc->i.err_mask, ap->link.sactive, ehc->i.err_mask, link->sactive,
ehc->i.serror, ehc->i.action, frozen); ehc->i.serror, ehc->i.action, frozen);
if (desc) if (desc)
ata_dev_printk(ehc->i.dev, KERN_ERR, "%s\n", desc); ata_dev_printk(ehc->i.dev, KERN_ERR, "%s\n", desc);
} else { } else {
ata_port_printk(ap, KERN_ERR, "exception Emask 0x%x " ata_link_printk(link, KERN_ERR, "exception Emask 0x%x "
"SAct 0x%x SErr 0x%x action 0x%x%s\n", "SAct 0x%x SErr 0x%x action 0x%x%s\n",
ehc->i.err_mask, ap->link.sactive, ehc->i.err_mask, link->sactive,
ehc->i.serror, ehc->i.action, frozen); ehc->i.serror, ehc->i.action, frozen);
if (desc) if (desc)
ata_port_printk(ap, KERN_ERR, "%s\n", desc); ata_link_printk(link, KERN_ERR, "%s\n", desc);
} }
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
...@@ -1714,7 +1716,8 @@ static void ata_eh_report(struct ata_port *ap) ...@@ -1714,7 +1716,8 @@ static void ata_eh_report(struct ata_port *ap)
struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf;
if (!(qc->flags & ATA_QCFLAG_FAILED) || !qc->err_mask) if (!(qc->flags & ATA_QCFLAG_FAILED) ||
qc->dev->link != link || !qc->err_mask)
continue; continue;
ata_dev_printk(qc->dev, KERN_ERR, ata_dev_printk(qc->dev, KERN_ERR,
...@@ -1936,10 +1939,11 @@ static int ata_eh_reset(struct ata_link *link, int classify, ...@@ -1936,10 +1939,11 @@ static int ata_eh_reset(struct ata_link *link, int classify,
return rc; return rc;
} }
static int ata_eh_revalidate_and_attach(struct ata_port *ap, static int ata_eh_revalidate_and_attach(struct ata_link *link,
struct ata_device **r_failed_dev) struct ata_device **r_failed_dev)
{ {
struct ata_eh_context *ehc = &ap->link.eh_context; struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context;
struct ata_device *dev; struct ata_device *dev;
unsigned int new_mask = 0; unsigned int new_mask = 0;
unsigned long flags; unsigned long flags;
...@@ -1951,7 +1955,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -1951,7 +1955,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
* be done backwards such that PDIAG- is released by the slave * be done backwards such that PDIAG- is released by the slave
* device before the master device is identified. * device before the master device is identified.
*/ */
ata_link_for_each_dev_reverse(dev, &ap->link) { ata_link_for_each_dev_reverse(dev, link) {
unsigned int action = ata_eh_dev_action(dev); unsigned int action = ata_eh_dev_action(dev);
unsigned int readid_flags = 0; unsigned int readid_flags = 0;
...@@ -1959,17 +1963,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -1959,17 +1963,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
readid_flags |= ATA_READID_POSTRESET; readid_flags |= ATA_READID_POSTRESET;
if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
if (ata_link_offline(&ap->link)) { if (ata_link_offline(link)) {
rc = -EIO; rc = -EIO;
goto err; goto err;
} }
ata_eh_about_to_do(&ap->link, dev, ATA_EH_REVALIDATE); ata_eh_about_to_do(link, dev, ATA_EH_REVALIDATE);
rc = ata_dev_revalidate(dev, readid_flags); rc = ata_dev_revalidate(dev, readid_flags);
if (rc) if (rc)
goto err; goto err;
ata_eh_done(&ap->link, dev, ATA_EH_REVALIDATE); ata_eh_done(link, dev, ATA_EH_REVALIDATE);
/* Configuration may have changed, reconfigure /* Configuration may have changed, reconfigure
* transfer mode. * transfer mode.
...@@ -2011,7 +2015,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -2011,7 +2015,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
/* Configure new devices forward such that user doesn't see /* Configure new devices forward such that user doesn't see
* device detection messages backwards. * device detection messages backwards.
*/ */
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (!(new_mask & (1 << dev->devno))) if (!(new_mask & (1 << dev->devno)))
continue; continue;
...@@ -2037,40 +2041,40 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -2037,40 +2041,40 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
return rc; return rc;
} }
static int ata_port_nr_enabled(struct ata_port *ap) static int ata_link_nr_enabled(struct ata_link *link)
{ {
struct ata_device *dev; struct ata_device *dev;
int cnt = 0; int cnt = 0;
ata_link_for_each_dev(dev, &ap->link) ata_link_for_each_dev(dev, link)
if (ata_dev_enabled(dev)) if (ata_dev_enabled(dev))
cnt++; cnt++;
return cnt; return cnt;
} }
static int ata_port_nr_vacant(struct ata_port *ap) static int ata_link_nr_vacant(struct ata_link *link)
{ {
struct ata_device *dev; struct ata_device *dev;
int cnt = 0; int cnt = 0;
ata_link_for_each_dev(dev, &ap->link) ata_link_for_each_dev(dev, link)
if (dev->class == ATA_DEV_UNKNOWN) if (dev->class == ATA_DEV_UNKNOWN)
cnt++; cnt++;
return cnt; return cnt;
} }
static int ata_eh_skip_recovery(struct ata_port *ap) static int ata_eh_skip_recovery(struct ata_link *link)
{ {
struct ata_eh_context *ehc = &ap->link.eh_context; struct ata_eh_context *ehc = &link->eh_context;
struct ata_device *dev; struct ata_device *dev;
/* thaw frozen port, resume link and recover failed devices */ /* thaw frozen port, resume link and recover failed devices */
if ((ap->pflags & ATA_PFLAG_FROZEN) || if ((link->ap->pflags & ATA_PFLAG_FROZEN) ||
(ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_link_nr_enabled(link))
return 0; return 0;
/* skip if class codes for all vacant slots are ATA_DEV_NONE */ /* skip if class codes for all vacant slots are ATA_DEV_NONE */
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (dev->class == ATA_DEV_UNKNOWN && if (dev->class == ATA_DEV_UNKNOWN &&
ehc->classes[dev->devno] != ATA_DEV_NONE) ehc->classes[dev->devno] != ATA_DEV_NONE)
return 0; return 0;
...@@ -2154,14 +2158,15 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -2154,14 +2158,15 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
ata_reset_fn_t softreset, ata_reset_fn_t hardreset, ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
ata_postreset_fn_t postreset) ata_postreset_fn_t postreset)
{ {
struct ata_eh_context *ehc = &ap->link.eh_context; struct ata_link *link = &ap->link;
struct ata_eh_context *ehc = &link->eh_context;
struct ata_device *dev; struct ata_device *dev;
int rc; int rc;
DPRINTK("ENTER\n"); DPRINTK("ENTER\n");
/* prep for recovery */ /* prep for recovery */
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; ehc->tries[dev->devno] = ATA_EH_DEV_TRIES;
/* collect port action mask recorded in dev actions */ /* collect port action mask recorded in dev actions */
...@@ -2191,20 +2196,20 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -2191,20 +2196,20 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
goto out; goto out;
/* skip EH if possible. */ /* skip EH if possible. */
if (ata_eh_skip_recovery(ap)) if (ata_eh_skip_recovery(link))
ehc->i.action = 0; ehc->i.action = 0;
ata_link_for_each_dev(dev, &ap->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 (ehc->i.action & ATA_EH_RESET_MASK) { if (ehc->i.action & ATA_EH_RESET_MASK) {
ata_eh_freeze_port(ap); ata_eh_freeze_port(ap);
rc = ata_eh_reset(&ap->link, ata_port_nr_vacant(ap), prereset, rc = ata_eh_reset(link, ata_link_nr_vacant(link), prereset,
softreset, hardreset, postreset); softreset, hardreset, postreset);
if (rc) { if (rc) {
ata_port_printk(ap, KERN_ERR, ata_link_printk(link, KERN_ERR,
"reset failed, giving up\n"); "reset failed, giving up\n");
goto out; goto out;
} }
...@@ -2213,13 +2218,13 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -2213,13 +2218,13 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
} }
/* revalidate existing devices and attach new ones */ /* revalidate existing devices and attach new ones */
rc = ata_eh_revalidate_and_attach(ap, &dev); rc = ata_eh_revalidate_and_attach(link, &dev);
if (rc) if (rc)
goto dev_fail; goto dev_fail;
/* configure transfer mode if necessary */ /* configure transfer mode if necessary */
if (ehc->i.flags & ATA_EHI_SETMODE) { if (ehc->i.flags & ATA_EHI_SETMODE) {
rc = ata_set_mode(ap, &dev); rc = ata_set_mode(link, &dev);
if (rc) if (rc)
goto dev_fail; goto dev_fail;
ehc->i.flags &= ~ATA_EHI_SETMODE; ehc->i.flags &= ~ATA_EHI_SETMODE;
...@@ -2230,8 +2235,8 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -2230,8 +2235,8 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
dev_fail: dev_fail:
ata_eh_handle_dev_fail(dev, rc); ata_eh_handle_dev_fail(dev, rc);
if (ata_port_nr_enabled(ap)) { if (ata_link_nr_enabled(link)) {
ata_port_printk(ap, KERN_WARNING, "failed to recover some " ata_link_printk(link, KERN_WARNING, "failed to recover some "
"devices, retrying in 5 secs\n"); "devices, retrying in 5 secs\n");
ssleep(5); ssleep(5);
} else { } else {
...@@ -2243,7 +2248,7 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -2243,7 +2248,7 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
out: out:
if (rc) { if (rc) {
ata_link_for_each_dev(dev, &ap->link); ata_link_for_each_dev(dev, link);
ata_dev_disable(dev); ata_dev_disable(dev);
} }
...@@ -2310,8 +2315,8 @@ void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -2310,8 +2315,8 @@ void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
ata_reset_fn_t softreset, ata_reset_fn_t hardreset, ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
ata_postreset_fn_t postreset) ata_postreset_fn_t postreset)
{ {
ata_eh_autopsy(ap); ata_eh_autopsy(&ap->link);
ata_eh_report(ap); ata_eh_report(&ap->link);
ata_eh_recover(ap, prereset, softreset, hardreset, postreset); ata_eh_recover(ap, prereset, softreset, hardreset, postreset);
ata_eh_finish(ap); ata_eh_finish(ap);
} }
......
...@@ -81,7 +81,7 @@ extern int ata_dev_configure(struct ata_device *dev); ...@@ -81,7 +81,7 @@ extern int ata_dev_configure(struct ata_device *dev);
extern int sata_down_spd_limit(struct ata_link *link); extern int sata_down_spd_limit(struct ata_link *link);
extern int sata_set_spd_needed(struct ata_link *link); extern int sata_set_spd_needed(struct ata_link *link);
extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); extern int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
extern void ata_sg_clean(struct ata_queued_cmd *qc); extern void ata_sg_clean(struct ata_queued_cmd *qc);
extern void ata_qc_free(struct ata_queued_cmd *qc); extern void ata_qc_free(struct ata_queued_cmd *qc);
extern void ata_qc_issue(struct ata_queued_cmd *qc); extern void ata_qc_issue(struct ata_queued_cmd *qc);
......
...@@ -450,7 +450,7 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc) ...@@ -450,7 +450,7 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc)
/** /**
* it821x_smart_set_mode - mode setting * it821x_smart_set_mode - mode setting
* @ap: interface to set up * @link: interface to set up
* @unused: device that failed (error only) * @unused: device that failed (error only)
* *
* Use a non standard set_mode function. We don't want to be tuned. * Use a non standard set_mode function. We don't want to be tuned.
...@@ -459,11 +459,11 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc) ...@@ -459,11 +459,11 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc)
* and respect them. * and respect them.
*/ */
static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused) static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unused)
{ {
struct ata_device *dev; struct ata_device *dev;
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (ata_dev_enabled(dev)) { if (ata_dev_enabled(dev)) {
/* We don't really care */ /* We don't really care */
dev->pio_mode = XFER_PIO_0; dev->pio_mode = XFER_PIO_0;
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#define DRV_NAME "pata_ixp4xx_cf" #define DRV_NAME "pata_ixp4xx_cf"
#define DRV_VERSION "0.2" #define DRV_VERSION "0.2"
static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) static int ixp4xx_set_mode(struct ata_link *link, struct ata_device **error)
{ {
struct ata_device *dev; struct ata_device *dev;
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (ata_dev_enabled(dev)) { if (ata_dev_enabled(dev)) {
ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
dev->pio_mode = XFER_PIO_0; dev->pio_mode = XFER_PIO_0;
......
...@@ -96,7 +96,7 @@ static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */ ...@@ -96,7 +96,7 @@ static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */
/** /**
* legacy_set_mode - mode setting * legacy_set_mode - mode setting
* @ap: IDE interface * @link: IDE link
* @unused: Device that failed when error is returned * @unused: Device that failed when error is returned
* *
* Use a non standard set_mode function. We don't want to be tuned. * Use a non standard set_mode function. We don't want to be tuned.
...@@ -107,11 +107,11 @@ static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */ ...@@ -107,11 +107,11 @@ static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */
* expand on this as per hdparm in the base kernel. * expand on this as per hdparm in the base kernel.
*/ */
static int legacy_set_mode(struct ata_port *ap, struct ata_device **unused) static int legacy_set_mode(struct ata_link *link, struct ata_device **unused)
{ {
struct ata_device *dev; struct ata_device *dev;
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (ata_dev_enabled(dev)) { if (ata_dev_enabled(dev)) {
ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
dev->pio_mode = XFER_PIO_0; dev->pio_mode = XFER_PIO_0;
......
...@@ -324,25 +324,26 @@ static u8 optidma_make_bits43(struct ata_device *adev) ...@@ -324,25 +324,26 @@ static u8 optidma_make_bits43(struct ata_device *adev)
/** /**
* optidma_set_mode - mode setup * optidma_set_mode - mode setup
* @ap: port to set up * @link: link to set up
* *
* Use the standard setup to tune the chipset and then finalise the * Use the standard setup to tune the chipset and then finalise the
* configuration by writing the nibble of extra bits of data into * configuration by writing the nibble of extra bits of data into
* the chip. * the chip.
*/ */
static int optidma_set_mode(struct ata_port *ap, struct ata_device **r_failed) static int optidma_set_mode(struct ata_link *link, struct ata_device **r_failed)
{ {
struct ata_port *ap = link->ap;
u8 r; u8 r;
int nybble = 4 * ap->port_no; int nybble = 4 * ap->port_no;
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
int rc = ata_do_set_mode(ap, r_failed); int rc = ata_do_set_mode(link, r_failed);
if (rc == 0) { if (rc == 0) {
pci_read_config_byte(pdev, 0x43, &r); pci_read_config_byte(pdev, 0x43, &r);
r &= (0x0F << nybble); r &= (0x0F << nybble);
r |= (optidma_make_bits43(&ap->link.device[0]) + r |= (optidma_make_bits43(&link->device[0]) +
(optidma_make_bits43(&ap->link.device[0]) << 2)) << nybble; (optidma_make_bits43(&link->device[0]) << 2)) << nybble;
pci_write_config_byte(pdev, 0x43, r); pci_write_config_byte(pdev, 0x43, r);
} }
return rc; return rc;
......
...@@ -56,7 +56,7 @@ struct ata_pcmcia_info { ...@@ -56,7 +56,7 @@ struct ata_pcmcia_info {
/** /**
* pcmcia_set_mode - PCMCIA specific mode setup * pcmcia_set_mode - PCMCIA specific mode setup
* @ap: Port * @link: link
* @r_failed_dev: Return pointer for failed device * @r_failed_dev: Return pointer for failed device
* *
* Perform the tuning and setup of the devices and timings, which * Perform the tuning and setup of the devices and timings, which
...@@ -65,13 +65,13 @@ struct ata_pcmcia_info { ...@@ -65,13 +65,13 @@ struct ata_pcmcia_info {
* decode, which alas is embarrassingly common in the PC world * decode, which alas is embarrassingly common in the PC world
*/ */
static int pcmcia_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) static int pcmcia_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
{ {
struct ata_device *master = &ap->link.device[0]; struct ata_device *master = &link->device[0];
struct ata_device *slave = &ap->link.device[1]; struct ata_device *slave = &link->device[1];
if (!ata_dev_enabled(master) || !ata_dev_enabled(slave)) if (!ata_dev_enabled(master) || !ata_dev_enabled(slave))
return ata_do_set_mode(ap, r_failed_dev); return ata_do_set_mode(link, r_failed_dev);
if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV, if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV,
ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0) ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0)
...@@ -84,7 +84,7 @@ static int pcmcia_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev ...@@ -84,7 +84,7 @@ static int pcmcia_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev
ata_dev_disable(slave); ata_dev_disable(slave);
} }
} }
return ata_do_set_mode(ap, r_failed_dev); return ata_do_set_mode(link, r_failed_dev);
} }
static struct scsi_host_template pcmcia_sht = { static struct scsi_host_template pcmcia_sht = {
......
...@@ -69,7 +69,7 @@ static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev); ...@@ -69,7 +69,7 @@ static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev);
static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc); static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc);
static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long mask); static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long mask);
static int pdc2027x_cable_detect(struct ata_port *ap); static int pdc2027x_cable_detect(struct ata_port *ap);
static int pdc2027x_set_mode(struct ata_port *ap, struct ata_device **r_failed); static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed);
/* /*
* ATA Timing Tables based on 133MHz controller clock. * ATA Timing Tables based on 133MHz controller clock.
...@@ -470,23 +470,24 @@ static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev) ...@@ -470,23 +470,24 @@ static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev)
/** /**
* pdc2027x_set_mode - Set the timing registers back to correct values. * pdc2027x_set_mode - Set the timing registers back to correct values.
* @ap: Port to configure * @link: link to configure
* @r_failed: Returned device for failure * @r_failed: Returned device for failure
* *
* The pdc2027x hardware will look at "SET FEATURES" and change the timing registers * The pdc2027x hardware will look at "SET FEATURES" and change the timing registers
* automatically. The values set by the hardware might be incorrect, under 133Mhz PLL. * automatically. The values set by the hardware might be incorrect, under 133Mhz PLL.
* This function overwrites the possibly incorrect values set by the hardware to be correct. * This function overwrites the possibly incorrect values set by the hardware to be correct.
*/ */
static int pdc2027x_set_mode(struct ata_port *ap, struct ata_device **r_failed) static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed)
{ {
struct ata_port *ap = link->ap;
struct ata_device *dev; struct ata_device *dev;
int rc; int rc;
rc = ata_do_set_mode(ap, r_failed); rc = ata_do_set_mode(link, r_failed);
if (rc < 0) if (rc < 0)
return rc; return rc;
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (ata_dev_enabled(dev)) { if (ata_dev_enabled(dev)) {
pdc2027x_set_piomode(ap, dev); pdc2027x_set_piomode(ap, dev);
......
...@@ -30,11 +30,11 @@ static int pio_mask = 1; ...@@ -30,11 +30,11 @@ static int pio_mask = 1;
* Provide our own set_mode() as we don't want to change anything that has * Provide our own set_mode() as we don't want to change anything that has
* already been configured.. * already been configured..
*/ */
static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unused) static int pata_platform_set_mode(struct ata_link *link, struct ata_device **unused)
{ {
struct ata_device *dev; struct ata_device *dev;
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (ata_dev_enabled(dev)) { if (ata_dev_enabled(dev)) {
/* We don't really care */ /* We don't really care */
dev->pio_mode = dev->xfer_mode = XFER_PIO_0; dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/** /**
* rz1000_set_mode - mode setting function * rz1000_set_mode - mode setting function
* @ap: ATA interface * @link: ATA link
* @unused: returned device on set_mode failure * @unused: returned device on set_mode failure
* *
* Use a non standard set_mode function. We don't want to be tuned. We * Use a non standard set_mode function. We don't want to be tuned. We
...@@ -34,11 +34,11 @@ ...@@ -34,11 +34,11 @@
* whacked out. * whacked out.
*/ */
static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused) static int rz1000_set_mode(struct ata_link *link, struct ata_device **unused)
{ {
struct ata_device *dev; struct ata_device *dev;
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (ata_dev_enabled(dev)) { if (ata_dev_enabled(dev)) {
/* We don't really care */ /* We don't really care */
dev->pio_mode = XFER_PIO_0; dev->pio_mode = XFER_PIO_0;
......
...@@ -297,15 +297,16 @@ static void adma_thaw(struct ata_port *ap) ...@@ -297,15 +297,16 @@ static void adma_thaw(struct ata_port *ap)
adma_reinit_engine(ap); adma_reinit_engine(ap);
} }
static int adma_prereset(struct ata_port *ap, unsigned long deadline) static int adma_prereset(struct ata_link *link, unsigned long deadline)
{ {
struct ata_port *ap = link->ap;
struct adma_port_priv *pp = ap->private_data; struct adma_port_priv *pp = ap->private_data;
if (pp->state != adma_state_idle) /* healthy paranoia */ if (pp->state != adma_state_idle) /* healthy paranoia */
pp->state = adma_state_mmio; pp->state = adma_state_mmio;
adma_reinit_engine(ap); adma_reinit_engine(ap);
return ata_std_prereset(ap, deadline); return ata_std_prereset(link, deadline);
} }
static void adma_error_handler(struct ata_port *ap) static void adma_error_handler(struct ata_port *ap)
......
...@@ -117,7 +117,7 @@ static int sil_pci_device_resume(struct pci_dev *pdev); ...@@ -117,7 +117,7 @@ static int sil_pci_device_resume(struct pci_dev *pdev);
static void sil_dev_config(struct ata_device *dev); static void sil_dev_config(struct ata_device *dev);
static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
static int sil_set_mode (struct ata_port *ap, struct ata_device **r_failed); static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed);
static void sil_freeze(struct ata_port *ap); static void sil_freeze(struct ata_port *ap);
static void sil_thaw(struct ata_port *ap); static void sil_thaw(struct ata_port *ap);
...@@ -290,27 +290,27 @@ static unsigned char sil_get_device_cache_line(struct pci_dev *pdev) ...@@ -290,27 +290,27 @@ static unsigned char sil_get_device_cache_line(struct pci_dev *pdev)
/** /**
* sil_set_mode - wrap set_mode functions * sil_set_mode - wrap set_mode functions
* @ap: port to set up * @link: link to set up
* @r_failed: returned device when we fail * @r_failed: returned device when we fail
* *
* Wrap the libata method for device setup as after the setup we need * Wrap the libata method for device setup as after the setup we need
* to inspect the results and do some configuration work * to inspect the results and do some configuration work
*/ */
static int sil_set_mode (struct ata_port *ap, struct ata_device **r_failed) static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed)
{ {
struct ata_host *host = ap->host; struct ata_port *ap = link->ap;
struct ata_device *dev; void __iomem *mmio_base = ap->host->iomap[SIL_MMIO_BAR];
void __iomem *mmio_base = host->iomap[SIL_MMIO_BAR];
void __iomem *addr = mmio_base + sil_port[ap->port_no].xfer_mode; void __iomem *addr = mmio_base + sil_port[ap->port_no].xfer_mode;
struct ata_device *dev;
u32 tmp, dev_mode[2] = { }; u32 tmp, dev_mode[2] = { };
int rc; int rc;
rc = ata_do_set_mode(ap, r_failed); rc = ata_do_set_mode(link, r_failed);
if (rc) if (rc)
return rc; return rc;
ata_link_for_each_dev(dev, &ap->link) { ata_link_for_each_dev(dev, link) {
if (!ata_dev_enabled(dev)) if (!ata_dev_enabled(dev))
dev_mode[dev->devno] = 0; /* PIO0/1/2 */ dev_mode[dev->devno] = 0; /* PIO0/1/2 */
else if (dev->flags & ATA_DFLAG_PIO) else if (dev->flags & ATA_DFLAG_PIO)
......
...@@ -607,7 +607,7 @@ struct ata_port_operations { ...@@ -607,7 +607,7 @@ struct ata_port_operations {
void (*dev_select)(struct ata_port *ap, unsigned int device); void (*dev_select)(struct ata_port *ap, unsigned int device);
void (*phy_reset) (struct ata_port *ap); /* obsolete */ void (*phy_reset) (struct ata_port *ap); /* obsolete */
int (*set_mode) (struct ata_port *ap, struct ata_device **r_failed_dev); int (*set_mode) (struct ata_link *link, struct ata_device **r_failed_dev);
int (*cable_detect) (struct ata_port *ap); int (*cable_detect) (struct ata_port *ap);
...@@ -838,7 +838,7 @@ extern void ata_scsi_slave_destroy(struct scsi_device *sdev); ...@@ -838,7 +838,7 @@ extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
int queue_depth); int queue_depth);
extern struct ata_device *ata_dev_pair(struct ata_device *adev); extern struct ata_device *ata_dev_pair(struct ata_device *adev);
extern int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
extern u8 ata_irq_on(struct ata_port *ap); extern u8 ata_irq_on(struct ata_port *ap);
extern u8 ata_dummy_irq_on(struct ata_port *ap); extern u8 ata_dummy_irq_on(struct ata_port *ap);
extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq); extern u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册