Hello,

My take to the purpose of calling XhcEvaluateContext/XhcEvaluateContext64 
functions is to “inform the xHC of the change to the Default Control endpoint’s 
Max Packet Size parameter.”
That is why the function only set bit 1 (Add Context bit 1) to inform the xHC 
only Endpoint Context for EP0 should be evaluated by xHC:
  InputContext->InputControlContext.Dword2 |= BIT1

I checked the xHCI spec, it does not prohibit only setting Add Context bit 1. 
According to section 4.6.7 Evaluate Context:
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.

If this is the case, the Slot Context should be ignored by the xHC, since Add 
Context bit 0 is cleared.

Then, according to section 6.2.3.3 Evaluate Context Command Usage:
A 'valid' Input Endpoint Context for an Evaluate Context Command requires that 
if the Add Context flag
(A1) for Default Control Endpoint is set to ‘1’, the Max Packet Size field 
shall be evaluated.

I do not think below code snippet violates with the above content in the spec:
  ZeroMem (InputContext, sizeof (INPUT_CONTEXT_64));

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

Do you have a chance to test other USB devices on your environment? Is it 
possible that the issue is a device specific case?
Thanks in advance.

Best Regards,
Hao Wu

From: Jiading Zhang <jdzh...@kunluntech.com.cn>
Sent: Wednesday, September 14, 2022 5:23 PM
To: Wu; Wu, Hao A <hao.a...@intel.com>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/XhciDxe: Fix the Bug of 
clean InputContext in XhcEvaluateContext64();

When I use the newest XhciDxe driver in Phytium Platform( ARM) ,  I found if 
clearing “Input Context” in XhcEvaluateContext64(), the usb KB doesn't work, 
and mark the  code   ZeroMem (InputContext, sizeof (INPUT_CONTEXT_64));  it 
works.
I viewed the code again, maybe change the ZeroMem (InputContext, sizeof 
(INPUT_CONTEXT_64)); to ZeroMem (InputContext, sizeof 
(INPUT_CONTRL_CONTEXT_64)); is more resonable.  Because when clearing the 
INPUT_CONTEXT_64, the Slot context and the endpoint context are cleared too. 
But according the xHCI Spec section 6.2.2
Note:Unless otherwise stated: As Input, all fields of the Slot Context shall be 
initialized to the appropriate value by software before issuing a command.
And I test again, just clear INPUT_CONTRL_CONTEXT_64 is OK.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93798): https://edk2.groups.io/g/devel/message/93798
Mute This Topic: https://groups.io/mt/93673303/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to