From nobody Fri May 3 16:48:08 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+85054+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+85054+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1639735022; cv=none; d=zohomail.com; s=zohoarc; b=U+FKJxZyNZM8xm/uWVnM/EMn4JeF4h/keYBVLLyHto2wUAMzZNnUrWcRUr2JaQZuX5TA1j5yawKqgZK2lXrAuTjQmkiKX1lmkobcMTAV3w0VqpyunptNtLqM1kGAS2euebsZAgq9+dYBDw0wGOBhItdUQZcyfEV3s7aWnfjD8YY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639735022; 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=4VM62iev6zT0hjNNeIE+HEb3hCUo7rcYxY67cIpB8r8=; b=Hw0qtONHA886Vgadbxnry0pxIpAPAcbC0NAyFKFhERx4EF+XgP6TO6Gh54upjX2coZiFw80B7qCdzuaEvUoKcp2qXdqtZ0ImBMazCYBfueCMmwxCgyX6KaExFVCdVNidZOO0CUHlpqbdK+ODTKUd8GTrkeZuPUTmP0IY8ahI47k= 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+85054+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 1639735022781160.31547580825554; Fri, 17 Dec 2021 01:57:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Yq7rYY1788612xq8q2OAVmDH; Fri, 17 Dec 2021 01:57:02 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.4382.1639735020525403781 for ; Fri, 17 Dec 2021 01:57:01 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10200"; a="219737663" X-IronPort-AV: E=Sophos;i="5.88,213,1635231600"; d="scan'208";a="219737663" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2021 01:57:00 -0800 X-IronPort-AV: E=Sophos;i="5.88,213,1635231600"; d="scan'208";a="605853856" X-Received: from kxinfux-win10.gar.corp.intel.com ([10.227.107.41]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2021 01:56:58 -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 v2] MdeModulePkg: Put off UFS HCS.DP checking to fix timing problem Date: Fri, 17 Dec 2021 17:56:23 +0800 Message-Id: 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: k5SW7eih4HGDqPQ3ElanJD8Dx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1639735022; bh=+ghbHccrdHPiKy2q0kGntjUCPoPgEkmQgJIldOqvZUQ=; h=Cc:Date:From:Reply-To:Subject:To; b=oSXM8i6Sy5MyV+N7ifLqxaSVCi6voqZ1/Ru/5fRcBWwbH8Hh7Z0EP/xAAwh1yfDuDHg 4XfWRr80BIQBFHP9xxlv+fuorFlmhrvAzrMm7wFXGLRcHtZvtgJwb3xbjwxpUmT9yi71X 7urBNPHBC+DtNIigF1Kn94X0RP/UtbbOSB8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1639735023556100001 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 2baa57593e..3da4274ca2 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -1307,23 +1307,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 @@ -1397,6 +1380,8 @@ UfsDeviceDetection ( ) { UINTN Retry; + UINTN Address; + UINT32 Data; EFI_STATUS Status; =20 // @@ -1405,22 +1390,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 (#85054): https://edk2.groups.io/g/devel/message/85054 Mute This Topic: https://groups.io/mt/87786397/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-