From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F29B8226D0F; Mon, 18 Aug 2025 13:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755523383; cv=none; b=m1+l2vAX+GP37tG5E7XtfUZ2zy3v5m+oHnZvIpMQSW1Kwc0heqBPNbWoEM3J6KiURMm/vMK/AGnMHNEDf8cYH7jWDktOjPXg07vWNvtD0MSfEu8/+adkPEtHOj+QonlhTITPS5Pr56gdOmYaGwP2xpNV9yWOHunU7sNBuwfa9+A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755523383; c=relaxed/simple; bh=OU5UH5e3Zn98ZrGoqR3XGOpA3mT0m1wdv/x82zy+jgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ebs/EfaaPVMcTkWB3qx2B+eG4PaUy/JB4Cnz5Rl2FWw2cqan7snU8P0qTwagrbKXF/aXQkuq64Vy3Qqll+Dg5Do3VZD0q4hmRbKljl0s8NNPyly9X29lNR6VzOsp98SmsMnoK8xnDJbDeviNhRATVK5NHoF8fucvsGNTWYoEsZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fzDxURKi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fzDxURKi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57864C4CEEB; Mon, 18 Aug 2025 13:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755523382; bh=OU5UH5e3Zn98ZrGoqR3XGOpA3mT0m1wdv/x82zy+jgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fzDxURKiW5dBW9iIlaTs5LPpVCGrcvab8oGCyw71b9LKE3+SDzBIzhM1838XdiTst Z7El1FyRYP6mtsYd+DjhtK1RGZDGXB7YT1tUWlpVj1avT5Ng8HoSZcqGcWQHdUBw9F JAROo/EC/Z7MS3tlwYte/6OIHzHaArHQdl8OtHtA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jay Chen , Mathias Nyman , Sasha Levin Subject: [PATCH 6.15 121/515] usb: xhci: Set avg_trb_len = 8 for EP0 during Address Device Command Date: Mon, 18 Aug 2025 14:41:47 +0200 Message-ID: <20250818124503.005229584@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250818124458.334548733@linuxfoundation.org> References: <20250818124458.334548733@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jay Chen [ Upstream commit f72b9aa821a2bfe4b6dfec4be19f264d0673b008 ] There is a subtle contradiction between sections of the xHCI 1.2 spec regarding the initialization of Input Endpoint Context fields. Section 4.8.2 ("Endpoint Context Initialization") states that all fields should be initialized to 0. However, Section 6.2.3 ("Endpoint Context", p.453) specifies that the Average TRB Length (avg_trb_len) field shall be greater than 0, and explicitly notes (p.454): "Software shall set Average TRB Length to '8' for control endpoints." Strictly setting all fields to 0 during initialization conflicts with the specific recommendation for control endpoints. In practice, setting avg_trb_len = 0 is not meaningful for the hardware/firmware, as the value is used for bandwidth calculation. Motivation: Our company is developing a custom Virtual xHC hardware platform that strictly follows the xHCI spec and its recommendations. During validation, we observed that enumeration fails and a parameter error (TRB Completion Code = 5) is reported if avg_trb_len for EP0 is not set to 8 as recommended by Section 6.2.3. This demonstrates the importance of assigning a meaningful, non-zero value to avg_trb_len, even in virtualized or emulated environments. This patch explicitly sets avg_trb_len to 8 for EP0 in xhci_setup_addressable_virt_dev(), as recommended in Section 6.2.3, to prevent potential issues with xHCI host controllers that enforce the spec strictly. Link: https://bugzilla.kernel.org/show_bug.cgi?id=220033 Signed-off-by: Jay Chen Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20250717073107.488599-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-mem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index a5e7980ac103..2a503de0a881 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1166,6 +1166,8 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud ep0_ctx->deq = cpu_to_le64(dev->eps[0].ring->first_seg->dma | dev->eps[0].ring->cycle_state); + ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(8)); + trace_xhci_setup_addressable_virt_device(dev); /* Steps 7 and 8 were done in xhci_alloc_virt_device() */ -- 2.39.5