[edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/XhciDxe: Fix the Bug of clean InputContext in XhcEvaluateContext64();

Jiading Zhang posted 1 patch 1 year, 7 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 1 -
1 file changed, 1 deletion(-)
[edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/XhciDxe: Fix the Bug of clean InputContext in XhcEvaluateContext64();
Posted by Jiading Zhang 1 year, 7 months ago
The value of InputContext structure is initialized in XhcInitializeDeviceSlot/XhcInitializeDeviceSlot64, it shouldn't be cleared when used in XhcEvaluateContext64().

Signed-off-by: jdzhang <jdzhang@kunluntech.com.cn>
---
MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index c2906e06fd..efbbe247c1 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -4021,7 +4021,6 @@ XhcEvaluateContext64 (
// 4.6.7 Evaluate Context
//
InputContext = Xhc->UsbDevContext[SlotId].InputContext;
-  ZeroMem (InputContext, sizeof (INPUT_CONTEXT_64));

InputContext->InputControlContext.Dword2 |= BIT1;
InputContext->EP[0].MaxPacketSize         = MaxPacketSize;
--
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93737): https://edk2.groups.io/g/devel/message/93737
Mute This Topic: https://groups.io/mt/93673303/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/XhciDxe: Fix the Bug of clean InputContext in XhcEvaluateContext64();
Posted by Wu, Hao A 1 year, 7 months ago
Hello,

For the proposed patch, may I know what kind of issue was met?

After referring to the xHCI spec, my take is that the “Input Context” is different (and should be re-initialed) for each xHC command.

1. Under section 4.6.5 Address Device of the xHCI 1.1 spec:
The Add Context flags A0 and A1 of the Input Control Context data structure (in the Input Context) shall be
set to ‘1’, and all remaining Add Context and Drop Context flags shall all be cleared to ‘0’.

System software shall initialize Slot Context and Endpoint Context 0 entries of the Input Context. All other
Endpoint Contexts in the Input Context shall be ignored by the xHC during the execution of this command.

2. And for section 4.6.7 Evaluate Context:
The state of the Add Context flags depends on the specific endpoints
affected by the command. All Drop Context flags of the Input Control Context shall be cleared to ‘0’ (these
flags do not apply to the Evaluate Context Command). System software shall initialize Contexts of the
Input Context affected by the command. All Contexts not referenced by an Add Context flag in the Input
Context are ignored by the xHC.

Could you help to provide more information for the background of the patch? Thanks in advance.

Best Regards,
Hao Wu

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jiading Zhang
Sent: Wednesday, September 14, 2022 3:15 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/XhciDxe: Fix the Bug of clean InputContext in XhcEvaluateContext64();

The value of InputContext structure is initialized in XhcInitializeDeviceSlot/XhcInitializeDeviceSlot64, it shouldn't be cleared when used in XhcEvaluateContext64().

Signed-off-by: jdzhang <jdzhang@kunluntech.com.cn<mailto:jdzhang@kunluntech.com.cn>>
---
 MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index c2906e06fd..efbbe247c1 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -4021,7 +4021,6 @@ XhcEvaluateContext64 (
   // 4.6.7 Evaluate Context
   //
   InputContext = Xhc->UsbDevContext[SlotId].InputContext;
-  ZeroMem (InputContext, sizeof (INPUT_CONTEXT_64));

   InputContext->InputControlContext.Dword2 |= BIT1;
   InputContext->EP[0].MaxPacketSize         = MaxPacketSize;
--
2.20.1.windows.1




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93740): https://edk2.groups.io/g/devel/message/93740
Mute This Topic: https://groups.io/mt/93673303/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-