From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=F7rnrI3q; spf=pass (domain: intel.com, ip: 192.55.52.136, 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=1639735020; x=1671271020; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PI3uxD+uDIQvHnry7k1QWtnJCEldCR6edp3yzkBtBhs=; b=F7rnrI3qFPXlpcf6PhOT1Hu2ul6KKbprK7ZK6DBet+S5sJ9+Dn7Ya8Vt bvOq3T4pHPLk16i8J/piE51ed0VhxXwS3f5+EdmH4Map8N3KqEgGuIk3p UiU09kaOIDeuUM9Z919QMfTjT5bBqTlqXuNIo4kCNUKYDLUDQzocRdkid WgK9K8s5r+6/fq/6VZMRZjvuDJMWR2oWJfMdGZi/JgdGugtnkulWyMcYk 5UF6gtfQ7zGzNyZwk5IhHAFLRI1vfv6goiGgKw7iz9fQWU3vrlq/0x+oy N3SSO6YLBQPN9SAtnryYyuM1iixp9DDXfLDW5LDaHVxVLs5I6VFbSSI38 w==; 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" 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" 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: [PATCH v2] MdeModulePkg: Put off UFS HCS.DP checking to fix timing problem Date: Fri, 17 Dec 2021 17:56:23 +0800 Message-Id: X-Mailer: git-send-email 2.18.0.windows.1 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 2baa57593e..3da4274ca2 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -1307,23 +1307,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; } @@ -1397,6 +1380,8 @@ UfsDeviceDetection ( ) { UINTN Retry; + UINTN Address; + UINT32 Data; EFI_STATUS Status; // @@ -1405,22 +1390,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.18.0.windows.1