/** * sata_pmp_scr_read - read PSCR * @link: ATA link to read PSCR for * @reg: PSCR to read * @r_val: resulting value * * Read PSCR @reg into @r_val for @link, to be called from * ata_scr_read(). * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, -errno on failure.
*/ int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *r_val)
{ unsignedint err_mask;
/** * sata_pmp_scr_write - write PSCR * @link: ATA link to write PSCR for * @reg: PSCR to write * @val: value to be written * * Write @val to PSCR @reg for @link, to be called from * ata_scr_write() and ata_scr_write_flush(). * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, -errno on failure.
*/ int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val)
{ unsignedint err_mask;
/** * sata_pmp_set_lpm - configure LPM for a PMP link * @link: PMP link to configure LPM for * @policy: target LPM policy * @hints: LPM hints * * Configure LPM for @link. This function will contain any PMP * specific workarounds if necessary. * * LOCKING: * EH context. * * RETURNS: * 0 on success, -errno on failure.
*/ int sata_pmp_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, unsigned hints)
{ return sata_link_scr_lpm(link, policy, true);
}
/** * sata_pmp_read_gscr - read GSCR block of SATA PMP * @dev: PMP device * @gscr: buffer to read GSCR block into * * Read selected PMP GSCRs from the PMP at @dev. This will serve * as configuration and identification info for the PMP. * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, -errno on failure.
*/ staticint sata_pmp_read_gscr(struct ata_device *dev, u32 *gscr)
{ staticconstint gscr_to_read[] = { 0, 1, 2, 32, 33, 64, 96 }; int i;
for (i = 0; i < ARRAY_SIZE(gscr_to_read); i++) { int reg = gscr_to_read[i]; unsignedint err_mask;
/* monitor SERR_PHYRDY_CHG on fan-out ports */
err_mask = sata_pmp_write(dev->link, SATA_PMP_GSCR_ERROR_EN,
SERR_PHYRDY_CHG); if (err_mask) {
rc = -EIO;
reason = "failed to write GSCR_ERROR_EN"; goto fail;
}
/* Disable sending Early R_OK. * With "cached read" HDD testing and multiple ports busy on a SATA * host controller, 3x26 PMP will very rarely drop a deferred * R_OK that was intended for the host. Symptom will be all * 5 drives under test will timeout, get reset, and recover.
*/ if (vendor == 0x1095 && (devid == 0x3726 || devid == 0x3826)) {
u32 reg;
if (!(dev->flags & ATA_DFLAG_AN))
ata_dev_info(dev, "Asynchronous notification not supported, " "hotplug won't work on fan-out ports. Use warm-plug instead.\n");
}
return 0;
fail:
ata_dev_err(dev, "failed to configure Port Multiplier (%s, Emask=0x%x)\n",
reason, err_mask); return rc;
}
staticint sata_pmp_init_links (struct ata_port *ap, int nr_ports)
{ struct ata_link *pmp_link = ap->pmp_link; int i, err;
if (!pmp_link) {
pmp_link = kcalloc(SATA_PMP_MAX_PORTS, sizeof(pmp_link[0]),
GFP_NOIO); if (!pmp_link) return -ENOMEM;
for (i = 0; i < SATA_PMP_MAX_PORTS; i++)
ata_link_init(ap, &pmp_link[i], i);
ap->pmp_link = pmp_link;
for (i = 0; i < SATA_PMP_MAX_PORTS; i++) {
err = ata_tlink_add(&pmp_link[i]); if (err) { goto err_tlink;
}
}
}
for (i = 0; i < nr_ports; i++) { struct ata_link *link = &pmp_link[i]; struct ata_eh_context *ehc = &link->eh_context;
/* * Class code report is unreliable and SRST times * out under certain configurations.
*/ if (link->pmp < 5)
link->flags |= ATA_LFLAG_NO_SRST |
ATA_LFLAG_ASSUME_ATA;
/* port 5 is for SEMB device and it doesn't like SRST */ if (link->pmp == 5)
link->flags |= ATA_LFLAG_NO_SRST |
ATA_LFLAG_ASSUME_SEMB;
}
} elseif (vendor == 0x1095 && devid == 0x4723) { /* * sil4723 quirks * * Link reports offline after LPM. Class code report is * unreliable. SIMG PMPs never got SRST reliable and the * config device at port 2 locks up on SRST.
*/
ata_for_each_link(link, ap, EDGE)
link->flags |= ATA_LFLAG_NO_LPM |
ATA_LFLAG_NO_SRST |
ATA_LFLAG_ASSUME_ATA;
} elseif (vendor == 0x1095 && devid == 0x4726) { /* sil4726 quirks */
ata_for_each_link(link, ap, EDGE) { /* link reports offline after LPM */
link->flags |= ATA_LFLAG_NO_LPM;
/* Class code report is unreliable and SRST * times out under certain configurations. * Config device can be at port 0 or 5 and * locks up on SRST.
*/ if (link->pmp <= 5)
link->flags |= ATA_LFLAG_NO_SRST |
ATA_LFLAG_ASSUME_ATA;
/* Port 6 is for SEMB device which doesn't * like SRST either.
*/ if (link->pmp == 6)
link->flags |= ATA_LFLAG_NO_SRST |
ATA_LFLAG_ASSUME_SEMB;
}
} elseif (vendor == 0x1095 && (devid == 0x5723 || devid == 0x5733 ||
devid == 0x5734 || devid == 0x5744)) { /* sil5723/5744 quirks */
/* sil5723/5744 has either two or three downstream * ports depending on operation mode. The last port * is empty if any actual IO device is available or * occupied by a pseudo configuration device * otherwise. Don't try hard to recover it.
*/
ap->pmp_link[ap->nr_pmp_links - 1].flags |= ATA_LFLAG_NO_RETRY;
} elseif (vendor == 0x197b && (devid == 0x2352 || devid == 0x0325)) { /* * 0x2352: found in Thermaltake BlackX Duet, jmicron JMB350? * 0x0325: jmicron JMB394.
*/
ata_for_each_link(link, ap, EDGE) { /* SRST breaks detection and disks get misclassified * LPM disabled to avoid potential problems
*/
link->flags |= ATA_LFLAG_NO_LPM |
ATA_LFLAG_NO_SRST |
ATA_LFLAG_ASSUME_ATA;
}
} elseif (vendor == 0x11ab && devid == 0x4140) { /* Marvell 4140 quirks */
ata_for_each_link(link, ap, EDGE) { /* port 4 is for SEMB device and it doesn't like SRST */ if (link->pmp == 4)
link->flags |= ATA_LFLAG_DISABLED;
}
}
}
/** * sata_pmp_attach - attach a SATA PMP device * @dev: SATA PMP device to attach * * Configure and attach SATA PMP device @dev. This function is * also responsible for allocating and initializing PMP links. * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, -errno on failure.
*/ int sata_pmp_attach(struct ata_device *dev)
{ struct ata_link *link = dev->link; struct ata_port *ap = link->ap; unsignedlong flags; struct ata_link *tlink; int rc;
/* is it hanging off the right place? */ if (!sata_pmp_supported(ap)) {
ata_dev_err(dev, "host does not support Port Multiplier\n"); return -EINVAL;
}
if (!ata_is_host_link(link)) {
ata_dev_err(dev, "Port Multipliers cannot be nested\n"); return -EINVAL;
}
if (dev->devno) {
ata_dev_err(dev, "Port Multiplier must be the first device\n"); return -EINVAL;
}
/** * sata_pmp_revalidate_quick - revalidate SATA PMP quickly * @dev: PMP device to revalidate * * Make sure the attached PMP is accessible. * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, -errno otherwise.
*/ staticint sata_pmp_revalidate_quick(struct ata_device *dev)
{ unsignedint err_mask;
u32 prod_id;
err_mask = sata_pmp_read(dev->link, SATA_PMP_GSCR_PROD_ID, &prod_id); if (err_mask) {
ata_dev_err(dev, "failed to read PMP product ID (Emask=0x%x)\n",
err_mask); return -EIO;
}
if (prod_id != dev->gscr[SATA_PMP_GSCR_PROD_ID]) {
ata_dev_err(dev, "PMP product ID mismatch\n"); /* something weird is going on, request full PMP recovery */ return -EIO;
}
return 0;
}
/** * sata_pmp_eh_recover_pmp - recover PMP * @ap: ATA port PMP is attached to * @reset_ops: The set of reset operations to use * * Recover PMP attached to @ap. Recovery procedure is somewhat * similar to that of ata_eh_recover() except that reset should * always be performed in hard->soft sequence and recovery * failure results in PMP detachment. * * LOCKING: * Kernel thread context (may sleep). * * RETURNS: * 0 on success, -errno on failure.
*/ staticint sata_pmp_eh_recover_pmp(struct ata_port *ap, struct ata_reset_operations *reset_ops)
{ struct ata_link *link = &ap->link; struct ata_eh_context *ehc = &link->eh_context; struct ata_device *dev = link->device; int tries = ATA_EH_PMP_TRIES; int detach = 0, rc = 0; int reval_failed = 0;
if (link_tries[link->pmp] && --link_tries[link->pmp]) return 1;
/* disable this link */ if (!(link->flags & ATA_LFLAG_DISABLED)) {
ata_link_warn(link, "failed to recover link after %d tries, disabling\n",
ATA_EH_PMP_LINK_TRIES);
/* PHY event notification can disturb reset and other recovery * operations. Turn it off.
*/ if (gscr[SATA_PMP_GSCR_FEAT_EN] & SATA_PMP_FEAT_NOTIFY) {
gscr[SATA_PMP_GSCR_FEAT_EN] &= ~SATA_PMP_FEAT_NOTIFY;
err_mask = sata_pmp_write(pmp_link, SATA_PMP_GSCR_FEAT_EN,
gscr[SATA_PMP_GSCR_FEAT_EN]); if (err_mask) {
ata_link_warn(pmp_link, "failed to disable NOTIFY (err_mask=0x%x)\n",
err_mask); goto pmp_fail;
}
}
/* * If LPM is active on any fan-out port, hotplug wouldn't * work. Return w/ PHY event notification disabled.
*/
ata_for_each_link(link, ap, EDGE) if (link->lpm_policy > ATA_LPM_MAX_POWER) return 0;
/* * Connection status might have changed while resetting other * links, enable notification and check SATA_PMP_GSCR_ERROR * before returning.
*/
if (sata_pmp_handle_link_fail(link, link_tries)) {
ata_ehi_hotplugged(&link->eh_context.i);
cnt++;
} else {
ata_link_warn(link, "PHY status changed but maxed out on retries, giving up\n");
ata_link_warn(link, "Manually issue scan to resume this link\n");
}
}
if (cnt) {
ata_port_info(ap, "PMP SError.N set for some ports, repeating recovery\n"); goto retry;
}
/* fall through */
pmp_fail: /* Control always ends up here after detaching PMP. Shut up * and return if we're unloading.
*/ if (ap->pflags & ATA_PFLAG_UNLOADING) return rc;
if (!sata_pmp_attached(ap)) goto retry;
if (--pmp_tries) {
pmp_ehc->i.action |= ATA_EH_RESET; goto retry;
}
ata_port_err(ap, "failed to recover PMP after %d tries, giving up\n",
ATA_EH_PMP_TRIES);
sata_pmp_detach(pmp_dev);
ata_dev_disable(pmp_dev);
return rc;
}
/** * sata_pmp_error_handler - do standard error handling for PMP-enabled host * @ap: host port to handle error for * * Perform standard error handling sequence for PMP-enabled host * @ap. * * LOCKING: * Kernel thread context (may sleep).
*/ void sata_pmp_error_handler(struct ata_port *ap)
{
ata_eh_autopsy(ap);
ata_eh_report(ap);
sata_pmp_eh_recover(ap);
ata_eh_finish(ap);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.