Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1885581lql; Wed, 13 Mar 2024 10:47:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXdrMZbvwwblGUVKoDtZ6iWK8Br6V6EZ65Rz+tx/+TczUC0AOOMqvNHF9VCaawfhyJY7uhN8JMkVmwfXkdLsfbPemQ0/FGoWugYKdNgFQ== X-Google-Smtp-Source: AGHT+IHF8tjPKqeAdD5/dYoWbFvf78KASlx9J+bJ2DM7LusGOKRps7mD87cMwWKP5ezhEB+bCSPb X-Received: by 2002:a17:902:dac7:b0:1dd:8cab:21da with SMTP id q7-20020a170902dac700b001dd8cab21damr4835977plx.11.1710352079158; Wed, 13 Mar 2024 10:47:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710352079; cv=pass; d=google.com; s=arc-20160816; b=eGippRm4EiKzehee6XfSk/SehqCJpRTucNKhUfoBmQ2T4RlyWfXHxAyXJmTFA7A3eJ InSjyIO7ioEfM26qGVkbasuNO8kVJ+WRIwf6UsvumArcBJX390+QyEkcR2U6bM9c+oxl Abic/HXD1NLiyXCR7TGDoX9fCzw01Dx08hEgYCD/GpJem+RiUw8yplykSGqk7erSTGoE ziF99QU3jISAbpfIP2EdHIKJVMflZMyzFmFF21hrm47uoNNzi7VCLb+uKKkFdE3h8UkP B2/pu4+NrndOOQ+0WA65fIDvIrsHf4c4cIESjFqhD8DH1ixlz/JQfGN0guILYj72mm2h FdIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rgPOwnU43+htrF1hIGJM+t2O40uXOyzgo7pMZ0ficBI=; fh=jQmGjFtT/7g87PxIEIvtCFfSuaF+X0fDNFv64fsJA6E=; b=O4wAEMeKSp88zy8F/nWreGnHkAx++h/q5g1sNhb7cHvMUhdqyGTi3Xz83io5VjWnvA 5/qVW4LxW2BhU07nx0jQsv/2DNLdBat/v0B24w5q72+6/m/O2G+l7ArIcngjHvuRyCVT GHUi4zKvjL7p8Kv7gzKGEySZi+7NptyLV/dfhktBuztAz5UlR1yMpKwh4WiL9kCH0vpr 3YFmF04kWnLmn5SeYVkwFaDeLpZP4IDs+X9Y6+zaNOKeJVgSHWgeErKziS/2cOGU1+PN 3Fqdq0n5l+OPnlFxYXjRq6rnQ0/g1oDUe/aWlQ8jWkr2K8u9+h3MsyY2uDtXXdClyYvW pjzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N3yKTJJ+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x9-20020a170902a38900b001dd7fc45425si8560305pla.56.2024.03.13.10.47.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:47:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N3yKTJJ+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 458A4B2359F for ; Wed, 13 Mar 2024 17:32:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3B5A148FE0; Wed, 13 Mar 2024 16:43:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N3yKTJJ+" 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 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: 8bit 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@linux.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, struct xhci_virt_ep *ep, case COMP_BANDWIDTH_OVERRUN_ERROR: frame->status = -ECOMM; break; - case COMP_ISOCH_BUFFER_OVERRUN: case COMP_BABBLE_DETECTED_ERROR: + sum_trbs_for_length = true; + fallthrough; + case COMP_ISOCH_BUFFER_OVERRUN: frame->status = -EOVERFLOW; + if (ep_trb != td->last_trb) + td->error_mid_td = true; break; case COMP_INCOMPATIBLE_DEVICE_ERROR: case COMP_STALL_ERROR: -- 2.43.0