From nobody Sun May 5 07:28:32 2024 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+42706+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+42706+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1561130861; cv=none; d=zoho.com; s=zohoarc; b=QfPi/J3iTaDbSx+NpJAL21B8yNxZD71HOEc6RsBnlF3F/tuwVvqhXISGbO9DLHFO9ez+LCRkN548uPhtktWuBXFRBUsti8IRAMVaygiCK1b9MaqLreKO+XTDebZl5BSbrrFe8hX0i2zP/NtJRzo2ri5EnmgB/xhkcz7wPHhIdaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561130861; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=d0GFxN1LU0i9yZtQuG5DCi1U9vfot+NroIiJwG6KJio=; b=KWCvxN7htc9LnNIarX8gYNWnmq3kvs9gj66wM8qU/1ScfQSWf+rVOAlQm2ttYML0JXTM+O70NFQn5SpRIWfwCOTjB5T+V75BB3W1PDLNiCVhvmACIwyHmejQEFcCLQnVFut/ekN4JJUbucodkSF+T41Guzgp/bUEwN2dz/aqQ5M= 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+42706+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 1561130861188969.2919780426797; Fri, 21 Jun 2019 08:27:41 -0700 (PDT) Return-Path: X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Fri, 21 Jun 2019 08:27:40 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2019 08:27:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,400,1557212400"; d="scan'208";a="151283344" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.10.44]) by orsmga007.jf.intel.com with ESMTP; 21 Jun 2019 08:27:37 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu Subject: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Refactor UFS device presence detection Date: Fri, 21 Jun 2019 17:27:02 +0200 Message-Id: <20190621152702.3092-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=1561130860; bh=wKiz4O06mN85TebN3rizMbIrCn2+AZ/haV4c+zr+Nxk=; h=Cc:Date:From:Reply-To:Subject:To; b=MmE3v1K4GKyXBJb200zinmDnCOjhmMkdapbkiVNId+guN7ZUKeavPjJHLEw1l794gMm +Q5SqOEXRje0oFFnpHUrJewwwxADv/q/H5TDAs3q9Q1E37+TNfxeY0bnwNs/gPBQKaLL7 SlNR2MNle1nPSxzKANA1hjZFnvT9+S5tE3U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In current implementation we are checking for device presence every time we execute UIC command. To make UfsExecUicCommands more generic checking device presence has been moved to UfsDeviceDetection. Cc: Hao A Wu Signed-off-by: Mateusz Albecki --- .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 50 ++++++++----------= ---- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 4b93821f38..633f975e30 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -1534,7 +1534,7 @@ Exit1: =20 =20 /** - Sent UIC DME_LINKSTARTUP command to start the link startup procedure. + Send UIC command. =20 @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DAT= A data structure. @param[in] UicOpcode The opcode of the UIC command. @@ -1544,7 +1544,6 @@ Exit1: =20 @return EFI_SUCCESS Successfully execute this UIC command and detec= t attached UFS device. @return EFI_DEVICE_ERROR Fail to execute this UIC command and detect att= ached UFS device. - @return EFI_NOT_FOUND The presence of the UFS device isn't detected. =20 **/ EFI_STATUS @@ -1629,24 +1628,6 @@ UfsExecUicCommands ( } } =20 - // - // Check value of HCS.DP and make sure that there is a device attached t= o the Link. - // - Status =3D UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data); - if (EFI_ERROR (Status)) { - return Status; - } - - if ((Data & UFS_HC_HCS_DP) =3D=3D 0) { - Status =3D UfsWaitMemSet (Private, UFS_HC_IS_OFFSET, UFS_HC_IS_ULSS, = UFS_HC_IS_ULSS, UFS_TIMEOUT); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; - } - return EFI_NOT_FOUND; - } - - DEBUG ((DEBUG_INFO, "UfsPassThruDxe: found a attached UFS device\n")); - return EFI_SUCCESS; } =20 @@ -1820,8 +1801,9 @@ UfsDeviceDetection ( IN UFS_PASS_THRU_PRIVATE_DATA *Private ) { - UINTN Retry; - EFI_STATUS Status; + UINTN Retry; + EFI_STATUS Status; + UINT32 Data; =20 // // Start UFS device detection. @@ -1829,22 +1811,26 @@ UfsDeviceDetection ( // for (Retry =3D 0; Retry < 3; Retry++) { Status =3D UfsExecUicCommands (Private, UfsUicDmeLinkStartup, 0, 0, 0); - if (!EFI_ERROR (Status)) { - break; + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; } =20 - if (Status =3D=3D EFI_NOT_FOUND) { - continue; + Status =3D UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; } =20 - return EFI_DEVICE_ERROR; - } - - if (Retry =3D=3D 3) { - return EFI_NOT_FOUND; + if ((Data & UFS_HC_HCS_DP) =3D=3D 0) { + Status =3D UfsWaitMemSet (Private, UFS_HC_IS_OFFSET, UFS_HC_IS_ULSS,= UFS_HC_IS_ULSS, UFS_TIMEOUT); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + } else { + return EFI_SUCCESS; + } } =20 - return EFI_SUCCESS; + return EFI_NOT_FOUND; } =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 (#42706): https://edk2.groups.io/g/devel/message/42706 Mute This Topic: https://groups.io/mt/32159554/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-