From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: mateusz.albecki@intel.com) Received: from mga14.intel.com (mga14.intel.com []) by groups.io with SMTP; Fri, 09 Aug 2019 05:21:17 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 05:21:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,364,1559545200"; d="scan'208";a="375186635" Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga006.fm.intel.com with ESMTP; 09 Aug 2019 05:21:15 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu Subject: [PATCHv2 3/4] MdeModulePkg/UfsPassThruDxe: Refactor private data to use EDKII_UFS_HC_INFO Date: Fri, 9 Aug 2019 14:20:52 +0200 Message-Id: <20190809122053.1784-4-mateusz.albecki@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20190809122053.1784-1-mateusz.albecki@intel.com> References: <20190809122053.1784-1-mateusz.albecki@intel.com> https://bugzilla.tianocore.org/show_bug.cgi?id=1343 Private data has been refactored to use EDKII_UFS_HC_INFO structure to store host controller capabilities and version information. Getting host controller data has been moved into single place and is done before host controller enable. Cc: Hao A Wu Signed-off-by: Mateusz Albecki --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 6 ++- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 15 +++++- .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 57 ++++++++++++++-------- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index e24eb40333..0c96dacf16 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -41,7 +41,7 @@ UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate = { }, 0, // UfsHostController 0, // UfsHcBase - 0, // Capabilities + {0, 0}, // UfsHcInfo 0, // TaskTag 0, // UtpTrlBase 0, // Nutrs @@ -871,6 +871,10 @@ UfsPassThruDriverBindingStart ( Private->UfsHostController = UfsHc; Private->UfsHcBase = UfsHcBase; InitializeListHead (&Private->Queue); + Status = GetUfsHcInfo (Private); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n")); + } // // Initialize UFS Host Controller H/W. diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index fad4a8ee90..101d0b4bb8 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -68,7 +68,7 @@ typedef struct _UFS_PASS_THRU_PRIVATE_DATA { EFI_UFS_DEVICE_CONFIG_PROTOCOL UfsDevConfig; EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController; UINTN UfsHcBase; - UINT32 Capabilities; + EDKII_UFS_HC_INFO UfsHcInfo; UINT8 TaskTag; @@ -965,6 +965,19 @@ UfsRwUfsAttribute ( IN OUT UINT32 *AttrSize ); +/** + Initializes UfsHcInfo field in private data. + + @param[in] Private Pointer to host controller private data. + + @retval EFI_SUCCESS UfsHcInfo initialized successfully. + @retval Others Failed to initalize UfsHcInfo. +**/ +EFI_STATUS +GetUfsHcInfo ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private + ); + extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName; extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2; extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding; diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 27f5711a31..edcd395091 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -737,7 +737,7 @@ UfsFindAvailableSlotInTrl ( return Status; } - Nutrs = (UINT8)((Private->Capabilities & UFS_HC_CAP_NUTRS) + 1); + Nutrs = (UINT8)((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_NUTRS) + 1); for (Index = 0; Index < Nutrs; Index++) { if ((Data & (BIT0 << Index)) == 0) { @@ -1790,7 +1790,7 @@ UfsAllocateAlignCommonBuffer ( BOOLEAN Is32BitAddr; EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; - if ((Private->Capabilities & UFS_HC_CAP_64ADDR) == UFS_HC_CAP_64ADDR) { + if ((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_64ADDR) == UFS_HC_CAP_64ADDR) { Is32BitAddr = FALSE; } else { Is32BitAddr = TRUE; @@ -1983,7 +1983,6 @@ UfsInitTaskManagementRequestList ( IN UFS_PASS_THRU_PRIVATE_DATA *Private ) { - UINT32 Data; UINT8 Nutmrs; VOID *CmdDescHost; EFI_PHYSICAL_ADDRESS CmdDescPhyAddr; @@ -1997,17 +1996,10 @@ UfsInitTaskManagementRequestList ( CmdDescMapping = NULL; CmdDescPhyAddr = 0; - Status = UfsMmioRead32 (Private, UFS_HC_CAP_OFFSET, &Data); - if (EFI_ERROR (Status)) { - return Status; - } - - Private->Capabilities = Data; - // // Allocate and initialize UTP Task Management Request List. // - Nutmrs = (UINT8) (RShiftU64 ((Private->Capabilities & UFS_HC_CAP_NUTMRS), 16) + 1); + Nutmrs = (UINT8) (RShiftU64 ((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_NUTMRS), 16) + 1); Status = UfsAllocateAlignCommonBuffer (Private, Nutmrs * sizeof (UTP_TMRD), &CmdDescHost, &CmdDescPhyAddr, &CmdDescMapping); if (EFI_ERROR (Status)) { return Status; @@ -2056,7 +2048,6 @@ UfsInitTransferRequestList ( IN UFS_PASS_THRU_PRIVATE_DATA *Private ) { - UINT32 Data; UINT8 Nutrs; VOID *CmdDescHost; EFI_PHYSICAL_ADDRESS CmdDescPhyAddr; @@ -2070,17 +2061,10 @@ UfsInitTransferRequestList ( CmdDescMapping = NULL; CmdDescPhyAddr = 0; - Status = UfsMmioRead32 (Private, UFS_HC_CAP_OFFSET, &Data); - if (EFI_ERROR (Status)) { - return Status; - } - - Private->Capabilities = Data; - // // Allocate and initialize UTP Transfer Request List. // - Nutrs = (UINT8)((Private->Capabilities & UFS_HC_CAP_NUTRS) + 1); + Nutrs = (UINT8)((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_NUTRS) + 1); Status = UfsAllocateAlignCommonBuffer (Private, Nutrs * sizeof (UTP_TRD), &CmdDescHost, &CmdDescPhyAddr, &CmdDescMapping); if (EFI_ERROR (Status)) { return Status; @@ -2395,3 +2379,36 @@ ProcessAsyncTaskList ( } } +/** + Initializes UfsHcInfo field in private data. + + @param[in] Private Pointer to host controller private data. + + @retval EFI_SUCCESS UfsHcInfo initialized successfully. + @retval Others Failed to initalize UfsHcInfo. +**/ +EFI_STATUS +GetUfsHcInfo ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private + ) +{ + UINT32 Data; + EFI_STATUS Status; + + Status = UfsMmioRead32 (Private, UFS_HC_VER_OFFSET, &Data); + if (EFI_ERROR (Status)) { + return Status; + } + + Private->UfsHcInfo.Version = Data; + + Status = UfsMmioRead32 (Private, UFS_HC_CAP_OFFSET, &Data); + if (EFI_ERROR (Status)) { + return Status; + } + + Private->UfsHcInfo.Capabilities = Data; + + return EFI_SUCCESS; +} + -- 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.