]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SdMmcPciHcDxe: Enhance driver traces
authorAlbecki, Mateusz <mateusz.albecki@intel.com>
Thu, 27 Feb 2020 17:25:22 +0000 (01:25 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 5 Mar 2020 01:51:59 +0000 (01:51 +0000)
To allow for easier debug of failing commands we
have added a capability to print TRB and command
packet when we start execution of the TRB(on
DEBUG_VERBOSE level) and when the TRB failed to
execute correctly(on DEBUG_ERROR level). Additionally
we will also print error interrupt status and interrupt
status register on failed SD command.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Marcin Wojtas <mw@semihalf.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
Tested-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c

index 7971196a253a84339798ec9480166edd8dcd884f..d6294eb4c88a15d126f30eeeeda4711661618ca4 100644 (file)
@@ -1647,6 +1647,82 @@ BuildAdmaDescTable (
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Prints the contents of the command packet to the debug port.\r
+\r
+  @param[in] DebugLevel  Debug level at which the packet should be printed.\r
+  @param[in] Packet      Pointer to packet to print.\r
+**/\r
+VOID\r
+SdMmcPrintPacket (\r
+  IN UINT32                               DebugLevel,\r
+  IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET  *Packet\r
+  )\r
+{\r
+  if (Packet == NULL) {\r
+    return;\r
+  }\r
+\r
+  DEBUG ((DebugLevel, "Printing EFI_SD_MMC_PASS_THRU_COMMAND_PACKET\n"));\r
+  if (Packet->SdMmcCmdBlk != NULL) {\r
+    DEBUG ((DebugLevel, "Command index: %d, argument: %X\n", Packet->SdMmcCmdBlk->CommandIndex, Packet->SdMmcCmdBlk->CommandArgument));\r
+    DEBUG ((DebugLevel, "Command type: %d, response type: %d\n", Packet->SdMmcCmdBlk->CommandType, Packet->SdMmcCmdBlk->ResponseType));\r
+  }\r
+  if (Packet->SdMmcStatusBlk != NULL) {\r
+    DEBUG ((DebugLevel, "Response 0: %X, 1: %X, 2: %X, 3: %X\n",\r
+                           Packet->SdMmcStatusBlk->Resp0,\r
+                           Packet->SdMmcStatusBlk->Resp1,\r
+                           Packet->SdMmcStatusBlk->Resp2,\r
+                           Packet->SdMmcStatusBlk->Resp3\r
+                           ));\r
+  }\r
+  DEBUG ((DebugLevel, "Timeout: %ld\n", Packet->Timeout));\r
+  DEBUG ((DebugLevel, "InDataBuffer: %p\n", Packet->InDataBuffer));\r
+  DEBUG ((DebugLevel, "OutDataBuffer: %p\n", Packet->OutDataBuffer));\r
+  DEBUG ((DebugLevel, "InTransferLength: %d\n", Packet->InTransferLength));\r
+  DEBUG ((DebugLevel, "OutTransferLength: %d\n", Packet->OutTransferLength));\r
+  DEBUG ((DebugLevel, "TransactionStatus: %r\n", Packet->TransactionStatus));\r
+}\r
+\r
+/**\r
+  Prints the contents of the TRB to the debug port.\r
+\r
+  @param[in] DebugLevel  Debug level at which the TRB should be printed.\r
+  @param[in] Trb         Pointer to the TRB structure.\r
+**/\r
+VOID\r
+SdMmcPrintTrb (\r
+  IN UINT32         DebugLevel,\r
+  IN SD_MMC_HC_TRB  *Trb\r
+  )\r
+{\r
+  if (Trb == NULL) {\r
+    return;\r
+  }\r
+\r
+  DEBUG ((DebugLevel, "Printing SD_MMC_HC_TRB\n"));\r
+  DEBUG ((DebugLevel, "Slot: %d\n", Trb->Slot));\r
+  DEBUG ((DebugLevel, "BlockSize: %d\n", Trb->BlockSize));\r
+  DEBUG ((DebugLevel, "Data: %p\n", Trb->Data));\r
+  DEBUG ((DebugLevel, "DataLen: %d\n", Trb->DataLen));\r
+  DEBUG ((DebugLevel, "Read: %d\n", Trb->Read));\r
+  DEBUG ((DebugLevel, "DataPhy: %lX\n", Trb->DataPhy));\r
+  DEBUG ((DebugLevel, "DataMap: %p\n", Trb->DataMap));\r
+  DEBUG ((DebugLevel, "Mode: %d\n", Trb->Mode));\r
+  DEBUG ((DebugLevel, "AdmaLengthMode: %d\n", Trb->AdmaLengthMode));\r
+  DEBUG ((DebugLevel, "Event: %p\n", Trb->Event));\r
+  DEBUG ((DebugLevel, "Started: %d\n", Trb->Started));\r
+  DEBUG ((DebugLevel, "Timeout: %ld\n", Trb->Timeout));\r
+  DEBUG ((DebugLevel, "Retries: %d\n", Trb->Retries));\r
+  DEBUG ((DebugLevel, "Adma32Desc: %p\n", Trb->Adma32Desc));\r
+  DEBUG ((DebugLevel, "Adma64V3Desc: %p\n", Trb->Adma64V3Desc));\r
+  DEBUG ((DebugLevel, "Adma64V4Desc: %p\n", Trb->Adma64V4Desc));\r
+  DEBUG ((DebugLevel, "AdmaMap: %p\n", Trb->AdmaMap));\r
+  DEBUG ((DebugLevel, "AdmaPages: %X\n", Trb->AdmaPages));\r
+\r
+  SdMmcPrintPacket (DebugLevel, Trb->Packet);\r
+}\r
+\r
 /**\r
   Create a new TRB for the SD/MMC cmd request.\r
 \r
 /**\r
   Create a new TRB for the SD/MMC cmd request.\r
 \r
@@ -2238,6 +2314,10 @@ SdMmcCheckAndRecoverErrors (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
+  DEBUG ((DEBUG_ERROR, "Error reported by SDHCI\n"));\r
+  DEBUG ((DEBUG_ERROR, "Interrupt status = %X\n", IntStatus));\r
+  DEBUG ((DEBUG_ERROR, "Error interrupt status = %X\n", ErrIntStatus));\r
+\r
   //\r
   // If the data timeout error is reported\r
   // but data transfer is signaled as completed we\r
   //\r
   // If the data timeout error is reported\r
   // but data transfer is signaled as completed we\r
@@ -2441,6 +2521,13 @@ Done:
 \r
   if (Status != EFI_NOT_READY) {\r
     SdMmcHcLedOnOff (Private->PciIo, Trb->Slot, FALSE);\r
 \r
   if (Status != EFI_NOT_READY) {\r
     SdMmcHcLedOnOff (Private->PciIo, Trb->Slot, FALSE);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((DEBUG_ERROR, "TRB failed with %r\n", Status));\r
+      SdMmcPrintTrb (DEBUG_ERROR, Trb);\r
+    } else {\r
+      DEBUG ((DEBUG_VERBOSE, "TRB success\n"));\r
+      SdMmcPrintTrb (DEBUG_VERBOSE, Trb);\r
+    }\r
   }\r
 \r
   return Status;\r
   }\r
 \r
   return Status;\r