From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.29149.1640233211398591117 for ; Wed, 22 Dec 2021 20:20:20 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=GuZ22lpN; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: vincentx.ke@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640233220; x=1671769220; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zvzndOnnPq/HgYJctWl8J/+Au3SbbsChkjnFlv+esVA=; b=GuZ22lpN6E3w5eQPjGipdJ0zX2WwNNvEf+tOX0W+4uCDVFmDurL4HQ5s FfcOycki3AmPbLx6b9V9AyBB1VveheMZtaekSg9tbtqCfpQGTDVyH2sRf i1omttcDKXYtZy0lVrJPgj0kG8JYsO/M6m8XijoN15sIoVa8hK4GhaVUj rEkapqmWiKZQg3oscnTL/+hYJMyCzuO1QkHt/koBbnd5PJaZ9/DuVdd4r Yyqbe5O6lG5ie0NByactAltcyHHIeK8+2J9Tguh2lMTwFvcuFYbT9/Rkt ME99W+qQXpV+HC1ABGYOfMDzH6Fi+V19vja/rIArz2jtMpJ+0t4VA8FPM A==; X-IronPort-AV: E=McAfee;i="6200,9189,10206"; a="264960112" X-IronPort-AV: E=Sophos;i="5.88,228,1635231600"; d="scan'208";a="264960112" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2021 20:20:20 -0800 X-IronPort-AV: E=Sophos;i="5.88,228,1635231600"; d="scan'208";a="617363105" Received: from kxinfux-mobl2.gar.corp.intel.com ([10.214.170.104]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2021 20:20:17 -0800 From: "VincentX Ke" To: devel@edk2.groups.io Cc: VincentX Ke , Hao A Wu , Ray Ni , Ian Chiu , Maggie Chu Subject: [PATCH v6 3/3] MdeModulePkg: Put off UFS HCS.DP checking to fix timing problem Date: Thu, 23 Dec 2021 12:19:19 +0800 Message-Id: <20211223041919.1307-4-vincentx.ke@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20211223041919.1307-1-vincentx.ke@intel.com> References: <20211223041919.1307-1-vincentx.ke@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3776 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 cffe8e02a7..864bf6928d 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -1353,23 +1353,6 @@ UfsExecUicCommands ( } } - // - // Check value of HCS.DP and make sure that there is a device attached to the Link. - // - Address = UfsHcBase + UFS_HC_STATUS_OFFSET; - Data = MmioRead32 (Address); - if ((Data & UFS_HC_HCS_DP) == 0) { - Address = UfsHcBase + UFS_HC_IS_OFFSET; - Status = UfsWaitMemSet (Address, 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, "UfsblockioPei: found a attached UFS device\n")); - return EFI_SUCCESS; } @@ -1443,6 +1426,8 @@ UfsDeviceDetection ( ) { UINTN Retry; + UINTN Address; + UINT32 Data; EFI_STATUS Status; // @@ -1451,22 +1436,28 @@ UfsDeviceDetection ( // for (Retry = 0; Retry < 3; Retry++) { Status = UfsExecUicCommands (Private, UfsUicDmeLinkStartup, 0, 0, 0); - if (!EFI_ERROR (Status)) { - break; + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; } - if (Status == EFI_NOT_FOUND) { - continue; + // + // Check value of HCS.DP and make sure that there is a device attached to the Link + // + Address = Private->UfsHcBase + UFS_HC_STATUS_OFFSET; + Data = MmioRead32 (Address); + if ((Data & UFS_HC_HCS_DP) == 0) { + Address = Private->UfsHcBase + UFS_HC_IS_OFFSET; + Status = 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; } - if (Retry == 3) { - return EFI_NOT_FOUND; - } - - return EFI_SUCCESS; + return EFI_NOT_FOUND; } /** -- 2.31.1.windows.1