From nobody Thu May 2 16:05:05 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+84964+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+84964+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1639637794; cv=none; d=zohomail.com; s=zohoarc; b=jDE/l6DkJ8kHjCGfBfWfSMMlSAd/S6Gr25Ht6iCmTpdCnTntufh0cQYU9mbZGwvxFMANfw2GDfxYPVu1Y5d/jqXhN5//NDBTIiyX34/rXMpvbdbOB0f6VN8NfyYC3Ax+YAyuhAVfiXUjozlsf6EJ4q2NKrPnphqoGpG0tMKBeZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639637794; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=tn/3oqCDwY3PkefhT8vip/pfm/5wsD2ndbdIWysLe0Y=; b=VECKizctfox5Rt58cHEn4u+iI2udXp6ltLr3B+W0MQyxTMNwPHuOR8MIEh8biZaBfyoKMatzhbFhXg9s3aYHcVkb07ohxobju67AayLd9WaGxn3QAVJuROa+lJt9okXqlRR9k3vtM2Hysgf1r1icpL/ETJ3xwva/QcMA98vyZQ8= 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+84964+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 163963779486372.82327852523508; Wed, 15 Dec 2021 22:56:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id XhzPYY1788612xH1uveEbR9Y; Wed, 15 Dec 2021 22:56:34 -0800 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.6931.1639637793147068148 for ; Wed, 15 Dec 2021 22:56:33 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10199"; a="325699611" X-IronPort-AV: E=Sophos;i="5.88,210,1635231600"; d="scan'208";a="325699611" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2021 22:56:31 -0800 X-IronPort-AV: E=Sophos;i="5.88,210,1635231600"; d="scan'208";a="568234923" X-Received: from kxinfux-win10.gar.corp.intel.com ([10.227.107.41]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2021 22:56:30 -0800 From: "VincentX Ke" To: devel@edk2.groups.io Cc: VincentX Ke , Hao A Wu , Ray Ni , Ian Chiu , Maggie Chu Subject: [edk2-devel] [PATCH] MdeModulePkg: Moving UFS HCS.DP checking out of UfsExecUicCommands() to fix timing problem Date: Thu, 16 Dec 2021 14:56:15 +0800 Message-Id: <20211216065615.16496-1-vincentx.ke@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,vincentx.ke@intel.com X-Gm-Message-State: nr4qAFJbMhOptT9RLdSLtJAlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1639637794; bh=dE8bWIWNOZVxteZSweP9xwgV2pKvt/AHyi+6cTBjiEk=; h=Cc:Date:From:Reply-To:Subject:To; b=pSFnlGsfEf3kz4w7p/kTJeHDzxmkzOspY/c8l3O1DVUivo22EXQTZbZx1GoJIyMmhBS wlcJoIrLsh5JNSyd0GpRepB1or6LgkMtRA8py6uln7Dxvhvp0lMZzag09QoehRrb4QEl6 XjDJydsIizkJTRTZJ4EzsNLuHOoyhKYTlcY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1639637796439100002 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3776 Moving UFS HCS.DP (Device Attached) checking under UfsDeviceDetection() to = fix timing problem. Cc: Hao A Wu Cc: Ray Ni Cc: Ian Chiu Cc: Maggie Chu Signed-off-by: VincentX Ke --- MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c | 51 +++++++++------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus= /Ufs/UfsBlockIoPei/UfsHci.c index 9fa5fcf46f..447d6cab7f 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -1353,23 +1353,6 @@ UfsExecUicCommands ( } } =20 - // - // Check value of HCS.DP and make sure that there is a device attached t= o the Link. - // - Address =3D UfsHcBase + UFS_HC_STATUS_OFFSET; - Data =3D MmioRead32 (Address); - if ((Data & UFS_HC_HCS_DP) =3D=3D 0) { - Address =3D UfsHcBase + UFS_HC_IS_OFFSET; - Status =3D UfsWaitMemSet (Address, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UF= S_TIMEOUT); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; - } - - return EFI_NOT_FOUND; - } - - DEBUG ((DEBUG_INFO, "UfsblockioPei: found a attached UFS device\n")); - return EFI_SUCCESS; } =20 @@ -1442,8 +1425,10 @@ UfsDeviceDetection ( IN UFS_PEIM_HC_PRIVATE_DATA *Private ) { - UINTN Retry; - EFI_STATUS Status; + UINTN Retry; + UINTN Address; + UINT32 Data; + EFI_STATUS Status; =20 // // Start UFS device detection. @@ -1451,22 +1436,28 @@ 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; + // + // Check value of HCS.DP and make sure that there is a device attached= to the Link. + // + Address =3D Private->UfsHcBase + UFS_HC_STATUS_OFFSET; + Data =3D MmioRead32 (Address); + if ((Data & UFS_HC_HCS_DP) =3D=3D 0) { + Address =3D Private->UfsHcBase + UFS_HC_IS_OFFSET; + Status =3D UfsWaitMemSet (Address, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, = UFS_TIMEOUT); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + } else { + DEBUG ((DEBUG_INFO, "UfsblockioPei: found a attached UFS device\n")); + return EFI_SUCCESS; } - - return EFI_DEVICE_ERROR; } =20 - if (Retry =3D=3D 3) { - return EFI_NOT_FOUND; - } - - return EFI_SUCCESS; + return EFI_NOT_FOUND; } =20 /** --=20 2.18.0.windows.1 -=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 (#84964): https://edk2.groups.io/g/devel/message/84964 Mute This Topic: https://groups.io/mt/87762457/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-