From nobody Fri Dec 19 20:34:35 2025 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 F17D21487E1; Wed, 13 Mar 2024 16:43:18 +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=1710348199; cv=none; b=sCJbz6ZKCAc+TuloSJXAiZejEuyTwMqdUP1DhMV44Z1X788OdJJAnO/t5MjAP7cQfYvSu3DZ0e1gZjOmxUNtwG7Pp0J++AnsJwWW0Si4PbGtYk9l7e2DXTVWmB/B2tCZjxHLen8bLbfnunf1UA8kCIncnvTXXITqCkO54jnVY04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348199; c=relaxed/simple; bh=H/BEk14QfxxwzVTPYhHlI6B6JlzJZBjZ/A9OkanOfRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VuCM7MpCo2r9RA9hs7Xhxf3aYByWAiR6xFOsX4iDSVY7yME6bNwr7Cyvh9l23PkzfQ4HYkqNYyrAmt0zTwireveQotraRhkusATyeIC3UMV8Kfq736HMNdG+IdQ8CXApJOCDyJZdgzD5zkYbbDOEzPqjnnDtr8fwMNjgNnxt/Ok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N3yKTJJ+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N3yKTJJ+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CD9CC43399; Wed, 13 Mar 2024 16:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348198; bh=H/BEk14QfxxwzVTPYhHlI6B6JlzJZBjZ/A9OkanOfRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N3yKTJJ+ERKYk3btlyzFfdPIuCR84FbEuFP/iB3NhZp53HwyqnhNflhUmsKj/6FK1 QrtsaPupj8Rd9l9Jnw4BEsKNzcD5vO8wq8QOqYMJ9N+M/zKuRXXyJGnv0x0Oh6s45Z 64sRvyOeqEdfA89Q/owUy6Bfdv4+vbwBL+BCC8UqOEidxHtOzWqk/0iNC5jAUk6PDc qU8iMswFUGw/MpbIRr3ua77Gy7h+D3xPrGZ4OVgSKM0jdOD6gITpEtMxwhvcjmepjL kTVWA3KFtIVu26cX5FCAkDnCUfyA88WA7LANKqdi0wUiUBIXbZK4m6hYOrRk98bwYN Z5LDnUJkCCWPg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michal Pecio , Mathias Nyman , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 47/76] xhci: handle isoc Babble and Buffer Overrun events properly Date: Wed, 13 Mar 2024 12:41:54 -0400 Message-ID: <20240313164223.615640-48-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Michal Pecio [ Upstream commit 7c4650ded49e5b88929ecbbb631efb8b0838e811 ] xHCI 4.9 explicitly forbids assuming that the xHC has released its ownership of a multi-TRB TD when it reports an error on one of the early TRBs. Yet the driver makes such assumption and releases the TD, allowing the remaining TRBs to be freed or overwritten by new TDs. The xHC should also report completion of the final TRB due to its IOC flag being set by us, regardless of prior errors. This event cannot be recognized if the TD has already been freed earlier, resulting in "Transfer event TRB DMA ptr not part of current TD" error message. Fix this by reusing the logic for processing isoc Transaction Errors. This also handles hosts which fail to report the final completion. Fix transfer length reporting on Babble errors. They may be caused by device malfunction, no guarantee that the buffer has been filled. Signed-off-by: Michal Pecio Cc: stable@vger.kernel.org Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20240125152737.2983959-5-mathias.nyman@linu= x.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-ring.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7e88b65b694ad..31d355613933f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2446,9 +2446,13 @@ static int process_isoc_td(struct xhci_hcd *xhci, st= ruct xhci_virt_ep *ep, case COMP_BANDWIDTH_OVERRUN_ERROR: frame->status =3D -ECOMM; break; - case COMP_ISOCH_BUFFER_OVERRUN: case COMP_BABBLE_DETECTED_ERROR: + sum_trbs_for_length =3D true; + fallthrough; + case COMP_ISOCH_BUFFER_OVERRUN: frame->status =3D -EOVERFLOW; + if (ep_trb !=3D td->last_trb) + td->error_mid_td =3D true; break; case COMP_INCOMPATIBLE_DEVICE_ERROR: case COMP_STALL_ERROR: --=20 2.43.0