public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST
       [not found] <cover.1711508722.git.xianglei.cai@intel.com>
@ 2024-03-27  3:05 ` Xianglei Cai
  2024-04-10 13:29   ` Lewandowski, Krzysztof
  0 siblings, 1 reply; 4+ messages in thread
From: Xianglei Cai @ 2024-03-27  3:05 UTC (permalink / raw)
  To: devel
  Cc: Xianglei Cai, Hao A Wu, Ray Ni, Jian J Wang, Liming Gao,
	Jenny Huang, More Shih, Chiu, Ian

https://bugzilla.tianocore.org/show_bug.cgi?id=4727

Recently some of XHCI host controllers require to have
extra 1ms delay before accessing any MMIO register
during reset. PHY transition from P3 to P0 can take
around 1.3ms and the xHCI reset can take around 1.5ms.
Add PCD to control the delay, the default is 2 ms.

Cc: Hao A Wu     <hao.a.wu@intel.com>
Cc: Ray Ni       <ray.ni@intel.com>
Cc: Jian J Wang  <jian.j.wang@intel.com>
Cc: Liming Gao   <gaoliming@byosoft.com.cn>
Cc: Jenny Huang  <jenny.huang@intel.com>
Cc: More Shih    <more.shih@intel.com>
Cc: Chiu, Ian    <ian.chiu@intel.com>

Signed-off-by: Xianglei Cai <xianglei.cai@intel.com>
---
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h      | 1 +
 MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf | 4 ++++
 MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c   | 2 +-
 MdePkg/MdePkg.dec                        | 4 ++++
 MdePkg/MdePkg.dsc                        | 1 +
 5 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
index 44016758724c..c9a12095c29e 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/DebugLib.h>
 #include <Library/ReportStatusCodeLib.h>
 #include <Library/TimerLib.h>
+#include <Library/PcdLib.h>
 
 #include <IndustryStandard/Pci.h>
 
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
index 18ef87916ae4..2ee4c22d1e32 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
@@ -56,6 +56,7 @@
   DebugLib
   ReportStatusCodeLib
   TimerLib
+  PcdLib
 
 [Guids]
   gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ## Event
