From nobody Thu Dec 18 22:25:25 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=1733992614; cv=none; d=zohomail.com; s=zohoarc; b=ZimtG4JrEVk5EM3kOJgc+QVpMAvFS1eF/W7k15o28xlB7/yzpIqe2aTRDHCYgbI8wJasCdB5dMSxkzzvMR9xqAbx4rlRfPvMArQkTETNVccnpmIfKWfAjBMCSs2nq955F6mQ3sia95HXrqWcF78g57IfiBtxxdnUhwTKKCMqY6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733992614; 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=sCY8QL0veLcvYLUXlMQP3OezQThH3JzWNYRzOQI/qEo=; b=YQ9uLcxOe0rWlFcWh3HrYoOZZKgLt4DlRMDMwfd3WicPhexkurFiq8lDP93A3JsLy6V0LSIS0IIyYxgfh/n0wJUknAZse5tVbx4NmwnTv/6S0f8kkvONWFxzCKuuaIklfKLTjQikcLaTI5IM+9qkNaxpvE183gJ7XmRGw1x1gLw= 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 1733992614799499.62340317204826; Thu, 12 Dec 2024 00:36:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLegP-0007B1-8t; Thu, 12 Dec 2024 03:36:29 -0500 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 1tLeg2-0006oj-6R for qemu-devel@nongnu.org; Thu, 12 Dec 2024 03:36:06 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLeg0-0005Ue-KS for qemu-devel@nongnu.org; Thu, 12 Dec 2024 03:36:05 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-21669fd5c7cso2665545ad.3 for ; Thu, 12 Dec 2024 00:36:04 -0800 (PST) Received: from wheely.local0.net ([1.146.48.169]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142dae788sm714624a91.12.2024.12.12.00.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 00:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733992563; x=1734597363; 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=sCY8QL0veLcvYLUXlMQP3OezQThH3JzWNYRzOQI/qEo=; b=blKIVvuXpkh85aY+R6R9hlfA4F0Q3+xo2vdso115SeMSznQV2/Ulv9TnAmQRgwxJE/ D2icVdoMVMFPxbDd/OtxxX+Et2jy/lYrhpXyArEiUXMbRGOZWZzZ+JbMagsJ6kF3x4SB XmY4ncqu99wjyvTEU8MEfBmJOh5mJqrfrLQNwrqPidGG7NJSfnmMHiL1BNqI58UdLkvd 9tfmDZ1sjaMVKzFcwQIpGADrLHz+ovqX/jGD+kHWNwFyjm9nDR+AW0kRzo5aBtAc4xrx V2pd7ojxT7OOGfl8qGm16WJAymbDUZzPMHtZRi6JNMsYj28eVE56ZalzlBFG/SwHiCuA g+5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733992563; x=1734597363; 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=sCY8QL0veLcvYLUXlMQP3OezQThH3JzWNYRzOQI/qEo=; b=mVKwcqkpFM+5xfTB6CvFedBpkKFdKjmbMRPQJ8YqF21/iG6q53XdXVAzRsyMXKN8T/ Ib9wz44b6jhEIFYqrZgE+cNJp782CNis75izbcVQSbVeB4KMU8MXcLqKvE4p27qEqQGo TIYppD/iFARy8z7zHbv8OPgr8Bpiwz7rVG9d2QNACnbMQLWfSTN2x2Q083RpSLL0L2pr 3A7ZmxzPG0uHk1Lq15NKw/GzgC1wIJoG0JUFsGOJqjkd3u5EWePUwWbi2do8rg8gm7S4 5IA35tDhmZdHi2f0HCPWVt+pLiWQgYiCFWakRANK3Bi90uzTFnSfaWyUFgccsTM9iv5C MixQ== X-Gm-Message-State: AOJu0Ywhtbi1RAcaZyAoCOjmv9UjCZycsgdaJJIY6lGa6Wi28GN/cAMO SUjuBF3k7zfXY0xQ/hQypYogYo/FxH84dhfD+LCub9bg00FwcCxdNZIEGQ== X-Gm-Gg: ASbGncsKM/Ms78vkyNRKSzbiQiLMS1wytrA7L/D5chVfYckLUUSviZDeqODD0ME2/uh ZeDPbyxbKfZwgRAtIHizTOVgkMDRoEhURqHUtrVayymtqWkBPwdAXjC246bIcxuGtdDc72IR47Y IvNyio1LGKCF6VSJ0e+zmBUzX4IMF+f0DmN/Mf5ql5eK93xFFBpigLvUSmg64KAlzJ9Ls+h4PRx YjJ+Vk6HwuD+7CSiD5U8P8Zja8L98uJAnrw/a8Qs2KtKB0ou/I135impNA= X-Google-Smtp-Source: AGHT+IG6HH6syHca/BoLf1y+YbDY3O/U+Ipp2m8X6xoXsEhz+Vx43TOWsfC62PWTuJqJFQTgAIbayQ== X-Received: by 2002:a17:90b:4ac4:b0:2ee:e18b:c1fa with SMTP id 98e67ed59e1d1-2f13930ba5cmr4149689a91.28.1733992561955; Thu, 12 Dec 2024 00:36:01 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , "Michael S. Tsirkin" , Marcel Apfelbaum , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Dmitry Fleytman , Akihiko Odaki , Sriram Yagnaraman Subject: [PATCH 7/8] hw/usb/xhci: Support TR NOOP commands Date: Thu, 12 Dec 2024 18:35:00 +1000 Message-ID: <20241212083502.1439033-8-npiggin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241212083502.1439033-1-npiggin@gmail.com> References: <20241212083502.1439033-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::631; envelope-from=npiggin@gmail.com; helo=mail-pl1-x631.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: 1733992616102116600 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 90273cd317e..844521e10f5 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1666,6 +1666,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) { @@ -1788,6 +1802,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) { @@ -1816,10 +1832,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.45.2