From nobody Mon Feb 9 19:08:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548833986490623.5457431401616; Tue, 29 Jan 2019 23:39:46 -0800 (PST) Received: from localhost ([127.0.0.1]:33545 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gokTH-0008S2-EP for importer@patchew.org; Wed, 30 Jan 2019 02:39:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gokOT-0004v9-FB for qemu-devel@nongnu.org; Wed, 30 Jan 2019 02:34:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gokOR-00078L-TW for qemu-devel@nongnu.org; Wed, 30 Jan 2019 02:34:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gokOR-00074h-Fg for qemu-devel@nongnu.org; Wed, 30 Jan 2019 02:34:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E51F7804F5; Wed, 30 Jan 2019 07:34:34 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-190.ams2.redhat.com [10.36.117.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32854608C1; Wed, 30 Jan 2019 07:34:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8E8E57702; Wed, 30 Jan 2019 08:34:26 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 30 Jan 2019 08:34:23 +0100 Message-Id: <20190130073426.11525-6-kraxel@redhat.com> In-Reply-To: <20190130073426.11525-1-kraxel@redhat.com> References: <20190130073426.11525-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 30 Jan 2019 07:34:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/8] usb: implement XHCI underrun/overrun events 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: Yuri Benditovich , Eduardo Habkost , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yuri Benditovich Implement underrun/overrun events of isochronous endpoints according to XHCI spec (4.10.3.1) Guest software restarts data streaming when receives these events. The XHCI reports these events using interrupter assigned to the slot (as these events do not have TRB), so current commit adds the field of assigned interrupter to the XHCISlot structure. Guest software assigns interrupter to the slot on 'Address Device' and 'Evaluate Context' commands. Signed-off-by: Yuri Benditovich Message-id: 20190128200444.5128-3-yuri.benditovich@janustech.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.h | 1 + hw/usb/hcd-xhci.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h index fc36a4c787..240caa4e51 100644 --- a/hw/usb/hcd-xhci.h +++ b/hw/usb/hcd-xhci.h @@ -140,6 +140,7 @@ typedef struct XHCIPort { typedef struct XHCISlot { bool enabled; bool addressed; + uint16_t intr; dma_addr_t ctx; USBPort *uport; XHCIEPContext *eps[31]; diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 1a8fd9644e..19c64f7ff4 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1949,6 +1949,16 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, un= signed int streamid) while (1) { length =3D xhci_ring_chain_length(xhci, ring); if (length <=3D 0) { + if (epctx->type =3D=3D ET_ISO_OUT || epctx->type =3D=3D ET_ISO= _IN) { + /* 4.10.3.1 */ + XHCIEvent ev =3D { ER_TRANSFER }; + ev.ccode =3D epctx->type =3D=3D ET_ISO_IN ? + CC_RING_OVERRUN : CC_RING_UNDERRUN; + ev.slotid =3D epctx->slotid; + ev.epid =3D epctx->epid; + ev.ptr =3D epctx->ring.dequeue; + xhci_event(xhci, &ev, xhci->slots[epctx->slotid-1].intr); + } break; } xfer =3D xhci_ep_alloc_xfer(epctx, length); @@ -2028,6 +2038,7 @@ static TRBCCode xhci_disable_slot(XHCIState *xhci, un= signed int slotid) xhci->slots[slotid-1].enabled =3D 0; xhci->slots[slotid-1].addressed =3D 0; xhci->slots[slotid-1].uport =3D NULL; + xhci->slots[slotid-1].intr =3D 0; return CC_SUCCESS; } =20 @@ -2127,6 +2138,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, un= signed int slotid, slot =3D &xhci->slots[slotid-1]; slot->uport =3D uport; slot->ctx =3D octx; + slot->intr =3D get_field(slot_ctx[2], TRB_INTR); =20 /* Make sure device is in USB_STATE_DEFAULT state */ usb_device_reset(dev); @@ -2300,8 +2312,9 @@ static TRBCCode xhci_evaluate_slot(XHCIState *xhci, u= nsigned int slotid, =20 slot_ctx[1] &=3D ~0xFFFF; /* max exit latency */ slot_ctx[1] |=3D islot_ctx[1] & 0xFFFF; - slot_ctx[2] &=3D ~0xFF00000; /* interrupter target */ - slot_ctx[2] |=3D islot_ctx[2] & 0xFF000000; + /* update interrupter target field */ + xhci->slots[slotid-1].intr =3D get_field(islot_ctx[2], TRB_INTR); + set_field(&slot_ctx[2], xhci->slots[slotid-1].intr, TRB_INTR); =20 DPRINTF("xhci: output slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); --=20 2.9.3