From patchwork Wed Jun 26 12:48:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712853 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 8E9E9181D0E for ; Wed, 26 Jun 2024 12:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406006; cv=none; b=F/0MM2y34hCcY6KI4druYUbv95a2NrDzEJfJL2eRcmOdN8Pg/4D8De0yCQ90nWj7J7Ed5pk+/KR9lK/HI/mQWPb2ljJba9dyNt0MKj/FZR3n/8GF4kAn7rPy50GrKKLUT1EjAvN/UI19pOcsLl0tTkCBYI/a4JfsYSFhtEpRzKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406006; c=relaxed/simple; bh=u39ZLQFVHadxLT8eot8yRJbsUgjzR6QW3AwD4UZL8RE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ja6vWwNJE0skKxMjLmbHjNqTnHGhspuP9KTO8gUKo9/gxvq6CJlPcClItsMnA6W/XZtOL5a0dgS0zZOWLUEo3mdV+k8kl3xiFEsX9HAOTkG5twIc09I3Nxc2YPIZYjo3lXUZuAkydPgAi69xbrkJhNsbWe561NnHzZh62cutLh8= 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=mAjfPhMo; arc=none smtp.client-ip=192.198.163.17 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="mAjfPhMo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406005; x=1750942005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u39ZLQFVHadxLT8eot8yRJbsUgjzR6QW3AwD4UZL8RE=; b=mAjfPhMoqXrfm4MnPepIzejkw1ihuORqOpTICf8ltawML8xUDbkYaeXt tEVjpU0U+QllFETqRli0W37gbzWY1gr1LxuZSyK8byPJ14aQAcOPkY9Qp P4kC8x0t3Qlum/5u+AmYrQ4cK1rQubzTeKV5sX5dcP0TOSNJ7B0bwnlxk cvdHu2TCH9xAJw81mvjGGUA4+RPvgt4HVcVxq3DX0FATfxYwqa0Y8du+r TMOYOQYUCxMsPvtMAO0bIXS2Fdk8+bElvpbg9+ZbFu1g9Ql2TTMbZ8t3k c9XESAQ5ea9cnCjhDJ3/AFs4DOtdjUaR6mACKz5c1SZGkakUTuEH4scK+ w==; X-CSE-ConnectionGUID: MvWBPavqSpebl8JxquoAbA== X-CSE-MsgGUID: EoM1KkZoT7WclV0OT9Szrg== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353363" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353363" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:44 -0700 X-CSE-ConnectionGUID: BSKhjCujQqS6lU/myTgofw== X-CSE-MsgGUID: ArLqbhkcT/m+DK3qe/fmiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442560" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:42 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Hector Martin , Mathias Nyman Subject: [PATCH 01/21] xhci: Remove dead code in xhci_move_dequeue_past_td() Date: Wed, 26 Jun 2024 15:48:15 +0300 Message-Id: <20240626124835.1023046-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Hector Martin This codepath is trivially dead, since the function is never called with a non-NULL td (the only callsite is immediately preceded by a NULL guard). [remove unused label 'deq_found' -Mathias] Signed-off-by: Hector Martin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index fd0cde3d1569..ffb3ebb72eaa 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -654,25 +654,6 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci, stream_id); return -ENODEV; } - /* - * A cancelled TD can complete with a stall if HW cached the trb. - * In this case driver can't find td, but if the ring is empty we - * can move the dequeue pointer to the current enqueue position. - * We shouldn't hit this anymore as cached cancelled TRBs are given back - * after clearing the cache, but be on the safe side and keep it anyway - */ - if (!td) { - if (list_empty(&ep_ring->td_list)) { - new_seg = ep_ring->enq_seg; - new_deq = ep_ring->enqueue; - new_cycle = ep_ring->cycle_state; - xhci_dbg(xhci, "ep ring empty, Set new dequeue = enqueue"); - goto deq_found; - } else { - xhci_warn(xhci, "Can't find new dequeue state, missing td\n"); - return -EINVAL; - } - } hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id); new_seg = ep_ring->deq_seg; @@ -709,8 +690,6 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci, } while (!cycle_found || !td_last_trb_found); -deq_found: - /* Don't update the ring cycle state for the producer (us). */ addr = xhci_trb_virt_to_dma(new_seg, new_deq); if (addr == 0) { From patchwork Wed Jun 26 12:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712854 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 5BFAC181D0C for ; Wed, 26 Jun 2024 12:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406007; cv=none; b=at692yxkMz+lrYN+jXRIwzMsn1SSNAcqN8LeADA4jgMzE2j6CgMHx1AJcj2/sZ3sFmu0wFgTUKNBIuJrkk7qOsaig7TP3/KxMiGRdWU/gRriY0nSuP7jlCdshoq89Ar7h7bwvzb+lLKF/ZEEt5/RB61Jlf39GxJNe7AzlE5JR8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406007; c=relaxed/simple; bh=ohlAzMIQfHAngwU+KcVNCQULz7kEC3fCYbAb9V+d1Ns=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AsF78Su6HU54TOTOpYNEo8hTRon17hJJ8djSFU8rR4FMsjCZSqWaqEAV3Wzq2SGYqJsWsB/XB16ye9rEcf+WJ+PegxUkwJp9cB6+auLReT4xyPT6DMnRDFCUNOsoc1x6e/aE68JQyp3wFpy+XVUAEMCIgZHs+suljqUg6wQB1nU= 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=EJUYZNTc; arc=none smtp.client-ip=192.198.163.17 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="EJUYZNTc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406005; x=1750942005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ohlAzMIQfHAngwU+KcVNCQULz7kEC3fCYbAb9V+d1Ns=; b=EJUYZNTcOt8JIsJkE3Rp7IbTF+q+3fRJ1cWNSiZo0wh10Lo4zooKbPGH G5hLJO3ZlrgkfVlkVSYZbxDplBoYij3MZfNUKjU5kYLQIUcxnCpLWbJDn jVytMT7HfOB4Vr7HENdu2ccJHf6rL8FhV+XBaLSomkxNHygOCqICMuxPY Y6gbCFkauQF58VjJaAKNo21MDb8T/XIF/B9b/HG7DEJTTHc2DepVQJDKY 6rENmlbeA1FTp8OzYy6wRLdZezgnFz360xZowpI3HSHWYW3EvchTIZ9XR 4uheRgo266IMOTavSU2WzimSHHPcNxyYEsLLo6ot9NmQe4FKsqLSKz2rZ g==; X-CSE-ConnectionGUID: z0FzgCiWTwq6f4U5+kgnlg== X-CSE-MsgGUID: 6A2Mm1BbRn6jgZwzQn7KuQ== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353366" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353366" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:45 -0700 X-CSE-ConnectionGUID: XB/VL4cvSRmzt9fBnSpFPw== X-CSE-MsgGUID: OrqvaRefSdazLypb0exMmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442569" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:44 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 02/21] xhci: show usb device name in xhci urb tracing Date: Wed, 26 Jun 2024 15:48:16 +0300 Message-Id: <20240626124835.1023046-3-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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 parsing xhci traces on systems with several xHCI controllers and connected usb devices is difficult as entries are all interleaved. showing usb devname in urb tracing reveals both which device, and which bus/controller the entry is for. old: xhci_urb_enqueue: ep2in-bulk: urb 0000000039224498 ... new: xhci_urb_enqueue: 3-9.4 ep1in-bulk: urb 0000000013bf21e7 ... Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-trace.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h index 5762564b9d73..24405315ffe6 100644 --- a/drivers/usb/host/xhci-trace.h +++ b/drivers/usb/host/xhci-trace.h @@ -250,6 +250,7 @@ DECLARE_EVENT_CLASS(xhci_log_urb, TP_PROTO(struct urb *urb), TP_ARGS(urb), TP_STRUCT__entry( + __string(devname, dev_name(&urb->dev->dev)) __field(void *, urb) __field(unsigned int, pipe) __field(unsigned int, stream) @@ -265,6 +266,7 @@ DECLARE_EVENT_CLASS(xhci_log_urb, __field(int, slot_id) ), TP_fast_assign( + __assign_str(devname); __entry->urb = urb; __entry->pipe = urb->pipe; __entry->stream = urb->stream_id; @@ -279,7 +281,8 @@ DECLARE_EVENT_CLASS(xhci_log_urb, __entry->type = usb_endpoint_type(&urb->ep->desc); __entry->slot_id = urb->dev->slot_id; ), - TP_printk("ep%d%s-%s: urb %p pipe %u slot %d length %d/%d sgs %d/%d stream %d flags %08x", + TP_printk("%s ep%d%s-%s: urb %p pipe %u slot %d length %d/%d sgs %d/%d stream %d flags %08x", + __get_str(devname), __entry->epnum, __entry->dir_in ? "in" : "out", __print_symbolic(__entry->type, { USB_ENDPOINT_XFER_INT, "intr" }, From patchwork Wed Jun 26 12:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712855 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 DA1C61850A6 for ; Wed, 26 Jun 2024 12:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406008; cv=none; b=Ysmqd5C1lWvQb0mOCG0/48PvXIatQKSAYd2joTNPJMkSr1UoY8J33Mwo3XX5kLUga4pp9lsdlrfi18f8uTNQy51sNmVJ9sCNetnm4La3CFuoaj0eijqKUQimddMupiQn7E+0fq+8Gf/xDB11V4I5Xtul60C6VD5jh2PZPOaOwTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406008; c=relaxed/simple; bh=7+iTBEdlfrKFKbc7K7Nyq9pAL6VazWI42smRq6uBE7s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kpFogbtfJSnJ20/8RxQ4gnEu1293WeMZwa3oYCd7ybOewAMAL/QbS3Q/pGScvAlQXwNE/TCHBMN5pbk+EtOT23v+OZ10LsPT1GCoi14V4j2v5eeYn6+vKWN4RuY04ym6jiNl1uCvwHkI8wf+mfqCQK8BQZIzDcwypbRlLKbi0Tw= 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=TP0ISuf6; arc=none smtp.client-ip=192.198.163.17 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="TP0ISuf6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406007; x=1750942007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7+iTBEdlfrKFKbc7K7Nyq9pAL6VazWI42smRq6uBE7s=; b=TP0ISuf6rSKaJDAr+EZVwIf5MPuoBxpyXkMXjtDtaL21v3FK4HTtLith T7qkLnzAVs3ccUJw2sZzlNvuJbGynro1m2S/kvBN/ne5ef3UHbhNCsxcM mGHzjdjgqaI19vq6W2s4y9x/jywFdlyevRE3bR8ZE+O5m2sxGHUACVcpS PV3yXBfWCOXx3IninakvaPIdFolhwtQsPmhd3OvdMtnLr+RK854ety231 UqOuCwHXV/uAclyYflW3KHAHPYzI4+2KLhMvr0FJavAXDXuoRM4nIXrsN VHbByqRkEj+H/pgxDnG0Ifq1wVnoWr5Yehlg8ZgqEd02jYNNE6ipI3jSK Q==; X-CSE-ConnectionGUID: lvF36v6eQQ2cssyY8EINlQ== X-CSE-MsgGUID: nHXvZ3iYThqx5nx7WWfb+g== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353370" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353370" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:47 -0700 X-CSE-ConnectionGUID: +WkQiUtVQcK7SjGBHU/DVg== X-CSE-MsgGUID: uSSNAzIkTvaEVlyPdwejgg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442576" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:45 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 03/21] xhci: Set correct transferred length for cancelled isoc transfers Date: Wed, 26 Jun 2024 15:48:17 +0300 Message-Id: <20240626124835.1023046-4-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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 The transferred length is incorrectly zeroed for cancelled isoc transfer TDs when the transfer ring stops on a cancelled TD with a 'Stop - Length Invalid' completion code. Length was always set to zero in these cases even if it should be set to the sum of the TRB transfer block lengths up to the TRB the ring stopped on, _excluding_ the one stopped on. No issues reported due to this isoc case. Found while inspecting related case in bulk transfer 'Stop - Length Invalid' handling. Change this so that 'Stop - Length Invalid' transfer completion cases always sum up TRB lengths instead of report a zero length. Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index ffb3ebb72eaa..a12009ed1b36 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2439,7 +2439,9 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, requested = remaining; break; case COMP_STOPPED_LENGTH_INVALID: - requested = 0; + /* exclude stopped trb with invalid length from length sum */ + sum_trbs_for_length = true; + ep_trb_len = 0; remaining = 0; break; default: From patchwork Wed Jun 26 12:48:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712856 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 A7BC2181D15 for ; Wed, 26 Jun 2024 12:46:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406011; cv=none; b=KtrtpbQj3Nn0DjSod9qPU0pnIUVs2u0NvjpTfwOPVJO/artHRBnOVc1US9qrdNJVKS5Ul6+wTHYsoeHJR/tjOUEXaRJBm4GpG3Bx9wim093jmorVcPcs808nlM+atInD6FczKtAq5uWkHaF3ValBrBhKqn1DfWykSmCOMI2JZqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406011; c=relaxed/simple; bh=V0psOe5Z5+WC51AaKP15D9NiBAQ8xA2cLo1nvDYCgZQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SEO033M3hplZcFJkw7nCPb4w0WiOhjsLTW1147aPLoSdO2OhGQ/SDaQFIl1oifHSXpudZmSPaRCv+rGhwGUER1AtOGw+YaqOKYPAps1zQJsy8WMk0odSeuzK1vfi7V2ClY5CFfEW/dVe+GuLl4xEIYmaP542eeOdTgZUTEvXNzQ= 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=Ae4rpsHW; arc=none smtp.client-ip=192.198.163.17 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="Ae4rpsHW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406010; x=1750942010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V0psOe5Z5+WC51AaKP15D9NiBAQ8xA2cLo1nvDYCgZQ=; b=Ae4rpsHWb5YmImlVVnAIE3ZJJPyTPOsGmVsXTzkdCcb2hB0KREAS2iOO HaDH/1CjQFimVTD/O75qt/BbvDURsBsUZFOK1/Cm1i/CWPLyQzYY3Tn73 fSbx5oLv8/V1URMzAnYcR6ayT620Q9O+xe4HetyfE5qgk3cRXQKMUJUmM 1pM6/1dyd1La1cm0r0sANAfF/dYOPLGxnalqrGGLKaKZE8dGXlWj6G0Hu zLXujAjTXr0Cb1JL36GpJbrg39GKa1/75CIh7BU5XI8MS/n34V3DtbZO1 0lSipvY0dm6Ql84oEUtRky9EnAMZciSp8EMkMVZB+oEBskG3I2jjXEACH A==; X-CSE-ConnectionGUID: izPVKuQNR8ScdznUnhaSVg== X-CSE-MsgGUID: AOdMU2vhRTWgqcHUqBNnFg== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353373" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353373" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:49 -0700 X-CSE-ConnectionGUID: cnZMdUvpQT2CXdFM0tHfhQ== X-CSE-MsgGUID: 2S7s28u4R6GUh6Ou4HOm0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442607" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:47 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Uday M Bhat , Samuel Jacob , Mathias Nyman Subject: [PATCH 04/21] xhci: dbc: Allow users to modify DbC poll interval via sysfs Date: Wed, 26 Jun 2024 15:48:18 +0300 Message-Id: <20240626124835.1023046-5-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Uday M Bhat xhci DbC driver polls the host controller for DbC events at a reduced rate when DbC is enabled but there are no active data transfers. Allow users to modify this reduced poll interval via dbc_poll_interval_ms sysfs entry. Unit is milliseconds and accepted range is 0 to 5000. Max interval of 5000 ms is selected as it matches the common 5 second timeout used in usb stack. Default value is 64 milliseconds. A long interval is useful when users know there won't be any activity on systems connected via DbC for long periods, and want to avoid battery drainage due to unnecessary CPU usage. Example being Android Debugger (ADB) usage over DbC on ChromeOS systems running Android Runtime. [minor changes and rewording -Mathias] Co-developed-by: Samuel Jacob Signed-off-by: Samuel Jacob Signed-off-by: Uday M Bhat Signed-off-by: Mathias Nyman --- .../testing/sysfs-bus-pci-drivers-xhci_hcd | 10 +++++ drivers/usb/host/xhci-dbgcap.c | 38 +++++++++++++++++++ drivers/usb/host/xhci-dbgcap.h | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd index 5a775b8f6543..fc82aa4e54b0 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd +++ b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd @@ -75,3 +75,13 @@ Description: The default value is 1 (GNU Remote Debug command). Other permissible value is 0 which is for vendor defined debug target. + +What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_poll_interval_ms +Date: February 2024 +Contact: Mathias Nyman +Description: + This attribute adjust the polling interval used to check for + DbC events. Unit is milliseconds. Accepted values range from 0 + up to 5000. The default value is 64 ms. + This polling interval is used while DbC is enabled but has no + active data transfers. diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 872d9cddbcef..161c09953c4e 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -1150,11 +1150,48 @@ static ssize_t dbc_bInterfaceProtocol_store(struct device *dev, return size; } +static ssize_t dbc_poll_interval_ms_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct xhci_dbc *dbc; + struct xhci_hcd *xhci; + + xhci = hcd_to_xhci(dev_get_drvdata(dev)); + dbc = xhci->dbc; + + return sysfs_emit(buf, "%u\n", dbc->poll_interval); +} + +static ssize_t dbc_poll_interval_ms_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + struct xhci_dbc *dbc; + struct xhci_hcd *xhci; + u32 value; + int ret; + + ret = kstrtou32(buf, 0, &value); + if (ret || value > DBC_POLL_INTERVAL_MAX) + return -EINVAL; + + xhci = hcd_to_xhci(dev_get_drvdata(dev)); + dbc = xhci->dbc; + + dbc->poll_interval = value; + + mod_delayed_work(system_wq, &dbc->event_work, 0); + + return size; +} + static DEVICE_ATTR_RW(dbc); static DEVICE_ATTR_RW(dbc_idVendor); static DEVICE_ATTR_RW(dbc_idProduct); static DEVICE_ATTR_RW(dbc_bcdDevice); static DEVICE_ATTR_RW(dbc_bInterfaceProtocol); +static DEVICE_ATTR_RW(dbc_poll_interval_ms); static struct attribute *dbc_dev_attrs[] = { &dev_attr_dbc.attr, @@ -1162,6 +1199,7 @@ static struct attribute *dbc_dev_attrs[] = { &dev_attr_dbc_idProduct.attr, &dev_attr_dbc_bcdDevice.attr, &dev_attr_dbc_bInterfaceProtocol.attr, + &dev_attr_dbc_poll_interval_ms.attr, NULL }; ATTRIBUTE_GROUPS(dbc_dev); diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 92661b555c2a..0118c6288a3c 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -95,7 +95,7 @@ struct dbc_ep { #define DBC_QUEUE_SIZE 16 #define DBC_WRITE_BUF_SIZE 8192 #define DBC_POLL_INTERVAL_DEFAULT 64 /* milliseconds */ - +#define DBC_POLL_INTERVAL_MAX 5000 /* milliseconds */ /* * Private structure for DbC hardware state: */ From patchwork Wed Jun 26 12:48:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712857 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 F25C31850B6 for ; Wed, 26 Jun 2024 12:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406012; cv=none; b=C1bes5oiYFCIrNPAjnwWMqtgzrm+X/3Xjbqy63c6SoUfO6jAvykXFw2Ixs1NbjJMGTpD2zowC9Ah7VLOkWpao0oUQ8uA3mCj5g+TFOS1bA8ipDExOYWHtssX6VLJhDe9Co6OTObNJtzbR1QECkDYTLN+0zz+GTOQKYUJBtR+57I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406012; c=relaxed/simple; bh=qnF1aabk6XmCDSWp1a9CS0xzmmTt7z/1KA1e+pqx+kc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CSg8xZ8EWWuXY6g3PGz233UWtkSeRFC8kew8vfjhScNMg2RPZHchNEpWGXF7LV9SOJ7nwtzAUMoqvxejrf7ajDXsYUWBkcwMOHkkTlh0H392hoTo20W5+ud1j9eT8jE4ShrBRvnBuvQlrwtTgLoat46T0x42twqat3WIxXcsXLo= 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=JlK9ysY+; arc=none smtp.client-ip=192.198.163.17 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="JlK9ysY+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406011; x=1750942011; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qnF1aabk6XmCDSWp1a9CS0xzmmTt7z/1KA1e+pqx+kc=; b=JlK9ysY+vnwrxDxAK1IyzlOfHg+Qd+fcdwrUC/CRdJAN1BZMaQGTVBUd w76mngxoWEfXGCu9+F1VYjVhEiqZUYk6EZD3sXsphSuX6JbFPRHEO9Qy0 N4fxJJYcqtALfMmQzue3f7SdxB/kPIKsaFlKZ28vm/nilWv3D+OfiDSAW jRyDr5POwfEWVdXnqwUtwaViCzaBZ68EIXOX+9mt5Tvt7NN8h+/BMBnwt qgudyCGTUv81BFjo6FTWOsobB/S7nv586hvUF0KLUmepp5xQwIzckhNyz BOuvJd5TyA4V1kHycxGKrzMhXFFp5uxfm5s4MAzTC6TuGYzfXFswU2z59 Q==; X-CSE-ConnectionGUID: /O6tMqxOQf67b5hcahxCJg== X-CSE-MsgGUID: N+ta9O4WTCqWJMZq9Legkw== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353376" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353376" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:50 -0700 X-CSE-ConnectionGUID: lYhcuFpyR7KVIHzq4sZhMg== X-CSE-MsgGUID: DlawZkd2QqG7X6UkasMmPw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442610" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:49 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 05/21] usb: xhci: remove 'num_trbs' from struct 'xhci_td' Date: Wed, 26 Jun 2024 15:48:19 +0300 Message-Id: <20240626124835.1023046-6-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Remove 'num_trbs' from 'xhci_td' as it's no longer used following the removal of 'num_trbs_free' tracking in commit 2710f8186f88 ("xhci: Stop unnecessary tracking of free trbs in a ring"). Tracking of 'num_trbs_free' is still performed in xhci DbC, but it does not utilize 'num_trbs'. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 4 ---- drivers/usb/host/xhci.h | 1 - 2 files changed, 5 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index a12009ed1b36..dfde9d3cca02 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3704,7 +3704,6 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, upper_32_bits(send_addr), length_field, field); - td->num_trbs++; addr += trb_buff_len; sent_len = trb_buff_len; @@ -3731,7 +3730,6 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, urb_priv->td[1].last_trb_seg = ring->enq_seg; field = TRB_TYPE(TRB_NORMAL) | ring->cycle_state | TRB_IOC; queue_trb(xhci, ring, 0, 0, 0, TRB_INTR_TARGET(0), field); - urb_priv->td[1].num_trbs++; } check_trb_math(urb, enqd_len); @@ -3782,7 +3780,6 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, urb_priv = urb->hcpriv; td = &urb_priv->td[0]; - td->num_trbs = num_trbs; /* * Don't give the first TRB to the hardware (by toggling the cycle bit) @@ -4103,7 +4100,6 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, goto cleanup; } td = &urb_priv->td[i]; - td->num_trbs = trbs_per_td; /* use SIA as default, if frame id is used overwrite it */ sia_frame_id = TRB_SIA; if (!(urb->transfer_flags & URB_ISO_ASAP) && diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 78d014c4d884..4298513f0f71 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1294,7 +1294,6 @@ struct xhci_td { /* actual_length of the URB has already been set */ bool urb_length_set; bool error_mid_td; - unsigned int num_trbs; }; /* From patchwork Wed Jun 26 12:48:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712858 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 11037185E5F for ; Wed, 26 Jun 2024 12:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406013; cv=none; b=cYpEAIwNgOwPY48Xdn39B9Ahj0fcLtoZn6x0Ma6rFK1xn+XNQmzztS7b0NKxs3qhGugXw3tlCpMG8TsOAy0ehz3VC8o0402rrCtx2LJVhqpMVz+eSPDwhvYHKGSvpFkq1xH3Kvb/1+u1P5kEZgkOaYIwVw2hV3E9UKXHqu6DRbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406013; c=relaxed/simple; bh=1l/6gZ1jpSqxM2iGGc9oFU22Wh9ch4UxBvTA0IouHO4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GSY8XW2djimS0fukmgDwB+7Qz/0QZR72OTEQ8dZeit7SgPHo2eXj7S/V55WiPm/TS3E775fmToSWJo3ZPqlV27jVdyqxES94J1B9ghHrdHI9KOls2aJypAkxy9aNj36Eg9wlELbe4+g4AoTIuZ1LAQ/zmNMie8SOyftwSauZGTQ= 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=RXNGiNHN; arc=none smtp.client-ip=192.198.163.17 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="RXNGiNHN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406012; x=1750942012; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1l/6gZ1jpSqxM2iGGc9oFU22Wh9ch4UxBvTA0IouHO4=; b=RXNGiNHNHV6C8L63Xab6Hw1LLAqK3iTD+72dkfD2+93tQOIZZfyx5Gl4 36O7f5RFU7TfN1k/T6ifBq6z4GXKGF7sSKuImRoIfOydZ4qQ6kdmfURSu mI9Y8xlvuGVazKK3W58/2fXKnHl0ryHgfWYZtVog4sCQCCc0OQXIjFF2g 8dwk8UhgM62OqjkB5Gq4pJlH0JBfk2EQ2TxZX4bVh5gz6e7QTbYo2l7sZ 2ptDw/HMqz86aKsG3n+3AO3oIMJxpKPjv5vNbZ+OeurZ45HTa9l6OVVI0 cst+zgSY2oMyL+1XXrh99a/EGZY4xxbcRO/2IHGUty/Fvm59+9QS2H0e0 A==; X-CSE-ConnectionGUID: Z7jBWoD8Se6zSwBYnz8t5w== X-CSE-MsgGUID: OC1GvCD2TBC4doSdk2qk1A== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353382" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353382" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:52 -0700 X-CSE-ConnectionGUID: r5NqoYxuRvm1NL2IO8z6zg== X-CSE-MsgGUID: 5uWFznpfRrS4PbT15+VRuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442615" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:50 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 06/21] usb: xhci: remove unused 'xhci' argument Date: Wed, 26 Jun 2024 15:48:20 +0300 Message-Id: <20240626124835.1023046-7-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Remove argument 'struct xhci_hcd *xhci' from functions which do not utilize it. This change contributes to a simpler codebase by avoiding redundant arguments. Functions which have the argument removed: check_interval() xhci_num_trbs_free() xhci_handle_cmd_enable_slot() xhci_clear_interrupt_pending() xhci_requires_manual_halt_cleanup() Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index dfde9d3cca02..c528dc97dd9a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -283,7 +283,7 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, * Only for transfer and command rings where driver is the producer, not for * event rings. */ -static unsigned int xhci_num_trbs_free(struct xhci_hcd *xhci, struct xhci_ring *ring) +static unsigned int xhci_num_trbs_free(struct xhci_ring *ring) { struct xhci_segment *enq_seg = ring->enq_seg; union xhci_trb *enq = ring->enqueue; @@ -1490,8 +1490,8 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id, ring_doorbell_for_active_rings(xhci, slot_id, ep_index); } -static void xhci_handle_cmd_enable_slot(struct xhci_hcd *xhci, int slot_id, - struct xhci_command *command, u32 cmd_comp_code) +static void xhci_handle_cmd_enable_slot(int slot_id, struct xhci_command *command, + u32 cmd_comp_code) { if (cmd_comp_code == COMP_SUCCESS) command->slot_id = slot_id; @@ -1759,7 +1759,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3])); switch (cmd_type) { case TRB_ENABLE_SLOT: - xhci_handle_cmd_enable_slot(xhci, slot_id, cmd, cmd_comp_code); + xhci_handle_cmd_enable_slot(slot_id, cmd, cmd_comp_code); break; case TRB_DISABLE_SLOT: xhci_handle_cmd_disable_slot(xhci, slot_id); @@ -2141,9 +2141,7 @@ static void xhci_clear_hub_tt_buffer(struct xhci_hcd *xhci, struct xhci_td *td, * driver won't clear the halt in that case, so we need to issue a Set Transfer * Ring Dequeue Pointer command manually. */ -static int xhci_requires_manual_halt_cleanup(struct xhci_hcd *xhci, - struct xhci_ep_ctx *ep_ctx, - unsigned int trb_comp_code) +static int xhci_requires_manual_halt_cleanup(struct xhci_ep_ctx *ep_ctx, unsigned int trb_comp_code) { /* TRB completion codes that may require a manual halt cleanup */ if (trb_comp_code == COMP_USB_TRANSACTION_ERROR || @@ -2328,8 +2326,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, case COMP_STOPPED_LENGTH_INVALID: goto finish_td; default: - if (!xhci_requires_manual_halt_cleanup(xhci, - ep_ctx, trb_comp_code)) + if (!xhci_requires_manual_halt_cleanup(ep_ctx, trb_comp_code)) break; xhci_dbg(xhci, "TRB error %u, halted endpoint index = %u\n", trb_comp_code, ep->ep_index); @@ -2804,8 +2801,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, slot_id, ep_index); } if (trb_comp_code == COMP_STALL_ERROR || - xhci_requires_manual_halt_cleanup(xhci, ep_ctx, - trb_comp_code)) { + xhci_requires_manual_halt_cleanup(ep_ctx, trb_comp_code)) { xhci_handle_halted_endpoint(xhci, ep, NULL, EP_HARD_RESET); } @@ -2925,8 +2921,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, if (trb_is_noop(ep_trb)) { if (trb_comp_code == COMP_STALL_ERROR || - xhci_requires_manual_halt_cleanup(xhci, ep_ctx, - trb_comp_code)) + xhci_requires_manual_halt_cleanup(ep_ctx, trb_comp_code)) xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET); } else { @@ -3046,8 +3041,7 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci, } /* Clear the interrupt pending bit for a specific interrupter. */ -static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci, - struct xhci_interrupter *ir) +static void xhci_clear_interrupt_pending(struct xhci_interrupter *ir) { if (!ir->ip_autoclear) { u32 irq_pending; @@ -3068,7 +3062,7 @@ static int xhci_handle_events(struct xhci_hcd *xhci, struct xhci_interrupter *ir int err; u64 temp; - xhci_clear_interrupt_pending(xhci, ir); + xhci_clear_interrupt_pending(ir); /* Event ring hasn't been allocated yet. */ if (!ir->event_ring || !ir->event_ring->dequeue) { @@ -3241,7 +3235,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, if (ep_ring != xhci->cmd_ring) { new_segs = xhci_ring_expansion_needed(xhci, ep_ring, num_trbs); - } else if (xhci_num_trbs_free(xhci, ep_ring) <= num_trbs) { + } else if (xhci_num_trbs_free(ep_ring) <= num_trbs) { xhci_err(xhci, "Do not support expand command ring\n"); return -ENOMEM; } @@ -3416,8 +3410,7 @@ static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id, xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id); } -static void check_interval(struct xhci_hcd *xhci, struct urb *urb, - struct xhci_ep_ctx *ep_ctx) +static void check_interval(struct urb *urb, struct xhci_ep_ctx *ep_ctx) { int xhci_interval; int ep_interval; @@ -3458,7 +3451,7 @@ int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct xhci_ep_ctx *ep_ctx; ep_ctx = xhci_get_ep_ctx(xhci, xhci->devs[slot_id]->out_ctx, ep_index); - check_interval(xhci, urb, ep_ctx); + check_interval(urb, ep_ctx); return xhci_queue_bulk_tx(xhci, mem_flags, urb, slot_id, ep_index); } @@ -4263,7 +4256,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, * Check interval value. This should be done before we start to * calculate the start frame value. */ - check_interval(xhci, urb, ep_ctx); + check_interval(urb, ep_ctx); /* Calculate the start frame and put it in urb->start_frame. */ if (HCC_CFC(xhci->hcc_params) && !list_empty(&ep_ring->td_list)) { From patchwork Wed Jun 26 12:48:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712859 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 89EF4185E74 for ; Wed, 26 Jun 2024 12:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406014; cv=none; b=HBYoXQcaICGoOoNW9/mvHYChtTcZg48EAp+L9oCqrwaXzqle0znyYtFoeMEXgqLgbcHgV9rcwxhjC8lYyf9Rw/CTAOxtQAF5pP2tX6kuBSYXyk2M91J8/z+qsLbSWKYxj8UhZbWWyrmusk45G7yRpK1fhyKDTAyi+/nEw3JS1Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406014; c=relaxed/simple; bh=rfAAQGB5R2HBy5HOhB5HCGGepa7BJWw6hAipjm4DFS4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G8fqbb5VpjhYNBb5w5IEXBn2spLTyTlcef4yrAtEl4RUCxGLvPK6s3vgASTK2DtXPyjAWCT1984UW+QRzi+/6OUhGZHeKGuoLW1mzDlYVAIBosU/fYtSLU2ndG3YqDXpUsEbQOyX11VTRxiQUj80cg8lFq1Z6frzYuvaTtMLCxU= 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=Ux+e29sh; arc=none smtp.client-ip=192.198.163.17 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="Ux+e29sh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406014; x=1750942014; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rfAAQGB5R2HBy5HOhB5HCGGepa7BJWw6hAipjm4DFS4=; b=Ux+e29sh66xyaTuLv8IQa5J20yTGnpFcbCAbEfO7Gp6iIjkMfmo1Hik0 16Xp37L5jKXmEnjeCZCoUwaKn2ME0ryEnzdWdmZtnYHa2CuzfY7zYavEj 0iDwdavvV60wxEMAzDHxxH8TKjkLvZfmd9zLzwmzZu/FBTpzW3zRvraa/ GPIVRTr0+7Vn9xdRwF2q1ora09jSwQxO7x8cBGM9eFNLtgTjQ4hmXs8uf 1mG4UFd+QVF07rRz9qoKiGNDBoEnsgjUl5PWgbVG9IjHt4c8XqSfPUdfy MU20NKKHkYRLEpbQEMSpcJgjpUGjlZbQ2dZhY2zdGdkAgLW15XgpJ5gVM w==; X-CSE-ConnectionGUID: dNWfaWcOS5mrhVnqvKUwwg== X-CSE-MsgGUID: ueQ6CdGmRcu3oXywR1dVrQ== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353384" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353384" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:53 -0700 X-CSE-ConnectionGUID: i2HpsXAVTpCJBPrAMDpR9Q== X-CSE-MsgGUID: UFugE2HrT2uIp3tS9elb0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442626" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:52 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 07/21] usb: xhci: remove unused argument from xhci_handle_cmd_config_ep() Date: Wed, 26 Jun 2024 15:48:21 +0300 Message-Id: <20240626124835.1023046-8-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Argument u32 'cmd_comp_code' is not used, and as a consequence is removed. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c528dc97dd9a..c2605e89adb0 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1516,8 +1516,7 @@ static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) xhci_free_device_endpoint_resources(xhci, virt_dev, true); } -static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id, - u32 cmd_comp_code) +static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id) { struct xhci_virt_device *virt_dev; struct xhci_input_control_ctx *ctrl_ctx; @@ -1766,7 +1765,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, break; case TRB_CONFIG_EP: if (!cmd->completion) - xhci_handle_cmd_config_ep(xhci, slot_id, cmd_comp_code); + xhci_handle_cmd_config_ep(xhci, slot_id); break; case TRB_EVAL_CONTEXT: break; From patchwork Wed Jun 26 12:48:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712860 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 9ABC91822EF for ; Wed, 26 Jun 2024 12:46:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406017; cv=none; b=fgvafPHgMYIZbs3w1n4zOXbPxaHbTSyN4lKLfcwgjCcmcEBFLNToYLXPFPloRwgYFPuSboNRu3xZiVYAy9TM59kDnn6YSK2BwsSzyuw92FDWF/btD/E6HdV5pr5pHaXwgHO3x7fM+bzUEzz5RTlxMTSaZiezjymnsSikRfVsNg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406017; c=relaxed/simple; bh=9veFRl0wSCnpDIZtRVTFqklQSHOIwfpiY4mWIGD+K/k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZRHlk8ygZ1hocXg3WGUO6s9WzjcqD6PY+rWr0vgHlUqx1ObRUJbCfD922UXiH39F0awzV5RuVdpC37ClDHkYZdZtvr5gjlPG7WdcHOeis2BGZiJiwommJ2gylp9kbR7SpwuPQOPcqkzAu5kfUT0wswH48LbEWrV+7ANT9hGfZOg= 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=SV7ZnN2V; arc=none smtp.client-ip=192.198.163.17 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="SV7ZnN2V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406016; x=1750942016; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9veFRl0wSCnpDIZtRVTFqklQSHOIwfpiY4mWIGD+K/k=; b=SV7ZnN2Vox06ybXSgpc+Uaby7ZxmOpbEbmai7z0LsTqteE1AF2xcJTnL 8LLeMXrDy64EXQ2mObwkxThP0ryGdWHlaGN0AUG5ZqslD4k2cdm3biE6z N2AuFvRp8cFI2+V4btaWBB/Ke7fHATbwOw2GIMznJh5qy81bHsDg3wD0c nWWcBWThgS/LrELd2TmququditAxCdyu8u7uQWHKLHhI0Ym2eGm9k9hTl hE/LUvUI3FSXUW4R56hsCRZB5MxsKLUB2oCUdk+n+NPRqsMYKjl91DN0J l56MS2VdCbzIT5WUMsPZ8Tkeo8WqrQtJ92jDR9GdlJukm/QlMSRrYS2e6 A==; X-CSE-ConnectionGUID: Bj3UATPRSlGzenrbwCBRpg== X-CSE-MsgGUID: RdPkAX6mRSuSmnxJA7/Eqw== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353387" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353387" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:55 -0700 X-CSE-ConnectionGUID: KEPPgcC+RGGmFTEZM/nUfQ== X-CSE-MsgGUID: kemX2FqXQhuq/tOoi9T5Fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442639" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:53 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 08/21] usb: xhci: remove unused argument from handle_port_status() Date: Wed, 26 Jun 2024 15:48:22 +0300 Message-Id: <20240626124835.1023046-9-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Argument struct 'xhci_interrupter *ir' is not used, and as a consequence is removed. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c2605e89adb0..e9130c7c2c53 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1883,9 +1883,7 @@ static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci) } while (!(pll_lock_check & 0x1) && --retry_count); } -static void handle_port_status(struct xhci_hcd *xhci, - struct xhci_interrupter *ir, - union xhci_trb *event) +static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event) { struct usb_hcd *hcd; u32 port_id; @@ -2980,7 +2978,7 @@ static int xhci_handle_event_trb(struct xhci_hcd *xhci, struct xhci_interrupter handle_cmd_completion(xhci, &event->event_cmd); break; case TRB_PORT_STATUS: - handle_port_status(xhci, ir, event); + handle_port_status(xhci, event); break; case TRB_TRANSFER: handle_tx_event(xhci, ir, &event->trans_event); From patchwork Wed Jun 26 12:48:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712861 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 144B21822F7 for ; Wed, 26 Jun 2024 12:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406018; cv=none; b=QEk15PkGxVEC1JiGy0aYdQed6OyTMswAalu7eL11DI8QnZVQb/WRp3jdrkmXxCHNvedggs6lx2UT8epwpqp0rW7jGfyL46h1DxNUu1miX8eFN2M3RPAb2IsFCYaMu20B6BbYnPNh4VN7M2SDcNIZk5P6FiFYSZFdCr8pp3bi/Kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406018; c=relaxed/simple; bh=YJk6v0xpGnY8jY3nTxxXSL+QxgXF22oqRT5S8JlFqkA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DVBtjmG4B/BQ2f79JWdklYwQleOcG7is26xFr1o84DWDmh7kTidufn00yRhtPG3f3PqNfHtzmz+ECL0gpdNMGJaHxPjiRyHqb2/KWg7XCs6y0pXsPY4Aq/qSgZOMPyTi12dWR2RKyQWxi/JZAwKTF8SyA+Ku3lU2KGwd0h4xrns= 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=avAkHPHW; arc=none smtp.client-ip=192.198.163.17 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="avAkHPHW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406017; x=1750942017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YJk6v0xpGnY8jY3nTxxXSL+QxgXF22oqRT5S8JlFqkA=; b=avAkHPHWELij6oZkPIITUMrrwiiQ1WlVWmb7t9RTR0HOZelew8StH0Ng aUdgKe3h78YfiVJBNGg+Y5OkFyHsIeUy3HASqvNsPN6BCDxQTFCnKHp3o ajIYd5sspYkInLB/fJuc66438W6taWcboJ1L4tMNZu+hijeJhUum4ITf/ 0WGo+761GPrqjg6oXZRJge9l7etS43hSUUONsSN4e466a9nTKXKDZdvRs eQYZNK0jhU6SmCnEZovEVZ8Qu7lOewcDSxx+p+XilzWBPcC45lD7bgwKE 4+7YXhu7U2AS0iJBys2kBP0GLNd3togTICKZCRp6lX7NJCn3jfHshfAMC A==; X-CSE-ConnectionGUID: L24eO/kjT5eZWsb6yqFvdQ== X-CSE-MsgGUID: SG0baQjfQECDrFEyWX/0Ag== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353391" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353391" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:56 -0700 X-CSE-ConnectionGUID: CUzDAhRARm6K4gh6xr/5Bg== X-CSE-MsgGUID: 8fBJgB98S4CmPMLBABjQuw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442642" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:55 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 09/21] usb: xhci: move link chain bit quirk checks into one helper function. Date: Wed, 26 Jun 2024 15:48:23 +0300 Message-Id: <20240626124835.1023046-10-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Older 0.95 xHCI hosts and some other specific newer hosts require the chain bit to be set for Link TRBs even if the link TRB is not in the middle of a transfer descriptor (TD). move the checks for all those cases into one xhci_link_chain_quirk() function to clean up and avoid code duplication. No functional changes. [skip renaming chain_links flag, reword commit message -Mathias] Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 10 ++-------- drivers/usb/host/xhci-ring.c | 8 ++------ drivers/usb/host/xhci.h | 7 +++++-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 3100219d6496..68994ce21933 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -136,10 +136,7 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, if (!ring || !first || !last) return; - /* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ - chain_links = !!(xhci_link_trb_quirk(xhci) || - (ring->type == TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))); + chain_links = xhci_link_chain_quirk(xhci, ring->type); next = ring->enq_seg->next; xhci_link_segments(ring->enq_seg, first, ring->type, chain_links); @@ -335,10 +332,7 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, struct xhci_segment *prev; bool chain_links; - /* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ - chain_links = !!(xhci_link_trb_quirk(xhci) || - (type == TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))); + chain_links = xhci_link_chain_quirk(xhci, type); prev = xhci_segment_alloc(xhci, cycle_state, max_packet, num, flags); if (!prev) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e9130c7c2c53..8502776d84d6 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -250,9 +250,7 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, * AMD 0.96 host, carry over the chain bit of the previous TRB * (which may mean the chain bit is cleared). */ - if (!(ring->type == TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST)) && - !xhci_link_trb_quirk(xhci)) { + if (!xhci_link_chain_quirk(xhci, ring->type)) { next->link.control &= cpu_to_le32(~TRB_CHAIN); next->link.control |= cpu_to_le32(chain); } @@ -3250,9 +3248,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, /* If we're not dealing with 0.95 hardware or isoc rings * on AMD 0.96 host, clear the chain bit. */ - if (!xhci_link_trb_quirk(xhci) && - !(ep_ring->type == TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))) + if (!xhci_link_chain_quirk(xhci, ep_ring->type)) ep_ring->enqueue->link.control &= cpu_to_le32(~TRB_CHAIN); else diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 4298513f0f71..65c84185c7fd 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1748,9 +1748,12 @@ static inline void xhci_write_64(struct xhci_hcd *xhci, lo_hi_writeq(val, regs); } -static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci) + +/* Link TRB chain should always be set on 0.95 hosts, and AMD 0.96 ISOC rings */ +static inline bool xhci_link_chain_quirk(struct xhci_hcd *xhci, enum xhci_ring_type type) { - return xhci->quirks & XHCI_LINK_TRB_QUIRK; + return (xhci->quirks & XHCI_LINK_TRB_QUIRK) || + (type == TYPE_ISOC && (xhci->quirks & XHCI_AMD_0x96_HOST)); } /* xHCI debugging */ From patchwork Wed Jun 26 12:48:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712862 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 18E781822EF for ; Wed, 26 Jun 2024 12:46:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406019; cv=none; b=l0H1DEhMaMtEYvA7WIWGDQ2qzmmPjKfTsUnZ/vSrNPlFLWbt8vyXL3OJbUcjAZgqqVCUqJDmPhIUW4mI095X8xsKnM7qk2uP/O8cBd9Fu10NdMQUIBnizkfaiSle2uEvVUhpDzJxCqOW+eS/JpdJ4TEbg1MmJtY5vCZMJNjViQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406019; c=relaxed/simple; bh=7p/GwfP6Ur9H7rPJHPEZwv2XZhgpwg2kH6lHtILt9kY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fIzTlIO/9OITNHTREsHxmcZBZVsqeIeLwx59MB7tIs6eL+NGeqCL2m8nL5724R5f35FUDTJjL7rk+pYXhZDPjMr58V34/FWWrIDbJYPeeUSPZ+Ddm27KoM+NqAZ22gQpcQKd4nSLRx0gnH/syYQOUO5xf4U7wap94zKhNo0u8LE= 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=iqBAxqYh; arc=none smtp.client-ip=192.198.163.17 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="iqBAxqYh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406018; x=1750942018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7p/GwfP6Ur9H7rPJHPEZwv2XZhgpwg2kH6lHtILt9kY=; b=iqBAxqYhliBLRf5lg2pPdtn8dCQIvdw1mJ0OKWH5gS96JjJEwOw96fuA sMvDzH2tPOTz/IeL1HI5JScIECauhsthvtF9Y63kVJX/2SdBzZLgZJ2JY LZtqUj4GU+jNyGiEMBqZz8jAFdDtDAKRkxzOzlugivi8jVrQnHXi5+xE3 IsEUz3bte207MUGTUIyTbwAsygMILQl2CGZ/JwWMXE5Du/mgOGpSLVslw HTbRKSFvOD8YmQffRkpQA6Ta7OX1Z+Vlv7BqZq1Cp+Wb3zkliE9Phv08y 6fglaxKtAhSSaXsf8jgR2PHv0OiADGBDioK83qdaYBWHTG3e/DYRRGtFI A==; X-CSE-ConnectionGUID: spRguPK9TvOT758o5iXF4w== X-CSE-MsgGUID: NJUPvoHfQlm9W8+p5miUjw== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353394" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353394" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:58 -0700 X-CSE-ConnectionGUID: XGZgt2RzRBmtmB5F/ZaYNg== X-CSE-MsgGUID: fjbYAFyOT6CMJ5BGhw7cRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442647" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:56 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 10/21] usb: xhci: move all segment re-numbering to xhci_link_rings() Date: Wed, 26 Jun 2024 15:48:24 +0300 Message-Id: <20240626124835.1023046-11-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin This is a preparation patch for switching from custom segment list handling to using list.h functions. Contain all segment re-numbering in xhci_link_rings() which links two segments lists together, and performs all necessary adjustments for them to fit together. No need to send segment number to xhci_alloc_segments_for_ring() as a parameter after this. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 68994ce21933..020a23ece74f 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -153,7 +153,7 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, ring->last_seg = last; } - for (seg = last; seg != ring->last_seg; seg = seg->next) + for (seg = ring->enq_seg; seg != ring->last_seg; seg = seg->next) seg->next->num = seg->num + 1; } @@ -324,12 +324,16 @@ EXPORT_SYMBOL_GPL(xhci_initialize_ring_info); /* Allocate segments and link them for a ring */ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, - struct xhci_segment **first, struct xhci_segment **last, - unsigned int num_segs, unsigned int num, - unsigned int cycle_state, enum xhci_ring_type type, - unsigned int max_packet, gfp_t flags) + struct xhci_segment **first, + struct xhci_segment **last, + unsigned int num_segs, + unsigned int cycle_state, + enum xhci_ring_type type, + unsigned int max_packet, + gfp_t flags) { struct xhci_segment *prev; + unsigned int num = 0; bool chain_links; chain_links = xhci_link_chain_quirk(xhci, type); @@ -388,9 +392,8 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, if (num_segs == 0) return ring; - ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, - &ring->last_seg, num_segs, 0, cycle_state, type, - max_packet, flags); + ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, &ring->last_seg, num_segs, + cycle_state, type, max_packet, flags); if (ret) goto fail; @@ -428,10 +431,8 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, struct xhci_segment *last; int ret; - ret = xhci_alloc_segments_for_ring(xhci, &first, &last, - num_new_segs, ring->enq_seg->num + 1, - ring->cycle_state, ring->type, - ring->bounce_buf_len, flags); + ret = xhci_alloc_segments_for_ring(xhci, &first, &last, num_new_segs, ring->cycle_state, + ring->type, ring->bounce_buf_len, flags); if (ret) return -ENOMEM; From patchwork Wed Jun 26 12:48:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712863 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 949B81822F7 for ; Wed, 26 Jun 2024 12:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406021; cv=none; b=s4TE9uTdhSx0c+FFVnluFzN1ygOBbZrmTSzn1lFggKYU+/AelLlvOKitp8ztW9OCrz4jGayLvSINz/mBA5rAGxH4BPxN3BW0f5h1dgJpgQcEEhwxSr1B28mqozQLs4thKl6hojPlOy3niagwjtVk3qNqTA3D31rtJ+Yc1pAJHeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406021; c=relaxed/simple; bh=fZwTs67BnEpBaW6b3/gDKaY8dkiRQzJyHp+ZIyB5gf0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KCHxihUIlvalJu6xt78Ggu4tKoxHUxvzCcpxh1cKv0+uWfhdP2n4M8KU7tBVYU7W/ZRikeAq0qF8dz9PhSIUpvJm4HLrTECpmg0LUgQgSx0rP/ipY7JRoGD1Ny9GyKnL8hpveAt5dhpH1A/LmVKs2/uffqmQLjJUH1ZxlOemPU8= 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=d84aTcj7; arc=none smtp.client-ip=192.198.163.17 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="d84aTcj7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406020; x=1750942020; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fZwTs67BnEpBaW6b3/gDKaY8dkiRQzJyHp+ZIyB5gf0=; b=d84aTcj7CITfnIRQfiUO1rGlpZ68oTlfvDpyHurZGpIMU+FvCA+giFL6 cM9nrdUtnyJq+T4W0dA/odRLyCVMx0AJbubQAq5xl2NY5x9BH+guXbPJc ykq2S9kC7MMT+KzfzqEoH34+i9wLnQ8sVtXYSEi1ywL++GJDFPwZIAgWE CR88kQcHvNguSFKrNCV0ot4rzgoRqET0/XhL+qgruMEWeIWZt0cbhvqld 0ZOeXiqfWwsG+KSnrZgqGleIhDKeApcCgu/LOJtcQPVdSPgx/R42Uw3zD fOjOiseI5pFrYoBPtlOf1lNDulhETctlwlqf8Y5E/gfot2ulp13qgRzxs Q==; X-CSE-ConnectionGUID: bG1Gbuw/TPGf24KP1BA2sg== X-CSE-MsgGUID: JDDmBbXITXqLOBhp3OXVMw== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353398" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353398" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:46:59 -0700 X-CSE-ConnectionGUID: 4cvR+9XjSt2t/4kwJwg52w== X-CSE-MsgGUID: t7w5xN1uSTiPWGfU6PrA8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442655" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:58 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 11/21] usb: xhci: move untargeted transfer event handling to a separate function Date: Wed, 26 Jun 2024 15:48:25 +0300 Message-Id: <20240626124835.1023046-12-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Move handling transfer events without a target transfer TRB into handle_transferless_tx_event(), this type of event does not utilize the rest of handle_tx_event() and as a result it's better to separate it into a dedicated function. Additionally, this change reduces handle_tx_event()'s size and makes it more readable. [Mathias: Simplify code to return helper function value directly. This removes the second xhci_err() message for untargeted and unexpected event completion types] Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 56 +++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 8502776d84d6..7f40be2a3885 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2562,6 +2562,33 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, return finish_td(xhci, ep, ep_ring, td, trb_comp_code); } +/* Transfer events which don't point to a transfer TRB, see xhci 4.17.4 */ +static int handle_transferless_tx_event(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, + u32 trb_comp_code) +{ + switch (trb_comp_code) { + case COMP_STALL_ERROR: + case COMP_USB_TRANSACTION_ERROR: + case COMP_INVALID_STREAM_TYPE_ERROR: + case COMP_INVALID_STREAM_ID_ERROR: + xhci_dbg(xhci, "Stream transaction error ep %u no id\n", ep->ep_index); + if (ep->err_count++ > MAX_SOFT_RETRY) + xhci_handle_halted_endpoint(xhci, ep, NULL, EP_HARD_RESET); + else + xhci_handle_halted_endpoint(xhci, ep, NULL, EP_SOFT_RESET); + break; + case COMP_RING_UNDERRUN: + case COMP_RING_OVERRUN: + case COMP_STOPPED_LENGTH_INVALID: + break; + default: + xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n", + ep->vdev->slot_id, ep->ep_index); + return -ENODEV; + } + return 0; +} + /* * If this function returns an error condition, it means it got a Transfer * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address. @@ -2605,33 +2632,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, goto err_out; } - /* Some transfer events don't always point to a trb, see xhci 4.17.4 */ - if (!ep_ring) { - switch (trb_comp_code) { - case COMP_STALL_ERROR: - case COMP_USB_TRANSACTION_ERROR: - case COMP_INVALID_STREAM_TYPE_ERROR: - case COMP_INVALID_STREAM_ID_ERROR: - xhci_dbg(xhci, "Stream transaction error ep %u no id\n", - ep_index); - if (ep->err_count++ > MAX_SOFT_RETRY) - xhci_handle_halted_endpoint(xhci, ep, NULL, - EP_HARD_RESET); - else - xhci_handle_halted_endpoint(xhci, ep, NULL, - EP_SOFT_RESET); - break; - case COMP_RING_UNDERRUN: - case COMP_RING_OVERRUN: - case COMP_STOPPED_LENGTH_INVALID: - break; - default: - xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n", - slot_id, ep_index); - goto err_out; - } - return 0; - } + if (!ep_ring) + return handle_transferless_tx_event(xhci, ep, trb_comp_code); /* Count current td numbers if ep->skip is set */ if (ep->skip) From patchwork Wed Jun 26 12:48:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712864 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 16BBF18629A for ; Wed, 26 Jun 2024 12:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406022; cv=none; b=pXHGYjouto9DQx2PtRxsBkKt30lUZjpxBs6GjuPc1xVc5C8PoWQgM8SWo6WKLn9khO9FyYXM4u7o9CZ3VT6HKJYTulR+Lmip9vX0s7oX+9zPC7BYZpMZre6mVRcCeSBGM4RvDtZi/K2F/86fXVHZza49KjwgfGFYzTjN4RV3+qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406022; c=relaxed/simple; bh=0fHEd6QUDtZVl/cbhF+63TlYYmDfWcI/JNnv82wIwhc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nWQ7wvmBNt8pkuq8f5BMOFI/t3mQ4MkcTUuEwWAEMWMsAAtb0xxcNPK/cWD0GNC3I6XUgc3KOtyhEmyJF6CbRBLBODxHjqWvgsqq+ZBWsG9zqLM+q6Qg6HTjLseDNRaBgljrjt7hzKjx9jTYY2t+yUxQjSW3lnEibV/HRCHa2jo= 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=G9YTDtSI; arc=none smtp.client-ip=192.198.163.17 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="G9YTDtSI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406021; x=1750942021; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0fHEd6QUDtZVl/cbhF+63TlYYmDfWcI/JNnv82wIwhc=; b=G9YTDtSInn4fl0ScCIWo+OkuWGAgvKo5CIZddV985uR1uwopC9i1YWHW ZKnVQyiWo17WHqmCU3Wbd1JtO00Y3R0pxU7yy/fBH/lBlldK0AA5+S0Xe jyz57PrST90I6Exr4Jh3qGFx4CkloxdvK+jrMpHgQToNsvJyNbui401qW Q2YJ/pAZH/YMDyl1VxX5NHPbMcMZ12WMrvCQ8kZxM2hOS5P5yZHHCTrNF kXtaxfAtTy/mxpKFctIMip4gSe6tpoe4BzoPZU/VCbnc7IYZbm81tIiTm r9KFRiWJclz63J+xCau+IFa/mS/byYFo6ysBCvGGLFvDAi/sVDkVHKHjZ Q==; X-CSE-ConnectionGUID: BMtSCxbwT8C/yIpEc5xINQ== X-CSE-MsgGUID: B6j47BYxTw6pljkI31G6DA== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353402" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353402" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:01 -0700 X-CSE-ConnectionGUID: o9KcJbXYTpmd744xXR6CRw== X-CSE-MsgGUID: ZmJ0oxvvRI6lpTlj8adAIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442664" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:46:59 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 12/21] usb: xhci: improve error message for targetless transfer event Date: Wed, 26 Jun 2024 15:48:26 +0300 Message-Id: <20240626124835.1023046-13-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Improve error message for unknown transfer event without a TRB, by also printing the event code number. This removes the inevitable question; "what was the unknown event code exactly?" Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7f40be2a3885..d4e4c1c71f90 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2582,8 +2582,8 @@ static int handle_transferless_tx_event(struct xhci_hcd *xhci, struct xhci_virt_ case COMP_STOPPED_LENGTH_INVALID: break; default: - xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n", - ep->vdev->slot_id, ep->ep_index); + xhci_err(xhci, "Transfer event %u for unknown stream ring slot %u ep %u\n", + trb_comp_code, ep->vdev->slot_id, ep->ep_index); return -ENODEV; } return 0; From patchwork Wed Jun 26 12:48:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712865 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 1395E1862A4 for ; Wed, 26 Jun 2024 12:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406024; cv=none; b=Ru3YhEaS6+gM+AV+MWNVEG49sJKxMJGTXfDAZr01M2hH+VRub7Hlj1We624Ix/+jJMrHdHj2E0oYCGS2jHY0Q9I6YtK7366mx5DmWuwTkDEhjK1pLoSwMs/t0JCY1pmVQhOtI7et/nXcWLmFHbO18R1D1J+hqiZF2RXtGrH6mu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406024; c=relaxed/simple; bh=XrZxLF1GsrrK3ggG/UOEThyva4VHGIqS1npY/wmHnHY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ceVIaalKD3jcr7QqA7gC1Kv6RvAvbcnnIKXwTmJXBKJxOCmcldZvybGHrvmZvM3Vy/88r6PM3ePA1hSKFsWxKqUkhdI1ACb+r9bpqJl907S9iciqgvPA9T7pIUVcbucnm6ecoBAyI3sRoOn8yGlxZyt8T1t2sUQ0FuTEzj1pyMU= 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=azki7HnW; arc=none smtp.client-ip=192.198.163.17 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="azki7HnW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406023; x=1750942023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XrZxLF1GsrrK3ggG/UOEThyva4VHGIqS1npY/wmHnHY=; b=azki7HnWKdvuxS7l4XweJ6J/kD9ffjCrETtFe0xi4AYrilhiN6v6IQ2Y 2fZLBoEHAQg4TuQ+aftIe5vStKdjXyWWC+BogdLyLaIC0uAzldwKyYgc0 XPf7Xg5Ldz5sF5r+Ts2Wsw7OWlsuyimGlHSqwEKrqdMy1PJ5pCLX0aymH RGaiFMXx0P+QKDkviA1kGinwE5UcTlO+86ua1dhuApTTX0zR2jziazdYj jMoEyadSxPkHl7/uIqBv1UT+wxouoCM6OpzEPr/2CtDmV4Wr29iUZFD4F ix0Zo3yKS/QVCNIAfUBSQvkI0KWO0UJoDZnW7D7O9WhPAgcFd4GcvXjk+ w==; X-CSE-ConnectionGUID: Z7b9I4lCSvSEAsH81WsrLQ== X-CSE-MsgGUID: rInFaToiSxWFkOpqX+zYQA== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353404" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353404" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:02 -0700 X-CSE-ConnectionGUID: ngMSNATARRqzJdHdy4eIrw== X-CSE-MsgGUID: cxGxdKALR2i/Cq7aG6iK2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442673" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:01 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 13/21] usb: xhci: remove obsolete sanity check debug messages Date: Wed, 26 Jun 2024 15:48:27 +0300 Message-Id: <20240626124835.1023046-14-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Remove debug messages that served as sanity checks during the initial implementation phase of underrun/overrun completion codes. These checks are now unnecessary. Instead, improve the default debug messages for underrun/overrun events, so that they are consistent with the reset of the completion codes. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d4e4c1c71f90..900bf34174f9 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2719,18 +2719,12 @@ static int handle_tx_event(struct xhci_hcd *xhci, * a Ring Overrun Event for IN Isoch endpoint or Ring * Underrun Event for OUT Isoch endpoint. */ - xhci_dbg(xhci, "underrun event on endpoint\n"); - if (!list_empty(&ep_ring->td_list)) - xhci_dbg(xhci, "Underrun Event for slot %u ep %d still with TDs queued?\n", - slot_id, ep_index); + xhci_dbg(xhci, "Underrun event on slot %u ep %u\n", slot_id, ep_index); if (ep->skip) break; return 0; case COMP_RING_OVERRUN: - xhci_dbg(xhci, "overrun event on endpoint\n"); - if (!list_empty(&ep_ring->td_list)) - xhci_dbg(xhci, "Overrun Event for slot %u ep %d still with TDs queued?\n", - slot_id, ep_index); + xhci_dbg(xhci, "Overrun event on slot %u ep %u\n", slot_id, ep_index); if (ep->skip) break; return 0; From patchwork Wed Jun 26 12:48:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712866 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 91CDC1836C8 for ; Wed, 26 Jun 2024 12:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406026; cv=none; b=h+iz0QpJ9FT4T1Dvqfx5KG+uCH6X/yl4DYwNbQ332JgWO752ORmi4otYClnN35IhsrMPTI3Rg/eMsks+TDoat0Z55w3Hk0rfnBMdTpnrUVmAWel1gtMvQWn8SJwIyEmHgxH/Z4JfO236Nqpxv3U6gn2i6j8YRXH8vQXQ/f2YUZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406026; c=relaxed/simple; bh=IACzM/uBS3sHDxS1V7z5DJRW3az1am/eJpqCCLcoJJo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tI/jYPewXjV8hKHz+4PCyK/K76t91LD0m4FNnVX2vhSh8jPB6Zy3FubYqqUQQpGil8ORZrAZ8foh2l8Z6s7AsJ+qeehm3hoG4DXgMoXXJwxAsT2MJQqlOoHr1Ht6tOYf+wPTE5xIv+QEcbO/xkovwKoTqKuzxAphI/x3TBRXG1o= 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=OD6wCfb9; arc=none smtp.client-ip=192.198.163.17 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="OD6wCfb9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406025; x=1750942025; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IACzM/uBS3sHDxS1V7z5DJRW3az1am/eJpqCCLcoJJo=; b=OD6wCfb9QIh4LiZcijPDjsrNIls7QZ6KGKl2ndowBff2P1JdZE2OGPVK nGhzGDm9zs7zHXxfL8orzZLDuntVnM0kEfhzpqMiKSgVLrNcSasBXvkBS bUBdehBrLaqgE/vGfRLvvr31rlf/6WJpSHgwaFAf9VQsREPk/0MhhokPw B+hOO/3nr1ih/896nmdLQQFI1rGmrcBFYM1D9Xki4qETySyKecj6icX+0 pmr5e5O89Moj2x3ySZ147XMU2SjRA7YO9jMmcCwdkDqeHraxZNeiyoI20 LBm+x2DsNL3LBTaYL5VLdmUWL1rtbw/Mupzc4+dyIvyMrxKKjjYGQA1ba Q==; X-CSE-ConnectionGUID: oil8qJfjRnenpblqrnzPHg== X-CSE-MsgGUID: /0JstX8hT+6LaTzwASnzKw== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353408" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353408" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:04 -0700 X-CSE-ConnectionGUID: MuvrZKyjQ2GacOcaQNjBfQ== X-CSE-MsgGUID: gYK/FWH6RqqNdCcCWfgCMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442689" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:02 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 14/21] xhci: rework xhci internal endpoint halt state detection. Date: Wed, 26 Jun 2024 15:48:28 +0300 Message-Id: <20240626124835.1023046-15-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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 When xhci_requires_manual_halt_cleanup() was written it wasn't clear that the xhci internal endpoint halt state always needs to be cleared with a reset endpoint command. Functional stall cases additionally halt the device side endpoint which requires class driver to clear the device side halt with a CLEAR_FEATURE(ENDPOINT_HALT) request as well. Clean up, rename, and make sure the new function always return true when internal endpoint state is halted, including stall cases. Based on related cleanup suggestion code by Niklas Neronin cc: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 56 +++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 900bf34174f9..3479c9cb5d33 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2130,28 +2130,34 @@ static void xhci_clear_hub_tt_buffer(struct xhci_hcd *xhci, struct xhci_td *td, } } -/* Check if an error has halted the endpoint ring. The class driver will - * cleanup the halt for a non-default control endpoint if we indicate a stall. - * However, a babble and other errors also halt the endpoint ring, and the class - * driver won't clear the halt in that case, so we need to issue a Set Transfer - * Ring Dequeue Pointer command manually. +/* + * Check if xhci internal endpoint state has gone to a "halt" state due to an + * error or stall, including default control pipe protocol stall. + * The internal halt needs to be cleared with a reset endpoint command. + * + * External device side is also halted in functional stall cases. Class driver + * will clear the device halt with a CLEAR_FEATURE(ENDPOINT_HALT) request later. */ -static int xhci_requires_manual_halt_cleanup(struct xhci_ep_ctx *ep_ctx, unsigned int trb_comp_code) +static bool xhci_halted_host_endpoint(struct xhci_ep_ctx *ep_ctx, unsigned int comp_code) { - /* TRB completion codes that may require a manual halt cleanup */ - if (trb_comp_code == COMP_USB_TRANSACTION_ERROR || - trb_comp_code == COMP_BABBLE_DETECTED_ERROR || - trb_comp_code == COMP_SPLIT_TRANSACTION_ERROR) - /* The 0.95 spec says a babbling control endpoint - * is not halted. The 0.96 spec says it is. Some HW - * claims to be 0.95 compliant, but it halts the control - * endpoint anyway. Check if a babble halted the - * endpoint. + /* Stall halts both internal and device side endpoint */ + if (comp_code == COMP_STALL_ERROR) + return true; + + /* TRB completion codes that may require internal halt cleanup */ + if (comp_code == COMP_USB_TRANSACTION_ERROR || + comp_code == COMP_BABBLE_DETECTED_ERROR || + comp_code == COMP_SPLIT_TRANSACTION_ERROR) + /* + * The 0.95 spec says a babbling control endpoint is not halted. + * The 0.96 spec says it is. Some HW claims to be 0.95 + * compliant, but it halts the control endpoint anyway. + * Check endpoint context if endpoint is halted. */ if (GET_EP_CTX_STATE(ep_ctx) == EP_STATE_HALTED) - return 1; + return true; - return 0; + return false; } int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) @@ -2321,7 +2327,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, case COMP_STOPPED_LENGTH_INVALID: goto finish_td; default: - if (!xhci_requires_manual_halt_cleanup(ep_ctx, trb_comp_code)) + if (!xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) break; xhci_dbg(xhci, "TRB error %u, halted endpoint index = %u\n", trb_comp_code, ep->ep_index); @@ -2791,11 +2797,9 @@ static int handle_tx_event(struct xhci_hcd *xhci, xhci_dbg(xhci, "td_list is empty while skip flag set. Clear skip flag for slot %u ep %u.\n", slot_id, ep_index); } - if (trb_comp_code == COMP_STALL_ERROR || - xhci_requires_manual_halt_cleanup(ep_ctx, trb_comp_code)) { - xhci_handle_halted_endpoint(xhci, ep, NULL, - EP_HARD_RESET); - } + if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) + xhci_handle_halted_endpoint(xhci, ep, NULL, EP_HARD_RESET); + return 0; } @@ -2911,10 +2915,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, */ if (trb_is_noop(ep_trb)) { - if (trb_comp_code == COMP_STALL_ERROR || - xhci_requires_manual_halt_cleanup(ep_ctx, trb_comp_code)) - xhci_handle_halted_endpoint(xhci, ep, td, - EP_HARD_RESET); + if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) + xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET); } else { td->status = status; From patchwork Wed Jun 26 12:48:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712867 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 E54B91822F3 for ; Wed, 26 Jun 2024 12:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406027; cv=none; b=OhcicmbkIdifHJqgqdSOYSLrdGlPSa9O6R3t0HHA4B7FSGVRjKNMZrhANUjlfSsarDiu3UyeOk8qTUmac9+grB5QWgU3JOb0ajcTnsAFoNhmy3mI42v62wOlBpOBY2NwQ3u4WdFtLcGJDnfevxedtIT/DSBmOOg+y7vDaTgz+yI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406027; c=relaxed/simple; bh=jmWZnCIqgkLd8OyOu0s6Mkzb6PVeEji6dumfz48P/Go=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i3MJc1i3QQphPhLEiVob9bcOiGC//u7do1MSY3M93+Pl1207sochwt8essguN3IaII7Ulak5hDwm9sv+RQ4Mtqy2NsEknDFU8txtzWTf8TucLjDhfs1bsSOTe/UIhFVr4qXjpzwaWmjS9gklmlPCGng3m8Af3rhrn0Q3PqFohww= 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=XjVdpqf7; arc=none smtp.client-ip=192.198.163.17 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="XjVdpqf7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406026; x=1750942026; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jmWZnCIqgkLd8OyOu0s6Mkzb6PVeEji6dumfz48P/Go=; b=XjVdpqf7B1E95IyEiycyvOsMQmN5kd0b8SYy2mr11qBMOXdLeYPqvCpI Ri4mRY9suH53eKnz6JqzGeDfmI+DVdBC1D8aBPOJaIFmukgyPBSMTiyA+ OO5ZACQi2fTw5tvkZjGZY6P8wSLAsTTp+WnDZNPnJtUX+TGFSnYLLVSYk 5g9B/Lu+SdJKavtbEQSlHFqafwndkqHX4Ar73jrFRRRThcSTYvl/LvDCX XqoHOXULJHiHeaWuSTT3dP8wbVjtc7Xu8KFea5donG7/cGohxUPaP+kFq a+RVPBJaGrDTMtrHx3+QmSw9Ivp2ZEgbS5Dg6ej0/iwi/SCswI2nGQLgV g==; X-CSE-ConnectionGUID: ELMlxjR6R3GDn16LUNkVmQ== X-CSE-MsgGUID: Oy8ApBI+QMKU1rU3GZ/DiA== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353412" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353412" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:06 -0700 X-CSE-ConnectionGUID: NEQCoS0kTcuzh60nmMdNSA== X-CSE-MsgGUID: xAS4TpsQT/G4UctCr9xAog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442706" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:04 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 15/21] usb: xhci: ensure skipped isoc TDs are returned when isoc ring is stopped Date: Wed, 26 Jun 2024 15:48:29 +0300 Message-Id: <20240626124835.1023046-16-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Missed service event tells the driver that the hardware wasn't able to process some queued isoc TDs in their right time slots, and some TDs will be skipped. The driver sets a 'skip' flag to indicate that the next transfer event after this event will point to some future TD instead of the next queued TD. Once the driver receives the next event, it will skip and give back all those hardware skipped TDs. However, should this subsequent event be a stop endpoint which does not point to the next pending TD, the driver fails to return the skipped TDs. Instead, it loops for a period before outputting an erroneous message. Fix this by repositioning the 'stop endpoint' check to follow the isoc skip check, ensuring the skipped TDs are properly returned. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 3479c9cb5d33..14898335d193 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2819,19 +2819,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, /* Is this a TRB in the currently executing TD? */ ep_seg = trb_in_td(xhci, td, ep_trb_dma, false); - /* - * Skip the Force Stopped Event. The event_trb(event_dma) of FSE - * is not in the current TD pointed by ep_ring->dequeue because - * that the hardware dequeue pointer still at the previous TRB - * of the current TD. The previous TRB maybe a Link TD or the - * last TRB of the previous TD. The command completion handle - * will take care the rest. - */ - if (!ep_seg && (trb_comp_code == COMP_STOPPED || - trb_comp_code == COMP_STOPPED_LENGTH_INVALID)) { - continue; - } - if (!ep_seg) { if (ep->skip && usb_endpoint_xfer_isoc(&td->urb->ep->desc)) { @@ -2839,6 +2826,18 @@ static int handle_tx_event(struct xhci_hcd *xhci, continue; } + /* + * Skip the Force Stopped Event. The 'ep_trb' of FSE is not in the current + * TD pointed by 'ep_ring->dequeue' because that the hardware dequeue + * pointer still at the previous TRB of the current TD. The previous TRB + * maybe a Link TD or the last TRB of the previous TD. The command + * completion handle will take care the rest. + */ + if (trb_comp_code == COMP_STOPPED || + trb_comp_code == COMP_STOPPED_LENGTH_INVALID) { + return 0; + } + /* * Some hosts give a spurious success event after a short * transfer. Ignore it. From patchwork Wed Jun 26 12:48:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712868 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 6C7B51862BB for ; Wed, 26 Jun 2024 12:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406028; cv=none; b=B3IRqFI5Fj7xx4Sf5j18V1SpHvMI+rJYmPtYt/pq46hPV7pRqE/PMaDxonVm+TCfvfuiUqfWANjtbcF++/T+MI01jkENkP/t2C5Hxk+61IRKMVtBatb1sIHgklZ2m8+SdgC/ZF0A7oUyQ08X14iswpmsR9JZm5DHyVVJssra/84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406028; c=relaxed/simple; bh=w4AA+wcWJnE+8cPEe2cewV+uhUoH9nz5oqtVXRyL8EE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kyii4k5AOjJL3J5tzCFzOJsM8lQDp4OVKhASVMgO5GctqzWf9NoyuWSM1YLL3P7s7O36rbPv5jVFlLkHjqy14BS2+dlw5+VbZbevCNqvIlTVWgAvrPdlLphdMfAYmIbf1BBTOLCDeGx7DpjyhV55MNQuIPpAxM+WNmNAB5PuNQA= 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=nr26iSNm; arc=none smtp.client-ip=192.198.163.17 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="nr26iSNm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406027; x=1750942027; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w4AA+wcWJnE+8cPEe2cewV+uhUoH9nz5oqtVXRyL8EE=; b=nr26iSNm8Uoz7GTKH2vb4OWSARNwnYA8hnJjvmz3dWKjHqWs+tKaE8dK N106quw6NJauVvCRUs3d7p86dYFiy/52ocTwdrdNB/wLpV2XbNc2yP9RC LP3rwmMDvtGBUEA+eY7NWCj7wRCYy9WEp0eFY/9iXH/jo6jDdfdbxna6x JQCdigkH7AxqstAKxuRMR3V2TVPo69b+rhgLIAzQTqbclDe0JIborJCeA yRXxvEN6uKclJaZNXyGJsA4uKYWLFu47qfSHewiZWjIPs8tpY/G3B+J40 CxrDFeac/JAvw+YQdIwamXoZH687X+tu9Dfxa+Ik6Yiiz2tXj+j7zGxCU A==; X-CSE-ConnectionGUID: te5xePYhTEyn0u1ozPyGIA== X-CSE-MsgGUID: sfPm3GtrQ+S4B+uwmA5dnQ== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353415" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353415" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:07 -0700 X-CSE-ConnectionGUID: uZjHRCRWTeC5+fRr4lGxZg== X-CSE-MsgGUID: cs6XywqeR7ekB2hOtyb+Gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442729" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:05 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 16/21] usb: xhci: remove false xhci_giveback_urb_in_irq() header comment Date: Wed, 26 Jun 2024 15:48:30 +0300 Message-Id: <20240626124835.1023046-17-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin The function doesn't releases and re-acquires the lock, this was removed in commit 36dc01657b49 ("usb: host: xhci: Support running urb giveback in tasklet context") Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 14898335d193..8289f69a6978 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -760,10 +760,6 @@ static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, } } -/* - * Must be called with xhci->lock held in interrupt context, - * releases and re-acquires xhci->lock - */ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci, struct xhci_td *cur_td, int status) { From patchwork Wed Jun 26 12:48:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712869 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 25F32186E24 for ; Wed, 26 Jun 2024 12:47:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406030; cv=none; b=fwj695g2K35kFHGbTQJ5hhJ3JbFyJUJPFBcsX4VdMEB4Q2A5fL7CmCdJOqnmAxJFq86mx/fkZgI60j5tMO48mG64UhWq87My+jN5JwpjvRwo9OIubENwkZ3lvHGV3woaNPtv4H9bVOcb5dJrV+HwHGiy19UWChAKJP8UGlgnI+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406030; c=relaxed/simple; bh=gyKO8IFwKr7MXu/XKILJaXKUfHQfFNfxpzzz0D0jN9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RmM4yoYHT8tF2SvzL0vIhv7Dog9tzXK1Ngy0gcWKYNIG0Mhek9fIsoLEz/eNx7kcbG+0+0ftreJSo7gEo3B7dWSCM7/X5RMdzWNxEWqC24uDSRhdvC2Na4TzsHoDpPN5qhS/nkDXN+ACJRK3n+iV5/pUut4QsdNpPuJaRePgRtE= 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=bs+55l+W; arc=none smtp.client-ip=192.198.163.17 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="bs+55l+W" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406029; x=1750942029; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gyKO8IFwKr7MXu/XKILJaXKUfHQfFNfxpzzz0D0jN9M=; b=bs+55l+WyLwPgp81byTzd8uUj+kCfyupPe/N7FTxLoaFzpW7SSYsORPG tMCdEQ9NgbuXzWFXjySxzQcnGg4mhbENdSJYSDA/W5KohgSF9N5cM7mNg M6p0EZ4bVwm5vzELiIkrHwIkXWqEAXyAJi7hqQuUmBJ4nqTx/aB3DoqHx t+rqr8y6B6hvuCBdks0FyrNvkvBm8JGhaZCSXVNfL5ZCHHhmFXfaKi6on JNizuZUPi2sAc796YDtMo8bZ+Lb5Rgo01uuK5XJI1+b/aeWjbHSjdWR1w DoHNKk0VoOMDSvpkInUienVXGEmNwWiZARkyw8yWCuqtJ3lbD3vsRd3xw Q==; X-CSE-ConnectionGUID: /1rf79BxQOGtt52mYL2Xtg== X-CSE-MsgGUID: h4mFc3fWR+6qdqb9k+M5mQ== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353420" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353420" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:09 -0700 X-CSE-ConnectionGUID: SA/TNRwgSeKhZQVd1Bw7GA== X-CSE-MsgGUID: XJvCFHs5Tyyr7MarGYHYvQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442745" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:07 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 17/21] usb: xhci: remove infinite loop prevention Date: Wed, 26 Jun 2024 15:48:31 +0300 Message-Id: <20240626124835.1023046-18-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin If a buggy HW reports some unpredicted event (for example, an overrun event following a MSE event while the EP ring is actually not empty), the driver will never find the TD, and it will loop until the TD list is empty. Before commits [1][2], the spin lock was released when giving back a URB in the do-while loop. This could cause more TD to be added to TD list, causing an infinite loop. Because of commits [1][2] the spin lock is not released any more, thus the infinite loop prevention is unnecessary and is removed. [1], commit 0c03d89d0c71 ("xhci: Giveback urb in finish_td directly") [2], commit 36dc01657b49 ("usb: host: xhci: Support running urb giveback in tasklet context") Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 8289f69a6978..7baa9dc706a1 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2611,7 +2611,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, int status = -EINPROGRESS; struct xhci_ep_ctx *ep_ctx; u32 trb_comp_code; - int td_num = 0; slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1; @@ -2637,10 +2636,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, if (!ep_ring) return handle_transferless_tx_event(xhci, ep, trb_comp_code); - /* Count current td numbers if ep->skip is set */ - if (ep->skip) - td_num += list_count_nodes(&ep_ring->td_list); - /* Look for common error cases */ switch (trb_comp_code) { /* Skip codes that require special handling depending on @@ -2799,18 +2794,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, return 0; } - /* We've skipped all the TDs on the ep ring when ep->skip set */ - if (ep->skip && td_num == 0) { - ep->skip = false; - xhci_dbg(xhci, "All tds on the ep_ring skipped. Clear skip flag for slot %u ep %u.\n", - slot_id, ep_index); - return 0; - } - td = list_first_entry(&ep_ring->td_list, struct xhci_td, td_list); - if (ep->skip) - td_num--; /* Is this a TRB in the currently executing TD? */ ep_seg = trb_in_td(xhci, td, ep_trb_dma, false); From patchwork Wed Jun 26 12:48:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712870 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 DB3B6186E2F for ; Wed, 26 Jun 2024 12:47:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406032; cv=none; b=JQQO7hKq1n+N2D83+xtatcSBB4epmz9bBBNBQ3P+TgJAn/ZQFL9uySNMO1rQ8XqFeHVzs1FipZVp2iSUrmePhgnIVgWoVbhA8PWOlkrZtquJoEiE1LYLg91Y2gnL4d4/Oeca53uk5KxlCoW3NRp3x0TVonCiFbzyvffcVEFA2no= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406032; c=relaxed/simple; bh=0KX1SWGKZPgHn9BKoc2/Di9yJ5BVdKiRXVmVIFawINE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hzVDwrGtAIqDSPod2mwh3y739IiYNXoUI6dlParAPPOKS8Lbm/VkocH0vTTWl4KACTbQ/IvlkhxJmawnhgoZf+xsfI0ZzE6Xpxthty9r6AzvdollwBx85+/Ws3oWr7gSHV/8JA3Z+OqHyQxjbuIl73Ertibf/7JhF/EeouJ+3aI= 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=ORbpjj9o; arc=none smtp.client-ip=192.198.163.17 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="ORbpjj9o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406031; x=1750942031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0KX1SWGKZPgHn9BKoc2/Di9yJ5BVdKiRXVmVIFawINE=; b=ORbpjj9osT5lfJEpTyxea/MsbrMUQpHwH6ImCMFSRvf/bvuIoYC3AfDf 2Mk1v/nzayjDUDU73RslTLaVuZLUvkbPIrQHfuArfUKVOtxC/HzzW8Dxq rfVOGUGvkqqWIlUdI+bqOyF8gExwwKLbgcKwdOSLKfDA0cAE4aDCu9I75 /wgOL09xMUlpWYHsrEXqWViHxVShi0FgtWZyssuHm0P9lEtHm8E/Bns5p shnkc5q2Ah9jSfil1sek1md1TKjdDSRL7Yr6aNyBB57+oPwdlXvX/QZsB oakbCyQGaFssoF7SvCAolB4K/dBxVARW+ysRSevrayMneFioNXJwWLgok A==; X-CSE-ConnectionGUID: qYaGZecXTHy6MxwrD+Wiqw== X-CSE-MsgGUID: xeN7Q0gjTO2HP4qemT7M4Q== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353424" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353424" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:10 -0700 X-CSE-ConnectionGUID: mrnxvpe2RtSOvIoTSEoU8A== X-CSE-MsgGUID: ksXbhk3aT3iRHvTRYYvMtw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442753" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:08 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 18/21] usb: xhci: move process TD code out of the while loop Date: Wed, 26 Jun 2024 15:48:32 +0300 Message-Id: <20240626124835.1023046-19-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin This part is and should only performed once, so it's moved out of the while loop to improve code readability. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 62 +++++++++++++++++------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7baa9dc706a1..d037d3bbc767 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2868,10 +2868,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, return -ESHUTDOWN; } } - if (trb_comp_code == COMP_SHORT_PACKET) - ep_ring->last_td_was_short = true; - else - ep_ring->last_td_was_short = false; if (ep->skip) { xhci_dbg(xhci, @@ -2880,34 +2876,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, ep->skip = false; } - ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) / - sizeof(*ep_trb)]; - - trace_xhci_handle_transfer(ep_ring, - (struct xhci_generic_trb *) ep_trb); - - /* - * No-op TRB could trigger interrupts in a case where - * a URB was killed and a STALL_ERROR happens right - * after the endpoint ring stopped. Reset the halted - * endpoint. Otherwise, the endpoint remains stalled - * indefinitely. - */ - - if (trb_is_noop(ep_trb)) { - if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) - xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET); - } else { - td->status = status; - - /* update the urb's actual_length and give back to the core */ - if (usb_endpoint_xfer_control(&td->urb->ep->desc)) - process_ctrl_td(xhci, ep, ep_ring, td, ep_trb, event); - else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc)) - process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event); - else - process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event); - } /* * If ep->skip is set, it means there are missed tds on the * endpoint ring need to take care of. @@ -2916,6 +2884,36 @@ static int handle_tx_event(struct xhci_hcd *xhci, */ } while (ep->skip); + if (trb_comp_code == COMP_SHORT_PACKET) + ep_ring->last_td_was_short = true; + else + ep_ring->last_td_was_short = false; + + ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) / sizeof(*ep_trb)]; + trace_xhci_handle_transfer(ep_ring, (struct xhci_generic_trb *) ep_trb); + + /* + * No-op TRB could trigger interrupts in a case where a URB was killed + * and a STALL_ERROR happens right after the endpoint ring stopped. + * Reset the halted endpoint. Otherwise, the endpoint remains stalled + * indefinitely. + */ + + if (trb_is_noop(ep_trb)) { + if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) + xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET); + } else { + td->status = status; + + /* update the urb's actual_length and give back to the core */ + if (usb_endpoint_xfer_control(&td->urb->ep->desc)) + process_ctrl_td(xhci, ep, ep_ring, td, ep_trb, event); + else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc)) + process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event); + else + process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event); + } + return 0; err_out: From patchwork Wed Jun 26 12:48:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712871 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 E566E1862BB for ; Wed, 26 Jun 2024 12:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406033; cv=none; b=N2GxFQqt8VTClRUDUu44TJV3WWZkjUOXqqR6bX0d0/dLT4Ft0kulePF06UsaihEAF7gxm7upmpuKRB0IuUyBXN+f/J4QEQHofy0Ha6qVyV+yGW1/XBDUz61efRDj6CR9eoHs+Se3SHTsOp0v9erNmvIk4ec+t3k0kH2aZw02+yA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406033; c=relaxed/simple; bh=hrd9w+sxQQLra8j3AHrj+5T3GehonSb9FUtvqUpbx+U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u2WtVrWLiI/xK6WsEB4Bmdr+yEbN4OUviwDC/E3xidnR6YU545mOfRcRlQD5/GavAYznBu4kJNuywkkl6/HKUrtYN73BA30m78WXrYOdrqhzYjx2Kx8ZHltd7/IkIfu6YHkO+jtX3LuMlbSMnUrvX+4wMKFLZv13d1NVdIcz/vg= 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=CMb0S3UU; arc=none smtp.client-ip=192.198.163.17 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="CMb0S3UU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406032; x=1750942032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hrd9w+sxQQLra8j3AHrj+5T3GehonSb9FUtvqUpbx+U=; b=CMb0S3UUxGwbK6ci0Qa5dUDCrzJWiI6tfU+lTJBtsLEqpkR7CgVmqlPB 0qE7vvG9/hGJZSYgg5DflAy970oyYf9xciFLRmOyxoCQtN8U+ntfkORzf +/K/9/Ku3OyOKeaB4uFOMhQjKKzV8WJKD7sEqi94w9hGdWU9uWjru0k8O 4ciDPGr2L3NL+ddiEA6PVvZGzbgIjW+B7mFrSZMxEKnv9XLdESW2y9sH2 6/nxkyYcv0klTgY+2v8v5PAfE7JIjp9qomNq+5o/nURD/uMDu2t14jM6M EjAxWnxb3yYD8NXVaJwPmTQ9gKngxkuWCIhnKXwpN+jlrLQqeXfOM3apU Q==; X-CSE-ConnectionGUID: /Xsw8qFhQz6z3+3KbQ0Qrg== X-CSE-MsgGUID: KAn43+q3QguzSr0LzbLjPQ== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353429" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353429" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:12 -0700 X-CSE-ConnectionGUID: XVsWRc7nQ3+bFasuJALxgA== X-CSE-MsgGUID: MnRyrbpBS1eS5cjwigOKqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442761" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:10 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 19/21] usb: xhci: add 'goto' for halted endpoint check in handle_tx_event() Date: Wed, 26 Jun 2024 15:48:33 +0300 Message-Id: <20240626124835.1023046-20-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Niklas Neronin Add 'goto' statement for a halted endpoint, streamlining the error handling process. In future handle_tx_event() changes this 'goto' statement will have more uses. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d037d3bbc767..49f8f980776b 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2788,10 +2788,9 @@ static int handle_tx_event(struct xhci_hcd *xhci, xhci_dbg(xhci, "td_list is empty while skip flag set. Clear skip flag for slot %u ep %u.\n", slot_id, ep_index); } - if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) - xhci_handle_halted_endpoint(xhci, ep, NULL, EP_HARD_RESET); - return 0; + td = NULL; + goto check_endpoint_halted; } td = list_first_entry(&ep_ring->td_list, struct xhci_td, @@ -2899,20 +2898,22 @@ static int handle_tx_event(struct xhci_hcd *xhci, * indefinitely. */ - if (trb_is_noop(ep_trb)) { - if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) - xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET); - } else { - td->status = status; + if (trb_is_noop(ep_trb)) + goto check_endpoint_halted; - /* update the urb's actual_length and give back to the core */ - if (usb_endpoint_xfer_control(&td->urb->ep->desc)) - process_ctrl_td(xhci, ep, ep_ring, td, ep_trb, event); - else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc)) - process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event); - else - process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event); - } + td->status = status; + + /* update the urb's actual_length and give back to the core */ + if (usb_endpoint_xfer_control(&td->urb->ep->desc)) + process_ctrl_td(xhci, ep, ep_ring, td, ep_trb, event); + else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc)) + process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event); + else + process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event); + +check_endpoint_halted: + if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code)) + xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET); return 0; From patchwork Wed Jun 26 12:48:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712872 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 0F51A186E40; Wed, 26 Jun 2024 12:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406035; cv=none; b=axQ/L0U2GgzJkLeEIZn2pxft6Nwvfi9XMAOq29OsF3UQEVXHxUf7JOCLicw1TcrrSe4Knmx/1+dX0tiC6ju3EAhC2MqmE3OMcrCBgH7oyqjbv+FdKJCSNquFsHJPenxJgVwEaXUITZ/6hUPQ3OcHzF4arIoSipWz86KYzVReECA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406035; c=relaxed/simple; bh=P9g/6krIxhfi7Sdu03FqW5zX9/IBp2+EqMPlCK0xQSE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nCLEjGJZT3knsrr2cIpsVUx/LKAFoV024hVsRqeDleIolhHtjsKExTsSVANOCAGfdVwjstAOEEK+ONDPehHFQfr23Xqvm6pQB9YtdmA7nUCLU+MS5LcxqSk79b3voF8xNf9Xwl2Ad1QmvuOsBIAojzG5eIeE6KA3erZr+3QUSwI= 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=B6wfdRip; arc=none smtp.client-ip=192.198.163.17 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="B6wfdRip" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406034; x=1750942034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P9g/6krIxhfi7Sdu03FqW5zX9/IBp2+EqMPlCK0xQSE=; b=B6wfdRip2WefpZ5t7jMXfZmtTz/auQjL2HWM2gGA+su4oJCCRnp9QeAW yWp2+PL9IJ0lMdmB1fhWwN03QfizJyYXTkBWquW/FXRnFwjmnrn0EHXKz 6Ts8ZzKRTzJJKLoNsi3eYTdy0fW6BJQr+ltOTpUWgEl6B8ZThLugEVen/ R5fdb0rXIaTSvxjeAYA56XYpGNl6HWgZ0K9CaAkGGyq123UtU7YjBaeDv 9S4o8jyce1iawP647UczoIeMM4OnrcuTt6vmz73sQKfttdiQtkzh2usDz IGwZ23vGkZcnSabYrqcEd2qH5T5quTulKD8XTSojxriKef47lbJ/euLvS A==; X-CSE-ConnectionGUID: 2yhParNkQ+GYgo6nRNc1PA== X-CSE-MsgGUID: fmwXxm8+Td+yJSZKIc+3lA== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353435" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353435" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:14 -0700 X-CSE-ConnectionGUID: XPKMWaXcR6yG86aGqaqG6A== X-CSE-MsgGUID: pnBievJeQdiocOfUJECxSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442770" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:11 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Reka Norman , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 20/21] xhci: Apply XHCI_RESET_TO_DEFAULT quirk to TGL Date: Wed, 26 Jun 2024 15:48:34 +0300 Message-Id: <20240626124835.1023046-21-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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: Reka Norman TGL systems have the same issue as ADL, where a large boot firmware delay is seen if USB ports are left in U3 at shutdown. So apply the XHCI_RESET_TO_DEFAULT quirk to TGL as well. The issue it fixes is a ~20s boot time delay when booting from S5. It affects TGL devices, and TGL support was added starting from v5.3. Cc: stable@vger.kernel.org Signed-off-by: Reka Norman Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 05881153883e..dc1e345ab67e 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -50,6 +50,7 @@ #define PCI_DEVICE_ID_INTEL_DENVERTON_XHCI 0x19d0 #define PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI 0x8a13 #define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI 0x9a13 +#define PCI_DEVICE_ID_INTEL_TIGER_LAKE_PCH_XHCI 0xa0ed #define PCI_DEVICE_ID_INTEL_COMET_LAKE_XHCI 0xa3af #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_PCH_XHCI 0x54ed @@ -373,7 +374,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) xhci->quirks |= XHCI_MISSING_CAS; if (pdev->vendor == PCI_VENDOR_ID_INTEL && - (pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI || + (pdev->device == PCI_DEVICE_ID_INTEL_TIGER_LAKE_PCH_XHCI || + pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_PCH_XHCI)) xhci->quirks |= XHCI_RESET_TO_DEFAULT; From patchwork Wed Jun 26 12:48:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13712873 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 9C315186E43 for ; Wed, 26 Jun 2024 12:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406037; cv=none; b=ozuFd+HR8Uipu1Q7jj87gDQOY/QtQ/WSRxAc96Pq/8Zm0Y/Qs3hBP1XIn8/B2e28Vv1pK+Sddyle8BmfiuwFAbSXf8b0B4Rvxn8LT+qbHGD93oyCNgKNiuQYvNfkO3Ci9FF7xwGREXMGZARLiIv8KU5oXui2m0CSwM07rUp0xOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719406037; c=relaxed/simple; bh=vmBUWblzpmIXath72nBkIqVv4PUWSos71TXTYhsxET0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EeOCgMUdyCiclpxTbeo/nvlR0ROoitztLgHJFJbrf1o5nU+pJiEy2MqlCcjYI4zcUMl/q9K3sEH7tSdAiqPHRH++sFgOMoAd8HYY1419W8c/avY5B7erIA935vxd52t5O+2As322zgC6mTwMO9vWykyLr5qdQjZVFTCofofF2dU= 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=feqtQsRf; arc=none smtp.client-ip=192.198.163.17 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="feqtQsRf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719406036; x=1750942036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vmBUWblzpmIXath72nBkIqVv4PUWSos71TXTYhsxET0=; b=feqtQsRfd69zYPFykg6AjhVkpjXyrZGgZ6ANi+1W+7RHmgMwcPIRNTkr cZWQt12XOBdtbgzQwsXYa8LHUM0QBuiNruf8UexSGi/A52Bx9WBivWvT0 UzQ+7Tp6uWchmrNTgi1rYBzI8DIJgCDv9rWi/dHxR+n7jqutxMAxeKffZ OC7ge9yCYtuBk8S+07+F/+2Ou9Dsq6C/EfW/osRgvvnHGaz8Yz3DsGJ0L WEmY71mmiI+vogqQgphbUTzS20dL/N5iWFxZtEu6wPRHDf3bxK3KWg0F/ cKgxTFxhb8mqrLXBFicGe17JmhXPS6UqkgShg4F6NzjeqJo71cY1gS+lO A==; X-CSE-ConnectionGUID: Mp8LjKlIRHe5uF4P+p+hpQ== X-CSE-MsgGUID: NNpfozK/SMSjjPI52tBABw== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="16353440" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="16353440" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 05:47:15 -0700 X-CSE-ConnectionGUID: VPEENAWRS4iTxtwXd7HdgQ== X-CSE-MsgGUID: ZJcsSEWOTEeQUL3mzP4FUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="48442776" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 26 Jun 2024 05:47:13 -0700 From: Mathias Nyman To: Cc: , niklas.neronin@linux.intel.com, Mathias Nyman Subject: [PATCH 21/21] xhci: sort out TRB Endpoint ID bitfield macros Date: Wed, 26 Jun 2024 15:48:35 +0300 Message-Id: <20240626124835.1023046-22-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626124835.1023046-1-mathias.nyman@linux.intel.com> References: <20240626124835.1023046-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 xhci macros that read and write endpoint ID bitfields of TRBs are mixing the 1-based Endpoint ID as described in the xHCI specification, and 0-based endpoint index used by driver as an array index. Sort this out by naming macros that deal with 1 based Endpoint ID fields to *_EP_ID_*, and 0 based endpoint index values to *_EP_INDEX_*. Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 6 +++--- drivers/usb/host/xhci.h | 33 ++++++++++++++------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 49f8f980776b..b7517c3c8059 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -715,7 +715,7 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci, lower_32_bits(addr) | trb_sct | new_cycle, upper_32_bits(addr), STREAM_ID_FOR_TRB(stream_id), SLOT_ID_FOR_TRB(slot_id) | - EP_ID_FOR_TRB(ep_index) | TRB_TYPE(TRB_SET_DEQ), false); + EP_INDEX_FOR_TRB(ep_index) | TRB_TYPE(TRB_SET_DEQ), false); if (ret < 0) { xhci_free_command(xhci, cmd); return ret; @@ -4379,7 +4379,7 @@ int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, struct xhci_command *cmd, int slot_id, unsigned int ep_index, int suspend) { u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id); - u32 trb_ep_index = EP_ID_FOR_TRB(ep_index); + u32 trb_ep_index = EP_INDEX_FOR_TRB(ep_index); u32 type = TRB_TYPE(TRB_STOP_RING); u32 trb_suspend = SUSPEND_PORT_FOR_TRB(suspend); @@ -4392,7 +4392,7 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd, enum xhci_ep_reset_type reset_type) { u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id); - u32 trb_ep_index = EP_ID_FOR_TRB(ep_index); + u32 trb_ep_index = EP_INDEX_FOR_TRB(ep_index); u32 type = TRB_TYPE(TRB_RESET_EP); if (reset_type == EP_SOFT_RESET) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 65c84185c7fd..9fa1b58121f0 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -805,13 +805,19 @@ struct xhci_transfer_event { __le32 flags; }; +/* Transfer event flags bitfield, also for select command completion events */ +#define TRB_TO_SLOT_ID(p) (((p) >> 24) & 0xff) +#define SLOT_ID_FOR_TRB(p) (((p) & 0xff) << 24) + +#define TRB_TO_EP_ID(p) (((p) >> 16) & 0x1f) /* Endpoint ID 1 - 31 */ +#define EP_ID_FOR_TRB(p) (((p) & 0x1f) << 16) + +#define TRB_TO_EP_INDEX(p) (TRB_TO_EP_ID(p) - 1) /* Endpoint index 0 - 30 */ +#define EP_INDEX_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16) + /* Transfer event TRB length bit mask */ -/* bits 0:23 */ #define EVENT_TRB_LEN(p) ((p) & 0xffffff) -/** Transfer Event bit fields **/ -#define TRB_TO_EP_ID(p) (((p) >> 16) & 0x1f) - /* Completion Code - only applicable for some types of TRBs */ #define COMP_CODE_MASK (0xff << 24) #define GET_COMP_CODE(p) (((p) & COMP_CODE_MASK) >> 24) @@ -950,8 +956,6 @@ struct xhci_event_cmd { __le32 flags; }; -/* flags bitmasks */ - /* Address device - disable SetAddress */ #define TRB_BSR (1<<9) @@ -987,13 +991,8 @@ enum xhci_setup_dev { /* bits 16:23 are the virtual function ID */ /* bits 24:31 are the slot ID */ -#define TRB_TO_SLOT_ID(p) (((p) & (0xff<<24)) >> 24) -#define SLOT_ID_FOR_TRB(p) (((p) & 0xff) << 24) /* Stop Endpoint TRB - ep_index to endpoint ID for this TRB */ -#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1) -#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16) - #define SUSPEND_PORT_FOR_TRB(p) (((p) & 1) << 23) #define TRB_TO_SUSPEND_PORT(p) (((p) & (1 << 23)) >> 23) #define LAST_EP_INDEX 30 @@ -2023,8 +2022,7 @@ static inline const char *xhci_decode_trb(char *str, size_t size, field1, field0, xhci_trb_comp_code_string(GET_COMP_CODE(field2)), EVENT_TRB_LEN(field2), TRB_TO_SLOT_ID(field3), - /* Macro decrements 1, maybe it shouldn't?!? */ - TRB_TO_EP_INDEX(field3) + 1, + TRB_TO_EP_ID(field3), xhci_trb_type_string(type), field3 & EVENT_DATA ? 'E' : 'e', field3 & TRB_CYCLE ? 'C' : 'c'); @@ -2139,8 +2137,7 @@ static inline const char *xhci_decode_trb(char *str, size_t size, xhci_trb_type_string(type), field1, field0, TRB_TO_SLOT_ID(field3), - /* Macro decrements 1, maybe it shouldn't?!? */ - TRB_TO_EP_INDEX(field3) + 1, + TRB_TO_EP_ID(field3), field3 & TRB_TSP ? 'T' : 't', field3 & TRB_CYCLE ? 'C' : 'c'); break; @@ -2150,8 +2147,7 @@ static inline const char *xhci_decode_trb(char *str, size_t size, xhci_trb_type_string(type), TRB_TO_SLOT_ID(field3), TRB_TO_SUSPEND_PORT(field3), - /* Macro decrements 1, maybe it shouldn't?!? */ - TRB_TO_EP_INDEX(field3) + 1, + TRB_TO_EP_ID(field3), field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_SET_DEQ: @@ -2161,8 +2157,7 @@ static inline const char *xhci_decode_trb(char *str, size_t size, field1, field0, TRB_TO_STREAM_ID(field2), TRB_TO_SLOT_ID(field3), - /* Macro decrements 1, maybe it shouldn't?!? */ - TRB_TO_EP_INDEX(field3) + 1, + TRB_TO_EP_ID(field3), field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_RESET_DEV: