From nobody Mon Nov 25 20:52:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+67037+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+67037+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1604580117; cv=none; d=zohomail.com; s=zohoarc; b=duP/PUVb28anDGOxDGGIijbm7X+9TKk7P/q4nZXo5xNZ6MuSmkDKNZ9/kw5erEj3uDX+k9YZQnSiXkgGrC9RFkOVc/472PnJ4jVicAnIPnwBeq8mUvOD4xpRwwdv+ous0IunOXFPyyH4EU+OHIZRjJUFCvMjPF2MdVksgHeZzuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604580117; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=j/UUcq79o2RkRdSQKwRjABgbiN1WPHd3bCr2r3ohC/k=; b=PuKNChdeMjae+qI5RW0xNvNHIQwURPFG1SqnIixt2s01ukAqN+WEkfAEAwYDgIuW1HMILLASq1QjOFzI/PdmgkO+EsWcsQX80pGkvjvehziJHgK2u86yO4bsgG3QDXWt92Dnjg0D/sEXQk1xLg1xvxbTaTayyzF4HvxWtdMtefY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+67037+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1604580117276671.2986727188032; Thu, 5 Nov 2020 04:41:57 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5BspYY1788612xxGvRk5MgU9; Thu, 05 Nov 2020 04:41:56 -0800 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web08.6944.1604580114483596974 for ; Thu, 05 Nov 2020 04:41:56 -0800 IronPort-SDR: 20I11y6DTtT1XEX+US8//XZ7S8xHhLwgMM9Zr7GFPm/1F1mGIu+GU9ouGTTWZq2333oNGmhrQN trE6KKxK6czg== X-IronPort-AV: E=McAfee;i="6000,8403,9795"; a="187281468" X-IronPort-AV: E=Sophos;i="5.77,453,1596524400"; d="scan'208";a="187281468" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 04:41:55 -0800 IronPort-SDR: AUhZz/nkJe4Uz9n36x8wE7lg8zG0swsAUPcu29uGBiyg2vthjZoglAQtbkUsWuR+oaeWlnK6gA NH684DlXKQjQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,453,1596524400"; d="scan'208";a="527949806" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga006.fm.intel.com with ESMTP; 05 Nov 2020 04:41:54 -0800 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Ray Ni , Hao A Wu Subject: [edk2-devel] [PATCH v2 4/4] MdeModulePkg/AtaAtapiPassThru: Trace ATA packets Date: Thu, 5 Nov 2020 13:40:46 +0100 Message-Id: <20201105124046.3744-5-mateusz.albecki@intel.com> In-Reply-To: <20201105124046.3744-1-mateusz.albecki@intel.com> References: <20201105124046.3744-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com X-Gm-Message-State: dZCIyEerk9RBKaBwUd7irdi6x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1604580116; bh=K3Q064u82yoBKf8LeO5qQbTptMGO1k1Oh6kLW+qR+MA=; h=Cc:Date:From:Reply-To:Subject:To; b=b6YTyuuBNVHsnQdLRywjkBe2HQhdF39enWx/6b9lqZgQJ5Z5AfW0o3TvLokB2KpASe6 /E7ocN27iwDhv3dKd1DzSonIn5PR5n8e6yx9pYuXlMqQ1oBKc1bkbT/CR85VAdI9wZy+d WUJXjEG2l9ufUWUiWzfWys6yhiul/0ipMcU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This simplify ATA driver debugging all ATA packets will be printed to debug port on DEBUG_VERBOSE level along with the packet execution status. Additionally failed packets and the failed packet execution status will be printed on DEBUG_ERROR level. Signed-off-by: Mateusz Albecki Cc: Ray Ni Cc: Hao A Wu --- .../Bus/Ata/AtaAtapiPassThru/AhciMode.c | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePk= g/Bus/Ata/AtaAtapiPassThru/AhciMode.c index 47275a851a..e506c8f2d5 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c @@ -846,6 +846,54 @@ AhciWaitUntilFisReceived ( return EFI_TIMEOUT; } =20 +/** + Prints contents of the ATA command block into the debug port. + + @param[in] AtaCommandBlock AtaCommandBlock to print. + @param[in] DebugLevel Debug level on which to print. +**/ +VOID +AhciPrintCommandBlock ( + IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, + IN UINT32 DebugLevel + ) +{ + DEBUG ((DebugLevel, "ATA COMMAND BLOCK:\n")); + DEBUG ((DebugLevel, "AtaCommand: %d\n", AtaCommandBlock->AtaCommand)); + DEBUG ((DebugLevel, "AtaFeatures: %X\n", AtaCommandBlock->AtaFeatures)); + DEBUG ((DebugLevel, "AtaSectorNumber: %d\n", AtaCommandBlock->AtaSectorN= umber)); + DEBUG ((DebugLevel, "AtaCylinderLow: %X\n", AtaCommandBlock->AtaCylinder= High)); + DEBUG ((DebugLevel, "AtaCylinderHigh: %X\n", AtaCommandBlock->AtaCylinde= rHigh)); + DEBUG ((DebugLevel, "AtaDeviceHead: %d\n", AtaCommandBlock->AtaDeviceHea= d)); + DEBUG ((DebugLevel, "AtaSectorNumberExp: %d\n", AtaCommandBlock->AtaSect= orNumberExp)); + DEBUG ((DebugLevel, "AtaCylinderLowExp: %X\n", AtaCommandBlock->AtaCylin= derLowExp)); + DEBUG ((DebugLevel, "AtaCylinderHighExp: %X\n", AtaCommandBlock->AtaCyli= nderHighExp)); + DEBUG ((DebugLevel, "AtaFeaturesExp: %X\n", AtaCommandBlock->AtaFeatures= Exp)); + DEBUG ((DebugLevel, "AtaSectorCount: %d\n", AtaCommandBlock->AtaSectorCo= unt)); + DEBUG ((DebugLevel, "AtaSectorCountExp: %d\n", AtaCommandBlock->AtaSecto= rCountExp)); +} + +/** + Prints contents of the ATA status block into the debug port. + + @param[in] AtaStatusBlock AtaStatusBlock to print. + @param[in] DebugLevel Debug level on which to print. +**/ +VOID +AhciPrintStatusBlock ( + IN EFI_ATA_STATUS_BLOCK *AtaStatusBlock, + IN UINT32 DebugLevel + ) +{ + // + // Only print status and error since we have all of the rest printed as + // a part of command block print. + // + DEBUG ((DebugLevel, "ATA STATUS BLOCK:\n")); + DEBUG ((DebugLevel, "AtaStatus: %d\n", AtaStatusBlock->AtaStatus)); + DEBUG ((DebugLevel, "AtaError: %d\n", AtaStatusBlock->AtaError)); +} + /** Start a PIO data transfer on specific port. =20 @@ -947,6 +995,8 @@ AhciPioTransfer ( DataCount ); =20 + DEBUG ((DEBUG_VERBOSE, "Starting command for PIO transfer:\n")); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status =3D AhciStartCommand ( PciIo, Port, @@ -1000,6 +1050,19 @@ AhciPioTransfer ( ); =20 AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); + + if (Status =3D=3D EFI_DEVICE_ERROR) { + DEBUG ((DEBUG_ERROR, "Failed to execute command: for PIO transfer\n")); + // + // Repeat command block here to make sure it is printed on + // device error debug level. + // + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR); + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR); + } else { + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE); + } + return Status; } =20 @@ -1132,6 +1195,8 @@ AhciDmaTransfer ( DataCount ); =20 + DEBUG ((DEBUG_VERBOSE, "Starting command for sync DMA transfer:\n")); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status =3D AhciStartCommand ( PciIo, Port, @@ -1168,6 +1233,8 @@ AhciDmaTransfer ( DataCount ); =20 + DEBUG ((DEBUG_VERBOSE, "Starting command for async DMA transfer:\n")= ); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status =3D AhciStartCommand ( PciIo, Port, @@ -1238,6 +1305,19 @@ AhciDmaTransfer ( } =20 AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); + + if (Status =3D=3D EFI_DEVICE_ERROR) { + DEBUG ((DEBUG_ERROR, "Failed to execute command for DMA transfer:\n")); + // + // Repeat command block here to make sure it is printed on + // device error debug level. + // + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR); + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR); + } else { + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE); + } + return Status; } =20 @@ -1307,6 +1387,8 @@ AhciNonDataTransfer ( 0 ); =20 + DEBUG ((DEBUG_VERBOSE, "Starting command for non data transfer:\n")); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status =3D AhciStartCommand ( PciIo, Port, @@ -1343,6 +1425,18 @@ AhciNonDataTransfer ( =20 AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); =20 + if (Status =3D=3D EFI_DEVICE_ERROR) { + DEBUG ((DEBUG_ERROR, "Failed to execute command for non data transfer:= \n")); + // + // Repeat command block here to make sure it is printed on + // device error debug level. + // + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR); + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR); + } else { + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE); + } + return Status; } =20 --=20 2.28.0.windows.1 --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Sowackiego 173 | 80-298 Gdask | Sd Rejonowy Gdask Pnoc | VII Wydzia Gos= podarczy Krajowego Rejestru Sdowego - KRS 101882 | NIP 957-07-52-316 | Kapi= ta zakadowy 200.000 PLN. Ta wiadomo wraz z zacznikami jest przeznaczona dla okrelonego adresata i mo= e zawiera informacje poufne. W razie przypadkowego otrzymania tej wiadomoci= , prosimy o powiadomienie nadawcy oraz trwae jej usunicie; jakiekolwiek prz= egldanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. =20 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#67037): https://edk2.groups.io/g/devel/message/67037 Mute This Topic: https://groups.io/mt/78049738/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-