From nobody Sun Nov 16 02:26:29 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1744358442; cv=none; d=zohomail.com; s=zohoarc; b=C3lBQN+1ddYJeIcDhks7M0aegLo+msCspQdAVcXna2huxxkCB8DiUNKCtp8grw48SCHLI/WCvZYtkI19xO6esAdvnfBCohdZGtgYa7Nwd/6Z0bKmiHKFjqQBiHL2ONw3vwhA6lrYluRRuWdK+Tmtw3Un+Pq0ksO1oS0IWFog120= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744358442; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7TtNN7VYXgzvwVBu/O4Bb4s2j9QKOdcKj2T3Ii/pMqs=; b=aluJLTUnT+4xnF3cfONs8T92pJndCCDAJ1fFcoTXPrrRK0IzPLJjPahMRv2W8T3CmUqSiJ5rIDmFWpl85d4BU1nSPfGAmhpfz1SgXZaXP54LGRqsby9uEaZnctlD45bXpli1cdsmJiDLrT5fxcAQA+w5jZ1L7JOD2YxNg+5Vmdk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1744358442566793.3070282426328; Fri, 11 Apr 2025 01:00:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u39IO-0002KC-OZ; Fri, 11 Apr 2025 03:59:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u39II-0002Jq-PY for qemu-devel@nongnu.org; Fri, 11 Apr 2025 03:59:22 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u39IF-0003sO-QK for qemu-devel@nongnu.org; Fri, 11 Apr 2025 03:59:21 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-736e52948ebso1931731b3a.1 for ; Fri, 11 Apr 2025 00:59:19 -0700 (PDT) Received: from wheely.local0.net ([220.253.99.94]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73bd233554asm851687b3a.180.2025.04.11.00.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Apr 2025 00:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744358358; x=1744963158; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7TtNN7VYXgzvwVBu/O4Bb4s2j9QKOdcKj2T3Ii/pMqs=; b=Xf9NJ1H7c/E4cb1d7gx8MV/qzTrAMkY/k6CjYqWSpRf2qds01KTBcBv2FrKN4WYXL+ pzNBgIa0X8ZvXkSJ0pqT2H5uQ9P/Vr62yxqW3ZejJnaOitza9Rin2ep5iG4DaYAnvj2W fhyD9MCgGsHWQeEc4mXkPFlGaEJvdgDG5xDJhtyTIzYtcAOVrmFgyAwfkUujreOw/qAf Pf5R0r3DjrZYegPCyZooOArfx9Kpg9Dfa6sWDO3f9ZYoH2u6Yo5jGSFpfqGqxqdU18Bz NymaGxqQRdltm/Gk26S9AeIilfMnqvuszuUOk42Jz1ld5ifDPWOLKb02eQi1AuFu0ZcB zwPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744358358; x=1744963158; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7TtNN7VYXgzvwVBu/O4Bb4s2j9QKOdcKj2T3Ii/pMqs=; b=ev5Ex5jKVBbo4rOZ5nUEwr1SUfgn2FJm706GWC8544HBa7JpqEcSBLdFkoIu+EmChX St4OoVNeR6hhSnNhjnViEOe3/1ugsVHb8p/5NrhEbDqz+vTMJGg9oalqyYtVrvQQNU0T EAMzFS7Wn3OMJM2Epnmqot2DHK8wS9lsy6NYb7s5B/oS32LaPOyD9/TjfXzrcsm4LoBL 9uyqCNhHag3yIm5I8/PTN24xHKwrn8OIGRhE8taxbgCma8bOcx0U2Gc2ES5eTEyWyCHr YBsRIt5Var2qYLx6pd23I/NewVbo2c5OYptl5LQSRsfV0oNeTs75TV70SM9m3AbUTeuM Lc+w== X-Gm-Message-State: AOJu0YyYsPv8MZMRO5XXa9HP+40otUGPDZ8QnXbkGRXgCGdhVJYAGNdU I93fdeWjWm3m+eiEvL/qJUT3XIDqq3cPidhi6C3XUkA6uHqt/PJ6NHwS4w== X-Gm-Gg: ASbGnct/i3zYVHWmcBci1Df3HoJn9l148PGKGmDmD4Ua6uO2eRr8Levs2S5mtoCWaFy P15YemvQQagAhRQBGXRYgBjbsl9RQlhnoLfjSLK+L4UwqxFDNE3lWLteb9O/NdVRecFMPlWzgjC T8Ibjdv3SaDLMV1xtX3SYQd95AWr5CH5bEM670u9ptQI1H7VaAycDGfOq4AjFirkbTOBjWAG9Nn b0pjmN1b+eLwC3HxXOfy5HdlfmoNSCxhRKPVU6aRuxb0La2+wNE1mb2dP5z9n1fBsMieYNi3WNh VFEXDReRTJnPP61WBm596xBiaqPfm+nYJiYBHxXKM2QL X-Google-Smtp-Source: AGHT+IE0DMpSWXRu9LNSwjUU/l6gz3TgLWTDyMr0d32sCGo0eafl385tCnskLmhQ5KrHMZuRcd7jVg== X-Received: by 2002:a05:6a00:2443:b0:736:a8db:93b4 with SMTP id d2e1a72fcca58-73bd11b500bmr2581387b3a.2.1744358357849; Fri, 11 Apr 2025 00:59:17 -0700 (PDT) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Paolo Bonzini , "Michael S. Tsirkin" , Marcel Apfelbaum , Fabiano Rosas , Laurent Vivier , Phil Dennis-Jordan , Bernhard Beschow Subject: [PATCH v3 4/8] hw/usb/xhci: Support TR NOOP commands Date: Fri, 11 Apr 2025 17:58:46 +1000 Message-ID: <20250411075851.206995-5-npiggin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250411075851.206995-1-npiggin@gmail.com> References: <20250411075851.206995-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1744358445020019000 Content-Type: text/plain; charset="utf-8" Implement XHCI TR NOOP commands by setting up then immediately completing the packet. The IBM AIX XHCI HCD driver uses NOOP commands to check driver and hardware health, which works after this change. Signed-off-by: Nicholas Piggin --- hw/usb/hcd-xhci.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 88973c485d1..b6f65628db7 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1663,6 +1663,20 @@ static int xhci_fire_transfer(XHCIState *xhci, XHCIT= ransfer *xfer, XHCIEPContext return xhci_submit(xhci, xfer, epctx); } =20 +static int xhci_noop_transfer(XHCIState *xhci, XHCITransfer *xfer) +{ + /* + * TR NOOP conceptually probably better not call into USB subsystem + * (usb_packet_setup() via xhci_setup_packet()). In practice it + * works and avoids code duplication. + */ + if (xhci_setup_packet(xfer) < 0) { + return -1; + } + xhci_try_complete_packet(xfer); + return 0; +} + static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid, unsigned int epid, unsigned int streamid) { @@ -1785,6 +1799,8 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) =20 epctx->kick_active++; while (1) { + bool noop =3D false; + 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) { @@ -1813,10 +1829,20 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, u= nsigned int streamid) epctx->kick_active--; return; } + if (type =3D=3D TR_NOOP) { + noop =3D true; + } } xfer->streamid =3D streamid; =20 - if (epctx->epid =3D=3D 1) { + if (noop) { + if (length !=3D 1) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: NOOP TR TRB within TRB chain!\n", __fun= c__); + /* Undefined behavior, we no-op the entire chain */ + } + xhci_noop_transfer(xhci, xfer); + } else if (epctx->epid =3D=3D 1) { xhci_fire_ctl_transfer(xhci, xfer); } else { xhci_fire_transfer(xhci, xfer, epctx); --=20 2.47.1