Partially workaround ASMedia HBA error recovery.

Taking closer look on my ASM1062 I found that it has bunch of issues around
error recovery: reported wrong CCS, failed commands reported as completed,
READ LOG EXT times out after NCQ error.  This patch workarounds first two
problems, that were making ATAPI devices close to unusable on these HBAs.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2017-01-25 18:16:17 +00:00
parent 1324fa835c
commit 72dc1ba904
3 changed files with 26 additions and 13 deletions

View File

@ -758,7 +758,7 @@ ahci_ch_attach(device_t dev)
/* Construct SIM entry */
ch->sim = cam_sim_alloc(ahciaction, ahcipoll, "ahcich", ch,
device_get_unit(dev), (struct mtx *)&ch->mtx,
min(2, ch->numslots),
(ch->quirks & AHCI_Q_NOCCS) ? 1 : min(2, ch->numslots),
(ch->caps & AHCI_CAP_SNCQ) ? ch->numslots : 0,
devq);
if (ch->sim == NULL) {
@ -1271,8 +1271,19 @@ ahci_ch_intr_main(struct ahci_channel *ch, uint32_t istatus)
/* Process command errors */
if (istatus & (AHCI_P_IX_OF | AHCI_P_IX_IF |
AHCI_P_IX_HBD | AHCI_P_IX_HBF | AHCI_P_IX_TFE)) {
ccs = (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_CCS_MASK)
>> AHCI_P_CMD_CCS_SHIFT;
if (ch->quirks & AHCI_Q_NOCCS) {
/*
* ASMedia chips sometimes report failed commands as
* completed. Count all running commands as failed.
*/
cstatus |= ch->rslots;
/* They also report wrong CCS, so try to guess one. */
ccs = powerof2(cstatus) ? ffs(cstatus) - 1 : -1;
} else {
ccs = (ATA_INL(ch->r_mem, AHCI_P_CMD) &
AHCI_P_CMD_CCS_MASK) >> AHCI_P_CMD_CCS_SHIFT;
}
//device_printf(dev, "%s ERROR is %08x cs %08x ss %08x rs %08x tfd %02x serr %08x fbs %08x ccs %d\n",
// __func__, istatus, cstatus, sstatus, ch->rslots, ATA_INL(ch->r_mem, AHCI_P_TFD),
// serr, ATA_INL(ch->r_mem, AHCI_P_FBS), ccs);

View File

@ -599,6 +599,7 @@ enum ahci_err_type {
#define AHCI_Q_RESTORE_CAP 0x00080000
#define AHCI_Q_NOMSIX 0x00100000
#define AHCI_Q_MRVL_SR_DEL 0x00200000
#define AHCI_Q_NOCCS 0x00400000
#define AHCI_Q_BIT_STRING \
"\020" \
@ -623,7 +624,8 @@ enum ahci_err_type {
"\023FORCE_PI" \
"\024RESTORE_CAP" \
"\025NOMSIX" \
"\026MRVL_SR_DEL"
"\026MRVL_SR_DEL" \
"\027NOCCS"
int ahci_attach(device_t dev);
int ahci_detach(device_t dev);

View File

@ -73,15 +73,15 @@ static const struct {
{0x78021022, 0x00, "AMD Hudson-2", 0},
{0x78031022, 0x00, "AMD Hudson-2", 0},
{0x78041022, 0x00, "AMD Hudson-2", 0},
{0x06011b21, 0x00, "ASMedia ASM1060", 0},
{0x06021b21, 0x00, "ASMedia ASM1060", 0},
{0x06111b21, 0x00, "ASMedia ASM1061", 0},
{0x06121b21, 0x00, "ASMedia ASM1062", 0},
{0x06201b21, 0x00, "ASMedia ASM106x", 0},
{0x06211b21, 0x00, "ASMedia ASM106x", 0},
{0x06221b21, 0x00, "ASMedia ASM106x", 0},
{0x06241b21, 0x00, "ASMedia ASM106x", 0},
{0x06251b21, 0x00, "ASMedia ASM106x", 0},
{0x06011b21, 0x00, "ASMedia ASM1060", AHCI_Q_NOCCS},
{0x06021b21, 0x00, "ASMedia ASM1060", AHCI_Q_NOCCS},
{0x06111b21, 0x00, "ASMedia ASM1061", AHCI_Q_NOCCS},
{0x06121b21, 0x00, "ASMedia ASM1062", AHCI_Q_NOCCS},
{0x06201b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS},
{0x06211b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS},
{0x06221b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS},
{0x06241b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS},
{0x06251b21, 0x00, "ASMedia ASM106x", AHCI_Q_NOCCS},
{0x26528086, 0x00, "Intel ICH6", AHCI_Q_NOFORCE},
{0x26538086, 0x00, "Intel ICH6M", AHCI_Q_NOFORCE},
{0x26818086, 0x00, "Intel ESB2", 0},