|
Lines 103-108
Link Here
|
| 103 |
#define RECOVERY_REQUEST_SENSE 2 |
103 |
#define RECOVERY_REQUEST_SENSE 2 |
| 104 |
#define recovery_slot spriv_field1 |
104 |
#define recovery_slot spriv_field1 |
| 105 |
|
105 |
|
|
|
106 |
int ahci_verbose = 0; |
| 107 |
SYSCTL_INT(_debug, OID_AUTO, ahci_verbose, CTLFLAG_RW, &ahci_verbose, |
| 108 |
0, "AHCI verbosity"); |
| 109 |
|
| 106 |
static uint32_t |
110 |
static uint32_t |
| 107 |
ahci_ch_detval(struct ahci_channel *ch, uint32_t val) |
111 |
ahci_ch_detval(struct ahci_channel *ch, uint32_t val) |
| 108 |
{ |
112 |
{ |
|
Lines 125-131
Link Here
|
| 125 |
AHCI_CCCC_EN); |
129 |
AHCI_CCCC_EN); |
| 126 |
ctlr->cccv = (ATA_INL(ctlr->r_mem, AHCI_CCCC) & |
130 |
ctlr->cccv = (ATA_INL(ctlr->r_mem, AHCI_CCCC) & |
| 127 |
AHCI_CCCC_INT_MASK) >> AHCI_CCCC_INT_SHIFT; |
131 |
AHCI_CCCC_INT_MASK) >> AHCI_CCCC_INT_SHIFT; |
| 128 |
if (bootverbose) { |
132 |
if (bootverbose || ahci_verbose) { |
| 129 |
device_printf(dev, |
133 |
device_printf(dev, |
| 130 |
"CCC with %dms/4cmd enabled on vector %d\n", |
134 |
"CCC with %dms/4cmd enabled on vector %d\n", |
| 131 |
ctlr->ccc, ctlr->cccv); |
135 |
ctlr->ccc, ctlr->cccv); |
|
Lines 322-328
Link Here
|
| 322 |
device_printf(dev, "quirks=0x%b\n", ctlr->quirks, |
326 |
device_printf(dev, "quirks=0x%b\n", ctlr->quirks, |
| 323 |
AHCI_Q_BIT_STRING); |
327 |
AHCI_Q_BIT_STRING); |
| 324 |
} |
328 |
} |
| 325 |
if (bootverbose) { |
329 |
if (bootverbose || ahci_verbose) { |
| 326 |
device_printf(dev, "Caps:%s%s%s%s%s%s%s%s %sGbps", |
330 |
device_printf(dev, "Caps:%s%s%s%s%s%s%s%s %sGbps", |
| 327 |
(ctlr->caps & AHCI_CAP_64BIT) ? " 64bit":"", |
331 |
(ctlr->caps & AHCI_CAP_64BIT) ? " 64bit":"", |
| 328 |
(ctlr->caps & AHCI_CAP_SNCQ) ? " NCQ":"", |
332 |
(ctlr->caps & AHCI_CAP_SNCQ) ? " NCQ":"", |
|
Lines 347-353
Link Here
|
| 347 |
(ctlr->caps & AHCI_CAP_SXS) ? " eSATA":"", |
351 |
(ctlr->caps & AHCI_CAP_SXS) ? " eSATA":"", |
| 348 |
(ctlr->caps & AHCI_CAP_NPMASK) + 1); |
352 |
(ctlr->caps & AHCI_CAP_NPMASK) + 1); |
| 349 |
} |
353 |
} |
| 350 |
if (bootverbose && version >= 0x00010200) { |
354 |
if ((bootverbose || ahci_verbose) && version >= 0x00010200) { |
| 351 |
device_printf(dev, "Caps2:%s%s%s%s%s%s\n", |
355 |
device_printf(dev, "Caps2:%s%s%s%s%s%s\n", |
| 352 |
(ctlr->caps2 & AHCI_CAP2_DESO) ? " DESO":"", |
356 |
(ctlr->caps2 & AHCI_CAP2_DESO) ? " DESO":"", |
| 353 |
(ctlr->caps2 & AHCI_CAP2_SADM) ? " SADM":"", |
357 |
(ctlr->caps2 & AHCI_CAP2_SADM) ? " SADM":"", |
|
Lines 857-863
Link Here
|
| 857 |
ch->chcaps |= AHCI_P_CMD_FBSCP; |
861 |
ch->chcaps |= AHCI_P_CMD_FBSCP; |
| 858 |
if (ch->caps2 & AHCI_CAP2_SDS) |
862 |
if (ch->caps2 & AHCI_CAP2_SDS) |
| 859 |
ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP); |
863 |
ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP); |
| 860 |
if (bootverbose) { |
864 |
if (bootverbose || ahci_verbose) { |
| 861 |
device_printf(dev, "Caps:%s%s%s%s%s%s\n", |
865 |
device_printf(dev, "Caps:%s%s%s%s%s%s\n", |
| 862 |
(ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"", |
866 |
(ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"", |
| 863 |
(ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"", |
867 |
(ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"", |
|
Lines 1224-1230
Link Here
|
| 1224 |
u_int32_t status = ATA_INL(ch->r_mem, AHCI_P_SSTS); |
1228 |
u_int32_t status = ATA_INL(ch->r_mem, AHCI_P_SSTS); |
| 1225 |
union ccb *ccb; |
1229 |
union ccb *ccb; |
| 1226 |
|
1230 |
|
| 1227 |
if (bootverbose) { |
1231 |
if (bootverbose || ahci_verbose) { |
| 1228 |
if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE) |
1232 |
if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE) |
| 1229 |
device_printf(ch->dev, "CONNECT requested\n"); |
1233 |
device_printf(ch->dev, "CONNECT requested\n"); |
| 1230 |
else |
1234 |
else |
|
Lines 1259-1265
Link Here
|
| 1259 |
if ((status & AHCI_P_CMD_CPD) == 0) |
1263 |
if ((status & AHCI_P_CMD_CPD) == 0) |
| 1260 |
return; |
1264 |
return; |
| 1261 |
|
1265 |
|
| 1262 |
if (bootverbose) { |
1266 |
if (bootverbose || ahci_verbose) { |
| 1263 |
dev = ch->dev; |
1267 |
dev = ch->dev; |
| 1264 |
if (status & AHCI_P_CMD_CPS) { |
1268 |
if (status & AHCI_P_CMD_CPS) { |
| 1265 |
device_printf(dev, "COLD CONNECT requested\n"); |
1269 |
device_printf(dev, "COLD CONNECT requested\n"); |
|
Lines 1285-1291
Link Here
|
| 1285 |
|
1289 |
|
| 1286 |
if (ch->caps & AHCI_CAP_SSNTF) |
1290 |
if (ch->caps & AHCI_CAP_SSNTF) |
| 1287 |
ATA_OUTL(ch->r_mem, AHCI_P_SNTF, status); |
1291 |
ATA_OUTL(ch->r_mem, AHCI_P_SNTF, status); |
| 1288 |
if (bootverbose) |
1292 |
if (bootverbose || ahci_verbose) |
| 1289 |
device_printf(ch->dev, "SNTF 0x%04x\n", status); |
1293 |
device_printf(ch->dev, "SNTF 0x%04x\n", status); |
| 1290 |
for (i = 0; i < 16; i++) { |
1294 |
for (i = 0; i < 16; i++) { |
| 1291 |
if ((status & (1 << i)) == 0) |
1295 |
if ((status & (1 << i)) == 0) |
|
Lines 2422-2428
Link Here
|
| 2422 |
DELAY(1000); |
2426 |
DELAY(1000); |
| 2423 |
timeout++; |
2427 |
timeout++; |
| 2424 |
} |
2428 |
} |
| 2425 |
if (bootverbose) |
2429 |
if (bootverbose || ahci_verbose) |
| 2426 |
device_printf(ch->dev, "AHCI reset: device ready after %dms\n", |
2430 |
device_printf(ch->dev, "AHCI reset: device ready after %dms\n", |
| 2427 |
timeout + t0); |
2431 |
timeout + t0); |
| 2428 |
return (0); |
2432 |
return (0); |
|
Lines 2459-2465
Link Here
|
| 2459 |
int i; |
2463 |
int i; |
| 2460 |
|
2464 |
|
| 2461 |
xpt_freeze_simq(ch->sim, 1); |
2465 |
xpt_freeze_simq(ch->sim, 1); |
| 2462 |
if (bootverbose) |
2466 |
if (bootverbose || ahci_verbose) |
| 2463 |
device_printf(ch->dev, "AHCI reset...\n"); |
2467 |
device_printf(ch->dev, "AHCI reset...\n"); |
| 2464 |
/* Forget about previous reset. */ |
2468 |
/* Forget about previous reset. */ |
| 2465 |
if (ch->resetting) { |
2469 |
if (ch->resetting) { |
|
Lines 2506-2512
Link Here
|
| 2506 |
ATA_OUTL(ch->r_mem, AHCI_P_IE, 0); |
2510 |
ATA_OUTL(ch->r_mem, AHCI_P_IE, 0); |
| 2507 |
/* Reset and reconnect PHY, */ |
2511 |
/* Reset and reconnect PHY, */ |
| 2508 |
if (!ahci_sata_phy_reset(ch)) { |
2512 |
if (!ahci_sata_phy_reset(ch)) { |
| 2509 |
if (bootverbose) |
2513 |
if (bootverbose || ahci_verbose) |
| 2510 |
device_printf(ch->dev, |
2514 |
device_printf(ch->dev, |
| 2511 |
"AHCI reset: device not found\n"); |
2515 |
"AHCI reset: device not found\n"); |
| 2512 |
ch->devices = 0; |
2516 |
ch->devices = 0; |
|
Lines 2517-2523
Link Here
|
| 2517 |
xpt_release_simq(ch->sim, TRUE); |
2521 |
xpt_release_simq(ch->sim, TRUE); |
| 2518 |
return; |
2522 |
return; |
| 2519 |
} |
2523 |
} |
| 2520 |
if (bootverbose) |
2524 |
if (bootverbose || ahci_verbose) |
| 2521 |
device_printf(ch->dev, "AHCI reset: device found\n"); |
2525 |
device_printf(ch->dev, "AHCI reset: device found\n"); |
| 2522 |
/* Wait for clearing busy status. */ |
2526 |
/* Wait for clearing busy status. */ |
| 2523 |
if (ahci_wait_ready(ch, dumping ? 31000 : 0, 0)) { |
2527 |
if (ahci_wait_ready(ch, dumping ? 31000 : 0, 0)) { |
|
Lines 2603-2612
Link Here
|
| 2603 |
{ |
2607 |
{ |
| 2604 |
u_int32_t status; |
2608 |
u_int32_t status; |
| 2605 |
int timeout, found = 0; |
2609 |
int timeout, found = 0; |
|
|
2610 |
int last_status = -1; |
| 2606 |
|
2611 |
|
|
|
2612 |
|
| 2607 |
/* Wait up to 100ms for "connect well" */ |
2613 |
/* Wait up to 100ms for "connect well" */ |
| 2608 |
for (timeout = 0; timeout < 1000 ; timeout++) { |
2614 |
for (timeout = 0; timeout < 10000 ; timeout++) { /* timeout < 1000 - Peter E */ |
| 2609 |
status = ATA_INL(ch->r_mem, AHCI_P_SSTS); |
2615 |
status = ATA_INL(ch->r_mem, AHCI_P_SSTS); |
|
|
2616 |
|
| 2617 |
if (ahci_verbose && status != last_status) { |
| 2618 |
device_printf(ch->dev, "SATA status changed %08x at time=%dus\n", status, timeout * 100); |
| 2619 |
last_status = status; |
| 2620 |
} |
| 2610 |
if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE) |
2621 |
if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE) |
| 2611 |
found = 1; |
2622 |
found = 1; |
| 2612 |
if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && |
2623 |
if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && |
|
Lines 2614-2631
Link Here
|
| 2614 |
((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) |
2625 |
((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) |
| 2615 |
break; |
2626 |
break; |
| 2616 |
if ((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_OFFLINE) { |
2627 |
if ((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_OFFLINE) { |
| 2617 |
if (bootverbose) { |
2628 |
if (bootverbose || ahci_verbose) { |
| 2618 |
device_printf(ch->dev, "SATA offline status=%08x\n", |
2629 |
device_printf(ch->dev, "SATA offline status=%08x\n", |
| 2619 |
status); |
2630 |
status); |
| 2620 |
} |
2631 |
} |
| 2621 |
return (0); |
2632 |
return (0); |
| 2622 |
} |
2633 |
} |
| 2623 |
if (found == 0 && timeout >= 100) |
2634 |
if (found == 0 && timeout >= 5000) /* timeout >= 100 */ |
| 2624 |
break; |
2635 |
break; |
| 2625 |
DELAY(100); |
2636 |
DELAY(100); |
| 2626 |
} |
2637 |
} |
| 2627 |
if (timeout >= 1000 || !found) { |
2638 |
if (timeout >= 5000 || !found) { |
| 2628 |
if (bootverbose) { |
2639 |
if (bootverbose || ahci_verbose) { |
| 2629 |
device_printf(ch->dev, |
2640 |
device_printf(ch->dev, |
| 2630 |
"SATA connect timeout time=%dus status=%08x\n", |
2641 |
"SATA connect timeout time=%dus status=%08x\n", |
| 2631 |
timeout * 100, status); |
2642 |
timeout * 100, status); |
|
Lines 2632-2638
Link Here
|
| 2632 |
} |
2643 |
} |
| 2633 |
return (0); |
2644 |
return (0); |
| 2634 |
} |
2645 |
} |
| 2635 |
if (bootverbose) { |
2646 |
if (bootverbose || ahci_verbose) { |
| 2636 |
device_printf(ch->dev, "SATA connect time=%dus status=%08x\n", |
2647 |
device_printf(ch->dev, "SATA connect time=%dus status=%08x\n", |
| 2637 |
timeout * 100, status); |
2648 |
timeout * 100, status); |
| 2638 |
} |
2649 |
} |