From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mx.groups.io with SMTP id smtpd.web11.39686.1622431100262735997 for ; Sun, 30 May 2021 20:18:20 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.188, mailfrom: xiewenyi2@huawei.com) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4FtgQc716wz67xT for ; Mon, 31 May 2021 11:15:20 +0800 (CST) Received: from dggpemm000003.china.huawei.com (7.185.36.128) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 11:18:16 +0800 Received: from [10.174.153.161] (10.174.153.161) by dggpemm000003.china.huawei.com (7.185.36.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 11:18:16 +0800 Subject: Re: [PATCH EDK2 v1 1/1] MdeModulePkg/Xhci: Fix TRT when data length is 0 To: "Wu, Hao A" , "devel@edk2.groups.io" , "Wang, Jian J" , "Ni, Ray" CC: "songdongkuang@huawei.com" References: <1622117066-67642-1-git-send-email-xiewenyi2@huawei.com> <1622117066-67642-2-git-send-email-xiewenyi2@huawei.com> From: "wenyi,xie" Message-ID: Date: Mon, 31 May 2021 11:18:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.0.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.174.153.161] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm000003.china.huawei.com (7.185.36.128) X-CFilter-Loop: Reflected Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit On 2021/5/31 9:44, Wu, Hao A wrote: >> -----Original Message----- >> From: Wenyi Xie >> Sent: Thursday, May 27, 2021 8:04 PM >> To: devel@edk2.groups.io; Wang, Jian J ; Wu, Hao A >> ; Ni, Ray >> Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com >> Subject: [PATCH EDK2 v1 1/1] MdeModulePkg/Xhci: Fix TRT when data length >> is 0 >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3418 >> >> According to xhci spec, at USB packet level, a Control Transfer consists of >> multiple transactions partitioned into stages: a setup stage, an optional data >> stage, and a terminating status stage. If Data Stage does not exist, the >> Transfer Type flag(TRT) should be No Data Stage. >> So if data length equals to 0, TRT is set to 0. > > > Thanks for the patch, the changes are good to me. > Could you help to provide the information on what kind of test has been performed for this patch? > > Best Regards, > Hao Wu > Hi, Wu Hao We use an AArch64 platform to test this patch. After merging this patch, during USB enumeration, Control Transfer with or without Data Stage works well. Our platform dsc only include XhciDxe. Thanks Wenyi > >> >> Cc: Jian J Wang >> Cc: Hao A Wu >> Cc: Ray Ni >> Signed-off-by: Wenyi Xie >> --- >> MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 13 +++++++++---- >> MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c | 13 +++++++++---- >> 2 files changed, 18 insertions(+), 8 deletions(-) >> >> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c >> b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c >> index dc36945962a0..7cbc9a8502ea 100644 >> --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c >> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c >> @@ -298,10 +298,15 @@ XhcCreateTransferTrb ( >> TrbStart->TrbCtrSetup.IOC = 1; >> TrbStart->TrbCtrSetup.IDT = 1; >> TrbStart->TrbCtrSetup.Type = TRB_TYPE_SETUP_STAGE; >> - if (Urb->Ep.Direction == EfiUsbDataIn) { >> - TrbStart->TrbCtrSetup.TRT = 3; >> - } else if (Urb->Ep.Direction == EfiUsbDataOut) { >> - TrbStart->TrbCtrSetup.TRT = 2; >> + if (Urb->DataLen > 0) { >> + if (Urb->Ep.Direction == EfiUsbDataIn) { >> + TrbStart->TrbCtrSetup.TRT = 3; >> + } else if (Urb->Ep.Direction == EfiUsbDataOut) { >> + TrbStart->TrbCtrSetup.TRT = 2; >> + } else { >> + DEBUG ((DEBUG_ERROR, "XhcCreateTransferTrb: Direction sholud be >> IN or OUT when Data exists!\n")); >> + ASSERT (FALSE); >> + } >> } else { >> TrbStart->TrbCtrSetup.TRT = 0; >> } >> diff --git a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c >> b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c >> index 32d72ef03c2d..5b9892a1cbbb 100644 >> --- a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c >> +++ b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c >> @@ -291,10 +291,15 @@ XhcPeiCreateTransferTrb ( >> TrbStart->TrbCtrSetup.IOC = 1; >> TrbStart->TrbCtrSetup.IDT = 1; >> TrbStart->TrbCtrSetup.Type = TRB_TYPE_SETUP_STAGE; >> - if (Urb->Ep.Direction == EfiUsbDataIn) { >> - TrbStart->TrbCtrSetup.TRT = 3; >> - } else if (Urb->Ep.Direction == EfiUsbDataOut) { >> - TrbStart->TrbCtrSetup.TRT = 2; >> + if (Urb->DataLen > 0) { >> + if (Urb->Ep.Direction == EfiUsbDataIn) { >> + TrbStart->TrbCtrSetup.TRT = 3; >> + } else if (Urb->Ep.Direction == EfiUsbDataOut) { >> + TrbStart->TrbCtrSetup.TRT = 2; >> + } else { >> + DEBUG ((DEBUG_ERROR, "XhcPeiCreateTransferTrb: Direction sholud >> be IN or OUT when Data exists!\n")); >> + ASSERT (FALSE); >> + } >> } else { >> TrbStart->TrbCtrSetup.TRT = 0; >> } >> -- >> 2.20.1.windows.1 > > . >