@@ -64,6 +65,9 @@
   gEfiPciIoProtocolGuid                         ## TO_START
   gEfiUsb2HcProtocolGuid                        ## BY_START
 
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset      ## CONSUMES
+
 # [Event]
 # EVENT_TYPE_PERIODIC_TIMER       ## CONSUMES
 #
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
index 40f2f1f22766..525942a167b0 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
@@ -864,7 +864,7 @@ XhcResetHC (
     // Otherwise there may have the timeout case happened.
     // The below is a workaround to solve such problem.
     //
-    gBS->Stall (XHC_1_MILLISECOND);
+    gBS->Stall (PcdGet16 (PcdDelayXhciHCReset));
     Status = XhcWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET, FALSE, Timeout);
 
     if (!EFI_ERROR (Status)) {
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 0459418906f8..a5b3ce94072c 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2510,5 +2510,9 @@
   # @Prompt Memory encryption attribute
   gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0|UINT64|0x0000002e
 
+  ## This dynamic PCD indicates time delay for XHCI registers access after it issues HCRST.
+  # @Prompt Delay access XHCI register after it issues HCRST (us)
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000|UINT16|0x00000043
+
 [UserExtensions.TianoCore."ExtraFiles"]
   MdePkgExtra.uni
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 109224c527f7..23aea04fea2e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -31,6 +31,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000
 
 [LibraryClasses]
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
-- 
2.42.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117147): https://edk2.groups.io/g/devel/message/117147
Mute This Topic: https://groups.io/mt/105171188/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST
  2024-03-27  3:05 ` [edk2-devel] [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST Xianglei Cai
@ 2024-04-10 13:29   ` Lewandowski, Krzysztof
  2024-04-12  1:54     ` Xianglei Cai
  0 siblings, 1 reply; 4+ messages in thread
From: Lewandowski, Krzysztof @ 2024-04-10 13:29 UTC (permalink / raw)
  To: Cai, Xianglei, devel@edk2.groups.io
  Cc: Ni, Ray, Liming Gao, Huang, Jenny, Shih, More, Chiu, Ian

[-- Attachment #1: Type: text/plain, Size: 5920 bytes --]

Looks good to me.

Reviewed-by: Krzysztof Lewandowski <krzysztof.lewandowski@intel.com>
________________________________
From: Cai, Xianglei <xianglei.cai@intel.com>
Sent: Wednesday, April 10, 2024 09:01
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Cai, Xianglei <xianglei.cai@intel.com>; Ni, Ray <ray.ni@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Lewandowski, Krzysztof <krzysztof.lewandowski@intel.com>; Huang, Jenny <jenny.huang@intel.com>; Shih, More <more.shih@intel.com>; Chiu, Ian <Ian.chiu@intel.com>
Subject: [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST

https://bugzilla.tianocore.org/show_bug.cgi?id=4727

Recently some of XHCI host controllers require to have
extra 1ms delay before accessing any MMIO register
during reset. PHY transition from P3 to P0 can take
around 1.3ms and the xHCI reset can take around 1.5ms.
Add PCD to control the delay, the default is 2 ms.

Cc: Ray Ni                                <ray.ni@intel.com>
Cc: Liming Gao                            <gaoliming@byosoft.com.cn>
Cc: Krzysztof Lewandowski    <krzysztof.lewandowski@intel.com>
Cc: Jenny Huang                           <jenny.huang@intel.com>
Cc: More Shih                             <more.shih@intel.com>
Cc: Ian Chiu                      <ian.chiu@intel.com>

Signed-off-by: Xianglei Cai <xianglei.cai@intel.com>
---
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h      | 1 +
 MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf | 4 ++++
 MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c   | 2 +-
 MdePkg/MdePkg.dec                        | 4 ++++
 MdePkg/MdePkg.dsc                        | 1 +
 5 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
index 44016758724c..c9a12095c29e 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/DebugLib.h>
 #include <Library/ReportStatusCodeLib.h>
 #include <Library/TimerLib.h>
+#include <Library/PcdLib.h>

 #include <IndustryStandard/Pci.h>

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
index 18ef87916ae4..2ee4c22d1e32 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
@@ -56,6 +56,7 @@
   DebugLib
   ReportStatusCodeLib
   TimerLib
+  PcdLib

 [Guids]
   gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ## Event
@@ -64,6 +65,9 @@
   gEfiPciIoProtocolGuid                         ## TO_START
   gEfiUsb2HcProtocolGuid                        ## BY_START

+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset      ## CONSUMES
+
 # [Event]
 # EVENT_TYPE_PERIODIC_TIMER       ## CONSUMES
 #
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
index 40f2f1f22766..525942a167b0 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
@@ -864,7 +864,7 @@ XhcResetHC (
     // Otherwise there may have the timeout case happened.
     // The below is a workaround to solve such problem.
     //
-    gBS->Stall (XHC_1_MILLISECOND);
+    gBS->Stall (PcdGet16 (PcdDelayXhciHCReset));
     Status = XhcWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET, FALSE, Timeout);

     if (!EFI_ERROR (Status)) {
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 0459418906f8..a5b3ce94072c 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2510,5 +2510,9 @@
   # @Prompt Memory encryption attribute
   gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0|UINT64|0x0000002e

+  ## This dynamic PCD indicates time delay for XHCI registers access after it issues HCRST.
+  # @Prompt Delay access XHCI register after it issues HCRST (us)
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000|UINT16|0x00000043
+
 [UserExtensions.TianoCore."ExtraFiles"]
   MdePkgExtra.uni
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 109224c527f7..23aea04fea2e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -31,6 +31,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000

 [LibraryClasses]
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
--
2.42.0.windows.2

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117587): https://edk2.groups.io/g/devel/message/117587
Mute This Topic: https://groups.io/mt/105171188/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 10285 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST
  2024-04-10 13:29   ` Lewandowski, Krzysztof
@ 2024-04-12  1:54     ` Xianglei Cai
  2024-04-15  5:19       ` [edk2-devel] 回复: " gaoliming via groups.io
  0 siblings, 1 reply; 4+ messages in thread
