From nobody Sat Nov 15 23:36: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=1746156828; cv=none; d=zohomail.com; s=zohoarc; b=Mx6YlqvwVdi6E5hQt/5nVfLgkVq4IbwqvFXvphw2nrTpR3UyS5nw0BbHLPDq7BdTppHdGScB89EoFa9udBHNhVHG3N7JWH6+qBw77KROoipIWqRwL0aD1XJFQ8q8JHvvr8/KtzgfzJvlBzQ//R11lRrPO5Ob0vdCcMMBVn1KAI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746156828; 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=1lmS65fZf1hovgzPaFQwZvs4bM/iLU2g3QpGdLfzqQg=; b=BT2DSD2iVg22ghm8sW11Z3DD7OiQ1fL/bt3kdgWwKtae7Q+Pi2pLEVWwTGDUnS0j3X2TVrBplh56SIY/vnvJEi9RpJmuUMAkm0Dc2GGhJ7He4hLveRuEfCVkM4NClr+z2Imb8rY0ajZ5V0ejJcQMTcenDLMiXSg2sR+ven2ht2Q= 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 1746156828183108.47555823229663; Thu, 1 May 2025 20:33:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAh7o-0004DJ-Lp; Thu, 01 May 2025 23:31:45 -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 1uAh7c-0004AQ-P5 for qemu-devel@nongnu.org; Thu, 01 May 2025 23:31:32 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uAh7b-0001GP-22 for qemu-devel@nongnu.org; Thu, 01 May 2025 23:31:32 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-736c1cf75e4so1530695b3a.2 for ; Thu, 01 May 2025 20:31:30 -0700 (PDT) Received: from wheely.local0.net ([220.253.99.94]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74059063f6esm488055b3a.139.2025.05.01.20.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 May 2025 20:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746156690; x=1746761490; 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=1lmS65fZf1hovgzPaFQwZvs4bM/iLU2g3QpGdLfzqQg=; b=frU3hhTnhO8zK6M92RKOhGxBtXIDgwb3AtPtob2nChiO/5JKGuYcHQX/nqUtLWuMbX NrCZQC64DfWBkHGA4+5GI/xjQOddVh8jWgK1OB4dpMqoleJ7aGwcM501I5jhSwEXJKIb EsOMZKHdAqbmxEsoPfSlCkMo76GwLDTZh5EmQQgy0ujasyPeL75TRW7fDcT9Ao32xLj5 dngVwLRdurFLJH7pNcfF201sS0hIqQP4PjouAqQXIiRTaJjw0XEByzW0sRkvcc4aNrc8 V3xeXMDJzicR+pagonX9tBK6vb2DIyT0mSlO+InT9LOOA1ZW/yQeVkIDZyKnMsAw2hss +CBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746156690; x=1746761490; 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=1lmS65fZf1hovgzPaFQwZvs4bM/iLU2g3QpGdLfzqQg=; b=IkMW/aVZl3xlfhuTCG1JVW9G07a/5Nup31Su+f3llti/8bx/U4KFo1mL7j1LAAMdaD IWV0KzvPejPy+10iQxRRrhWsI/tjfvoGrhz/M5EMLbW03iLROkJtCpomJMapt2pv9RIi Upxc3QUgHarOZ+ukSAxw27CKD/JUT/6rc6D/zUygj1zMvRDn5chfh7EpfH+6oTRmEDRh wJNDxskJJD3S5Ic77veh8lMBSLZ/xA0KKTKU61oZk3u1IbkKyWNPihLPV6y4CWjyRKKE RxZlh5+OTkJNLEOKy0/ctt+Ph1H1WavyTlL7rqC3ft1Te1yXXMoEPH4oCMUanDgJ+wj0 1J+w== X-Forwarded-Encrypted: i=1; AJvYcCV0A5gBS0cl71RBk/0cykEs4aSjR8/NeqCxa82D/UPmWyTMbycfbrOJfo/pyLg6Cb/jIS5qfERdon/9@nongnu.org X-Gm-Message-State: AOJu0Ywb8BxnsQRBHOvYVNTH2NGM4p7tNaxiondtQT3nTzSvA7kVf2Zx 4A3i4HEEaMl07lUPKob4y4ZgKeeawygEEpSEPf3/8L/ROCE9eLlG X-Gm-Gg: ASbGncv97atwXS6KUqkxPz0lwlxTQC8rZlcM60pwQE1xCRGnMzeKOFIx3BuKDNzdRWb Nyzy3kYazU31TyoPhCuQBEwHmypV2T/zpmmSwwsrK6YrEsTL3MZVBbyYLSWUUP09VobtCQydSa9 woEP7FNP//9D0pz7kNcW+dMlv5glqJZt7oOXcSQcYowPLHRlCrz9mToj5EKdAYFw0iJF/nUa5YP bQ6myrSe5PT9UYsMwyhzCElqbRJXsTMPNd90Aeoodf84RxtCXJRtrqY/fVJs6tt6FnXvb1Zrttt 4WP7Y+ZxunswOtzRKk6laZTCYcXHBnPDmZK9Gajh2WPf X-Google-Smtp-Source: AGHT+IEu6VlXM40BhVUfDkOtcaxFsZzttNGo+ZBqotB3iXtqlqr4Prb78Mc+2b7k8vONhS8F2v99UQ== X-Received: by 2002:a05:6a21:b8a:b0:1d9:c615:d1e6 with SMTP id adf61e73a8af0-20cdc1ec1d6mr1999394637.0.1746156689651; Thu, 01 May 2025 20:31:29 -0700 (PDT) From: Nicholas Piggin To: Gerd Hoffmann Cc: Nicholas Piggin , qemu-devel@nongnu.org, Kevin Wolf , Paolo Bonzini , "Michael S. Tsirkin" , Marcel Apfelbaum , Fabiano Rosas , Laurent Vivier , Phil Dennis-Jordan , Bernhard Beschow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 06/22] hw/usb/xhci: Support TR NOOP commands Date: Fri, 2 May 2025 13:30:30 +1000 Message-ID: <20250502033047.102465-7-npiggin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250502033047.102465-1-npiggin@gmail.com> References: <20250502033047.102465-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::42d; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42d.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: 1746156829427019100 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 Reviewed-by: Peter Maydell --- 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 ef9f2a7db41..6a490a5febf 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1664,6 +1664,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) { @@ -1786,6 +1800,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) { @@ -1814,10 +1830,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