From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 035B735966 for ; Tue, 4 Aug 2026 10:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785837680; cv=none; b=qVsURdLmDH7fesoXPRGkBoLIJBVoO94qleGt9aiMb8c0KJWIfWov5rJvbJBjfcM5CWSHTCiqVfusKb58sgBMlTrVhnT5GTXxK2m4fREPyCruXHprIuxyrvp2B4tn9E41jBpTMmEzDuIE5Dw622WEp9E39xdB0rZoZgHDvzbKKKQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785837680; c=relaxed/simple; bh=bf9E1OT/5MsAiXVjLqoVX53ARQezQ/P1MffsZjiEV+E=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=awXFcP9/fGntNQi1hOzDUe0WKBQS5fyEQuCDcQVDd3zwWExDvCexanmygkOKGKTM7UBhaWyXYPKjBjh0pgddJimtlEUYzBiiUtPuBHlle6koPMI+6el+yNusAqtlNVgfGRbCs3MhBD8VmPGWeGdGrkyg8xPf8k56YrETetV93TY= 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=QZQ4+zw1; arc=none smtp.client-ip=209.85.128.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="QZQ4+zw1" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-49548e01d02so17196925e9.0 for ; Tue, 04 Aug 2026 03:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785837677; x=1786442477; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yZR9jSlKe7g6Silg9pcPprlK6JN19RsyTKeQ3eWYjJc=; b=QZQ4+zw1nD+9btmlkPVCq0ZWURG/8adjJbYRJJfGd7WFv92DuzSnVd5bPMRql+AcAw QiPehb3yNxhpvm6BpBrpML2ZrpC/O1+q1MbEpqVrvexyst0KzbHuwQli4euxyUhZR44r +TsMLHybcPq20I7MJjslzXsMd2IYqMxNfPxuFfHl4Hb77wmcTc+Xmurx89Wejgr6HNFA Shn+uXFbN8TdCKIOXLtuKEJR9I0XcQB4H0LBCoOK2+8fTbwaL2l+5xiH/s1JiPY0k3fW GvPf9l9pn2QEkXGGPIhKGeyEnYJYQkjym1dz07SMaOIbZPjaxPvFTDAbl7Rf3AXUtWQP Bfjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785837677; x=1786442477; h=content-transfer-encoding:content-type:mime-version:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=yZR9jSlKe7g6Silg9pcPprlK6JN19RsyTKeQ3eWYjJc=; b=b5xelVwzDRwR2JCsC1P70Vu0RDXo+BC6SN9Go+xkSJd1sUc3G6jvPcpsbIc2WWiAQk FAvx4r5fAln+zSULM191i3nHgDpoGBUFL67D+feYaeeX42790Za0oWvmHCVor9tQTaad iuW97X4tmBp9TqV1TY5ZEZ7+X1RilJUzp7faqgQEYdZntG4gKaDlcBf0LsA1VG0iNNQa 4bdwTL5cf7iAYky3qqS+7kJrLzboNp31c/lo3Vf30jAZm9Xbtl6CbPXWRUogtUUSnF2g TEtQLA8H5aMTcTQNDv3IKSJ5sQkKw9dtdAE3AG736ekP69HWU5IbwP2UCTF5jbcXsKd1 fO6Q== X-Forwarded-Encrypted: i=1; AHgh+RrbMZBWWnfkmVBZ3c/GN5dV+mZEYS1qi9AuJIzhdq6Y8VfdroHet3sHrwQZGaOBp1nHHSdQgwgWmmMVvHI=@vger.kernel.org X-Gm-Message-State: AOJu0YyY0Lm243Ylp+CpTkSmViyoDgSMyLmdf902g7wClTAdS+Lj34VG lg3Eo32thXn0xVoMz0OyTi5PlaC+lesssmkEcrBHKNI0/bx7IScEkOFK X-Gm-Gg: AR+sD13G54/bkZnHLzRabT+Dl3BtAautd2sj1Ka4Wv747rFAEkeharW6i2Llo9npOua mWUzIcDQsLzdJ3wxd5CqSZOzw2kQs6U8gG0q6E5d77yif2pLYD9zZUZRXtCVvUi3vwiyM6B/k7U +Q5tIaKRKQbB1ABLAA28297VIFrKdXSt7b70tIlcqvSSnlOJABLsa++xBNWYSfLdyuFxEPInKv2 KI/PIJVfwyg3TEAtsxJr6Dxgxp8TtlCbo6K82cBBoYm5HrqblhPkBLK+2+npRm9f/olpJJZNuzd PtQb737xqjuFib/HgnBCz9A9eGtz96V+qyHuIhL8Qo8yIflpMQ72QEnxmOxk/5d4QyUz93C0I2W wedWmsTizXoiM0FBdoTR9uQLQ5ag/SBMHwUkGUvmXGn6xNOm2VmxcYaEqIjp7T46MeuJYv+Tvf1 DdVRxThJhKaEs6RB8qRMfNTzvlAJ2KcenEWsSUyjdlqxXbs6brPLmwICzw3W8efZPG/q7KB2kE X-Received: by 2002:a05:600c:698e:b0:499:49f3:77b1 with SMTP id 5b1f17b1804b1-49949f377d2mr95203705e9.3.1785837676750; Tue, 04 Aug 2026 03:01:16 -0700 (PDT) Received: from foxbook (bgt135.neoplus.adsl.tpnet.pl. [83.28.83.135]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49807bb45ebsm228697455e9.4.2026.08.04.03.01.15 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 04 Aug 2026 03:01:16 -0700 (PDT) Date: Tue, 4 Aug 2026 12:01:10 +0200 From: Michal Pecio To: Mathias Nyman , Greg Kroah-Hartman Cc: Bart Nagel , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/5] xhci: Sort out the TD skipping business Message-ID: <20260804120110.01bda0e2.michal.pecio@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi, This series is motivated by a recently found rare regression due to my commit from last year and the solution suggested by Mathias Nyman. https://lore.kernel.org/linux-usb/al_hchyOdPoPWKEo@spiral/ I think it's a good solution not only for this specific case, but also in general, because the next event after Missed Service Error almost always references some TD - exceptions are Ring Underrun, which we have special handling for, and Stopped - Length Invalid, which would be a rare occurrence, not currently supported anyway, and possible to support within the proposed framework by making find_td_by_dma() calculate accurate 'missed_tds' value while still returning NULL. The first two patches fix bugs, because I found another obscure one. The next two patches prepare for the last one by simplifying things. The last patch implements the big change, the whole matching/skipping loop is replaced with a more straightforward and robust version. New functionality is paid for with a net increase of 4 LOC, not too bad. I gave this a bit of testing and it seems to be working, including weird cases like: Missed Service Error retires a waiting TD with error_mid_td, then skipping is triggered by another Transaction Error immediately afterwards, and it turns out that two TDs were missed. [ 1665.224921] xhci_hcd 0000:0a:00.0: Transfer error for slot 1 ep 2 on endpoint [ 1665.225151] xhci_hcd 0000:0a:00.0: Missed Service Error for slot 1 ep 2, skip 1, try now 0 [ 1665.225156] xhci_hcd 0000:0a:00.0: Missing TD completion event after mid TD error [ 1665.225305] xhci_hcd 0000:0a:00.0: Transfer error for slot 1 ep 2 on endpoint [ 1665.225308] xhci_hcd 0000:0a:00.0: Skipped 2 TDs on slot 1 ep 2 comp_code 4, TD found 1, skip flag 0 Additional testing of patch 1 in isolation would be appreciated from the reporter of the regression (Cc). That patch would go to v6.18. Regards, Michal Michal Pecio (5): usb: xhci: Handle bogus TRB pointers in Missed Service Error events usb: xhci: Guarantee URB giveback on Ring Underrun/Overrun usb: xhci: Don't set the skip flag on non-isoc endpoints usb: xhci: Shorten the TD skipping loop usb: xhci: Rework and improve the TD matching and skipping logic drivers/usb/host/xhci-ring.c | 200 ++++++++++++++++++----------------- 1 file changed, 102 insertions(+), 98 deletions(-) -- 2.48.1