From 8f2cf3fcfbceb4e3f5f66dcb7c2a178c91092529 Mon Sep 17 00:00:00 2001
From: Alexander von Gluck IV <kallisti5@unixzen.com>
Date: Thu, 7 Jul 2016 18:16:14 -0500
Subject: [PATCH] ahci: Disable tracing, make tracing more chatty
* AHCI has been shipping with tracing enabled which
account for most of the chatty messages in #12634
* Instead of covering up a bunch of AHCI trace messages,
lets disable tracing by default and make tracing more
chatty overall.
* Tracing now should give you a ton of insight into
whats going on to an obnoxious degree. Disable tracing
and things are silent (minus the nice link port speed)
---
src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp | 106 +++++++++++-----------
1 file changed, 52 insertions(+), 54 deletions(-)
diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp b/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
index dbe64cc..28201e2 100644
a
|
b
|
|
30 | 30 | #include "util.h" |
31 | 31 | |
32 | 32 | |
33 | | #define TRACE_AHCI |
| 33 | //#define TRACE_AHCI |
34 | 34 | #ifdef TRACE_AHCI |
35 | 35 | # define TRACE(a...) dprintf("ahci: " a) |
36 | 36 | #else |
… |
… |
AHCIPort::Probe()
|
284 | 284 | return B_ERROR; |
285 | 285 | } |
286 | 286 | |
287 | | switch (fRegs->ssts & HBA_PORT_SPD_MASK) { |
288 | | case 0x10: |
289 | | TRACE("%s: port %d link speed 1.5Gb/s\n", __func__, fIndex); |
290 | | break; |
291 | | case 0x20: |
292 | | TRACE("%s: port %d link speed 3.0Gb/s\n", __func__, fIndex); |
293 | | break; |
294 | | case 0x30: |
295 | | TRACE("%s: port %d link speed 6.0Gb/s\n", __func__, fIndex); |
296 | | break; |
297 | | default: |
298 | | TRACE("%s: port %d link speed unrestricted\n", __func__, fIndex); |
299 | | break; |
| 287 | if (!fTestUnitReadyActive) { |
| 288 | switch (fRegs->ssts & HBA_PORT_SPD_MASK) { |
| 289 | case 0x10: |
| 290 | ERROR("%s: port %d link speed 1.5Gb/s\n", __func__, fIndex); |
| 291 | break; |
| 292 | case 0x20: |
| 293 | ERROR("%s: port %d link speed 3.0Gb/s\n", __func__, fIndex); |
| 294 | break; |
| 295 | case 0x30: |
| 296 | ERROR("%s: port %d link speed 6.0Gb/s\n", __func__, fIndex); |
| 297 | break; |
| 298 | default: |
| 299 | ERROR("%s: port %d link speed unrestricted\n", __func__, fIndex); |
| 300 | break; |
| 301 | } |
300 | 302 | } |
301 | 303 | |
302 | 304 | wait_until_clear(&fRegs->tfd, ATA_STATUS_BUSY, 31000000); |
… |
… |
AHCIPort::Probe()
|
310 | 312 | fRegs->cmd &= ~PORT_CMD_ATAPI; |
311 | 313 | FlushPostedWrites(); |
312 | 314 | |
313 | | if (!fTestUnitReadyActive) { |
314 | | TRACE("device signature 0x%08" B_PRIx32 " (%s)\n", fRegs->sig, |
315 | | fRegs->sig == SATA_SIG_ATAPI ? "ATAPI" : fRegs->sig == SATA_SIG_ATA |
316 | | ? "ATA" : "unknown"); |
317 | | } |
| 315 | TRACE("device signature 0x%08" B_PRIx32 " (%s)\n", fRegs->sig, |
| 316 | fRegs->sig == SATA_SIG_ATAPI ? "ATAPI" : fRegs->sig == SATA_SIG_ATA |
| 317 | ? "ATA" : "unknown"); |
318 | 318 | |
319 | 319 | return B_OK; |
320 | 320 | } |
… |
… |
AHCIPort::InterruptErrorHandler(uint32 is)
|
383 | 383 | { |
384 | 384 | uint32 ci = fRegs->ci; |
385 | 385 | |
386 | | if (!fTestUnitReadyActive) { |
387 | | TRACE("AHCIPort::InterruptErrorHandler port %d, fCommandsActive 0x%08" |
388 | | B_PRIx32 ", is 0x%08" B_PRIx32 ", ci 0x%08" B_PRIx32 "\n", fIndex, |
389 | | fCommandsActive, is, ci); |
390 | | TRACE("ssts 0x%08" B_PRIx32 "\n", fRegs->ssts); |
391 | | TRACE("sctl 0x%08" B_PRIx32 "\n", fRegs->sctl); |
392 | | TRACE("serr 0x%08" B_PRIx32 "\n", fRegs->serr); |
393 | | TRACE("sact 0x%08" B_PRIx32 "\n", fRegs->sact); |
394 | | } |
| 386 | TRACE("AHCIPort::InterruptErrorHandler port %d, fCommandsActive 0x%08" |
| 387 | B_PRIx32 ", is 0x%08" B_PRIx32 ", ci 0x%08" B_PRIx32 "\n", fIndex, |
| 388 | fCommandsActive, is, ci); |
| 389 | TRACE("ssts 0x%08" B_PRIx32 "\n", fRegs->ssts); |
| 390 | TRACE("sctl 0x%08" B_PRIx32 "\n", fRegs->sctl); |
| 391 | TRACE("serr 0x%08" B_PRIx32 "\n", fRegs->serr); |
| 392 | TRACE("sact 0x%08" B_PRIx32 "\n", fRegs->sact); |
395 | 393 | |
396 | 394 | // read and clear SError |
397 | 395 | _ClearErrorRegister(); |
398 | 396 | |
399 | 397 | if (is & PORT_INT_TFE) { |
400 | | if (!fTestUnitReadyActive) |
401 | | TRACE("Task File Error\n"); |
| 398 | TRACE("Task File Error\n"); |
402 | 399 | |
403 | 400 | fPortReset = true; |
404 | 401 | fError = true; |
405 | 402 | } |
406 | 403 | if (is & PORT_INT_HBF) { |
407 | | TRACE("Host Bus Fatal Error\n"); |
| 404 | ERROR("Host Bus Fatal Error\n"); |
408 | 405 | fPortReset = true; |
409 | 406 | fError = true; |
410 | 407 | } |
411 | 408 | if (is & PORT_INT_HBD) { |
412 | | TRACE("Host Bus Data Error\n"); |
| 409 | ERROR("Host Bus Data Error\n"); |
413 | 410 | fPortReset = true; |
414 | 411 | fError = true; |
415 | 412 | } |
416 | 413 | if (is & PORT_INT_IF) { |
417 | | TRACE("Interface Fatal Error\n"); |
| 414 | ERROR("Interface Fatal Error\n"); |
418 | 415 | fPortReset = true; |
419 | 416 | fError = true; |
420 | 417 | } |
… |
… |
AHCIPort::FillPrdTable(volatile prd* prdTable, int* prdCount, int prdMax,
|
468 | 465 | status_t status = get_memory_map_etc(B_CURRENT_TEAM, data, dataSize, |
469 | 466 | entries, &entriesUsed); |
470 | 467 | if (status != B_OK) { |
471 | | TRACE("%s: get_memory_map() failed: %s\n", __func__, strerror(status)); |
| 468 | ERROR("%s: get_memory_map() failed: %s\n", __func__, strerror(status)); |
472 | 469 | return B_ERROR; |
473 | 470 | } |
474 | 471 | |
… |
… |
AHCIPort::FillPrdTable(volatile prd* prdTable, int* prdCount, int prdMax,
|
489 | 486 | FLOW("FillPrdTable: sg-entry addr %#" B_PRIxPHYSADDR ", size %lu\n", |
490 | 487 | address, size); |
491 | 488 | if (address & 1) { |
492 | | TRACE("AHCIPort::FillPrdTable: data alignment error\n"); |
| 489 | ERROR("AHCIPort::FillPrdTable: data alignment error\n"); |
493 | 490 | return B_ERROR; |
494 | 491 | } |
495 | 492 | dataSize -= size; |
496 | 493 | while (size > 0) { |
497 | 494 | size_t bytes = min_c(size, PRD_MAX_DATA_LENGTH); |
498 | 495 | if (*prdCount == prdMax) { |
499 | | TRACE("AHCIPort::FillPrdTable: prd table exhausted\n"); |
| 496 | ERROR("AHCIPort::FillPrdTable: prd table exhausted\n"); |
500 | 497 | return B_ERROR; |
501 | 498 | } |
502 | 499 | FLOW("FillPrdTable: prd-entry %u, addr %p, size %lu\n", |
… |
… |
AHCIPort::FillPrdTable(volatile prd* prdTable, int* prdCount, int prdMax,
|
515 | 512 | sgCount--; |
516 | 513 | } |
517 | 514 | if (*prdCount == 0) { |
518 | | TRACE("%s: count is 0\n", __func__); |
| 515 | ERROR("%s: count is 0\n", __func__); |
519 | 516 | return B_ERROR; |
520 | 517 | } |
521 | 518 | if (dataSize > 0) { |
522 | | TRACE("AHCIPort::FillPrdTable: sg table %ld bytes too small\n", |
| 519 | ERROR("AHCIPort::FillPrdTable: sg table %ld bytes too small\n", |
523 | 520 | dataSize); |
524 | 521 | return B_ERROR; |
525 | 522 | } |
… |
… |
AHCIPort::ScsiSynchronizeCache(scsi_ccb* request)
|
811 | 808 | |
812 | 809 | sata_request* sreq = new(std::nothrow) sata_request(request); |
813 | 810 | if (sreq == NULL) { |
814 | | TRACE("out of memory when allocating sync request\n"); |
| 811 | ERROR("out of memory when allocating sync request\n"); |
815 | 812 | request->subsys_status = SCSI_REQ_ABORTED; |
816 | 813 | gSCSI->finished(request, 1); |
817 | 814 | return; |
… |
… |
for (uint32 i = 0; i < scsiRangeCount; i++) {
|
981 | 978 | uint32 lbaRangesSize = lbaRangeCount * sizeof(uint64); |
982 | 979 | uint64* lbaRanges = (uint64*)malloc(lbaRangesSize); |
983 | 980 | if (lbaRanges == NULL) { |
984 | | TRACE("out of memory when allocating %" B_PRIu32 " unmap ranges\n", |
| 981 | ERROR("out of memory when allocating %" B_PRIu32 " unmap ranges\n", |
985 | 982 | lbaRangeCount); |
986 | 983 | request->subsys_status = SCSI_REQ_ABORTED; |
987 | 984 | gSCSI->finished(request, 1); |
… |
… |
for (uint32 i = 0; i < lbaRangeCount; i++) {
|
1037 | 1034 | sreq.WaitForCompletion(); |
1038 | 1035 | |
1039 | 1036 | if ((sreq.CompletionStatus() & ATA_STATUS_ERROR) != 0) { |
1040 | | TRACE("trim failed (%" B_PRIu32 " ranges)!\n", lbaRangeCount); |
| 1037 | ERROR("trim failed (%" B_PRIu32 " ranges)!\n", lbaRangeCount); |
1041 | 1038 | request->subsys_status = SCSI_REQ_CMP_ERR; |
1042 | 1039 | } else |
1043 | 1040 | request->subsys_status = SCSI_REQ_CMP; |
… |
… |
AHCIPort::ExecuteSataRequest(sata_request* request, bool isWrite)
|
1093 | 1090 | |
1094 | 1091 | if (wait_until_clear(&fRegs->tfd, ATA_STATUS_BUSY | ATA_STATUS_DATA_REQUEST, |
1095 | 1092 | 1000000) < B_OK) { |
1096 | | TRACE("ExecuteAtaRequest port %d: device is busy\n", fIndex); |
| 1093 | ERROR("ExecuteAtaRequest port %d: device is busy\n", fIndex); |
1097 | 1094 | PortReset(); |
1098 | 1095 | FinishTransfer(); |
1099 | 1096 | request->Abort(); |
… |
… |
AHCIPort::ExecuteSataRequest(sata_request* request, bool isWrite)
|
1140 | 1137 | FinishTransfer(); |
1141 | 1138 | |
1142 | 1139 | if (status == B_TIMED_OUT) { |
1143 | | TRACE("ExecuteAtaRequest port %d: device timeout\n", fIndex); |
| 1140 | ERROR("ExecuteAtaRequest port %d: device timeout\n", fIndex); |
1144 | 1141 | request->Abort(); |
1145 | 1142 | return; |
1146 | 1143 | } |
… |
… |
AHCIPort::ScsiExecuteRequest(scsi_ccb* request)
|
1175 | 1172 | |
1176 | 1173 | sata_request* sreq = new(std::nothrow) sata_request(request); |
1177 | 1174 | if (sreq == NULL) { |
1178 | | TRACE("out of memory when allocating atapi request\n"); |
| 1175 | ERROR("out of memory when allocating atapi request\n"); |
1179 | 1176 | request->subsys_status = SCSI_REQ_ABORTED; |
1180 | 1177 | gSCSI->finished(request, 1); |
1181 | 1178 | return; |
… |
… |
AHCIPort::ScsiExecuteRequest(scsi_ccb* request)
|
1246 | 1243 | if (length) { |
1247 | 1244 | ScsiReadWrite(request, position, length, isWrite); |
1248 | 1245 | } else { |
1249 | | TRACE("AHCIPort::ScsiExecuteRequest error: transfer without " |
| 1246 | ERROR("AHCIPort::ScsiExecuteRequest error: transfer without " |
1250 | 1247 | "data!\n"); |
1251 | 1248 | request->subsys_status = SCSI_REQ_INVALID; |
1252 | 1249 | gSCSI->finished(request, 1); |
… |
… |
AHCIPort::ScsiExecuteRequest(scsi_ccb* request)
|
1263 | 1260 | if (length) { |
1264 | 1261 | ScsiReadWrite(request, position, length, isWrite); |
1265 | 1262 | } else { |
1266 | | TRACE("AHCIPort::ScsiExecuteRequest error: transfer without " |
| 1263 | ERROR("AHCIPort::ScsiExecuteRequest error: transfer without " |
1267 | 1264 | "data!\n"); |
1268 | 1265 | request->subsys_status = SCSI_REQ_INVALID; |
1269 | 1266 | gSCSI->finished(request, 1); |
… |
… |
AHCIPort::ScsiExecuteRequest(scsi_ccb* request)
|
1280 | 1277 | if (length) { |
1281 | 1278 | ScsiReadWrite(request, position, length, isWrite); |
1282 | 1279 | } else { |
1283 | | TRACE("AHCIPort::ScsiExecuteRequest error: transfer without " |
| 1280 | ERROR("AHCIPort::ScsiExecuteRequest error: transfer without " |
1284 | 1281 | "data!\n"); |
1285 | 1282 | request->subsys_status = SCSI_REQ_INVALID; |
1286 | 1283 | gSCSI->finished(request, 1); |
… |
… |
AHCIPort::ScsiExecuteRequest(scsi_ccb* request)
|
1292 | 1289 | const scsi_cmd_unmap* cmd = (const scsi_cmd_unmap*)request->cdb; |
1293 | 1290 | |
1294 | 1291 | if (!fTrimSupported) { |
1295 | | TRACE("%s port %d: unsupported request opcode 0x%02x\n", |
| 1292 | ERROR("%s port %d: unsupported request opcode 0x%02x\n", |
1296 | 1293 | __func__, fIndex, request->cdb[0]); |
1297 | 1294 | request->subsys_status = SCSI_REQ_ABORTED; |
1298 | 1295 | gSCSI->finished(request, 1); |
… |
… |
AHCIPort::ScsiExecuteRequest(scsi_ccb* request)
|
1305 | 1302 | || B_BENDIAN_TO_HOST_INT16(cmd->length) != request->data_length |
1306 | 1303 | || B_BENDIAN_TO_HOST_INT16(unmapBlocks->data_length) |
1307 | 1304 | != request->data_length - 1) { |
1308 | | TRACE("%s port %d: invalid unmap parameter data length\n", |
| 1305 | ERROR("%s port %d: invalid unmap parameter data length\n", |
1309 | 1306 | __func__, fIndex); |
1310 | 1307 | request->subsys_status = SCSI_REQ_ABORTED; |
1311 | 1308 | gSCSI->finished(request, 1); |
… |
… |
AHCIPort::ScsiExecuteRequest(scsi_ccb* request)
|
1315 | 1312 | break; |
1316 | 1313 | } |
1317 | 1314 | default: |
1318 | | TRACE("AHCIPort::ScsiExecuteRequest port %d unsupported request " |
| 1315 | ERROR("AHCIPort::ScsiExecuteRequest port %d unsupported request " |
1319 | 1316 | "opcode 0x%02x\n", fIndex, request->cdb[0]); |
1320 | 1317 | request->subsys_status = SCSI_REQ_ABORTED; |
1321 | 1318 | gSCSI->finished(request, 1); |
… |
… |
AHCIPort::Enable()
|
1362 | 1359 | { |
1363 | 1360 | // Spec v1.3.1, §10.3.1 Start (PxCMD.ST) |
1364 | 1361 | TRACE("%s: port %d\n", __func__, fIndex); |
| 1362 | |
1365 | 1363 | if ((fRegs->cmd & PORT_CMD_ST) != 0) { |
1366 | | TRACE("%s: Starting port already running!\n", __func__); |
| 1364 | ERROR("%s: Starting port already running!\n", __func__); |
1367 | 1365 | return false; |
1368 | 1366 | } |
1369 | 1367 | |
1370 | 1368 | if ((fRegs->cmd & PORT_CMD_FRE) == 0) { |
1371 | | TRACE("%s: Unable to start port without FRE enabled!\n", __func__); |
| 1369 | ERROR("%s: Unable to start port without FRE enabled!\n", __func__); |
1372 | 1370 | return false; |
1373 | 1371 | } |
1374 | 1372 | |
1375 | 1373 | // Clear DMA engine and wait for completion |
1376 | 1374 | if (wait_until_clear(&fRegs->cmd, PORT_CMD_CR, 500000) < B_OK) { |
1377 | | TRACE("%s: port %d error DMA engine still running\n", __func__, |
| 1375 | ERROR("%s: port %d error DMA engine still running\n", __func__, |
1378 | 1376 | fIndex); |
1379 | 1377 | return false; |
1380 | 1378 | } |
… |
… |
AHCIPort::Disable()
|
1403 | 1401 | // Spec v1.3.1, §10.4.2 Port Reset - assume hung after 500 mil. |
1404 | 1402 | // Clear DMA engine and wait for completion |
1405 | 1403 | if (wait_until_clear(&fRegs->cmd, PORT_CMD_CR, 500000) < B_OK) { |
1406 | | TRACE("%s: port %d error DMA engine still running\n", __func__, |
| 1404 | ERROR("%s: port %d error DMA engine still running\n", __func__, |
1407 | 1405 | fIndex); |
1408 | 1406 | return false; |
1409 | 1407 | } |