From nobody Mon Nov 25 11:49:29 2024 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A81918A92C; Mon, 28 Oct 2024 02:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084063; cv=none; b=pmbDbGBUL9AYUQRKACbUfF+04eBgBh2TtdKo9KGxfx3dfvs9efkGTavfUCiB7EaESwZlCqYEapPtE5yehBjcZ2OGSBJxPlVPJfKngcdSveHy6f0QMW07r1N33l0rMiokUh00SByZDXh11/SPIAbw++Nd4hVc4jIl7XHKZW1oeHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084063; c=relaxed/simple; bh=8yAOCH/5oVbc/VWtxtpJpnWwkugwBt/hyzC1N8Mplpo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=itLzRHLqOMjb329qUL60+D4ByFcmIIW8DsPZSoF05Pge4g4Fl6524dddJvXAMlfIBJRzLqHTwS9o7ujPB0zh0UFiYtQO6XHyZAfXTa2MX4NdLgd2eQcnFz6gU3uDzWDtunIttrLZgKcZlok0ohaRevJmcFR91koZYxsPIW20X4c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RWWQ+h+C; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RWWQ+h+C" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2e2a97c2681so2714613a91.2; Sun, 27 Oct 2024 19:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730084060; x=1730688860; darn=vger.kernel.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=icnzZRaIqKkWcfBQ8BZ/wsCIQ7yvPTT6fqKPWIQ7kVs=; b=RWWQ+h+CjqLZ0D6pSS1eBPlok3Eq9dAhkKLUvTD1tq2X5rUar6Sk8Khr+4/5XhbRHA W8UtYyM3QU2kh9ghLgY5IYXOgbymN047hq+GJCAmNtSn4BDAQIk3FS6FifOcJsrv3N/X ro5zuoaBvIyr42h/oSnMjtQJoA++hroVh8Ioxcqg3n/2078H8JNyv7680artNSL2ynfo T4dOGdT3FH26Th6tzKte/nE+dijA0f4RFUDAW/4eZWWN1QkeVfjfDvqr7L+6tN+KXcOl zAnLCx+KUhd5GLzauQM2qxh0pl8jzAbojpHvssjEoqVK/RtkCdxPPo/Ew+nHIhGL96e7 enHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730084060; x=1730688860; 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=icnzZRaIqKkWcfBQ8BZ/wsCIQ7yvPTT6fqKPWIQ7kVs=; b=bLWd+oEcJ8Ddhf8i0tV5KQhiVUkaBypQmSPpYBKV76FivZbYeP7Mr6rf4i4CIUlWfZ M/qTaiO65s/SK3qG9h/AYgdUQ4vsOch2VWgeMVS5acj85NdSXB2I4iPNZ1+RnTApdgaw czx0wrO+b5uA2UrxyInpkxw/wHft2WzmOAg2uTBQATzccCw2COuk85s4RsbexwDfJUOp ZdfB1h44jEdGDI5XlWPOoIY/tdvGWSDeteiZAacim6/IGOvD0JigseWqDAg7sZWRqe4/ Oqmm0JSzvvNJoPANCxadmXGslTSXMTK44v9VjPXTuWtveA8QkSN7S9+LmRQYMomMJi+0 sEYw== X-Forwarded-Encrypted: i=1; AJvYcCVAg+eiQ4StqdbY/0NbrwWuyrPUUzBorRBPWkjV4VHwaE66i1xNIFxvtdspG2adqYJh1Uep0/4f@vger.kernel.org, AJvYcCWQWRC10hg0VnX+CvYE4lPzInXJ0dMdsuA6Fho/5kwY1L6Pm2X7gb+mcxaHsoyA8fannFCok93Peze3qZQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyeOC7GyHLTZWqd9lkT4NXJUM2BauC81LYa5wSOTLcEFhxNmgFG kSWAvqBZpM/ibVUhFw6+lOwQ2Bec4ttiMvHXr+R0GuYldv9EDHR7 X-Google-Smtp-Source: AGHT+IF/DXrsSgB53/f+vdHvP5JHLMOMaohlipY5A+64+th+HvseCzk+rsVXgoEiH2HMAvyZoeY2PQ== X-Received: by 2002:a17:90b:3ec9:b0:2d3:da6d:8330 with SMTP id 98e67ed59e1d1-2e8f10507f6mr9070599a91.4.1730084060261; Sun, 27 Oct 2024 19:54:20 -0700 (PDT) Received: from kic-machine.localdomain (122-117-151-175.hinet-ip.hinet.net. [122.117.151.175]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4ca3fcsm8062236a91.13.2024.10.27.19.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 19:54:19 -0700 (PDT) From: Kuangyi Chiang To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ki.chiang65@gmail.com, stable@vger.kernel.org Subject: [PATCH v2 1/5] xhci: Combine two if statements for Etron xHCI host Date: Mon, 28 Oct 2024 10:53:33 +0800 Message-Id: <20241028025337.6372-2-ki.chiang65@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241028025337.6372-1-ki.chiang65@gmail.com> References: <20241028025337.6372-1-ki.chiang65@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Combine two if statements, because these hosts have the same quirk flags applied. Fixes: 91f7a1524a92 ("xhci: Apply broken streams quirk to Etron EJ188 xHCI = host") Cc: Signed-off-by: Kuangyi Chiang --- drivers/usb/host/xhci-pci.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 7e538194a0a4..33a6d99afc10 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -395,12 +395,8 @@ static void xhci_pci_quirks(struct device *dev, struct= xhci_hcd *xhci) xhci->quirks |=3D XHCI_DEFAULT_PM_RUNTIME_ALLOW; =20 if (pdev->vendor =3D=3D PCI_VENDOR_ID_ETRON && - pdev->device =3D=3D PCI_DEVICE_ID_EJ168) { - xhci->quirks |=3D XHCI_RESET_ON_RESUME; - xhci->quirks |=3D XHCI_BROKEN_STREAMS; - } - if (pdev->vendor =3D=3D PCI_VENDOR_ID_ETRON && - pdev->device =3D=3D PCI_DEVICE_ID_EJ188) { + (pdev->device =3D=3D PCI_DEVICE_ID_EJ168 || + pdev->device =3D=3D PCI_DEVICE_ID_EJ188)) { xhci->quirks |=3D XHCI_RESET_ON_RESUME; xhci->quirks |=3D XHCI_BROKEN_STREAMS; } --=20 2.25.1 From nobody Mon Nov 25 11:49:29 2024 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1C8A188917; Mon, 28 Oct 2024 02:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084073; cv=none; b=TEp9MCUa1u5OMflo3fdXPh3KZSGUaxOo0xQmfQepWrh5uygW3nm8NzhZpvC06J8NyS+KFBGCWnjgeDaQk52DPtFKSHGlv63kGMWidZ4xGHzQqqnFqW5Qh9dZSpxGdQ5eW8J5GpqMj2qVykm4X5b4DMj9n1Tqxc0NNs9rq6BVRSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084073; c=relaxed/simple; bh=THNvtpDf6RD8r1gTD1glpT99xqlWAFtlu/f8pbzGBCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ga5tEWCYY2wUrQM6KD4hRHe7V5vjrBv6JgRh4n2cAskNzi2H8XOEOBGIUc0HZw5+nszF6Qw/t1+QvDAjFNj8fQTNNtpYyA5pkjKJP4J8yeX6nxnfHAnYH5HvclF9udDY7/AQdfeROA8nIZqjTsfY8uTjlmTW7SY0+DRc/vGvpLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M9HUjyHo; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M9HUjyHo" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2e2e8c8915eso2947476a91.3; Sun, 27 Oct 2024 19:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730084071; x=1730688871; darn=vger.kernel.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=e6241+IQ+gPSntMSqtbQTA4Zs9SgWvlCVF1HFnw4CGA=; b=M9HUjyHozmTnbicX+JbJhLUgb0ij9AepUfvDnoJgZhUnrx2Kjv21t2y18hDlrRq1Kt gfhCPRgb/I98O7Cx8joeZcZlQSLJnR9A1lzL+TOT2SYtq7lfgFVnZ3oi+tvtkRuXNSD0 NumZVIc1oATs0SR2iuyvi+733PugYehX2TooWfMiPhiv6yvB76yqsfM0MDeu+Juw9scI QpMKQI9duwheXkG4Hoc+eveV3t3DYd7PfWWztNdAYYHv6xKQ9gZvzQEY8q/YP7MG/bsN R3h/iEE90EMZWMDFzVOBZRMTF+P/i47Zllg5N0rHtYjw3oti2yuDeXW7uItyHUrJr/k9 F/NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730084071; x=1730688871; 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=e6241+IQ+gPSntMSqtbQTA4Zs9SgWvlCVF1HFnw4CGA=; b=ECyq06/6/8m9bGn4YJzf7tbeD1nEsmgDYHfuxGgUit3A0Df6JZhvCySgpDtezwHuUt tfs+NuUxVVAy0G/vejU7u1w6c3ci9GvYa1iC+97CMJTDPv+PadaTcvId9accY1Tl5Cb3 VHMbcfvl4RSiH00KUZ5sDJCXcpqjZwpwuK5ZhlH18nzKayjywxjbdLlaQUIbACYpNIpy dnR7SSqTz8QbCuvfKA1kTv9/KbWwpqosbglGEnFI11dQdTyt7eHWS5ivKK2MQvVby/o1 jlex4SEISlaJnGXdw8t216KfFnoHz1Rb1SyvY8ml8icilD9NaQvuPIAnGBT910++b/N1 zKzw== X-Forwarded-Encrypted: i=1; AJvYcCVKE1sSdXUJCNTA8o8yzG0kDny1pzTIfqF3dkwvSfTCeJVWzfrhrgV2yvsQuud1OrsjfCLIu8nFIWz8yUk=@vger.kernel.org, AJvYcCXhxEVeJ4N52tpz6EXOfxUBdd9IXvhZypYkBENcRi8lvRLoqNng85P89jAd2VkgbAlsok1z5WXe@vger.kernel.org X-Gm-Message-State: AOJu0Yx55jFbxD1KkVDe97/a835GubDMre/PDmy7SzPcrV4WRY4E1ize qGCnqR3nD3s1rB/OWdlHFkriMn9AwvkBZJmbNpzH9xLBqR8+QJie X-Google-Smtp-Source: AGHT+IFlS+vzvtRYT2KLuakjh78ZcCJaADricoLgfFaHy4yT4yA05Pag436gSCJ6nNfRedkTfASBZA== X-Received: by 2002:a17:90a:1157:b0:2e0:b26c:906f with SMTP id 98e67ed59e1d1-2e8f11a879cmr8407834a91.27.1730084071030; Sun, 27 Oct 2024 19:54:31 -0700 (PDT) Received: from kic-machine.localdomain (122-117-151-175.hinet-ip.hinet.net. [122.117.151.175]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4ca3fcsm8062236a91.13.2024.10.27.19.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 19:54:30 -0700 (PDT) From: Kuangyi Chiang To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ki.chiang65@gmail.com, stable@vger.kernel.org Subject: [PATCH v2 2/5] xhci: Don't issue Reset Device command to Etron xHCI host Date: Mon, 28 Oct 2024 10:53:34 +0800 Message-Id: <20241028025337.6372-3-ki.chiang65@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241028025337.6372-1-ki.chiang65@gmail.com> References: <20241028025337.6372-1-ki.chiang65@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Sometimes the hub driver does not recognize the USB device connected to the external USB2.0 hub when the system resumes from S4. After the SetPortFeature(PORT_RESET) request is completed, the hub driver calls the HCD reset_device callback, which will issue a Reset Device command and free all structures associated with endpoints that were disabled. This happens when the xHCI driver issue a Reset Device command to inform the Etron xHCI host that the USB device associated with a device slot has been reset. Seems that the Etron xHCI host can not perform this command correctly, affecting the USB device. To work around this, the xHCI driver should obtain a new device slot with reference to commit 651aaf36a7d7 ("usb: xhci: Handle USB transaction error on address command"), which is another way to inform the Etron xHCI host that the USB device has been reset. Add a new XHCI_ETRON_HOST quirk flag to invoke the workaround in xhci_discover_or_reset_device(). Fixes: 2a8f82c4ceaf ("USB: xhci: Notify the xHC when a device is reset.") Cc: Signed-off-by: Kuangyi Chiang --- drivers/usb/host/xhci-pci.c | 1 + drivers/usb/host/xhci.c | 19 +++++++++++++++++++ drivers/usb/host/xhci.h | 1 + 3 files changed, 21 insertions(+) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 33a6d99afc10..ddc9a82cceec 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -397,6 +397,7 @@ static void xhci_pci_quirks(struct device *dev, struct = xhci_hcd *xhci) if (pdev->vendor =3D=3D PCI_VENDOR_ID_ETRON && (pdev->device =3D=3D PCI_DEVICE_ID_EJ168 || pdev->device =3D=3D PCI_DEVICE_ID_EJ188)) { + xhci->quirks |=3D XHCI_ETRON_HOST; xhci->quirks |=3D XHCI_RESET_ON_RESUME; xhci->quirks |=3D XHCI_BROKEN_STREAMS; } diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 899c0effb5d3..ef7ead6393d4 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3692,6 +3692,8 @@ void xhci_free_device_endpoint_resources(struct xhci_= hcd *xhci, xhci->num_active_eps); } =20 +static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); + /* * This submits a Reset Device Command, which will set the device state to= 0, * set the device address to 0, and disable all the endpoints except the d= efault @@ -3762,6 +3764,23 @@ static int xhci_discover_or_reset_device(struct usb_= hcd *hcd, SLOT_STATE_DISABLED) return 0; =20 + if (xhci->quirks & XHCI_ETRON_HOST) { + /* + * Obtaining a new device slot to inform the xHCI host that + * the USB device has been reset. + */ + ret =3D xhci_disable_slot(xhci, udev->slot_id); + xhci_free_virt_device(xhci, udev->slot_id); + if (!ret) { + ret =3D xhci_alloc_dev(hcd, udev); + if (ret =3D=3D 1) + ret =3D 0; + else + ret =3D -EINVAL; + } + return ret; + } + trace_xhci_discover_or_reset_device(slot_ctx); =20 xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index f0fb696d5619..4f5b732e8944 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1624,6 +1624,7 @@ struct xhci_hcd { #define XHCI_ZHAOXIN_HOST BIT_ULL(46) #define XHCI_WRITE_64_HI_LO BIT_ULL(47) #define XHCI_CDNS_SCTX_QUIRK BIT_ULL(48) +#define XHCI_ETRON_HOST BIT_ULL(49) =20 unsigned int num_active_eps; unsigned int limit_active_eps; --=20 2.25.1 From nobody Mon Nov 25 11:49:29 2024 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90F701885BE; Mon, 28 Oct 2024 02:54:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084084; cv=none; b=CK0YxpNTKmpbWm1fkRUpEU9thFSUxdTN+FxFmZMBWg1ax8WLytsa8P94Mhy7LnxeOZjZnEQu7hV8boebjphQWT8JxBX+m2JCSk1ZNVl515PnAYjrXO9q3WVRLsXeHfvd30FnWwnukJojzjxwMBRhadJRoU3ZPbgLJmBsjozOyFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084084; c=relaxed/simple; bh=4bVMTJO1yGoBazKUkcY3SKAuFa2zfFXwwrJaUJPJrOQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J5W5xMi+oR8lUfm4TgnakZs/QJYE28guBRpIET8todfFAFn4Wfwi8QcYqQgd5GhqR7Maa02CLAD1ALTtLHmU5TLGMVZ+82K/rmzFOKBnfjjRPMFjXrr4jwFzU1dZNxMHjZC6L2B/QB0OPBqkCPn37AcXq4/TuthgczgBhZowq/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OWj7mImb; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OWj7mImb" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2e2a97c2681so2714719a91.2; Sun, 27 Oct 2024 19:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730084082; x=1730688882; darn=vger.kernel.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=Ad7qNqPRwzi69bvd1QX3RJsedo6Iqsq69Lx8P2N8p58=; b=OWj7mImbS+57MGJdVeixMyunQDZipDPnmjACX4I59bfzXLCKK/ymNAX+pJG3vsN6Xf EStxmoW9ZsQZdfwYFlfRTXnb0/HoR7+D6nv3bkWAa6PzP1c5PTT+Hle1HbZSs6sOWysX VkOvjaxEZHuzu76b4Ya/fdm9oKbOBrrOzN2HUXilYurqKftfRSRQcQ8PhCUX5dWSiYJg LDZo5d8BUxM8wFwR0cHu2/d80VzV3+xliMhJXQgwTZuIB+WTD2MdXFpK5I2Gl9WARZ3z iuGEDrUFIIS1KqeoDJsDeL4T2oq5lNmMxPwk7VXbwU4jYPSfmNGsnYCEiXtoUNHfGB7n uMGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730084082; x=1730688882; 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=Ad7qNqPRwzi69bvd1QX3RJsedo6Iqsq69Lx8P2N8p58=; b=L9GqqneQIZLAI0uT++KBmAcp6b0VyHr1nvH2W1zOTmCbmTdQEmqe8nKsy9UHNe5JQe dYc0+QkdHESIV7mKb6p2upzL/63sJEM6ix1C+LrHiCkiRCHOTHtLbXCSjfPE1Bn5iQc4 cjImL+u27HAqOQUOYVLnEAMdt+7H2wqK803+Sm7sr7Mf18QnSH2ZFx8qoSEeIgsu5FX+ 4/2JZZZ/5lrCmjiq7LBuTgmeG37AAjyMrO+ppH4LCc9OPv0lh1q2E4wm/j3O2BRNdKu4 2eQgrlVv5I6dOPHJ6nzxPesZrh19w1vsI7nWJHWMd/tkEWiUL4v5WHfauyewTXgv1BIz XDjg== X-Forwarded-Encrypted: i=1; AJvYcCX8iWpJWYZY1myQ+74hmi2oPK++vbme7p2gEFp40NCTvsu0ZecSw+kdegygdJ3G+qGJVh2yvT9q1JXwLAY=@vger.kernel.org, AJvYcCXlVRTMIlsWqkGMRJ5NxSQKJFrl4/amgSbNCi3rKFsN1veyls44GXEtSkVIZ2VcQq1GICS6qJud@vger.kernel.org X-Gm-Message-State: AOJu0Yz+vfOKhXJfGMGQuw7xbqRXdvB2NSTzSjk3UKuZbI5ioYBkY0UZ nutb3U32tOZbCrjXoPDU3+U9z6KMGeGS18DgC4LnRx5DWZMtUefD X-Google-Smtp-Source: AGHT+IHJHR4KTwPQNs9iH7vI16zhLaBn6np4PZGNBpaLV3Am8NktDzUH/HuIEMx0pZxcly3R7IfPGw== X-Received: by 2002:a17:90a:68c9:b0:2d8:a672:1869 with SMTP id 98e67ed59e1d1-2e8f11a82bcmr8393426a91.32.1730084081791; Sun, 27 Oct 2024 19:54:41 -0700 (PDT) Received: from kic-machine.localdomain (122-117-151-175.hinet-ip.hinet.net. [122.117.151.175]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4ca3fcsm8062236a91.13.2024.10.27.19.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 19:54:41 -0700 (PDT) From: Kuangyi Chiang To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ki.chiang65@gmail.com, stable@vger.kernel.org Subject: [PATCH v2 3/5] xhci: Fix control transfer error on Etron xHCI host Date: Mon, 28 Oct 2024 10:53:35 +0800 Message-Id: <20241028025337.6372-4-ki.chiang65@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241028025337.6372-1-ki.chiang65@gmail.com> References: <20241028025337.6372-1-ki.chiang65@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Performing a stability stress test on a USB3.0 2.5G ethernet adapter results in errors like this: [ 91.441469] r8152 2-3:1.0 eth3: get_registers -71 [ 91.458659] r8152 2-3:1.0 eth3: get_registers -71 [ 91.475911] r8152 2-3:1.0 eth3: get_registers -71 [ 91.493203] r8152 2-3:1.0 eth3: get_registers -71 [ 91.510421] r8152 2-3:1.0 eth3: get_registers -71 The r8152 driver will periodically issue lots of control-IN requests to access the status of ethernet adapter hardware registers during the test. This happens when the xHCI driver enqueue a control TD (which cross over the Link TRB between two ring segments, as shown) in the endpoint zero's transfer ring. Seems the Etron xHCI host can not perform this TD correctly, causing the USB transfer error occurred, maybe the upper driver retry that control-IN request can solve problem, but not all drivers do this. | | ------- | TRB | Setup Stage ------- | TRB | Link ------- ------- | TRB | Data Stage ------- | TRB | Status Stage ------- | | To work around this, the xHCI driver should enqueue a No Op TRB if next available TRB is the Link TRB in the ring segment, this can prevent the Setup and Data Stage TRB to be breaked by the Link TRB. Check if the XHCI_ETRON_HOST quirk flag is set before invoking the workaround in xhci_queue_ctrl_tx(). Fixes: d0e96f5a71a0 ("USB: xhci: Control transfer support.") Cc: Signed-off-by: Kuangyi Chiang --- drivers/usb/host/xhci-ring.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b6eb928e260f..9e132b08bfde 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3727,6 +3727,20 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t = mem_flags, if (!urb->setup_packet) return -EINVAL; =20 + if ((xhci->quirks & XHCI_ETRON_HOST) && + urb->dev->speed >=3D USB_SPEED_SUPER) { + /* + * If next available TRB is the Link TRB in the ring segment then + * enqueue a No Op TRB, this can prevent the Setup and Data Stage + * TRB to be breaked by the Link TRB. + */ + if (trb_is_link(ep_ring->enqueue + 1)) { + field =3D TRB_TYPE(TRB_TR_NOOP) | ep_ring->cycle_state; + queue_trb(xhci, ep_ring, false, 0, 0, + TRB_INTR_TARGET(0), field); + } + } + /* 1 TRB for setup, 1 for status */ num_trbs =3D 2; /* --=20 2.25.1 From nobody Mon Nov 25 11:49:29 2024 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE786186E56; Mon, 28 Oct 2024 02:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084098; cv=none; b=PD7O7jP22kbIaR3EdCqnpFeQrdehPf2NJq3WkDfUAbTKow/RPyilKG/unjL63UZ9bIyyd8F6KZCtzD11RvScftoBT0BDCsUgcdErJUn2zAxHLXBugpBGe6i3yBo2VNQZ8S0CXryEQ8zmbsr3Ta+Uw2aVogKdMAwbTu11zfbbtFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084098; c=relaxed/simple; bh=8aJ72J3uShMo3aQrLTV90CjREd5Jx3aaV+9tVdJCtZ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tCukwqf74N3MvrurFtOjds0QMGsvcPSStZLTsh9gZyv61ElTYS6ce0TCp2BvralMvDYKY4KZicA0X4EnmTYMIm0LKBVw3TidJVq3H6yn2i8FnxgKFFoCsxgirQe2qPNLSc3CpEgPtIBQphKu5TMNU5hmwmluusq2vre0lhKsI6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BHbKlpiU; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BHbKlpiU" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2e2b9480617so3039125a91.1; Sun, 27 Oct 2024 19:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730084096; x=1730688896; darn=vger.kernel.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=nSvONcZYerkXhxJYp5FBOVnq9rockH+jmTpBlMHJfrs=; b=BHbKlpiUhpbWUGlQZ8kXL5amtxRNL/E4fA+H4tltp0JTTnCdCjdJFJPe1kEByQrsoA ipxWJhtBT6p+OpB/Z6qcbef3u+qhSc+iETy7wW9lDgPTJFw4SRfY342iFR80E5gvprME 2LTkT7tEEmAXkaYlAtRTppDl2hNwswYZVvetNEdlGxr6qN8FWx7M54QUJeMS8uH2F2qM Q3MJ1HEk7JCIPh0l8yrIhD7Rn2sGHxHV/HgUyHMhu/uQM6WLtjJWMMjpGLIU0DfKRnND RbDXGw4oua1E28WngnNTKozKNRv+dcbC3kKRFYdsXJCIgvdcxIHEw0NKfH4nBfBqQ/ha XHKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730084096; x=1730688896; 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=nSvONcZYerkXhxJYp5FBOVnq9rockH+jmTpBlMHJfrs=; b=d7xtbs0Mwa3MXfS0oL9EY3pPKCsGU3+3YHHjC/ek8P/AX335ktPypLuyaNktH3+vlw 53+ZJ0wX5Cg0z4TsGWWd2EtaYT8ZL5nCZ8iC9DwS3u68ugosWSSKy/YUzPTVdLz2A796 /PKAx/P6iYA+HwVmvqtKySH+CdiS+F9bmvLJRseF++eSLvGWRPsdACtXwrE+J/OhduYa cGrpCWzTgBTPmblflmN5g5gp46ZYBoGzNtJ26rHRnG0HxjlkAxfDwXUSrUdUeho+MJm/ rz7yjOiTpj2fd/umsG2Qb7JRnm5pWPBPtslexGHeXrd6JMPkChA0SB9wLWSMRnhgz7mA cYvg== X-Forwarded-Encrypted: i=1; AJvYcCU+mTDop+BO0RPG9OjLNjvBnQIMl/XAB27XxP5d3IJ1J3KwoWQN3kbZ85izFcXeN7bjbQRQ7G/Q@vger.kernel.org, AJvYcCX0SDWh2r7xZYMeSakLBNsUq4+rb27nFYJOPFJPE+BDmFm0nMkAumGQw7+DlqlPAVonpPZXInequBtzhfU=@vger.kernel.org X-Gm-Message-State: AOJu0YwWSyHplG6yQjDnt3RZiwJ3SK7lFWRS5dur03xWzCEfA/pI4Xep Cn03OYoF9IYEf02yVoQcYhdG8DAnYt2Qfn8jYTRmbBCsRy6kokku X-Google-Smtp-Source: AGHT+IHkvyPe2PiqNYzslfpIG+xTD3M2I/RWCiYR6TBRNnErJYy7MhV0TUPoUnGvJaQvg4J6Na+GZA== X-Received: by 2002:a17:90a:9a86:b0:2da:8e9b:f37b with SMTP id 98e67ed59e1d1-2e8f107c738mr8471784a91.24.1730084095917; Sun, 27 Oct 2024 19:54:55 -0700 (PDT) Received: from kic-machine.localdomain (122-117-151-175.hinet-ip.hinet.net. [122.117.151.175]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4ca3fcsm8062236a91.13.2024.10.27.19.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 19:54:55 -0700 (PDT) From: Kuangyi Chiang To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ki.chiang65@gmail.com, stable@vger.kernel.org Subject: [PATCH v2 4/5] xhci: Don't perform Soft Retry for Etron xHCI host Date: Mon, 28 Oct 2024 10:53:36 +0800 Message-Id: <20241028025337.6372-5-ki.chiang65@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241028025337.6372-1-ki.chiang65@gmail.com> References: <20241028025337.6372-1-ki.chiang65@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since commit f8f80be501aa ("xhci: Use soft retry to recover faster from transaction errors"), unplugging USB device while enumeration results in errors like this: [ 364.855321] xhci_hcd 0000:0b:00.0: ERROR Transfer event for disabled endp= oint slot 5 ep 2 [ 364.864622] xhci_hcd 0000:0b:00.0: @0000002167656d70 67f03000 00000021 0c= 000000 05038001 [ 374.934793] xhci_hcd 0000:0b:00.0: Abort failed to stop command ring: -110 [ 374.958793] xhci_hcd 0000:0b:00.0: xHCI host controller not responding, a= ssume dead [ 374.967590] xhci_hcd 0000:0b:00.0: HC died; cleaning up [ 374.973984] xhci_hcd 0000:0b:00.0: Timeout while waiting for configure en= dpoint command Seems that Etorn xHCI host can not perform Soft Retry correctly, apply XHCI_NO_SOFT_RETRY quirk to disable Soft Retry and then issue is gone. This patch depends on commit a4a251f8c235 ("usb: xhci: do not perform Soft Retry for some xHCI hosts"). Fixes: f8f80be501aa ("xhci: Use soft retry to recover faster from transacti= on errors") Cc: Signed-off-by: Kuangyi Chiang --- drivers/usb/host/xhci-pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index ddc9a82cceec..f2ca0b912977 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -400,6 +400,7 @@ static void xhci_pci_quirks(struct device *dev, struct = xhci_hcd *xhci) xhci->quirks |=3D XHCI_ETRON_HOST; xhci->quirks |=3D XHCI_RESET_ON_RESUME; xhci->quirks |=3D XHCI_BROKEN_STREAMS; + xhci->quirks |=3D XHCI_NO_SOFT_RETRY; } =20 if (pdev->vendor =3D=3D PCI_VENDOR_ID_RENESAS && --=20 2.25.1 From nobody Mon Nov 25 11:49:29 2024 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63D3118858E; Mon, 28 Oct 2024 02:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084108; cv=none; b=FCi3mm+5ghc3DgfC/pPBU3B8iyz+C2A9Adcxf/R/VEu62GBRpRQ4KFLs1WaxoFZtdli68o6sHG8rxCFMJwa/2cDlhh6dA43sQxcxS9tFtsatqpKNzngXl8GBD8lBYh0+Bb90lGTpv6TQlSl6B7xD+vFaNTtIFo0rQzcWspRxd1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730084108; c=relaxed/simple; bh=OvqEXPqvXBkzuyq/8dwNHAkExETVfjQgts5CQ+WWSdI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZG3CBfamBcYhCBK/Q6mcq1oYN70I79KfENSrx9O4KjUEdNlQfIn+TkoUwTMw3RlSh1kJ6AggN1NBcQKKnJxwOj0ZKfOyCYDp+niA6prk/2XacWenSHk/IWke0nWDiHADgcaN7w64xI0VJXgFenGvpaeGuafmlqtIKpBPhLVEXkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hrcj6PaW; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hrcj6PaW" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2e2bb1efe78so2510267a91.1; Sun, 27 Oct 2024 19:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730084106; x=1730688906; darn=vger.kernel.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=/7R76DTFIGHT3/ZwOkD+UOJ8gdIJ1q/s6dEZm9rOVzM=; b=hrcj6PaWXOEwLTnk9l4HwmbWTVSCyCTE1f09v31TjaH1qC+B1uUmZPz+r9/SFGZc7r 6WI/uZ/MWH6RLwm3iQbtqMpO97ivjPfKxIL11+af93IThIAjkrjrIhVxgOaz90FgsGH8 z9rW/vub2aIhBqS/J0YXyAoNNuCe3K+KsCusR9jY7U7Tya3YhdL3jv43bJPKUOkZEIl0 Q6lQidjnbNdw56100gB6zIfCS4BuqNjZCKFz+JzwEdGzttCK8vYk44mZ0HHLMPFf9/hh D+wU9+WMoL5JB7IGpHgYQmECjIf88eQ2C+1V1TncK3HqZSakY5CuGUB1yb4aUpZFfMgf bUtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730084106; x=1730688906; 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=/7R76DTFIGHT3/ZwOkD+UOJ8gdIJ1q/s6dEZm9rOVzM=; b=eHisj7HeckPBIBM7Yx5lxMvPGKdwqMDEHRDdVzMGDK8iG/ZXKGRdPCZv5oSulx3K1O BFRiJ6qgVuHVVIujl/N+CKIP6miJjX8EE6kYOYNuXWOV73t6ntuNOsu7EKxXxfdalN3X y1fZeTNJJhtXqNGFglxwzWScgdyO1n1kHMadx7jG+o86QeQtxmoSPR6CitW/Cc1/QqPW Xvf46HI28nV9oqhgKNJAUZ4zam2/KzkwJdhS3qfIkr4cZK0zYsMwfXCMO0CQMMtdZrwc 0gdEPXDwRqiXT3t6V03rSrW92oqN2TYycMDkXcQVPq44ZhaW8tewDfl8HjCXlbCjKGsI KtEA== X-Forwarded-Encrypted: i=1; AJvYcCVmvqD61jPbsy2xfOCeefTKtZCtOIjos4Yi0yn9JrCn+vkyQSg/oYBEXeRZpAoFE1DpuknzaTUOReK2K1w=@vger.kernel.org X-Gm-Message-State: AOJu0YycNTOU3FfTlpp0MSMz95nho1Eqn/wXQP/XvEvFI5LSECin3GEU KX0sykmocXqw9bpTReVgdg8SB6Z5mZCShuI7BdRKoyffanj15l/liyA32w== X-Google-Smtp-Source: AGHT+IES92iz8ovreAv3UEhDJQFHin9vugvKJpXlxX5PqYxDCIWhKr79Y4P6gqNMgc0xEQaI+AD6gw== X-Received: by 2002:a17:90a:68c5:b0:2c9:6abd:ca64 with SMTP id 98e67ed59e1d1-2e8f076cfadmr10477605a91.9.1730084105616; Sun, 27 Oct 2024 19:55:05 -0700 (PDT) Received: from kic-machine.localdomain (122-117-151-175.hinet-ip.hinet.net. [122.117.151.175]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4ca3fcsm8062236a91.13.2024.10.27.19.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 19:55:05 -0700 (PDT) From: Kuangyi Chiang To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ki.chiang65@gmail.com Subject: [PATCH v2 5/5] xhci: Correct handling of one-TRB isoc TD on Etron xHCI host Date: Mon, 28 Oct 2024 10:53:37 +0800 Message-Id: <20241028025337.6372-6-ki.chiang65@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241028025337.6372-1-ki.chiang65@gmail.com> References: <20241028025337.6372-1-ki.chiang65@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Unplugging a USB3.0 webcam while streaming results in errors like this: [ 132.646387] xhci_hcd 0000:03:00.0: ERROR Transfer event TRB DMA ptr not p= art of current TD ep_index 18 comp_code 13 [ 132.646446] xhci_hcd 0000:03:00.0: Looking for event-dma 000000002fdf8630= trb-start 000000002fdf8640 trb-end 000000002fdf8650 seg-start 000000002fdf= 8000 seg-end 000000002fdf8ff0 [ 132.646560] xhci_hcd 0000:03:00.0: ERROR Transfer event TRB DMA ptr not p= art of current TD ep_index 18 comp_code 13 [ 132.646568] xhci_hcd 0000:03:00.0: Looking for event-dma 000000002fdf8660= trb-start 000000002fdf8670 trb-end 000000002fdf8670 seg-start 000000002fdf= 8000 seg-end 000000002fdf8ff0 If an error is detected while processing an one-TRB isoc TD, the Etron xHC generates two transfer events for the TRB that the error was detected on. The first event is "USB Transcation Error", and the second event is "Success". The xHCI driver will handle the TD after the first event and remove it from its internal list, and then print an "Transfer event TRB DMA ptr not part of current TD" error message after the second event. As a solution, we can set the flag after the first error event and don't print the error message after the second event if the flag is set. Commit ad808333d820 ("Intel xhci: Ignore spurious successful event.") implements a similar mechanism that we can reuse to solve this problem since short transfer and transfer error doesn't occur concurrently. Also, rename the flag to make it more meaningful. Check if the XHCI_ETRON_HOST quirk flag is set before invoking the workaround in process_isoc_td(). This patch doesn't affect other host controllers that have the XHCI_SPURIOUS_SUCCESS quirk flag applied. Signed-off-by: Kuangyi Chiang --- drivers/usb/host/xhci-ring.c | 26 +++++++++++++++----------- drivers/usb/host/xhci.h | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 9e132b08bfde..33fa8a11c934 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2437,6 +2437,10 @@ static int process_isoc_td(struct xhci_hcd *xhci, st= ruct xhci_virt_ep *ep, sum_trbs_for_length =3D true; if (ep_trb !=3D td->last_trb) td->error_mid_td =3D true; + if ((xhci->quirks & XHCI_ETRON_HOST) && + td->urb->dev->speed >=3D USB_SPEED_SUPER && + td->first_trb =3D=3D td->last_trb) + ep_ring->spurious_event =3D true; break; case COMP_STOPPED: sum_trbs_for_length =3D true; @@ -2655,8 +2659,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, case COMP_SUCCESS: if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) !=3D 0) { trb_comp_code =3D COMP_SHORT_PACKET; - xhci_dbg(xhci, "Successful completion on short TX for slot %u ep %u wit= h last td short %d\n", - slot_id, ep_index, ep_ring->last_td_was_short); + xhci_dbg(xhci, "Successful completion on short TX for slot %u ep %u wit= h spurious event %d\n", + slot_id, ep_index, ep_ring->spurious_event); } break; case COMP_SHORT_PACKET: @@ -2801,13 +2805,13 @@ static int handle_tx_event(struct xhci_hcd *xhci, if (list_empty(&ep_ring->td_list)) { /* * Don't print wanings if ring is empty due to a stopped endpoint genera= ting an - * extra completion event if the device was suspended. Or, a event for t= he last TRB - * of a short TD we already got a short event for. The short TD is alrea= dy removed - * from the TD list. + * extra completion event if the device was suspended. Or, the spurious = event flag + * is set at the last TD of the TD list due to a short transfer or an on= e-TRB isoc + * TD error, and such TD is already removed from the TD list. */ if (trb_comp_code !=3D COMP_STOPPED && trb_comp_code !=3D COMP_STOPPED_LENGTH_INVALID && - !ep_ring->last_td_was_short) { + !ep_ring->spurious_event) { xhci_warn(xhci, "Event TRB for slot %u ep %u with no TDs queued\n", slot_id, ep_index); } @@ -2851,11 +2855,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, =20 /* * Some hosts give a spurious success event after a short - * transfer. Ignore it. + * transfer or an one-TRB isoc TD error. Ignore it. */ if ((xhci->quirks & XHCI_SPURIOUS_SUCCESS) && - ep_ring->last_td_was_short) { - ep_ring->last_td_was_short =3D false; + ep_ring->spurious_event) { + ep_ring->spurious_event =3D false; return 0; } =20 @@ -2884,9 +2888,9 @@ static int handle_tx_event(struct xhci_hcd *xhci, } while (ep->skip); =20 if (trb_comp_code =3D=3D COMP_SHORT_PACKET) - ep_ring->last_td_was_short =3D true; + ep_ring->spurious_event =3D true; else - ep_ring->last_td_was_short =3D false; + ep_ring->spurious_event =3D false; =20 ep_trb =3D &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) / sizeof(*ep_trb)]; trace_xhci_handle_transfer(ep_ring, (struct xhci_generic_trb *) ep_trb); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 4f5b732e8944..dca9091b8134 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1359,7 +1359,7 @@ struct xhci_ring { unsigned int num_trbs_free; /* used only by xhci DbC */ unsigned int bounce_buf_len; enum xhci_ring_type type; - bool last_td_was_short; + bool spurious_event; struct radix_tree_root *trb_address_map; }; =20 --=20 2.25.1