Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1873459lql; Wed, 13 Mar 2024 10:23:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHyUrKDLcWGTx9VqK8kxXe2VWB0QKkZgbGoBHYTOuWUX1rKbLPzToYGVe2hBUATzCwUR9QzOAa4p8WEfUgnqpZQpjWf3UzQLqdAXi/Wg== X-Google-Smtp-Source: AGHT+IGF0G6jV9WrhKpjvQWMehUN0DDR+6X/1w2QC1CoQAdjtdLMYk3SrBKcdGFTy15QY1HkBO7f X-Received: by 2002:a05:6a21:789b:b0:1a1:3e6e:56fc with SMTP id bf27-20020a056a21789b00b001a13e6e56fcmr4522323pzc.14.1710350621571; Wed, 13 Mar 2024 10:23:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350621; cv=pass; d=google.com; s=arc-20160816; b=HHqSw7FQxX6dWNJc1bIdvNYpd1rgpH7A1V0joAjeg7Glqc0DkEEhuHJT6OM3kxJky1 3VH9v+PREa2ys39JeELoQKfYvXKX905YYGMzCGDw/P57MffZQ4yCtWQK6gWMm/dKojGv bgXbcEX9v0B0EyqLX+Ly1CYwnIdfze6K8m3kbYiBNBfzgz+wAlb5BSt2WyvpdN0seVqy +ilxNN8b8aosfyr+koukhrQQBZ9LrwOpEv3bHuXNzgNspkDQT7gi8s1URD+h03jCMhw/ nDDHKC5Fge2ckW6ygYKVEOxo1K2bxyHlYXhMFanQWmiNsfxrrgGWrKuQJIEpCdOUKzk1 ZObA== 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=aoZPqYMJgpRrXzLlTyV1qaYShnG+BiPHzWHUPP4fjJM=; fh=jQmGjFtT/7g87PxIEIvtCFfSuaF+X0fDNFv64fsJA6E=; b=zffxjBWorXA3YmM5PmbmsztPEG3bFFz41nSB6d5u8zUGtM2iGZr6M+ip4AqIs9J+yY PbSi3mw8/ZoBAMXF/EveAiRJDjkpcom334VZxyruICPgJNvAoV2lFDMCtm54zlTHpfCg zzOvMEuw/s8xx02b7j3W0Uq9iBuUbachBVC19RSm2BdHkrTfSWkC5p9BimOhsdRERDnE IEsVWH5ms6kezrEt1uzFbKwonJcIH9Hzg4zAFs+hnanCKEVrtvn5KdGaet+RXHz6nG/6 BYKcInqyd90Fs+osvUhfK0XV6zWJ/E1XP/q7/xIV9DtL26GbPbHN0ySNO2nGmp9pgM0e O6Xg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z8jax7Z/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101909-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b5-20020a17090a9bc500b0029bc35ddf0dsi1810827pjw.24.2024.03.13.10.23.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z8jax7Z/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101909-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 56E6728C5EA for ; Wed, 13 Mar 2024 17:13:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F73383CB4; Wed, 13 Mar 2024 16:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z8jax7Z/" 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 3104482D8C; Wed, 13 Mar 2024 16:40:48 +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=1710348048; cv=none; b=lvLWBCToEencZm4W6sgTyOK1TuNvYC5ZCJpKyCugrryI5E0txF0yoJ9qBc/Q4VPqPeRRp+u9BoieIP+Dl5DK+dQOgVcWo0MJ10Hly1AM/zFHPPr2zZveTXs7m6aMJTGEjYxTJazdxRpq3yycuycCg8HhGSEnLINy0X1JrYc+RVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348048; c=relaxed/simple; bh=7DWbzPl442ohtOHoxnzWDE6LolLZYu9I1GkNcad+P4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rwyAn2nCWlGdfXq/uvQbXkaKslnNsPo1+pk9qHxlGkO28ETmfy2k1djdgV78gSzBVyObZVb/orSGfrGo3ImIOh0wc8nx1MEPTSORE0ztP0B9AtXBa3pJEpHzqQIvL58dYamX3XNIuE1E2IU8dZYK4h6b06H3LhnX+qHg4Y7vtVw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z8jax7Z/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EB18C433C7; Wed, 13 Mar 2024 16:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348048; bh=7DWbzPl442ohtOHoxnzWDE6LolLZYu9I1GkNcad+P4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8jax7Z/JDBJSKJqLww7BllCTPB4w/mo1S91B+35UFa/1A4ix6jWzc02GdRSTCUYW 7HHIn2O8ymfdFQ5AnVobs73yX9lxwWVBR3UrJ2MnX2FpyK9sIRLBG2TaBY33BcDUvi wuxcZ9p/ZFT3s34ehwmYHNazpJKyLVZrwp2fcoFGmFxADBaCzn2LXWyHGvE90ECt/3 sw0sA6OpEgQdbE54nE0k7IxOLaw88+I74/YJQpmjdWhjSAg2i9gZlAMjpFGetZ1lZm dACBu53qrk+xoaxSIrujDYTrIz0p+Y2AwIl0ck0oK2THfClynyEoe0yOSDgDaBzeKF SdA9l0MT9naNA== 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 6.1 41/71] xhci: handle isoc Babble and Buffer Overrun events properly Date: Wed, 13 Mar 2024 12:39:27 -0400 Message-ID: <20240313163957.615276-42-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163957.615276-1-sashal@kernel.org> References: <20240313163957.615276-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/v6.x/stable-review/patch-6.1.82-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.1.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.1.82-rc1 X-KernelTest-Deadline: 2024-03-15T16:39+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 e4441a71368e5..239b5edee3268 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2381,9 +2381,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