From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3580F2110BD5C for ; Fri, 31 Aug 2018 07:03:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 783FD401EF02; Fri, 31 Aug 2018 14:03:35 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-58.rdu2.redhat.com [10.10.120.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ECF32027EA0; Fri, 31 Aug 2018 14:03:32 +0000 (UTC) From: Laszlo Ersek To: edk2-devel-01 Cc: Gerd Hoffmann , Jian J Wang , Ruiyu Ni , Star Zeng , Steven Shi Date: Fri, 31 Aug 2018 16:03:30 +0200 Message-Id: <20180831140330.26888-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 31 Aug 2018 14:03:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 31 Aug 2018 14:03:35 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: [PATCH] MdeModulePkg/EhciDxe: fix host controller reset condition in BindingStart X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2018 14:03:36 -0000 Commit 09943f5ecc0f ("MdeModulePkg: Skip to manage usb debug port in EDKII EHCI driver if it's used by usb debug port driver", 2012-04-28) made the host controller reset in EhcDriverBindingStart() conditional. The intent was to avoid the reset when - one of the USB ports on the host controller was a Debug Port, AND - the Debug Port was in use. This translates to the following positive condition: reset the controller only if: - no USB port on the host controller is a Debug Port, OR - the Debug Port is not in use. Commit 09943f5ecc0f failed to implement the first subcondition, and thus the result is too strict now (for resetting the host controller). Relax it to the correct condition. This issue was found by Steven Shi on QEMU. QEMU's EHCI device model does not have a Debug Port. In repeated disconnect / connect cycles, the controller is never reset in EhcDriverBindingStart(), therefore the devices on the controller are never re-enumerated after a disconnect. Cc: Gerd Hoffmann Cc: Jian J Wang Cc: Ruiyu Ni Cc: Star Zeng Cc: Steven Shi Reported-by: Steven Shi Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1129 Fixes: 09943f5ecc0fbc0c98c511c82703a0ba3b2b5819 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek --- Notes: Repo: https://github.com/lersek/edk2.git Branch: ehci_start_reset_1129 MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c index 30ad2b2ffeef..89ed034b9093 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c +++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c @@ -1916,11 +1916,13 @@ EhcDriverBindingStart ( // if (FeaturePcdGet (PcdTurnOffUsbLegacySupport)) { EhcClearLegacySupport (Ehc); } - if (Ehc->DebugPortNum != 0) { + if (Ehc->DebugPortNum == 0) { + EhcResetHC (Ehc, EHC_RESET_TIMEOUT); + } else { State = EhcReadDbgRegister(Ehc, 0); if ((State & (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) != (USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_OWNER)) { EhcResetHC (Ehc, EHC_RESET_TIMEOUT); } } -- 2.14.1.3.gb7cf6e02401b