From patchwork Wed Nov 6 10:14:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13864327 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 7FE6B1DE3CA; Wed, 6 Nov 2024 10:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730887998; cv=none; b=or2fzkcjqjChXsxvJnhr3AMFDLvxuwU4W3iz0/jsOWxWt3D7A6Zu29sT4ApoZLYWHy0w3/lCPkIcdVw3sE0MDZmh5UH0FcUfprCv1fBRBM8Kx+ekXMs3EXNA6v65n0WPxDV2LWkEVZA1lw+S1V4Z4irNrQIJvga3blO8yazKcoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730887998; c=relaxed/simple; bh=aKZ6V63J9JW78flvSmlum82Zf2Y5tv9KBNFKrzKjKno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rnBqDh0MB+BjbCgq4NV3iwD9K6mvKktIjqTk2AuR9pL5MyBq24D+iZPVcqisMsiGaSbJH9r9NRZSfgTJfPCqwLghFdaObrDhAoYOAMIaAyuB+M9FkmN4IpMXM6aPYyWWp0K6FpHOtN0Lkd1e54MvBYDuRbYggrKL1Yu9BP7oS2U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YwDbyymG; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YwDbyymG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730887996; x=1762423996; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aKZ6V63J9JW78flvSmlum82Zf2Y5tv9KBNFKrzKjKno=; b=YwDbyymGTPupPBFhyk6EqdF6GnrPrhGMXYjBVzhJBdrnoPX2S3R0S5Pm MqSbefmSd0P7pKpz+tLGQ2rHrWQHRitUaEscuHn5a/BvbSSyK/n8u0veS GFdCVNV5S4kBDLDfBLB3APT0BgPyEjNCLh5aZ+q2ypzFEWo36TLvPRFFl EbdobboXoGLJk7FkQlOn6QYkU+19mkXAafH6ZNFTy8Edv8Di6pzPt0/8W sokjHXYwAQpO0zvVnF4iWv1XG8tBbEeVquV1EQLPOLtQf2FKqLynxR5ld 5+4bxbgHOCkAX6accPR0LVksBHMPQVS+BozUjpt3Yqzs6oiKEYG4cYTax A==; X-CSE-ConnectionGUID: M/uADl8oSy2p9N1sA0dFKg== X-CSE-MsgGUID: 8vdn2/JuQ1OTMPy6DG+kQA== X-IronPort-AV: E=McAfee;i="6700,10204,11247"; a="42059428" X-IronPort-AV: E=Sophos;i="6.11,262,1725346800"; d="scan'208";a="42059428" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2024 02:13:16 -0800 X-CSE-ConnectionGUID: OP/7ER/MQ7urgMszywnmeQ== X-CSE-MsgGUID: 7uBlzzTITsW05iiWjpX0kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,262,1725346800"; d="scan'208";a="84813255" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa010.fm.intel.com with ESMTP; 06 Nov 2024 02:13:14 -0800 From: Mathias Nyman To: Cc: , Kuangyi Chiang , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 19/33] xhci: Fix control transfer error on Etron xHCI host Date: Wed, 6 Nov 2024 12:14:45 +0200 Message-Id: <20241106101459.775897-20-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241106101459.775897-1-mathias.nyman@linux.intel.com> References: <20241106101459.775897-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kuangyi Chiang 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 Signed-off-by: Mathias Nyman --- 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 f62b243d0fc4..517df97ef496 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3733,6 +3733,20 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, if (!urb->setup_packet) return -EINVAL; + if ((xhci->quirks & XHCI_ETRON_HOST) && + urb->dev->speed >= 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 = 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 = 2; /*