From nobody Tue Feb 10 02:49:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45026+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45026+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565196705; cv=none; d=zoho.com; s=zohoarc; b=JNLsPnFqeH8rJMmxb4/XCoJLzcGndebqbjYPP1osIByDmLFn7kc8h4CsdYdXsSKr1DJlPEKEKdbIvcLpAsAEorg2oFXfrN1N/qm/SyaSfI17W8ebFcsS7SC7lJbEPfrYNlpGpSJVRDj5nMPjgFJeW98fnrmgbTWbJDrRHF0/GWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565196705; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=wmfSzKiCsImQFh7zcdIyLzKCIeoV1ESM+V4tteKRuNM=; b=nsv3ca+DoFiw0mwbzIgue4DvY8mLUCV/RgtTEPK1ZkYhELlOSv6YI/ZLl9dRcAG/Ynju0/RQubmS3g923ypint/2BW4M1PNSCxsI03VNTbox0kJEKOk9PmPkgB/hmdwsgOI4482KrQ4pCQQEdeoAullw4i7PRJ8cTTtupgtXN9k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45026+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565196705140199.7948691682792; Wed, 7 Aug 2019 09:51:45 -0700 (PDT) Return-Path: X-Received: from mga07.intel.com (mga07.intel.com []) by groups.io with SMTP; Wed, 07 Aug 2019 09:51:44 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2019 09:51:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,357,1559545200"; d="scan'208";a="192949646" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga001.fm.intel.com with ESMTP; 07 Aug 2019 09:51:42 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu Subject: [edk2-devel] [PATCH 4/4] MdeModulePkg/UfsPassThruDxe: Implement EDKII_UFS_HC_PLATFORM_PROTOCOL Date: Wed, 7 Aug 2019 18:51:07 +0200 Message-Id: <20190807165107.688-5-mateusz.albecki@intel.com> In-Reply-To: <20190807165107.688-1-mateusz.albecki@intel.com> References: <20190807165107.688-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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565196704; bh=BYt3Te7MvecshojKI6g5TrktMqrUTgeZFw6i5aB1yQg=; h=Cc:Date:From:Reply-To:Subject:To; b=aSvYCdCTf5g13YvEdQug3D4np4zKfJWDa5x02omUIWXXLP3WJbetrKQIZyl+x538Npy dn6z5RULHl8EFV5FgU83nmBuOazdaFdtckYz78hsQomfqt1c+ZLq3eW7Up7kRE4p8Mr91 fzTsSt2lnLq9WFPqNOdowjxRrr19Yc3FODQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D1343 This commit adds EDKII_UFS_HC_PLATFORM_PROTOCOL implementation in UfsPassThruDxe driver in version 1. Driver assumes that at most one instance of the protocol exists in the system. Presence of the protocol is not mandatory. Cc: Hao A Wu Signed-off-by: Mateusz Albecki --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 17 ++++++ MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 26 +++++++++ .../Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf | 3 +- .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 68 ++++++++++++++++++= ++++ 4 files changed, 113 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 09333c51d6..1559efe191 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -36,6 +36,7 @@ UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate =3D { 0, // UfsHostController 0, // UfsHcBase {0, 0}, // UfsHcInfo + {NULL, NULL}, // UfsHcDriverInterface 0, // TaskTag 0, // UtpTrlBase 0, // Nutrs @@ -92,6 +93,8 @@ UFS_DEVICE_PATH mUfsDevicePathTemplate =3D { =20 UINT8 mUfsTargetId[TARGET_MAX_BYTES]; =20 +GLOBAL_REMOVE_IF_UNREFERENCED EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatf= orm; + /** Sends a SCSI Request Packet to a SCSI device that is attached to the SCS= I channel. This function supports both blocking I/O and nonblocking I/O. The blocking I/O functio= nality is required, and the @@ -864,7 +867,21 @@ UfsPassThruDriverBindingStart ( Private->ExtScsiPassThru.Mode =3D &Private->ExtScsiPassThruMode; Private->UfsHostController =3D UfsHc; Private->UfsHcBase =3D UfsHcBase; + Private->Handle =3D Controller; + Private->UfsHcDriverInterface.UfsHcProtocol =3D UfsHc; + Private->UfsHcDriverInterface.UfsExecUicCommand =3D UfsHcDriverInterface= ExecUicCommand; InitializeListHead (&Private->Queue); + + // + // This has to be done before initializing UfsHcInfo or calling the UfsC= ontrollerInit + // + if (mUfsHcPlatform =3D=3D NULL) { + Status =3D gBS->LocateProtocol (&gEdkiiUfsHcPlatformProtocolGuid, NULL= , (VOID**)&mUfsHcPlatform); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "No UfsHcPlatformProtocol present\n")); + } + } + Status =3D GetUfsHcInfo (Private); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n")); diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index c511aa8c7a..cbc0c2126e 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -63,6 +63,7 @@ typedef struct _UFS_PASS_THRU_PRIVATE_DATA { EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController; UINTN UfsHcBase; EDKII_UFS_HC_INFO UfsHcInfo; + EDKII_UFS_HC_DRIVER_INTERFACE UfsHcDriverInterface; =20 UINT8 TaskTag; =20 @@ -126,6 +127,13 @@ typedef struct { UFS_PASS_THRU_SIG \ ) =20 +#define UFS_PASS_THRU_PRIVATE_DATA_FROM_DRIVER_INTF(a) \ + CR (a, \ + UFS_PASS_THRU_PRIVATE_DATA, \ + UfsHcDriverInterface, \ + UFS_PASS_THRU_SIG \ + ) + typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET { UINT64 Timeout; VOID *DataBuffer; @@ -959,6 +967,23 @@ UfsRwUfsAttribute ( IN OUT UINT32 *AttrSize ); =20 +/** + Execute UIC command. + + @param[in] This Pointer to driver interface produced by the = UFS controller. + @param[in, out] UicCommand Descriptor of the command that will be execu= ted. + + @retval EFI_SUCCESS Command executed successfully. + @retval EFI_INVALID_PARAMETER This or UicCommand is NULL. + @retval Others Command failed to execute. +**/ +EFI_STATUS +EFIAPI +UfsHcDriverInterfaceExecUicCommand ( + IN EDKII_UFS_HC_DRIVER_INTERFACE *This, + IN OUT EDKII_UIC_COMMAND *UicCommand + ); + /** Initializes UfsHcInfo field in private data. =20 @@ -975,5 +1000,6 @@ GetUfsHcInfo ( extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName; extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2; extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding; +extern EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatform; =20 #endif diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf b/MdeMo= dulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf index 24f5ea3a8f..92dc25714b 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf @@ -1,7 +1,7 @@ ## @file # Description file for the Universal Flash Storage (UFS) Pass Thru driver. # -# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -54,6 +54,7 @@ gEfiExtScsiPassThruProtocolGuid ## BY_START gEfiUfsDeviceConfigProtocolGuid ## BY_START gEdkiiUfsHostControllerProtocolGuid ## TO_START + gEdkiiUfsHcPlatformProtocolGuid ## SOMETIMES_CONSUMES =20 [UserExtensions.TianoCore."ExtraFiles"] UfsPassThruExtra.uni diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 74be3efc41..e2c104b103 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -1835,6 +1835,14 @@ UfsEnableHostController ( EFI_STATUS Status; UINT32 Data; =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPreHce= , &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHc= PreHce, Status =3D %r\n", Status)); + return Status; + } + } + // // UFS 2.0 spec section 7.1.1 - Host Controller Initialization // @@ -1878,6 +1886,14 @@ UfsEnableHostController ( return EFI_DEVICE_ERROR; } =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostHc= e, &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHc= PostHce, Status =3D %r\n", Status)); + return Status; + } + } + return EFI_SUCCESS; } =20 @@ -1901,6 +1917,14 @@ UfsDeviceDetection ( UINT32 Data; EDKII_UIC_COMMAND LinkStartupCommand; =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPreLin= kStartup, &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHc= PreLinkStartup, Status =3D %r\n", Status)); + return Status; + } + } + // // Start UFS device detection. // Try up to 3 times for establishing data link with device. @@ -1930,6 +1954,14 @@ UfsDeviceDetection ( } } =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostLi= nkStartup, &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHc= PostLinkStartup, Status =3D %r\n", Status)); + return Status; + } + } + return EFI_NOT_FOUND; } =20 @@ -2350,6 +2382,34 @@ ProcessAsyncTaskList ( } } =20 +/** + Execute UIC command. + + @param[in] This Pointer to driver interface produced by the = UFS controller. + @param[in, out] UicCommand Descriptor of the command that will be execu= ted. + + @retval EFI_SUCCESS Command executed successfully. + @retval EFI_INVALID_PARAMETER This or UicCommand is NULL. + @retval Others Command failed to execute. +**/ +EFI_STATUS +EFIAPI +UfsHcDriverInterfaceExecUicCommand ( + IN EDKII_UFS_HC_DRIVER_INTERFACE *This, + IN OUT EDKII_UIC_COMMAND *UicCommand + ) +{ + UFS_PASS_THRU_PRIVATE_DATA *Private; + + if (This =3D=3D NULL || UicCommand =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Private =3D UFS_PASS_THRU_PRIVATE_DATA_FROM_DRIVER_INTF (This); + + return UfsExecUicCommands (Private, UicCommand); +} + /** Initializes UfsHcInfo field in private data. =20 @@ -2380,6 +2440,14 @@ GetUfsHcInfo ( =20 Private->UfsHcInfo.Capabilities =3D Data; =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->OverrideHcInfo !=3D NULL= ) { + Status =3D mUfsHcPlatform->OverrideHcInfo (Private->Handle, &Private->= UfsHcInfo); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform on OverrideHcInfo, Statu= s =3D %r\n", Status)); + return Status; + } + } + return EFI_SUCCESS; } =20 --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | 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 wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie 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. -=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 (#45026): https://edk2.groups.io/g/devel/message/45026 Mute This Topic: https://groups.io/mt/32784360/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-