From nobody Mon Feb 9 16:02:48 2026 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+85170+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+85170+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1640166906; cv=none; d=zohomail.com; s=zohoarc; b=nVRsu90fIXu6W2uITqFAAUUqRSvHbzgsNCEic8yHJRkVSQQZWAPhqgSmqh/mm+eDRd8M3OE2FUAgw7RWffRmcy4uKLBhV97Obnz3oAJh73UTVESWxZQc1rvGMpr46D29mMxkyZDaNruE5Ea/yoK91QuYemENQaeZJDc9KG2FODQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640166906; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=6Eyj4RyPzLgrO3ZSbD5Ini4JqDLN6GDVmZ/fnhHraOo=; b=H0eoT0mJzYIV5b9Zl7F1Y30cM7zNZTssz9jJR7twH63NmBFiU4DGQZ52PfyQpmYP2JgBQ6NQawQyTIHUhKYSr+Eyn6hDmp+7YIKF2xcd+/NZfB2UHvCwK6pneIuPQGD+yPuOXfOdfen97Z4/h/CSVuJTGPEWKYvFHwWOxCDzp2o= 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+85170+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 164016690687276.36682603381041; Wed, 22 Dec 2021 01:55:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id zQzIYY1788612xXHXey2UmxJ; Wed, 22 Dec 2021 01:55:06 -0800 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.17414.1640166898945655141 for ; Wed, 22 Dec 2021 01:55:06 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10205"; a="238124934" X-IronPort-AV: E=Sophos;i="5.88,226,1635231600"; d="scan'208";a="238124934" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2021 01:55:05 -0800 X-IronPort-AV: E=Sophos;i="5.88,226,1635231600"; d="scan'208";a="684972134" X-Received: from kxinfux-mobl2.gar.corp.intel.com ([10.213.42.103]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2021 01:55:02 -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 3/3] MdeModulePkg: Put off UFS HCS.DP checking to fix timing problem Date: Wed, 22 Dec 2021 17:53:14 +0800 Message-Id: <20211222095314.2023-4-vincentx.ke@intel.com> In-Reply-To: <20211222095314.2023-1-vincentx.ke@intel.com> References: <20211222095314.2023-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: EUFZIX3KtRbFUZhoPzhaWr1mx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1640166906; bh=bEbStsufp+3WcrTCoXGdPY8PUTpcHDY9gKiJZz5ldFw=; h=Cc:Date:From:Reply-To:Subject:To; b=EH3psB8+y2bRO7jXr92+zKtb91D7wLKVjHviFBLl68StM7zgPh3l8UL2FJZFZErZ30u z6/20cfAytnKU/jte6jndV9g5kb2rIanw5N8vPZeFzBrYvGY/Ddv4VPQiKUvxA69HsZU/ YSjhMUrt2hLZfnn+ZH9rQ1ASs2i7Y+QIWig= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640166908021100001 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3776 Put off UFS HCS.DP (Device Attached) checking until 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 | 47 +++++++++------------ 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus= /Ufs/UfsBlockIoPei/UfsHci.c index 4305fab7dc..d0f14d511c 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 @@ -1443,6 +1426,8 @@ UfsDeviceDetection ( ) { UINTN Retry; + UINTN Address; + UINT32 Data; EFI_STATUS Status; =20 // @@ -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.31.1.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 (#85170): https://edk2.groups.io/g/devel/message/85170 Mute This Topic: https://groups.io/mt/87895212/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-