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

Wu, Hao A hao.a.wu at intel.com
Tue Sep 20 03:16:44 UTC 2022


Sorry, missed one change, “EPState” field should be cleared to 0 for input context:

  INPUT_CONTEXT_64            *InputContext;
  DEVICE_CONTEXT_64           *OutputContext;
  EFI_PHYSICAL_ADDRESS        PhyAddr;

  ASSERT (Xhc->UsbDevContext[SlotId].SlotId != 0);

  //
  // 4.6.7 Evaluate Context
  //
  InputContext  = Xhc->UsbDevContext[SlotId].InputContext;
  OutputContext = Xhc->UsbDevContext[SlotId].OutputContext;
  ZeroMem (InputContext, sizeof (INPUT_CONTEXT_64));
  CopyMem (&InputContext->EP[0], &OutputContext->EP[0], sizeof (ENDPOINT_CONTEXT_64));

  InputContext->InputControlContext.Dword2 |= BIT1;
  InputContext->EP[0].MaxPacketSize         = MaxPacketSize;
  InputContext->EP[0].EPState               = 0;


From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Wu, Hao A
Sent: Tuesday, September 20, 2022 11:04 AM
To: Jiading Zhang <jdzhang at kunluntech.com.cn>; devel at edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/XhciDxe: Fix the Bug of clean InputContext in XhcEvaluateContext64();

Thanks for the information.

Yes, I think the “EPType” field should be initialized properly for the Evaluate Context command to work.
The spec mentions in 6.2.3 Endpoint Context that:
* Note: Unless otherwise stated: As Input, all fields of the Endpoint Context shall be initialized to the appropriate value by software before issuing a command.
* Endpoint Type (EP Type). This field identifies whether an Endpoint Context is Valid

Could you help to update XhcEvaluateContext64 to (please help to update XhcEvaluateContext accordingly as well) and check below changes work on your environment?
  INPUT_CONTEXT_64            *InputContext;
  DEVICE_CONTEXT_64           *OutputContext;
  EFI_PHYSICAL_ADDRESS        PhyAddr;

  ASSERT (Xhc->UsbDevContext[SlotId].SlotId != 0);

  //
  // 4.6.7 Evaluate Context
  //
  InputContext  = Xhc->UsbDevContext[SlotId].InputContext;
  OutputContext = Xhc->UsbDevContext[SlotId].OutputContext;
  ZeroMem (InputContext, sizeof (INPUT_CONTEXT_64));
  CopyMem (&InputContext->EP[0], &OutputContext->EP[0], sizeof (ENDPOINT_CONTEXT_64));

My take is that doing so will initialize the input context of EP0 for the Evaluate Context command with previous output context of the Address Device command.

Best Regards,
Hao Wu

From: Jiading Zhang <jdzhang at kunluntech.com.cn<mailto:jdzhang at kunluntech.com.cn>>
Sent: Tuesday, September 20, 2022 8:46 AM
To: Wu; Wu, Hao A <hao.a.wu at intel.com<mailto:hao.a.wu at intel.com>>; devel at edk2.groups.io<mailto:devel at edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/XhciDxe: Fix the Bug of clean InputContext in XhcEvaluateContext64();

Hello,
   I test for several times and find that if add the following line, the KB and MassStorage will work,
       InputContext->EP[0].EPType = ED_CONTROL_BIDIR;

   I don't know if the issue is brought in by the different of xHCI controllers or else.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93979): https://edk2.groups.io/g/devel/message/93979
Mute This Topic: https://groups.io/mt/93673303/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20220920/0c0d7b96/attachment-0001.htm>


More information about the edk2-devel-archive mailing list