From: Xianglei Cai @ 2024-04-12  1:54 UTC (permalink / raw)
  To: Lewandowski, Krzysztof, devel@edk2.groups.io, Ni, Ray, Liming Gao
  Cc: Huang, Jenny, Shih, More, Chiu, Ian

[-- Attachment #1: Type: text/plain, Size: 6038 bytes --]

@Liming Gao<mailto:gaoliming@byosoft.com.cn> @Ni, Ray<mailto:ray.ni@intel.com> Would you like to merge the patch to upstream?

Thanks,
Xianglei

From: Lewandowski, Krzysztof <krzysztof.lewandowski@intel.com>
Sent: Wednesday, April 10, 2024 9:29 PM
To: Cai, Xianglei <xianglei.cai@intel.com>; devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Huang, Jenny <jenny.huang@intel.com>; Shih, More <more.shih@intel.com>; Chiu, Ian <Ian.chiu@intel.com>
Subject: Re: [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST

Looks good to me.

Reviewed-by: Krzysztof Lewandowski <krzysztof.lewandowski@intel.com<mailto:krzysztof.lewandowski@intel.com>>
________________________________
From: Cai, Xianglei <xianglei.cai@intel.com<mailto:xianglei.cai@intel.com>>
Sent: Wednesday, April 10, 2024 09:01
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>
Cc: Cai, Xianglei <xianglei.cai@intel.com<mailto:xianglei.cai@intel.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Liming Gao <gaoliming@byosoft.com.cn<mailto:gaoliming@byosoft.com.cn>>; Lewandowski, Krzysztof <krzysztof.lewandowski@intel.com<mailto:krzysztof.lewandowski@intel.com>>; Huang, Jenny <jenny.huang@intel.com<mailto:jenny.huang@intel.com>>; Shih, More <more.shih@intel.com<mailto:more.shih@intel.com>>; Chiu, Ian <Ian.chiu@intel.com<mailto:Ian.chiu@intel.com>>
Subject: [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST

https://bugzilla.tianocore.org/show_bug.cgi?id=4727

Recently some of XHCI host controllers require to have
extra 1ms delay before accessing any MMIO register
during reset. PHY transition from P3 to P0 can take
around 1.3ms and the xHCI reset can take around 1.5ms.
Add PCD to control the delay, the default is 2 ms.

Cc: Ray Ni                                <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: Liming Gao                            <gaoliming@byosoft.com.cn<mailto:gaoliming@byosoft.com.cn>>
Cc: Krzysztof Lewandowski    <krzysztof.lewandowski@intel.com<mailto:krzysztof.lewandowski@intel.com>>
Cc: Jenny Huang                           <jenny.huang@intel.com<mailto:jenny.huang@intel.com>>
Cc: More Shih                             <more.shih@intel.com<mailto:more.shih@intel.com>>
Cc: Ian Chiu                      <ian.chiu@intel.com<mailto:ian.chiu@intel.com>>

Signed-off-by: Xianglei Cai <xianglei.cai@intel.com<mailto:xianglei.cai@intel.com>>
---
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h      | 1 +
 MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf | 4 ++++
 MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c   | 2 +-
 MdePkg/MdePkg.dec                        | 4 ++++
 MdePkg/MdePkg.dsc                        | 1 +
 5 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
index 44016758724c..c9a12095c29e 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/DebugLib.h>
 #include <Library/ReportStatusCodeLib.h>
 #include <Library/TimerLib.h>
+#include <Library/PcdLib.h>

 #include <IndustryStandard/Pci.h>

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
index 18ef87916ae4..2ee4c22d1e32 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
@@ -56,6 +56,7 @@
   DebugLib
   ReportStatusCodeLib
   TimerLib
+  PcdLib

 [Guids]
   gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ## Event
@@ -64,6 +65,9 @@
   gEfiPciIoProtocolGuid                         ## TO_START
   gEfiUsb2HcProtocolGuid                        ## BY_START

+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset      ## CONSUMES
+
 # [Event]
 # EVENT_TYPE_PERIODIC_TIMER       ## CONSUMES
 #
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
index 40f2f1f22766..525942a167b0 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
@@ -864,7 +864,7 @@ XhcResetHC (
     // Otherwise there may have the timeout case happened.
     // The below is a workaround to solve such problem.
     //
-    gBS->Stall (XHC_1_MILLISECOND);
+    gBS->Stall (PcdGet16 (PcdDelayXhciHCReset));
     Status = XhcWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET, FALSE, Timeout);

     if (!EFI_ERROR (Status)) {
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 0459418906f8..a5b3ce94072c 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2510,5 +2510,9 @@
   # @Prompt Memory encryption attribute
   gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0|UINT64|0x0000002e

+  ## This dynamic PCD indicates time delay for XHCI registers access after it issues HCRST.
+  # @Prompt Delay access XHCI register after it issues HCRST (us)
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000|UINT16|0x00000043
+
 [UserExtensions.TianoCore."ExtraFiles"]
   MdePkgExtra.uni
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 109224c527f7..23aea04fea2e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -31,6 +31,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000

 [LibraryClasses]
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
--
2.42.0.windows.2


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117638): https://edk2.groups.io/g/devel/message/117638
Mute This Topic: https://groups.io/mt/105171188/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 12205 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [edk2-devel] 回复: [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST
  2024-04-12  1:54     ` Xianglei Cai
@ 2024-04-15  5:19       ` gaoliming via groups.io
  0 siblings, 0 replies; 4+ messages in thread
From: gaoliming via groups.io @ 2024-04-15  5:19 UTC (permalink / raw)
  To: 'Cai, Xianglei', 'Lewandowski, Krzysztof', devel,
	'Ni, Ray'
  Cc: 'Huang, Jenny', 'Shih, More', 'Chiu, Ian'

[-- Attachment #1: Type: text/plain, Size: 6968 bytes --]

I suggest to define this PCD in MdeModulePkg instead of MdePkg. This PCD is
only consumed by MdeModulePkg XhciDxe module. 

 

Thanks

Liming

发件人: Cai, Xianglei <xianglei.cai@intel.com> 
发送时间: 2024年4月12日 9:54
收件人: Lewandowski, Krzysztof <krzysztof.lewandowski@intel.com>;
devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Liming Gao
<gaoliming@byosoft.com.cn>
抄送: Huang, Jenny <jenny.huang@intel.com>; Shih, More
<more.shih@intel.com>; Chiu, Ian <Ian.chiu@intel.com>
主题: RE: [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST

 

 <mailto:gaoliming@byosoft.com.cn> @Liming Gao  <mailto:ray.ni@intel.com>
@Ni, Ray Would you like to merge the patch to upstream?

 

Thanks,

Xianglei

 

From: Lewandowski, Krzysztof <krzysztof.lewandowski@intel.com
<mailto:krzysztof.lewandowski@intel.com> > 
Sent: Wednesday, April 10, 2024 9:29 PM
To: Cai, Xianglei <xianglei.cai@intel.com <mailto:xianglei.cai@intel.com> >;
devel@edk2.groups.io <mailto:devel@edk2.groups.io> 
Cc: Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com> >; Liming Gao
<gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> >; Huang, Jenny
<jenny.huang@intel.com <mailto:jenny.huang@intel.com> >; Shih, More
<more.shih@intel.com <mailto:more.shih@intel.com> >; Chiu, Ian
<Ian.chiu@intel.com <mailto:Ian.chiu@intel.com> >
Subject: Re: [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of
HCRST

 

Looks good to me.

Reviewed-by: Krzysztof Lewandowski <krzysztof.lewandowski@intel.com
<mailto:krzysztof.lewandowski@intel.com> >

  _____  

From: Cai, Xianglei <xianglei.cai@intel.com <mailto:xianglei.cai@intel.com>
>
Sent: Wednesday, April 10, 2024 09:01
To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>
<devel@edk2.groups.io <mailto:devel@edk2.groups.io> >
Cc: Cai, Xianglei <xianglei.cai@intel.com <mailto:xianglei.cai@intel.com> >;
Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com> >; Liming Gao
<gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> >; Lewandowski,
Krzysztof <krzysztof.lewandowski@intel.com
<mailto:krzysztof.lewandowski@intel.com> >; Huang, Jenny <jenny.huang@intel.
com <mailto:jenny.huang@intel.com> >; Shih, More <more.shih@intel.com
<mailto:more.shih@intel.com> >; Chiu, Ian <Ian.chiu@intel.com
<mailto:Ian.chiu@intel.com> >
Subject: [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST 

 

https://bugzilla.tianocore.org/show_bug.cgi?id=4727

Recently some of XHCI host controllers require to have
extra 1ms delay before accessing any MMIO register
during reset. PHY transition from P3 to P0 can take
around 1.3ms and the xHCI reset can take around 1.5ms.
Add PCD to control the delay, the default is 2 ms.

Cc: Ray Ni                                <ray.ni@intel.com
<mailto:ray.ni@intel.com> >
Cc: Liming Gao                            <gaoliming@byosoft.com.cn
<mailto:gaoliming@byosoft.com.cn> >
Cc: Krzysztof Lewandowski    <krzysztof.lewandowski@intel.com
<mailto:krzysztof.lewandowski@intel.com> >
Cc: Jenny Huang                           <jenny.huang@intel.com
<mailto:jenny.huang@intel.com> >
Cc: More Shih                             <more.shih@intel.com <mailto:more.
shih@intel.com> >
Cc: Ian Chiu                      <ian.chiu@intel.com
<mailto:ian.chiu@intel.com> >

Signed-off-by: Xianglei Cai <xianglei.cai@intel.com
<mailto:xianglei.cai@intel.com> >
---
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h      | 1 +
 MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf | 4 ++++
 MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c   | 2 +-
 MdePkg/MdePkg.dec                        | 4 ++++
 MdePkg/MdePkg.dsc                        | 1 +
 5 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
index 44016758724c..c9a12095c29e 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/DebugLib.h>
 #include <Library/ReportStatusCodeLib.h>
 #include <Library/TimerLib.h>
+#include <Library/PcdLib.h>
 
 #include <IndustryStandard/Pci.h>
 
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
index 18ef87916ae4..2ee4c22d1e32 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
@@ -56,6 +56,7 @@
   DebugLib
   ReportStatusCodeLib
   TimerLib
+  PcdLib
 
 [Guids]
   gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ##
Event
@@ -64,6 +65,9 @@
   gEfiPciIoProtocolGuid                         ## TO_START
   gEfiUsb2HcProtocolGuid                        ## BY_START
 
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset      ## CONSUMES
+
 # [Event]
 # EVENT_TYPE_PERIODIC_TIMER       ## CONSUMES
 #
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
index 40f2f1f22766..525942a167b0 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
@@ -864,7 +864,7 @@ XhcResetHC (
     // Otherwise there may have the timeout case happened.
     // The below is a workaround to solve such problem.
     //
-    gBS->Stall (XHC_1_MILLISECOND);
+    gBS->Stall (PcdGet16 (PcdDelayXhciHCReset));
     Status = XhcWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET,
FALSE, Timeout);
 
     if (!EFI_ERROR (Status)) {
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 0459418906f8..a5b3ce94072c 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -2510,5 +2510,9 @@
   # @Prompt Memory encryption attribute
 
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0|UINT64|0x000000
2e
 
+  ## This dynamic PCD indicates time delay for XHCI registers access after
it issues HCRST.
+  # @Prompt Delay access XHCI register after it issues HCRST (us)
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000|UINT16|0x00000043
+
 [UserExtensions.TianoCore."ExtraFiles"]
   MdePkgExtra.uni
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 109224c527f7..23aea04fea2e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -31,6 +31,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
+  gEfiMdePkgTokenSpaceGuid.PcdDelayXhciHCReset|2000
 
 [LibraryClasses]
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
-- 
2.42.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117748): https://edk2.groups.io/g/devel/message/117748
Mute This Topic: https://groups.io/mt/105530278/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 14463 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-15  5:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1711508722.git.xianglei.cai@intel.com>
2024-03-27  3:05 ` [edk2-devel] [PATCH 1/1] MdeModulePkg/XhciDxe: Add PCD for the delay of HCRST Xianglei Cai
2024-04-10 13:29   ` Lewandowski, Krzysztof
2024-04-12  1:54     ` Xianglei Cai
2024-04-15  5:19       ` [edk2-devel] 回复: " gaoliming via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox