From nobody Mon Feb 9 07:11:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529966405730953.8901963909069; Mon, 25 Jun 2018 15:40:05 -0700 (PDT) Received: from localhost ([::1]:49571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXa9Q-00055v-O7 for importer@patchew.org; Mon, 25 Jun 2018 18:40:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXZxP-0003J0-Sl for qemu-devel@nongnu.org; Mon, 25 Jun 2018 18:27:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXZxM-0004b1-JD for qemu-devel@nongnu.org; Mon, 25 Jun 2018 18:27:35 -0400 Received: from relay4.mail.vrmd.de ([81.28.224.58]:58473) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fXZxM-0004Zv-Bo for qemu-devel@nongnu.org; Mon, 25 Jun 2018 18:27:32 -0400 Received: from [94.223.86.198] (helo=murray.fritz.box) by relay2.mail.vrmd.de with esmtpa (Exim 4.86_2) (envelope-from ) id 1fXZxC-000XAn-Ok; Tue, 26 Jun 2018 00:27:23 +0200 From: Sebastian Bauer To: mail@sebastianbauer.info Date: Tue, 26 Jun 2018 00:27:18 +0200 Message-Id: <20180625222718.4488-1-mail@sebastianbauer.info> X-Mailer: git-send-email 2.17.1 X-Relay-User: mail@sebastianbauer.info X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 81.28.224.58 Subject: [Qemu-devel] [PATCH] ehci: Don't fetch a NULL current qtd but advance the queue instead. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Fetching qtd with the NULL address most likely makes no sense so from now on, we handle it this case similarly as if the terminate (T) bit is not set, which is already an exception as according to section 3.6 of the EHCI spec there is no T bit defined for the current_qtd field. The spec is a bit vague on how an EHCI driver should initialize these fields: "The general operational model is that the host controller can detect whether the overlay area contains a description of an active transfer" (p. 49). QEMU primarily uses the QTD_TOKEN_ACTIVE bit of the queue header to infer the activity state but there are other ways conceivable. This change allows QEMU to boot further into AmigaOS. The public available version of the EHCI driver recycles queue heads in some rare conditions but only clears the current_qtd field but not the status field. This works with many available EHCI PCI cards but e.g., not with the Freescale USB controller's found on the P5040. On the emulated EHCI controller of QEMU the consequence is that some garbage was read in, which resulted in a reset of the controller. This change fixes the problem. Signed-off-by: Sebastian Bauer Tested-by: BALATON Zoltan --- The fix is probably not the best solution. However, it is one that is very small. QEMU still warns that an active qh will be changed if the qh is recycled, so more changes could be done. But I didn't notice any negative consequences implied by the warning so I would leave a possible fix to this problem to a further patch. --- hw/usb/hcd-ehci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 0134232627..e5acfc5ba5 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1672,7 +1672,8 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci,= int async) ehci_set_state(ehci, async, EST_HORIZONTALQH); =20 } else if ((q->qh.token & QTD_TOKEN_ACTIVE) && - (NLPTR_TBIT(q->qh.current_qtd) =3D=3D 0)) { + (NLPTR_TBIT(q->qh.current_qtd) =3D=3D 0) && + (q->qh.current_qtd !=3D 0)) { q->qtdaddr =3D q->qh.current_qtd; ehci_set_state(ehci, async, EST_FETCHQTD); =20 --=20 2.17.1