From patchwork Mon Apr 29 14:02: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: 794082 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 1A08D745ED for ; Mon, 29 Apr 2024 14:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399260; cv=none; b=kVzXVwUHC9EqTNVtwyNqPAjVKKeCnHGZoMtytat4yjuuehLCMRUTEutxnVM8avEfxVSOqJ5DXMDWsgqi2A5pJlwRvh78WBwsr4n98u0xJX+ihG5PdhH9xtDWZN6N703aoh6yEIyNDTunUsbL4g0czLT8Sv96ectAfu16Yz8id60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399260; c=relaxed/simple; bh=uBHpdgfXYDHqqLUzjS9tEh9OLd8olCrWwN/k2zfznaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IdLFHonUhX35At8YEZu2pYqNbZvcPARYb0cSrE+BBM3dgH7KmCdOOIznVL887S4F+m3J76nzxrqGYsWkg92d4Xx3YPVeXM7auxLaZCo38EqLJiYoj9tP5TCmiOHKMka1X8S3AafusjFLl9OXpGAwRg403D6sCZAEMea5DPsDtig= 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=YnthhJx/; arc=none smtp.client-ip=192.198.163.18 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="YnthhJx/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399259; x=1745935259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uBHpdgfXYDHqqLUzjS9tEh9OLd8olCrWwN/k2zfznaw=; b=YnthhJx/2h2ShfO61s3WFMnnFU6OILuoLP6vROxgyykG8ZRaB+z0x0dM /nsUzgYh074ZsW+vt+JroKeg6LWe98sMdbO6CleE8S2LZH0hfATMii0RV qdqKj5JW+0QXYZWB/LbiEHhHDIdWpMReT2v5CrchZVYWHDWK3IwLhyizH m44Ika/nfVE//fr6lw6ymlyOO9Fj8MbIcr6qT7StVczdUNAMlbGNRdCeI z9UAAN0fpmOA93KLAXOi08zxIQBWKJYz7IaIvj1/ugK10UNIM5CAizSaQ ufOSNyFohxjWUkR40guZCjhmP1DMV4zc7jr0vVXR2Yq/vMyckxz8/p8wM A==; X-CSE-ConnectionGUID: AyKjQpmZRvyqdUfTDqVznQ== X-CSE-MsgGUID: syCZyPiAS06nFwwrkA5s5g== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911380" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911380" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:00:58 -0700 X-CSE-ConnectionGUID: uh6h8/jCT+2pjww/ej8Dxg== X-CSE-MsgGUID: 8/uECPFxROqrV5/8PyPpRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521646" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:00:56 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman Subject: [PATCH 01/18] xhci: stored cached port capability values in one place Date: Mon, 29 Apr 2024 17:02:28 +0300 Message-Id: <20240429140245.3955523-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Port capability flags for USB2 ports have been cached in an u32 xhci->ext_caps[] array long before the driver had struct xhci_port and struct xhci_port_cap structures. Move these cached USB2 port capability values together with the other port capability values into struct xhci_port_cap cability structure. This also gets rid of the cumbersome way of mapping port to USB2 capability based on portnum as each port has a pointer to its capability structure. Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 12 +----------- drivers/usb/host/xhci.c | 19 +++++-------------- drivers/usb/host/xhci.h | 4 +--- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 69dd86669883..7ff2ff29b48e 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1950,7 +1950,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) kfree(xhci->usb3_rhub.ports); kfree(xhci->hw_ports); kfree(xhci->rh_bw); - kfree(xhci->ext_caps); for (i = 0; i < xhci->num_port_caps; i++) kfree(xhci->port_caps[i].psi); kfree(xhci->port_caps); @@ -1961,7 +1960,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) xhci->usb3_rhub.ports = NULL; xhci->hw_ports = NULL; xhci->rh_bw = NULL; - xhci->ext_caps = NULL; xhci->port_caps = NULL; xhci->interrupters = NULL; @@ -2089,10 +2087,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, port_cap->maj_rev = major_revision; port_cap->min_rev = minor_revision; - - /* cache usb2 port capabilities */ - if (major_revision < 0x03 && xhci->num_ext_caps < max_caps) - xhci->ext_caps[xhci->num_ext_caps++] = temp; + port_cap->protocol_caps = temp; if ((xhci->hci_version >= 0x100) && (major_revision != 0x03) && (temp & XHCI_HLC)) { @@ -2212,11 +2207,6 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) XHCI_EXT_CAPS_PROTOCOL); } - xhci->ext_caps = kcalloc_node(cap_count, sizeof(*xhci->ext_caps), - flags, dev_to_node(dev)); - if (!xhci->ext_caps) - return -ENOMEM; - xhci->port_caps = kcalloc_node(cap_count, sizeof(*xhci->port_caps), flags, dev_to_node(dev)); if (!xhci->port_caps) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 8579603edaff..7f07672d4110 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4511,23 +4511,14 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, * only USB2 ports extended protocol capability values are cached. * Return 1 if capability is supported */ -static int xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int port, +static bool xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int portnum, unsigned capability) { - u32 port_offset, port_count; - int i; + struct xhci_port *port; - for (i = 0; i < xhci->num_ext_caps; i++) { - if (xhci->ext_caps[i] & capability) { - /* port offsets starts at 1 */ - port_offset = XHCI_EXT_PORT_OFF(xhci->ext_caps[i]) - 1; - port_count = XHCI_EXT_PORT_COUNT(xhci->ext_caps[i]); - if (port >= port_offset && - port < port_offset + port_count) - return 1; - } - } - return 0; + port = xhci->usb2_rhub.ports[portnum]; + + return !!(port->port_cap->protocol_caps & capability); } static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6f4bf98a6282..1c9519205330 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1451,6 +1451,7 @@ struct xhci_port_cap { u8 psi_uid_count; u8 maj_rev; u8 min_rev; + u32 protocol_caps; }; struct xhci_port { @@ -1640,9 +1641,6 @@ struct xhci_hcd { unsigned broken_suspend:1; /* Indicates that omitting hcd is supported if root hub has no ports */ unsigned allow_single_roothub:1; - /* cached usb2 extened protocol capabilites */ - u32 *ext_caps; - unsigned int num_ext_caps; /* cached extended protocol port capabilities */ struct xhci_port_cap *port_caps; unsigned int num_port_caps; From patchwork Mon Apr 29 14:02: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: 793279 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 0785274C09 for ; Mon, 29 Apr 2024 14:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399261; cv=none; b=HkM9iUNL7UxgZ6jUnSUUCSM8O0L7sodAzxHFduqZpPyUozcyJA697V4v6n/YnGBHsOnM0LqRHoYLzhiY7n4Q68H1UE7GsFGVcNWGVSR5lUC+OLsOLRCD5IfF/9UrSXazVcNFrd10uW4iY+mJk7X4jgmioucGgyXWcmcJtW9Dz4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399261; c=relaxed/simple; bh=1p91F6Dt9s+w7EmMhhZPUClWa7pKpEUcU9Iem6I32Vw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R0UiPtTMvX+AF1peRc2SG3Q18B/7U3UKmbeEzJ1KoyBPfIMtrOYDwqTkRHqOt178h2nZZzvTSB8CNd/R9qjFC4VYE822XQ/48SaXS77ANq0KBuWz+9bZXN4yGU8V5AcobrelKYJlL9ZFhHi3q6VbMw0gEuBGzFPrmPY023crGLQ= 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=ebb7gUeG; arc=none smtp.client-ip=192.198.163.18 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="ebb7gUeG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399260; x=1745935260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1p91F6Dt9s+w7EmMhhZPUClWa7pKpEUcU9Iem6I32Vw=; b=ebb7gUeGhV9kV6zMNzvelAVbiXJ5wr/mNR6CvYfd9HlpGFlcdlzrMvzC 3N/E9ggxKix2fygqGKPWjblbkdXGytYXbUoELU+r6Aace9ZEF7ZT783GS GC87TZMcjBpx344/HvzaK2K93qs2tJ8XdyvMcAoS+ky6vB+LGbzNLkjWI iRrvR0ot23HQ+z0RfjZmv1t8PJj75wQzld6gOtaqBQ5/1UD6aFcc7gLv7 NyYilWQ3ncMxs20T0wWL6H3l0Je6Hzt12Pg8ILmimrT9g1MkfikkUOK7f fJ2nIdg4EfqAO9S1b6ttombLJxfcHpHDEC2LeGH+nkRSHlCcm7VHOWUT/ g==; X-CSE-ConnectionGUID: 58m1W6dUShOKGbOHfTYoHg== X-CSE-MsgGUID: igYOAaOURby7wTi7GxTGKg== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911389" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911389" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:00 -0700 X-CSE-ConnectionGUID: CI+c7lx5Trmaa+R6WSCtAA== X-CSE-MsgGUID: wbq8t7AwT1+S3bXs1NfeZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521669" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:00:58 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman Subject: [PATCH 02/18] xhci: remove xhci_check_usb2_port_capability helper Date: Mon, 29 Apr 2024 17:02:29 +0300 Message-Id: <20240429140245.3955523-3-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 This helper was only called from one function. Removing it both reduces lines of code and made it more readable. Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 7f07672d4110..37eb37b0affa 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4507,26 +4507,13 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, return 0; } -/* check if a usb2 port supports a given extened capability protocol - * only USB2 ports extended protocol capability values are cached. - * Return 1 if capability is supported - */ -static bool xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int portnum, - unsigned capability) -{ - struct xhci_port *port; - - port = xhci->usb2_rhub.ports[portnum]; - - return !!(port->port_cap->protocol_caps & capability); -} - static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); - int portnum = udev->portnum - 1; + struct xhci_port *port; + u32 capability; - if (hcd->speed >= HCD_USB3 || !udev->lpm_capable) + if (hcd->speed >= HCD_USB3 || !udev->lpm_capable || !xhci->hw_lpm_support) return 0; /* we only support lpm for non-hub device connected to root hub yet */ @@ -4534,14 +4521,14 @@ static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) udev->descriptor.bDeviceClass == USB_CLASS_HUB) return 0; - if (xhci->hw_lpm_support == 1 && - xhci_check_usb2_port_capability( - xhci, portnum, XHCI_HLC)) { + port = xhci->usb2_rhub.ports[udev->portnum - 1]; + capability = port->port_cap->protocol_caps; + + if (capability & XHCI_HLC) { udev->usb2_hw_lpm_capable = 1; udev->l1_params.timeout = XHCI_L1_TIMEOUT; udev->l1_params.besl = XHCI_DEFAULT_BESL; - if (xhci_check_usb2_port_capability(xhci, portnum, - XHCI_BLC)) + if (capability & XHCI_BLC) udev->usb2_hw_lpm_besl_capable = 1; } From patchwork Mon Apr 29 14:02: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: 794081 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 536D876402 for ; Mon, 29 Apr 2024 14:01:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399263; cv=none; b=Y15vOPlNm9aMx8xqbStGGqQgqPSJtfJibcPUYz3Zn8+Zo+QeIi+GqR8PcwC2shAkABR6toqhsEtypT4RLN00gJZ/3w6Y3TU4nowKCdPp4CPBHLr1u5wa9ncpBov/x5Ian91YwdcKN8CE5atrpP+z7t3WVMdn5ndG4XEjh9tGdCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399263; c=relaxed/simple; bh=9caxdvmsgFGTSe0fqdsl+P2W9t2tew2KcLKI7d68k4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i7xRoMSzV9iOZfhf1ECwyJUDSb47JbleLthyYMVTk3f49n1s5H1756gKUOwc70FiXvlB027HoWMy6/S2uBTNkspvx5q6E+KnZG60nicFZFXztyIpYeLlS4Y0BiSVXb+kF/HKEkElVCuj6tYbnwsKJxtjQEwr/Dgk6gWsaevUFkw= 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=SN3zN6pd; arc=none smtp.client-ip=192.198.163.18 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="SN3zN6pd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399262; x=1745935262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9caxdvmsgFGTSe0fqdsl+P2W9t2tew2KcLKI7d68k4U=; b=SN3zN6pdKYLGSwUSbt+U4OQMQqgm5ej0SX+mV5+6BupiWmqQVjVhp/vz gf6BgCejFbJWRckmQXPeaH0Pfgr8ET6d+hf//L1Px42zgoDAxWiIJVox5 +2Jo33GqLlS8cI2Ap0iiUMRjoXKd3wfcgAbjL3du2OTBT79TSzVY7Acur rE5LmvkBDAyh6+x8Mo9M0X3QivVftE9mCe4dN1RZioqJKP55If0JbvukA mgzAVu2DUaKUB84MRizAAsNSx61aIlLcKjjpbCR75A9UfxWA9JhDNSg3l kYywEPcn6JBVxXoRLYjXp1CdKC33YVHY7hFZDnORFHegLo3LJFpyD71Qg A==; X-CSE-ConnectionGUID: kwn+sb5nRV6Xc3YoyEFYVw== X-CSE-MsgGUID: WhMd+x6yRGSrhl+dHeir2w== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911396" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911396" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:01 -0700 X-CSE-ConnectionGUID: mFVdWyGNT6aCIEm+Gi3Img== X-CSE-MsgGUID: sbqnhGr5TbOvJcX8Xx9JWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521687" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:00:59 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 03/18] usb: xhci: check if 'requested segments' exceeds ERST capacity Date: Mon, 29 Apr 2024 17:02:30 +0300 Message-Id: <20240429140245.3955523-4-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Check if requested segments ('segs' or 'ERST_DEFAULT_SEGS') exceeds the maximum amount ERST supports. When 'segs' is '0', 'ERST_DEFAULT_SEGS' is used instead. But both values may not exceed ERST max. Macro 'ERST_MAX_SEGS' is renamed to 'ERST_DEFAULT_SEGS'. The new name better represents the macros, which is the number of Event Ring segments to allocate, when the amount is not specified. Additionally, rename and change xhci_create_secondary_interrupter()'s argument 'int num_segs' to 'unsigned int segs'. This makes it the same as its counter part in xhci_alloc_interrupter(). Fixes: c99b38c41234 ("xhci: add support to allocate several interrupters") Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 22 +++++++++++----------- drivers/usb/host/xhci.h | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 7ff2ff29b48e..1a16b44506da 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2259,24 +2259,24 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) } static struct xhci_interrupter * -xhci_alloc_interrupter(struct xhci_hcd *xhci, int segs, gfp_t flags) +xhci_alloc_interrupter(struct xhci_hcd *xhci, unsigned int segs, gfp_t flags) { struct device *dev = xhci_to_hcd(xhci)->self.sysdev; struct xhci_interrupter *ir; - unsigned int num_segs = segs; + unsigned int max_segs; int ret; + if (!segs) + segs = ERST_DEFAULT_SEGS; + + max_segs = BIT(HCS_ERST_MAX(xhci->hcs_params2)); + segs = min(segs, max_segs); + ir = kzalloc_node(sizeof(*ir), flags, dev_to_node(dev)); if (!ir) return NULL; - /* number of ring segments should be greater than 0 */ - if (segs <= 0) - num_segs = min_t(unsigned int, 1 << HCS_ERST_MAX(xhci->hcs_params2), - ERST_MAX_SEGS); - - ir->event_ring = xhci_ring_alloc(xhci, num_segs, 1, TYPE_EVENT, 0, - flags); + ir->event_ring = xhci_ring_alloc(xhci, segs, 1, TYPE_EVENT, 0, flags); if (!ir->event_ring) { xhci_warn(xhci, "Failed to allocate interrupter event ring\n"); kfree(ir); @@ -2334,7 +2334,7 @@ xhci_add_interrupter(struct xhci_hcd *xhci, struct xhci_interrupter *ir, } struct xhci_interrupter * -xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg) +xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct xhci_interrupter *ir; @@ -2344,7 +2344,7 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg) if (!xhci->interrupters || xhci->max_interrupters <= 1) return NULL; - ir = xhci_alloc_interrupter(xhci, num_seg, GFP_KERNEL); + ir = xhci_alloc_interrupter(xhci, segs, GFP_KERNEL); if (!ir) return NULL; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 1c9519205330..8a3ae5049d1c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1392,8 +1392,8 @@ struct urb_priv { struct xhci_td td[] __counted_by(num_tds); }; -/* Reasonable limit for number of Event Ring segments (spec allows 32k) */ -#define ERST_MAX_SEGS 2 +/* Number of Event Ring segments to allocate, when amount is not specified. (spec allows 32k) */ +#define ERST_DEFAULT_SEGS 2 /* Poll every 60 seconds */ #define POLL_TIMEOUT 60 /* Stop endpoint command timeout (secs) for URB cancellation watchdog timer */ @@ -1831,7 +1831,7 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, void xhci_free_container_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); struct xhci_interrupter * -xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg); +xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs); void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct xhci_interrupter *ir); From patchwork Mon Apr 29 14:02: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: 793278 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 04256757E3 for ; Mon, 29 Apr 2024 14:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399265; cv=none; b=oUtG5POGkI+Dozq2PCCi2G9vhEvK9vg6ZkJvkgcYSywYQ/UU3rkK85UMIVUxSFcbL8tpcxjMARNkbD6rgkwr/TGer4z2gvngHQzkt7eF/t91nHcpgv7PmGB6NK80aqQ2zjQi4RnOhSncJ6RXRXfW8QrsDIMO5MtxtY8gp762EA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399265; c=relaxed/simple; bh=TrVmpoQBnatVsTfMlrc5YFUnDB6w6aMg4DgIs4VWnjE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=srkUZb2/gOaVP7ne+F1bRdPNB9r3pRyWg/M0qxLa0jeJKOqBnNmGQLhN1/SiceqT7F58xoWBDlvn1X0lUcwEaLKInQyLOMKiKHJTmE5v8G/ByVJOoCgomDhURFAyAZcvZBCZdoo9JHtf4WaPWNCAG8UDlyMdeWoP375BpaOSIR4= 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=YtyDjaxQ; arc=none smtp.client-ip=192.198.163.18 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="YtyDjaxQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399264; x=1745935264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TrVmpoQBnatVsTfMlrc5YFUnDB6w6aMg4DgIs4VWnjE=; b=YtyDjaxQ0z+P8CGBKa+XKkvtchHXh1NrCojCVHJpLs69LUcvvJEN2aiv s4FhhkHBE7EzkwClruAyk/BN1quMiYMCJ3UOJ3d+8Td873fejo0avKwal MnqEy5EouqP5lkngaZYFllzNBkwYJ0YOsE8TZda2vu1tZ6Yq2XwMjB7eC I5YtR3CVpNdNg70kaVxKxLcuz+nPZXyz5yNX0SEyy3s39cdgu4F5ZZN5b FK5iPn2kyNdXNw5dRmyt4zO4/KCobFDg4tqJkxbjcItnWfrmsPm5K9cZ8 uKCvmYLsM+A+6SwAuTwRnPVG/2VV8YbX+32RJ3+4J+0su3hUHsPkDTd/E g==; X-CSE-ConnectionGUID: 51CUKC2wRW+LwPgZDSNmSQ== X-CSE-MsgGUID: Kj5+L36KSh+6HsEAlcRB8g== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911410" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911410" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:03 -0700 X-CSE-ConnectionGUID: QbBdeY62QlG999QONIFMqw== X-CSE-MsgGUID: NlCoGLhLTuWiroUkGrUe2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521719" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:01 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 04/18] usb: xhci: improve debug message in xhci_ring_expansion_needed() Date: Mon, 29 Apr 2024 17:02:31 +0300 Message-Id: <20240429140245.3955523-5-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Address debug message inaccuracies in xhci_ring_expansion_needed(). Specifically, remove the portion of the debug message that indicates the number of enqueue TRBs to be added to the dequeue segment. This part of the message may mislead and the calculated value is incorrect. Given that this value is not of significant importance and the statement is not consistently accurate, it has been omitted. The specific issues with the debug message that this commit resolves: - The calculation of the number of TRBs is incorrect. The current calculation erroneously includes the link TRB, which is reserved. Furthermore, the calculated number of TRBs can exceed the dequeue segment, resulting in a misleading debug message. - The current phrasing suggests that "ring expansion by X is needed, adding X TRBs moves enqueue Y TRBs into the dequeue segment". The intended message, however, is "IF the ring is NOT expanded by X, THEN adding X TRBs moves enqueue Y TRBs into the dequeue segment". 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 575f0fd9c9f1..3cc5c70d54c7 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -351,10 +351,8 @@ static unsigned int xhci_ring_expansion_needed(struct xhci_hcd *xhci, struct xhc while (new_segs > 0) { seg = seg->next; if (seg == ring->deq_seg) { - xhci_dbg(xhci, "Ring expansion by %d segments needed\n", - new_segs); - xhci_dbg(xhci, "Adding %d trbs moves enq %d trbs into deq seg\n", - num_trbs, trbs_past_seg % TRBS_PER_SEGMENT); + xhci_dbg(xhci, "Adding %d trbs requires expanding ring by %d segments\n", + num_trbs, new_segs); return new_segs; } new_segs--; From patchwork Mon Apr 29 14:02: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: 794080 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 9B1AB74C08 for ; Mon, 29 Apr 2024 14:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399267; cv=none; b=Dj+QxY6OtnFMfbQyBCWKm2euCwi/mZ/zyyLY3yt6b/dxdjgJt54qzRFXuD4oiwCZAIn8D8W0IzPEUKcNdiQ6hcW30QXc0VAr12UVPR8PxCSn0apSptlMScvl2zu/HVIemTh9JAS04dBu/y7jQa3Pywm8WLBsFXdA22AjsnD0c7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399267; c=relaxed/simple; bh=gh7v0TPcm8kafkASBUIJLKChTl6CDwYRLGq0V7ItfFY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Zo0ar3SB2Envzi86GmVP325O33sSmpdHz607gbPMNi5ZJnRHQeWKxkzc+cWxKOlPaCKXulByNGZCFrC7896TtcZr/WZlkYWa0ulrmzNoM/47TpB7yH42p4YQJe1xhqly++KsvTXx4R4p053AdXGDP7KMUXEL451DnSl2CHt/m9g= 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=HzG7hs+1; arc=none smtp.client-ip=192.198.163.18 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="HzG7hs+1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399265; x=1745935265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gh7v0TPcm8kafkASBUIJLKChTl6CDwYRLGq0V7ItfFY=; b=HzG7hs+1wGcytG/vOA0QrI6OEDeaBwoSE87xWPSNR7GOVq3ILT1myDbg /kx0hWauWzeAOcd2VMlBRaUgc6MS6ZWv6IBJoNgFbxMBmyDdgkCLP4QUs NaT67yItYmuJJetgiFyTd/pW6VYV5FdMv2aKSnFfVKq8s8FmuLwP1B1KZ TJG6U8TPd2dhzgxkU2RiAQ42TSQPQ4C+CthVAmcGyM3LJu1r+NJVf9AtR 5bgzA6liVY2NZdSaHDs64RXl3PpYFv8ahkSVMgnZzk4acUXmIEzlwxfQx YPz1dzqvMhjzbVkv7dqhFLZC26dLYpO/QjpCHi1T+H4M1TSHrRS9w6Y/x Q==; X-CSE-ConnectionGUID: ohJk6EvaRLOx4VMl5f6BhQ== X-CSE-MsgGUID: phStoBo5TbmHl9m7GQltsA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911423" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911423" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:05 -0700 X-CSE-ConnectionGUID: MmsuarwLTdSrxsnOq2Wi3Q== X-CSE-MsgGUID: S5WVU9JiQ62s/ATP6xPPew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521744" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:02 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 05/18] usb: xhci: address off-by-one in xhci_num_trbs_free() Date: Mon, 29 Apr 2024 17:02:32 +0300 Message-Id: <20240429140245.3955523-6-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Reduce the number of do-while loops by 1. The number of loops should be number of segment + 1, the +1 is in case deq and enq are on the same segment. But due to the use of a do-while loop, the expression is evaluated after executing the loop, thus the loop is executed 1 extra time. Changing the do-while loop expression from "<=" to "<", reduces the loop amount by 1. The expression "<=" would also work if it was a while loop instead of a do-while loop. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 3cc5c70d54c7..0a7c70ae5edc 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -308,7 +308,7 @@ static unsigned int xhci_num_trbs_free(struct xhci_hcd *xhci, struct xhci_ring * free += last_on_seg - enq; enq_seg = enq_seg->next; enq = enq_seg->trbs; - } while (i++ <= ring->num_segs); + } while (i++ < ring->num_segs); return free; } From patchwork Mon Apr 29 14:02: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: 793277 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 0597D74BF5 for ; Mon, 29 Apr 2024 14:01:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399268; cv=none; b=mbF9gF5P5T0x8vO/utGTvwsiANnxzfqXka/SEecJam9KxZNVPSBmuuDnrUC6FGEl6ZlmIhD91xfGpPzO3bLBRoFaGd/nwtvB9YsUSZFX8sCg5J9xL84H53Xulje+yxwI3AH2k0QfTtSsPemZm5mPX0EFKunlNkHRrIqUkjmZFQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399268; c=relaxed/simple; bh=TCl8LJOvGgdj3eFQUyujeJsy9mLdMahSN6r2KXKroBs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VdYDhqQNfGI01RgfmBTWW2cLOY3X1PcOtHsI6pOePdTcHlTklL5c81IB8vzzbRz/+hCfhjP/BBhFh2AgoDQiJqOKMTqRYTAt9aV/ONxJmjf03nrqTryLhJOKapgiNQOm5d9NVYSncIzIuEaU2GCEW6IMfFKhXuGkx2flVUywMIw= 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=kNz3ljeO; arc=none smtp.client-ip=192.198.163.18 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="kNz3ljeO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399267; x=1745935267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TCl8LJOvGgdj3eFQUyujeJsy9mLdMahSN6r2KXKroBs=; b=kNz3ljeO3Mqpr0BNAcLM8uWr1m+Etv852N6HyT9dlnpK1ds40tqYBpjd U4kSMl/x1anvx9EgDFO1Nd0/vLtzN9nuIBmLX63hPWXBMIpx6/qIlkA91 W3iCq4Sd8I98IJFY9fq2ffTxjUZTzuvvYTbf99gisFy2Ota4eapV4v3Ub mO8iJsA0vbg97jrJuQJlAkUjEQumAH0Cs/dRUhh3EcMaUpIRkUaBHbZsS e4yT/h49par1I8Ea0OzXeJmoJvsapHDoKXUM+7Fmd2mSow1MZ8/miAwQu lj4hgv/8hL3WjnraX6gwkT4V5XwW3B5FlgcbQBrHAhNI9AYI7oznj79kj g==; X-CSE-ConnectionGUID: 7AB2nd6sTnKmghCZBaE9Zw== X-CSE-MsgGUID: BfGdya5NT+Ka8FFw9AQS+w== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911429" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911429" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:06 -0700 X-CSE-ConnectionGUID: Du70qNkNQgWq0XP2SIp3mQ== X-CSE-MsgGUID: F0l09UY0TTK1YNXNZMj9Zw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521761" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:04 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 06/18] usb: xhci: remove redundant variable 'erst_size' Date: Mon, 29 Apr 2024 17:02:33 +0300 Message-Id: <20240429140245.3955523-7-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 'erst_size' represents the maximum capacity of entries that ERST can hold, while 'num_entries' indicates the actual number of entries currently held in the ERST. These two values are identical because the xhci driver does not support ERST expansion. Thus, 'erst_size' is removed. Suggested-by: Mathias Nyman Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-dbgcap.c | 2 +- drivers/usb/host/xhci.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 8a9869ef0db6..872d9cddbcef 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -516,7 +516,7 @@ static int xhci_dbc_mem_init(struct xhci_dbc *dbc, gfp_t flags) goto string_fail; /* Setup ERST register: */ - writel(dbc->erst.erst_size, &dbc->regs->ersts); + writel(dbc->erst.num_entries, &dbc->regs->ersts); lo_hi_writeq(dbc->erst.erst_dma_addr, &dbc->regs->erstba); deq = xhci_trb_virt_to_dma(dbc->ring_evt->deq_seg, diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 8a3ae5049d1c..10805196e197 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1376,8 +1376,6 @@ struct xhci_erst { unsigned int num_entries; /* xhci->event_ring keeps track of segment dma addresses */ dma_addr_t erst_dma_addr; - /* Num entries the ERST can contain */ - unsigned int erst_size; }; struct xhci_scratchpad { From patchwork Mon Apr 29 14:02: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: 794079 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 305137580B for ; Mon, 29 Apr 2024 14:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399270; cv=none; b=IAsCgg/gBbvOwAw5o0e+hfMeB7Dpp7KmzoUY5zJCU0CKahIi4LFa9R4mQjJzRNezbAxp7l8EdZQzAnAYoIjzFQgzPZ48aO/mn371k5naU5h9FQX4wkw/YapbCKVySaHkNuGxq+5r4Y+mocAuJflAEZqDqbmU/8uqhVRSRxajVEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399270; c=relaxed/simple; bh=l1F38xgqcSgczXjmSKwDFuOllZLOa+rHxLYHeJOrwVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s4GHEcW5qtWDCJiUMiEPSDRn5NgHXTBRv3+vs80Aq/1q+j9PGiRpAJEomeBM4Fnmxw+4733gXC/wYwOjty/TJP9nprGfCa9+hdBZz0q3ACjoLbAL0kiC7Yj16t/7c6PoQherHEEs3eNlB9gCkSe2TX1P1QAdn88RbLjwidjwdQ4= 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=lsh2S9M5; arc=none smtp.client-ip=192.198.163.18 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="lsh2S9M5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399269; x=1745935269; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l1F38xgqcSgczXjmSKwDFuOllZLOa+rHxLYHeJOrwVY=; b=lsh2S9M5s1ON/KjdwjoNA14g2MLSuoAhTUBjB9AjGd8Z0UxEbXJxKT/U IF4tGIX08SFI/1ugqEQ0jCLu1gkCiu0VwswX47M5yL++rsQTZiwEt9cyc GyZzd6cdITK4/TZ9GUwG0iDfoA6FulOZUy5meIfnms0FaQr692jUN8+mf YA1HN0/VPo27kIUJgOiGDzj1Xm2yhG0hxxOMZyTxe4RTNEAjhJnPVm0Vb P0N1gRjzsgoNccXs7jR+6IRv+M+UcVMv4RMFWNfAlhhV6uwoUtM8u6nAs GJUUPvIjqmDsm/DAlgfeAGydpjC7TviEiM5cFQgRqW9mDdFV4rWTdOQF2 w==; X-CSE-ConnectionGUID: OmUDmKD1RwGgN91QHbqVsQ== X-CSE-MsgGUID: oYdk1l5ST7K7c2z60BIefQ== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911438" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911438" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:08 -0700 X-CSE-ConnectionGUID: XdglHEObT5WMH9AOvgzNRw== X-CSE-MsgGUID: Hdiob1waQtqVTkN6LFs1uQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521782" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:06 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Andy Shevchenko , Mathias Nyman Subject: [PATCH 07/18] usb: xhci: use array_size() when allocating and freeing memory Date: Mon, 29 Apr 2024 17:02:34 +0300 Message-Id: <20240429140245.3955523-8-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Replace size_mul() with array_size() in memory allocation and freeing processes, it fits better semantically. Macro array_size() is identical to size_mult(), which clamps the max size, so it's imperative that array_size() is used when freeing said memory. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 1a16b44506da..3100219d6496 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -536,7 +536,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci, struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) { struct device *dev = xhci_to_hcd(xhci)->self.sysdev; - size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; + size_t size = array_size(sizeof(struct xhci_stream_ctx), num_stream_ctxs); if (size > MEDIUM_STREAM_ARRAY_SIZE) dma_free_coherent(dev, size, stream_ctx, dma); @@ -561,7 +561,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, gfp_t mem_flags) { struct device *dev = xhci_to_hcd(xhci)->self.sysdev; - size_t size = size_mul(sizeof(struct xhci_stream_ctx), num_stream_ctxs); + size_t size = array_size(sizeof(struct xhci_stream_ctx), num_stream_ctxs); if (size > MEDIUM_STREAM_ARRAY_SIZE) return dma_alloc_coherent(dev, size, dma, mem_flags); @@ -1638,7 +1638,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) goto fail_sp; xhci->scratchpad->sp_array = dma_alloc_coherent(dev, - size_mul(sizeof(u64), num_sp), + array_size(sizeof(u64), num_sp), &xhci->scratchpad->sp_dma, flags); if (!xhci->scratchpad->sp_array) goto fail_sp2; @@ -1671,7 +1671,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) kfree(xhci->scratchpad->sp_buffers); fail_sp3: - dma_free_coherent(dev, num_sp * sizeof(u64), + dma_free_coherent(dev, array_size(sizeof(u64), num_sp), xhci->scratchpad->sp_array, xhci->scratchpad->sp_dma); @@ -1700,7 +1700,7 @@ static void scratchpad_free(struct xhci_hcd *xhci) xhci->scratchpad->sp_array[i]); } kfree(xhci->scratchpad->sp_buffers); - dma_free_coherent(dev, num_sp * sizeof(u64), + dma_free_coherent(dev, array_size(sizeof(u64), num_sp), xhci->scratchpad->sp_array, xhci->scratchpad->sp_dma); kfree(xhci->scratchpad); @@ -1778,7 +1778,7 @@ static int xhci_alloc_erst(struct xhci_hcd *xhci, struct xhci_segment *seg; struct xhci_erst_entry *entry; - size = size_mul(sizeof(struct xhci_erst_entry), evt_ring->num_segs); + size = array_size(sizeof(struct xhci_erst_entry), evt_ring->num_segs); erst->entries = dma_alloc_coherent(xhci_to_hcd(xhci)->self.sysdev, size, &erst->erst_dma_addr, flags); if (!erst->entries) @@ -1829,7 +1829,7 @@ xhci_free_interrupter(struct xhci_hcd *xhci, struct xhci_interrupter *ir) if (!ir) return; - erst_size = sizeof(struct xhci_erst_entry) * ir->erst.num_entries; + erst_size = array_size(sizeof(struct xhci_erst_entry), ir->erst.num_entries); if (ir->erst.entries) dma_free_coherent(dev, erst_size, ir->erst.entries, From patchwork Mon Apr 29 14:02: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: 793276 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 A747875810 for ; Mon, 29 Apr 2024 14:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399272; cv=none; b=uWPwvnttv7LdtxSAdj6eMGrNuEYSpQ9Z6dB8NFAY6Rk/eUX1oPn8YVAA0nfYR9m+aa2XcuEVy6OttUqhEI5fKidhDMK/y+h3NED6NprQ+35mQXfDUoHSymSJjIgK1LCSG1OltmupQCVaaT86ppNedxZxkrG3KYQEoh8fQk+/awI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399272; c=relaxed/simple; bh=xBl/L+VXB8RBzVqO/J3S6IPFK+4HVCi+ovnKlUTawHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TG/UMS/o7BfPX0P1cXqoR0uk/tugOIf0JJoDn7YhPbop3yKV04ddL1UzJyeToIfUBdOX8+EMF5Os2owWmstFt03VtmKJvoZPbLmbR9LAMU/DMDrEwPInKwZVa88WLupVTh2YaNgrIP9T85En2jBvg3NdEPy5+Rpd0v60TMu84PM= 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=DtCOAvSe; arc=none smtp.client-ip=192.198.163.18 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="DtCOAvSe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399270; x=1745935270; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xBl/L+VXB8RBzVqO/J3S6IPFK+4HVCi+ovnKlUTawHc=; b=DtCOAvSeNX8DUyTLZs8kgu8lK6tE+V/8Fk0aYwODy7MBWa4xkNQkyeKq +wprBs4O9NqrcXF4T46nI2Jmvec+ta2f3lKP1F/EX/wH/eDtcCe7v1aEN 25zRBzBGURKxSjweHFNlBIA0toLG4hvABqk8wsIgBKu3LqbBxwXcgoOWD xdJZVTE4fiWZyodlAVlqCkY/VkUbc5vMHHy2kLvh7qZzZ79jzyq5pNcRH kzmh5UB1+yD9FJ9D0Eji1oDt/xXinXuRmZAWUiF6WyVWrxpvrGu2SOkQ0 D7AXL5nNXhO6i1uzFVPlG926xxrmDgx7L9/3Amc/R4vBt/PQ2JFq0qsTX Q==; X-CSE-ConnectionGUID: uVNV40PmTTK53kikxr6LcA== X-CSE-MsgGUID: 9t+bqOACRpWAfgaVPccUuw== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911443" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911443" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:10 -0700 X-CSE-ConnectionGUID: 8ld7ByqpTF+P/VeuD5+CuA== X-CSE-MsgGUID: YVWAOG5kT6qt3A6A1PpOUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521794" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:08 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman Subject: [PATCH 08/18] xhci: improve PORTSC register debugging output Date: Mon, 29 Apr 2024 17:02:35 +0300 Message-Id: <20240429140245.3955523-9-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Print the full hex value of PORTSC register in addition to the human readable decoded string while debugging PORTSC value. If PORTSC value is 0xffffffff then don't decode it. This lets us inspect Rsvd bits of PORTSC. Same is done for USBSTS register values. Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 10805196e197..8c96dd6ef3d4 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2336,7 +2336,12 @@ static inline const char *xhci_decode_portsc(char *str, u32 portsc) { int ret; - ret = sprintf(str, "%s %s %s Link:%s PortSpeed:%d ", + ret = sprintf(str, "0x%08x ", portsc); + + if (portsc == ~(u32)0) + return str; + + ret += sprintf(str + ret, "%s %s %s Link:%s PortSpeed:%d ", portsc & PORT_POWER ? "Powered" : "Powered-off", portsc & PORT_CONNECT ? "Connected" : "Not-connected", portsc & PORT_PE ? "Enabled" : "Disabled", From patchwork Mon Apr 29 14:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 794078 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 EEB127580B for ; Mon, 29 Apr 2024 14:01:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399273; cv=none; b=qtkyOW/Q4NQIt1Z1G3123M51gwoX9P7/BcfzA5H8zD5FvxGBHBQ80Dk3Y1EmZJjx3/Ve5FCBIlR/1fIQFWbu+Q2ewbbS6yEmwIgtJ8rsu6Qp9Uyp+tPVFrVY9cIhSl7dxJf1fFeWceHpyeEhRJKt597wK85W3hzIEwfQTJt0JsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399273; c=relaxed/simple; bh=61nePizSv2lbpRAvQQgT5lWNxRYmKYIsnIKUv6mk8ss=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LRPualD35vZa6eaYWV8vo2qSLSs+8Hi4LEHW2AOdC9q/xJd9oXVTMcNIE7e59L4PndFut2CcWS4qDqu5EfGfZbpuzMwdWXnfbt+PTB8XaHxAORFjFmIo2wCqi2NUCG+HcGLBhiw/40xAQ7Jm786iYh9m8KId4pL4FoS3Ch7oR7I= 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=RYqZSvY/; arc=none smtp.client-ip=192.198.163.18 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="RYqZSvY/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399272; x=1745935272; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=61nePizSv2lbpRAvQQgT5lWNxRYmKYIsnIKUv6mk8ss=; b=RYqZSvY//nPBgqAuVObLLBYbsyp6K7uPxhZrWOUk2CeMxkdE9CVcZxps eoQWf/fg7p19fTY93pwuWaYqOp1jbP5p41P/Mtr5mhIJWYLNoFTDRgbVi My2XOBESYTNzVr703F4yj6HiWK2PcMvzEs4hclNEoIuxa58x0Dcekq/HQ KHYV4JP/4/XIJYP34gprSfcB4AMkzaMfxWBo+Cowqxz2h/UtIKqLJiE3Y Kmem9h5mENBpzEwvtqFxATCedaH4LQD8EyiysTEPk5PWhjdSBTxW8hJ2p QMpfHX9an/34HUtavm2a9mj8AlBc0zYVV6YHPLBh+vOfaUAFyu19+Jxis g==; X-CSE-ConnectionGUID: btygtLVBS42LHbMdCE6eig== X-CSE-MsgGUID: Vv6tilyAQ06nJ10AHnvBZQ== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911456" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911456" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:11 -0700 X-CSE-ConnectionGUID: /oJnT4zYTp+f5g32dFcT3Q== X-CSE-MsgGUID: K0wl/2aZRdiVlPoWoUQZBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521802" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:09 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman , Niklas Neronin Subject: [PATCH 09/18] xhci: remove XHCI_TRUST_TX_LENGTH quirk Date: Mon, 29 Apr 2024 17:02:36 +0300 Message-Id: <20240429140245.3955523-10-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 If this quirk was set then driver would treat transfer events with 'Success' completion code as 'Short packet' if there were untransferred bytes left. This is so common that turn it into default behavior. xhci_warn_ratelimited() is no longer used after this, so remove it. A success event with untransferred bytes left doesn't always mean a misbehaving controller. If there was an error mid a multi-TRB TD it's allowed to issue a success event for the last TRB in that TD. See xhci 1.2 spec 4.9.1 Transfer Descriptors "Note: If an error is detected while processing a multi-TRB TD, the xHC shall generate a Transfer Event for the TRB that the error was detected on with the appropriate error Condition Code, then may advance to the next TD. If in the process of advancing to the next TD, a Transfer TRB is encountered with its IOC flag set, then the Condition Code of the Transfer Event generated for that Transfer TRB should be Success, because there was no error actually associated with the TRB that generated the Event. However, an xHC implementation may redundantly assert the original error Condition Code." Co-developed-by: Niklas Neronin Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 15 ++------------- drivers/usb/host/xhci-rcar.c | 6 ++---- drivers/usb/host/xhci-ring.c | 15 +++++---------- drivers/usb/host/xhci.h | 4 +--- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 93b697648018..653b47c45591 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -270,17 +270,12 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) "QUIRK: Fresco Logic revision %u " "has broken MSI implementation", pdev->revision); - xhci->quirks |= XHCI_TRUST_TX_LENGTH; } if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1009) xhci->quirks |= XHCI_BROKEN_STREAMS; - if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && - pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1100) - xhci->quirks |= XHCI_TRUST_TX_LENGTH; - if (pdev->vendor == PCI_VENDOR_ID_NEC) xhci->quirks |= XHCI_NEC_HOST; @@ -307,11 +302,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) xhci->quirks |= XHCI_RESET_ON_RESUME; } - if (pdev->vendor == PCI_VENDOR_ID_AMD) { - xhci->quirks |= XHCI_TRUST_TX_LENGTH; - if (pdev->device == 0x43f7) - xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; - } + if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43f7) + xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; if ((pdev->vendor == PCI_VENDOR_ID_AMD) && ((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) || @@ -399,12 +391,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) if (pdev->vendor == PCI_VENDOR_ID_ETRON && pdev->device == PCI_DEVICE_ID_EJ168) { xhci->quirks |= XHCI_RESET_ON_RESUME; - xhci->quirks |= XHCI_TRUST_TX_LENGTH; xhci->quirks |= XHCI_BROKEN_STREAMS; } if (pdev->vendor == PCI_VENDOR_ID_RENESAS && pdev->device == 0x0014) { - xhci->quirks |= XHCI_TRUST_TX_LENGTH; xhci->quirks |= XHCI_ZERO_64B_REGS; } if (pdev->vendor == PCI_VENDOR_ID_RENESAS && @@ -434,7 +424,6 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) } if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) { - xhci->quirks |= XHCI_TRUST_TX_LENGTH; xhci->quirks |= XHCI_NO_64BIT_SUPPORT; } if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index ab9c5969e462..8b357647728c 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -214,8 +214,7 @@ static int xhci_rcar_resume_quirk(struct usb_hcd *hcd) */ #define SET_XHCI_PLAT_PRIV_FOR_RCAR(firmware) \ .firmware_name = firmware, \ - .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_TRUST_TX_LENGTH | \ - XHCI_SLOW_SUSPEND, \ + .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND, \ .init_quirk = xhci_rcar_init_quirk, \ .plat_start = xhci_rcar_start, \ .resume_quirk = xhci_rcar_resume_quirk, @@ -229,8 +228,7 @@ static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = { }; static const struct xhci_plat_priv xhci_plat_renesas_rzv2m = { - .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_TRUST_TX_LENGTH | - XHCI_SLOW_SUSPEND, + .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND, .init_quirk = xhci_rzv2m_init_quirk, .plat_start = xhci_rzv2m_start, }; diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0a7c70ae5edc..07c529e072c9 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2397,8 +2397,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, break; if (remaining) { frame->status = short_framestatus; - if (xhci->quirks & XHCI_TRUST_TX_LENGTH) - sum_trbs_for_length = true; + sum_trbs_for_length = true; break; } frame->status = 0; @@ -2648,15 +2647,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, * transfer type */ case COMP_SUCCESS: - if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) - break; - if (xhci->quirks & XHCI_TRUST_TX_LENGTH || - ep_ring->last_td_was_short) + if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { trb_comp_code = COMP_SHORT_PACKET; - else - xhci_warn_ratelimited(xhci, - "WARN Successful completion on short TX for slot %u ep %u: needs XHCI_TRUST_TX_LENGTH quirk?\n", - slot_id, ep_index); + xhci_dbg(xhci, "Successful completion on short TX for slot %u ep %u with last td short %d\n", + slot_id, ep_index, ep_ring->last_td_was_short); + } break; case COMP_SHORT_PACKET: break; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 8c96dd6ef3d4..933f8a296014 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1588,7 +1588,7 @@ struct xhci_hcd { #define XHCI_RESET_ON_RESUME BIT_ULL(7) #define XHCI_SW_BW_CHECKING BIT_ULL(8) #define XHCI_AMD_0x96_HOST BIT_ULL(9) -#define XHCI_TRUST_TX_LENGTH BIT_ULL(10) +#define XHCI_TRUST_TX_LENGTH BIT_ULL(10) /* Deprecated */ #define XHCI_LPM_SUPPORT BIT_ULL(11) #define XHCI_INTEL_HOST BIT_ULL(12) #define XHCI_SPURIOUS_REBOOT BIT_ULL(13) @@ -1725,8 +1725,6 @@ static inline bool xhci_has_one_roothub(struct xhci_hcd *xhci) dev_err(xhci_to_hcd(xhci)->self.controller , fmt , ## args) #define xhci_warn(xhci, fmt, args...) \ dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args) -#define xhci_warn_ratelimited(xhci, fmt, args...) \ - dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args) #define xhci_info(xhci, fmt, args...) \ dev_info(xhci_to_hcd(xhci)->self.controller , fmt , ## args) From patchwork Mon Apr 29 14:02:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 793275 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 48E617BAF7 for ; Mon, 29 Apr 2024 14:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399275; cv=none; b=sNsuVqiKKOuTBxCX0t4uvGTyLC1MGk/frhXYXLvvMaLUgeRC6pVF9fDhO+JA77ycsL+JW1LoQPkxQfVDFjfluR5M1a4EgRyRsV7Iv87q6Tva9FYZoo01Yylh/W+QZzcP1tKpAPp/DoqkEiubJ9YOfsZsCY0mVr5oHnerW3x1IVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399275; c=relaxed/simple; bh=iee2tMXtIwhrLCpcwk2TZxZxA4tIJpkiuevKkLsnFeg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AXWwn9BWx4EbymdY2X607wu6vQ+Z6oWlPcYUs2RmDZ6+c/A8QOMgATlgpBcFu0pq6EhzVODp3LHCayOrj3/ldqTu32fmZPa2AXlkOk+RyydkiOqKMddknGNZ5L3MRhgLWtVpNC4sDuVHhoiUsJOJOSXleA8o8MFx3/jM77O/lX0= 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=l1OWSWrR; arc=none smtp.client-ip=192.198.163.18 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="l1OWSWrR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399274; x=1745935274; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iee2tMXtIwhrLCpcwk2TZxZxA4tIJpkiuevKkLsnFeg=; b=l1OWSWrR2L6HW/jCp4MkQKZmdTqHIIneotyRk2gftXv7RAVsHiB+5vh6 S/MNt2h0k3WcNumhr8zID/NmTwcr08VFBDKQ9iIZEt38BLgX5q9mJzF75 MlNtaqsnZyR/YCVa2A+8f13Zg/bB3zmauwTrsF6GWqD+rre9dJp71QOk/ vwV2GraVELySmfCcy3yib4SRUb69cRPsCi1xoMRPNgJjTCYjUSMe+tQxQ VHuKMwcL9ydAxBdcMhOBSsIdEY0XChUFvtwmiLrsdhkAU4NIlT/1Wz4v/ mZ75F0FGVuKXx6f12xdTIhxn3zSaO0gLw3gTon/2LgauqoeIEF194lSVF Q==; X-CSE-ConnectionGUID: BNqjYZTYTP+1Z+Tr7ZuZYQ== X-CSE-MsgGUID: JSb1MOv4Th2lv5fF5/vbIw== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911463" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911463" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:13 -0700 X-CSE-ConnectionGUID: 8AnAcF48RkS8EikmNCYZ+g== X-CSE-MsgGUID: wa8VWWcEQ8OMaka5FOArTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521813" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:11 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 10/18] usb: xhci: prevent potential failure in handle_tx_event() for Transfer events without TRB Date: Mon, 29 Apr 2024 17:02:37 +0300 Message-Id: <20240429140245.3955523-11-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Some transfer events don't always point to a TRB, and consequently don't have a endpoint ring. In these cases, function handle_tx_event() should not proceed, because if 'ep->skip' is set, the pointer to the endpoint ring is used. To prevent a potential failure and make the code logical, return after checking the completion code for a Transfer event without TRBs. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 07c529e072c9..00f48dd197ac 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2625,16 +2625,17 @@ static int handle_tx_event(struct xhci_hcd *xhci, else xhci_handle_halted_endpoint(xhci, ep, NULL, EP_SOFT_RESET); - goto cleanup; + break; case COMP_RING_UNDERRUN: case COMP_RING_OVERRUN: case COMP_STOPPED_LENGTH_INVALID: - goto cleanup; + 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; } /* Count current td numbers if ep->skip is set */ From patchwork Mon Apr 29 14:02:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 794077 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 BF2E17580B for ; Mon, 29 Apr 2024 14:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399277; cv=none; b=AenwQ/9RxKj52LBnf08SlfvRyga/iFP8bHzqKQiRIs6N9SLm9T8c4g+lmiVTLR2m25OfDKj7aWD996BkBHU/DTBmFZOc8EWwruX+JjHum+9MXBuTdU+4PSJPdDNLzbmpf1gb29bvTAq7HNlDbiQTI5xlcsvjsmyQ0KOYugpZHe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399277; c=relaxed/simple; bh=ZBcJ7kpP+wzthbCxksQVXJ0M6gz//zrZI03BHng7CYI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lFFmdxX6ZGH5cmrWmfNTKSbGZ/XLNxyGOy80niMVm9lgMq32oTXb/OqbroOJqumrY5cmNwYb7LgHgux+nCygKT3+hvwF+mqa1264ExVRZ2pS/P57svRCRbhhOQXk1Qf49/9LSMClKWu5h4jVdZ3xAbxbupCcubQ2JYJvVoYh4pI= 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=lkk6Bo/I; arc=none smtp.client-ip=192.198.163.18 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="lkk6Bo/I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399276; x=1745935276; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZBcJ7kpP+wzthbCxksQVXJ0M6gz//zrZI03BHng7CYI=; b=lkk6Bo/IIljU/7Wu4z8hpedN+TTrz0Acp56CLDgE8G8IpMjKQ1jD93Id 3xn9QPjJnySjPcJr98Nptg4I9r3wduIVIz5znlqIdJ1pFB3Agt9oStAWT FO2CSny4aXfk/IxT/r0hOKiP4iopAdWn0b6416ukyHNdObduZsE+5IKt6 BcBnwp5PuOlAddELcEYz3a1Ey6kBQbPkZzFhCSsyBpM++5g92gi7nwJeL 815IDFe5eMoqzlQ1wkU0iabJq2h9GDt/kMSnZCpWGiHK7AHeThsJDr3qq YjabGaTmOCiJpHSA6FZ5mLSeN+0vV8QBxmLsKVk6oaL2iW1gIJ3cjT9NE Q==; X-CSE-ConnectionGUID: UqmWO05hRl68sR9s6LPdkg== X-CSE-MsgGUID: vxO8WE0jSLaYRqJV+cwrHA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911474" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911474" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:15 -0700 X-CSE-ConnectionGUID: 5BfJ2D+xR0mxIOWLlBhoig== X-CSE-MsgGUID: eeaHUMqaRw+/AmJ6kEUO6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521825" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:13 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 11/18] usb: xhci: remove 'handling_skipped_tds' from handle_tx_event() Date: Mon, 29 Apr 2024 17:02:38 +0300 Message-Id: <20240429140245.3955523-12-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 When handle_tx_event() encounters a COMP_MISSED_SERVICE_ERROR or COMP_NO_PING_RESPONSE_ERROR event, it moves to 'goto cleanup'. Here, it sets a flag, 'handling_skipped_tds', based on conditions that exclude these two error events. Subsequently, the process evaluates the loop that persists as long as 'handling_skipped_tds' remains true. However, since 'trb_comp_code' does not change after its assignment, if it indicates either of the two error conditions, the loop terminates immediately. To simplify this process and enhance clarity, the modification involves returning immediately upon detecting COMP_MISSED_SERVICE_ERROR or COMP_NO_PING_RESPONSE_ERROR. This adjustment allows for the direct use of 'ep->skip', removing the necessity for the 'handling_skipped_tds' flag. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 00f48dd197ac..e96ac2d7b9b1 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2587,7 +2587,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, struct xhci_ep_ctx *ep_ctx; u32 trb_comp_code; int td_num = 0; - bool handling_skipped_tds = false; slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1; @@ -2748,13 +2747,13 @@ static int handle_tx_event(struct xhci_hcd *xhci, xhci_dbg(xhci, "Miss service interval error for slot %u ep %u, set skip flag\n", slot_id, ep_index); - goto cleanup; + return 0; case COMP_NO_PING_RESPONSE_ERROR: ep->skip = true; xhci_dbg(xhci, "No Ping response error for slot %u ep %u, Skip one Isoc TD\n", slot_id, ep_index); - goto cleanup; + return 0; case COMP_INCOMPATIBLE_DEVICE_ERROR: /* needs disable slot command to recover */ @@ -2939,18 +2938,14 @@ static int handle_tx_event(struct xhci_hcd *xhci, process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event); else process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event); -cleanup: - handling_skipped_tds = ep->skip && - trb_comp_code != COMP_MISSED_SERVICE_ERROR && - trb_comp_code != COMP_NO_PING_RESPONSE_ERROR; - +cleanup:; /* * If ep->skip is set, it means there are missed tds on the * endpoint ring need to take care of. * Process them as short transfer until reach the td pointed by * the event. */ - } while (handling_skipped_tds); + } while (ep->skip); return 0; From patchwork Mon Apr 29 14:02:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 793274 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 8D6C97BB17 for ; Mon, 29 Apr 2024 14:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399278; cv=none; b=Mj8xFyV4fojjOAWMT1ZSDJlq+G9LrH7GWCVRnB666VqZVUt1MaW1gKUuNZGrXa5OfEJmDzEfawFRjGs24kA/U54RIXGG593admHDnYYdS8Dxg+xUL5AjhkC6SJ/fo5M27tvcRHtjdeHspnmNwxu1JgGD82KFxULBykoxYhYKkhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399278; c=relaxed/simple; bh=kQu+z7O+4ThimD1k+IyZuwLD8oXS15XBxt1q2Acs1PY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EAZGjmf3EWiaf5+f+gMw2XlOk8IncN3JtjL4ZBXEAmGUZ0Qe15ZiK4wBdox5I3VKPqPr77Z2lnCo7gjp7Bt59a9ihjvKHKCWNOQn+eqIJCoYwLR/c5G3OPzzNqerpBUvmgwz35990eRXhnd6d4VcvTs9fy6cxtj3PYd3TkRsfRU= 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=bu9RRcmr; arc=none smtp.client-ip=192.198.163.18 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="bu9RRcmr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399277; x=1745935277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kQu+z7O+4ThimD1k+IyZuwLD8oXS15XBxt1q2Acs1PY=; b=bu9RRcmr/8VBeHzD96nQtqC1RmxlL6kAz7PONJDPVwPnAOMr3bANsdp4 VTm2Z+pcvTktl/EwiCEIxB7xtXDBPmjDkyN2V9unEzR+5rd0vYe07rCfP P8AkWsRCBFqQpQd7UQ05IuXGYnpruFRZH3kMq2yhdYFyT+lpeE0jAWbLj 6RTYOAq9poRMgjpb8f2GuUQcMVe82r4ZXfWCHc0ELEHd0k7MablR5HNDp jLE5fUYpXZiqqGDV7HomRZFhgyDaERDVVVnRScrBOcyRogjn9Nz+O8iry yLSkprCFd5/QQ5hZhyjlu9IFaOxcZThL6T0E5rIFuxbnZshd6KXAEBY+5 w==; X-CSE-ConnectionGUID: J5ow7KJfQ1So4i41uLez6g== X-CSE-MsgGUID: PXug1N9lRYGKrlKczAK4dA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911484" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911484" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:17 -0700 X-CSE-ConnectionGUID: twIAEIwvQpWRGoDgTWpJaw== X-CSE-MsgGUID: bt4JMsGqQ7uvG+hAu9F55g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521841" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:14 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 12/18] usb: xhci: replace goto with return when possible in handle_tx_event() Date: Mon, 29 Apr 2024 17:02:39 +0300 Message-Id: <20240429140245.3955523-13-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Simplifying the handle_tx_event() function by addressing the complexity of its while loop. Replaces specific 'goto cleanup' statements with 'return' statements, applicable only where 'ep->skip' is set to 'false', ensuring loop termination. The original while loop, combined with 'goto cleanup', adds unnecessary complexity. This change aims to untangle the loop's logic, facilitating a more straightforward review of the upcoming comprehensive rework. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e96ac2d7b9b1..0f48f9befc94 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2804,7 +2804,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, xhci_handle_halted_endpoint(xhci, ep, NULL, EP_HARD_RESET); } - goto cleanup; + return 0; } /* We've skipped all the TDs on the ep ring when ep->skip set */ @@ -2812,7 +2812,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, 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); - goto cleanup; + return 0; } td = list_first_entry(&ep_ring->td_list, struct xhci_td, @@ -2851,7 +2851,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, if ((xhci->quirks & XHCI_SPURIOUS_SUCCESS) && ep_ring->last_td_was_short) { ep_ring->last_td_was_short = false; - goto cleanup; + return 0; } /* From patchwork Mon Apr 29 14:02:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 794076 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 E37ED7580B for ; Mon, 29 Apr 2024 14:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399280; cv=none; b=l1EKIs+9FlZL7yffTeO6mEAetC3dlzfifRZn3P+DfH7Me7+nyFz3usymbnD4VuOQBuV+OXv3ZGxxJHz6zLHUmiXEtwLhNs7eeyfB9LvKCbrk+oR462Jd57OKiUOYNQL+Xi7a4kFKbL5x1ZB569V3jEVkkwuF3wuB+50czsyH+5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399280; c=relaxed/simple; bh=jammnbydRIvvkTFIneJHmsH8TaeqFT+5zvA808A9KOE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bOhZO7GSDzN+wpuRf0WCAADQVbOnRYwntMfe/D/eBqWkIj3yloKg5WjbpFmXQLsAFrd7Ym5xc0tP4JkpN4ut6Ydfc/tqVGhfr8qR9r8AV4PCSBq4zF+1OlBiwjzE1oUae9tsrSiAsO2Sn6/qqmmDud0oqICCtek7yEcYaZ9hFwQ= 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=R5esrwhb; arc=none smtp.client-ip=192.198.163.18 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="R5esrwhb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399279; x=1745935279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jammnbydRIvvkTFIneJHmsH8TaeqFT+5zvA808A9KOE=; b=R5esrwhbcNR2GRUAOJMxI31c3gC1f+yWBmAQB/gD7mVj0D8JuG0MKtWR 8lDx4RmKpL5/kB2IR0EkzEIWGL3HftqUXuYwLMqXFAIXze95u1vm9WCgk N15VZAqvtm67w9vLxv/d66x048k8AYWDJLRxVKasydGpoML7BtnBdIpPE h8OfVPHLQxD4H6gmeUsY6o7PuaRvebN6J6v2K/5bQY0bZmBB3yMT+wZ+Y EazxiHui+fuh+OCkHoqw9ZCC2Dj1qCUSCHFe4Yz5zV9mdqK+hJXydzo8o 2CwOd21oh2TBRGaQ33K8ztq1VR792n80SY47nqxVA6nV+pwEIR+CCGYs9 Q==; X-CSE-ConnectionGUID: 3zq0DqJgT4+si6L6kKDPpg== X-CSE-MsgGUID: BFrFAV70TPGKhjNQDQV8yQ== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911499" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911499" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:18 -0700 X-CSE-ConnectionGUID: Fe56bhqbRxWW5aveqpOX9A== X-CSE-MsgGUID: VDQ4Wj0bRJWcUl/AdCD84w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521865" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:16 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 13/18] usb: xhci: remove goto 'cleanup' in handle_tx_event() Date: Mon, 29 Apr 2024 17:02:40 +0300 Message-Id: <20240429140245.3955523-14-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 By removing the goto 'cleanup' statement, and replacing it with 'continue', 'break' and 'return', helps simplify the code and further showcase in which case the while loop iterates. This change prepares for the comprehensive handle_tx_event() rework. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0f48f9befc94..b395708c488c 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2727,7 +2727,9 @@ static int handle_tx_event(struct xhci_hcd *xhci, "still with TDs queued?\n", TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), ep_index); - goto cleanup; + 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)) @@ -2735,7 +2737,9 @@ static int handle_tx_event(struct xhci_hcd *xhci, "still with TDs queued?\n", TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), ep_index); - goto cleanup; + if (ep->skip) + break; + return 0; case COMP_MISSED_SERVICE_ERROR: /* * When encounter missed service error, one or more isoc tds @@ -2770,7 +2774,9 @@ static int handle_tx_event(struct xhci_hcd *xhci, xhci_warn(xhci, "ERROR Unknown event condition %u for slot %u ep %u , HC probably busted\n", trb_comp_code, slot_id, ep_index); - goto cleanup; + if (ep->skip) + break; + return 0; } do { @@ -2834,14 +2840,14 @@ static int handle_tx_event(struct xhci_hcd *xhci, */ if (!ep_seg && (trb_comp_code == COMP_STOPPED || trb_comp_code == COMP_STOPPED_LENGTH_INVALID)) { - goto cleanup; + continue; } if (!ep_seg) { if (ep->skip && usb_endpoint_xfer_isoc(&td->urb->ep->desc)) { skip_isoc_td(xhci, td, ep, status); - goto cleanup; + continue; } /* @@ -2926,19 +2932,17 @@ static int handle_tx_event(struct xhci_hcd *xhci, trb_comp_code)) xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET); - goto cleanup; - } - - td->status = status; + } 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); -cleanup:; + /* 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. From patchwork Mon Apr 29 14:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 793273 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 06D04757F7 for ; Mon, 29 Apr 2024 14:01:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399282; cv=none; b=Q//zsiujVlJnrU28XJZvxrQuAMyyL0VPyls5Y0XbIFrdBUK31vtBHRzBgB0Xo7QUdO6/QT531VjRFtecl8oQvebxfTNvXQOt99brpUVdAQeh0jYpZAPqm5wzHRTZLMPebBMdqUlxsU77+H9mfKba7c7wXX8f4ZnW+9ugt/vqoIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399282; c=relaxed/simple; bh=a5V+zK/1XdlyieapHpVstbqrdALLtIRPs6CDu3bU+Kw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DoPbFxYA+X5rPJmjZhTHS+fdZN5rASnHeHQMcfCMxasiwa/2Zqiz3KYdgpa/t35R0mbxmrZXb+jYapMlNiHhsCGY24ZWCWR7qUlp2rHJ7dJyBWoy/bFGMi0Ox+Yd8QBRhpjqOtL35IjL2Yy+yS+i80eKrQiWHCoYn97O/WS255c= 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=L/XGLWBq; arc=none smtp.client-ip=192.198.163.18 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="L/XGLWBq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399281; x=1745935281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a5V+zK/1XdlyieapHpVstbqrdALLtIRPs6CDu3bU+Kw=; b=L/XGLWBqS4d5AlZS3bHu1brF6+XHGl9/c9bOwxpeAbjS+px+9krJPMOt /aLXmFZtBF+gMifOZ6IXL28wl9qTXZ44Wpqb7MttirOqInspg85lavIzu Py/Bx7uhaKUAGZRBVdllXSOIpjTRoSbJUWYXMmMGk1Eo84FnHODL1aqOb kYLa6oOIz7Qcra7jAZ9f68Zi6YTcB/0O2bkGGFcyQXnioAArBOBO/BJL1 yj3V79CKzkrBM+txyNQOTYo0FEb10dcE48k0nO6Vu/yD+WUYC/1z0x3gT gxhv0R4dIl3t5VWOwfL36b1tedjYeTRTG81Lr0FvX5unnB8WJrl38oBBQ Q==; X-CSE-ConnectionGUID: vG2u1QDsQ/q9mKBPhZkTMg== X-CSE-MsgGUID: bFelZL9/Sm2A27X1A8tuEA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911512" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911512" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:20 -0700 X-CSE-ConnectionGUID: xYQSnqIVTTamkbkHC+oyvA== X-CSE-MsgGUID: isRcltKPT/CcadADPHI7vQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521892" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:18 -0700 From: Mathias Nyman To: Cc: , Andy Shevchenko , Mathias Nyman Subject: [PATCH 14/18] xhci: pci: Use full names in PCI IDs for Intel platforms Date: Mon, 29 Apr 2024 17:02:41 +0300 Message-Id: <20240429140245.3955523-15-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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: Andy Shevchenko There are three out of many Intel platforms that are using TLAs instead of the full names in the PCI IDs. Modify them accordingly. This also fixes the logic of grouping as seemed to be by an LSB byte of the ID. Signed-off-by: Andy Shevchenko Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 653b47c45591..d45c84062b61 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -45,8 +45,7 @@ #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f #define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 #define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 -#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8 -#define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0 +#define PCI_DEVICE_ID_INTEL_APOLLO_LAKE_XHCI 0x5aa8 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI 0x15b5 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI 0x15b6 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_XHCI 0x15c1 @@ -55,9 +54,10 @@ #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI 0x15e9 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI 0x15ec #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI 0x15f0 +#define PCI_DEVICE_ID_INTEL_DENVERTON_XHCI 0x19d0 #define PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI 0x8a13 -#define PCI_DEVICE_ID_INTEL_CML_XHCI 0xa3af #define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI 0x9a13 +#define PCI_DEVICE_ID_INTEL_COMET_LAKE_XHCI 0xa3af #define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138 #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_PCH_XHCI 0x54ed @@ -348,9 +348,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_CML_XHCI)) { + pdev->device == PCI_DEVICE_ID_INTEL_APOLLO_LAKE_XHCI || + pdev->device == PCI_DEVICE_ID_INTEL_DENVERTON_XHCI || + pdev->device == PCI_DEVICE_ID_INTEL_COMET_LAKE_XHCI)) { xhci->quirks |= XHCI_PME_STUCK_QUIRK; } if (pdev->vendor == PCI_VENDOR_ID_INTEL && @@ -359,14 +359,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) if (pdev->vendor == PCI_VENDOR_ID_INTEL && (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) + pdev->device == PCI_DEVICE_ID_INTEL_APOLLO_LAKE_XHCI)) xhci->quirks |= XHCI_INTEL_USB_ROLE_SW; if (pdev->vendor == PCI_VENDOR_ID_INTEL && (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) + pdev->device == PCI_DEVICE_ID_INTEL_APOLLO_LAKE_XHCI || + pdev->device == PCI_DEVICE_ID_INTEL_DENVERTON_XHCI)) xhci->quirks |= XHCI_MISSING_CAS; if (pdev->vendor == PCI_VENDOR_ID_INTEL && From patchwork Mon Apr 29 14:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 794075 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 8650477F11 for ; Mon, 29 Apr 2024 14:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399283; cv=none; b=lGd5+ZthdiDu8LPI5BPUiKrRJg1Xu1svv1gb5A3YOz2AmdEygnaXrIvjNo7cBDNoHxVLZH3KGJfSA7n+2P3wI7XNWVmmM0cC7gaaAARvMlfrfl6SBLksdkDGTEoW1YdcaDgdhWjPmTp71OD4hMnJ97tJ2cBIdUVeLVKwvIvQp2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399283; c=relaxed/simple; bh=DViq93Pit0NKqrFxw65mJiHhOCoOtXyVKIsAQ4hul38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UuZAm2UYwPrTbuHvH11+WBB0vUNGO8Vo2/gRriq1D4ipWA8Pl1giQ/SKceK34uX3/wPdOCfDUm0VHenaQ1ftfyrDr5tYDbQ0Qm/dEApk5XySnLQkXwjSGT/SlpWGQPH13x6uqS7M3w6ED79mFqI8GV0LMTC1aTQwiYkcHcvOPkw= 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=N5mMiHea; arc=none smtp.client-ip=192.198.163.18 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="N5mMiHea" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399282; x=1745935282; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DViq93Pit0NKqrFxw65mJiHhOCoOtXyVKIsAQ4hul38=; b=N5mMiHea/QczUJ7/uAZTxW/SCWH2M9/OlOFeTr+Fngi93eXmp/cI9/4S Ad9CqEL275SjmXntg+O4/KouFLSaxB/Z9YJr74xzPTpNcQ1/+COuQ7dgo JkUrmMAnOBQjYpWH8aH7mgoYLMvMiQPr1us7j6ZaiIxiFP2QmVXK80Whx pNtM1AAw+Xak9H6yLZ3aR3P2bND3Jgeitge3CFdzkkiD/LxEQUmJLiIEQ I4OF9bRefRqz3qF+T6bkt+8gsCbYvJ0HDenDtsQTM+beeZZU32VEvmpVp NEBb0VTCuDfLBGV/FnnhzIc0mqk38hvMh211Czebkm2RGo1Kf+TvE1Gw/ A==; X-CSE-ConnectionGUID: dv90pg1KSLq/kiYcWQHLwA== X-CSE-MsgGUID: uAT23XPgSsGIpoTzEy2Ycw== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911522" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911522" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:22 -0700 X-CSE-ConnectionGUID: byUT0RlAQqOBLva/PRTu+w== X-CSE-MsgGUID: jsSaW6DUQvSuhbwaIbNQtw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521912" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:20 -0700 From: Mathias Nyman To: Cc: , Andy Shevchenko , Mathias Nyman Subject: [PATCH 15/18] xhci: pci: Group out Thunderbolt xHCI IDs Date: Mon, 29 Apr 2024 17:02:42 +0300 Message-Id: <20240429140245.3955523-16-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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: Andy Shevchenko It's better to keep track on Thunderbolt xHCI IDs in a separate group. Signed-off-by: Andy Shevchenko Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index d45c84062b61..8e9b720ab330 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -46,6 +46,15 @@ #define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 #define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 #define PCI_DEVICE_ID_INTEL_APOLLO_LAKE_XHCI 0x5aa8 +#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_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 + +/* Thunderbolt */ +#define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI 0x15b5 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI 0x15b6 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_XHCI 0x15c1 @@ -54,13 +63,6 @@ #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI 0x15e9 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI 0x15ec #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI 0x15f0 -#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_COMET_LAKE_XHCI 0xa3af -#define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138 -#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed -#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_PCH_XHCI 0x54ed #define PCI_DEVICE_ID_AMD_RENOIR_XHCI 0x1639 #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9 From patchwork Mon Apr 29 14:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 793272 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 636E079949 for ; Mon, 29 Apr 2024 14:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399285; cv=none; b=UVf8sRB1LjpNAmHUWFWkEZAUplO6zEDMJi7OqfK4y8IwRvFxxE8VnQC10KhFx6n/j+VuY6RlOGV5Bi6KNB9Nt1FOX9fLfNZEQ+YZ84Uf4+l6a1jTcAejt7ymygU7G5xITZ/BoUhbuDxGZs6RxSM56NABd5OssynwkfDJQWCwQRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399285; c=relaxed/simple; bh=6hNh8B4aj2DewcL4LFaIg61YW6hHICTKrnO6paEQM3E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l7mGuswqFm7mpB/zIAAp4bMbNu3eTWGZx94BL/60NjsU6FiNuSBrR7t7ZRisSgliaFkyt2XQcviIEc5577zBoEZiyLb4ya2/jFCMcZRJN8P5+dQljprv/nDC/4MwjESe72R2wvHMnQv63S0gJ9XpGdai9hZ/7aXHDmwoAr7sTj8= 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=mMbbiwim; arc=none smtp.client-ip=192.198.163.18 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="mMbbiwim" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399284; x=1745935284; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6hNh8B4aj2DewcL4LFaIg61YW6hHICTKrnO6paEQM3E=; b=mMbbiwimYb0sOvPjm/w4fWPnCkBfNDtgBlLdcMV5QJtDD4Ra+XU8zwEj V5fa8lOMcee8th3PTfuJzuS4V2zjcE5F6wKesVx3qJTJ/sU3gppdv2yJQ tVhaCwAkxBq7ja1OKNI/mrrbOHadeMUBBcNo1WB8LiDYfEheBlSeEaUIf 6QSRkA6vkPof0xsR07I+Ck5bkQdBMPExCcoeZ8YiDgDRGXGxwVgWjdhOv vqpNMo6N08Ius9y4AEAJsp4BkDlBntUqcgYNGNvVxB+w02J4TZ/bsrKUm P+PBbCbTUg41KbE20Sj3xqfGZYttpZlrf2qu+xwzqMVQUQp52q+4oNONl g==; X-CSE-ConnectionGUID: vXtDuDW0TrytfTEc2g0u6g== X-CSE-MsgGUID: va14yX3oSHukDdpTbBXGeQ== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911533" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911533" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:24 -0700 X-CSE-ConnectionGUID: 6++Q/spOQyCATE9thB3Deg== X-CSE-MsgGUID: L1vdTHKkRVGeiYs/9QPZIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521932" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:21 -0700 From: Mathias Nyman To: Cc: , Andy Shevchenko , Mathias Nyman Subject: [PATCH 16/18] xhci: pci: Use PCI_VENDOR_ID_RENESAS Date: Mon, 29 Apr 2024 17:02:43 +0300 Message-Id: <20240429140245.3955523-17-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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: Andy Shevchenko Instead of plain hexadecimal, use already defined PCI_VENDOR_ID_RENESAS. Signed-off-by: Andy Shevchenko Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 8e9b720ab330..c040d816e626 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -880,10 +880,10 @@ static const struct xhci_driver_data reneses_data = { /* PCI driver selection metadata; PCI hotplugging uses this */ static const struct pci_device_id pci_ids[] = { - { PCI_DEVICE(0x1912, 0x0014), + { PCI_DEVICE(PCI_VENDOR_ID_RENESAS, 0x0014), .driver_data = (unsigned long)&reneses_data, }, - { PCI_DEVICE(0x1912, 0x0015), + { PCI_DEVICE(PCI_VENDOR_ID_RENESAS, 0x0015), .driver_data = (unsigned long)&reneses_data, }, /* handle any USB 3.0 xHCI controller */ From patchwork Mon Apr 29 14:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 794074 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 C980B74BE2 for ; Mon, 29 Apr 2024 14:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399287; cv=none; b=dmvr50cA4KXWDP1gU50n69HjpuYQu2eNbNQ7WVa4zNHvcorNZw2SIVOdP0WFW2m2oEs7Zgm8UFGwPJZY7Dwt7O1mPO/Qag5C4X8SdMLJSIQC1UCpFvupm2/JcbL5vZyhVzxuPMd9SaHruy5EJHlEVN3m09H+GWH22bC9oqRlX28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399287; c=relaxed/simple; bh=1Aq+4wp4kygQSouNeLmoTUAfpl0acq/WvxnMb6/5c/I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k+on9wHNuqdh0vsQuq97EWzcC8M4KITUxzS/yjbFSmLAaXRAgvBbiE7AEKV6m/JH/F1Z14+T5FvBnSlhjp9ltI806SAlU9DoD8oO4ppm8Cpx2jq75FaDBEiGAAz1ywshjiKNqtv/sHT6SSqulLIpsSXumFdIVLQmRSJCzRvrOso= 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=S9pVbLNV; arc=none smtp.client-ip=192.198.163.18 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="S9pVbLNV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399286; x=1745935286; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Aq+4wp4kygQSouNeLmoTUAfpl0acq/WvxnMb6/5c/I=; b=S9pVbLNVMMATkDM3UMqAflrZQ3QDLd8V3Vq9ZoWPmd0zdUUy2k1yZUvd AdZsTRoiRzHTmFnI6QHDv8mo4RsnUNj8Mc8p/vMkyZR3QY9xS0N/f68H7 OWWPADg2RQp2iGydVa/5g04LHrScCv30yb6+7jjjRywnhhOmPkD1YzVim ZbWY3EOd1EiXYC6W4MPsq/UcdxssTZpo/xPafrhiD/egtng9pRxnmgvXG 7LNMGll2tskwqHPFFP/yVitxg9DGJQOKcsKJ1NRVv2iD8pbEZ5iDLC2pK zmppSekA0qnPH9YOknHQxzEdPrYMXqzWegZze49Z4g+G/hDTc1eBlclkq A==; X-CSE-ConnectionGUID: +Sjfgmf1StivoeUePY3ufw== X-CSE-MsgGUID: qY3gNNVARyCuvvMJQAzycA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911543" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911543" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:25 -0700 X-CSE-ConnectionGUID: WdhzIsARQYe8I7kS5/7OSw== X-CSE-MsgGUID: QTUwj01OSRm2snucUvWM7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521942" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:23 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 17/18] usb: xhci: remove duplicate TRB_TO_SLOT_ID() calls Date: Mon, 29 Apr 2024 17:02:44 +0300 Message-Id: <20240429140245.3955523-18-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 unnecessary repeated calls to TRB_TO_SLOT_ID(). The slot ID is stored in the 'slot_id' variable at the function's start. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b395708c488c..a7423ed992ee 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2723,20 +2723,16 @@ static int handle_tx_event(struct xhci_hcd *xhci, */ xhci_dbg(xhci, "underrun event on endpoint\n"); if (!list_empty(&ep_ring->td_list)) - xhci_dbg(xhci, "Underrun Event for slot %d ep %d " - "still with TDs queued?\n", - TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), - ep_index); + xhci_dbg(xhci, "Underrun Event for slot %u ep %d still with TDs queued?\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 %d ep %d " - "still with TDs queued?\n", - TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), - ep_index); + xhci_dbg(xhci, "Overrun Event for slot %u ep %d still with TDs queued?\n", + slot_id, ep_index); if (ep->skip) break; return 0; @@ -2795,9 +2791,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, if (!(trb_comp_code == COMP_STOPPED || trb_comp_code == COMP_STOPPED_LENGTH_INVALID || ep_ring->last_td_was_short)) { - xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n", - TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), - ep_index); + xhci_warn(xhci, "WARN Event TRB for slot %u ep %d with no TDs queued?\n", + slot_id, ep_index); } if (ep->skip) { ep->skip = false; From patchwork Mon Apr 29 14:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 793271 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 9862D7C6C8 for ; Mon, 29 Apr 2024 14:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399289; cv=none; b=bxai18ZoMcNl8GXTBw2bxF6PmGnarLZgW6nEmkkS3ujx2KHegbaFRFaOvQui408WuFcrbxGBHhP9PhnXuaj3nzLAXm5uMFXjV6PTb+nL48C8/OxoJwnNoEvsD6dSMVOa8NF5RZgyL9SAzAoS5kGYqG8rPxEMqQeqRFDI+QFPsqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714399289; c=relaxed/simple; bh=wJH0Mxm6yA9D40pR2pcIKMVid7B8zIpkjtcCxZdlAlw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aowueoYZo53D8d9UPmLy/e3iLGg0adqwWdmqo3YhVyuIh34j9HBE51BHZmFOXc6fK9MZlfV3aDvhc5dJqPOt+vIwBgps0XplRgWOl3IqjLu6RoLDP9p9BL+6a6Mnb6cYRWYvD7XrszOZk4Am1fej6q+rqWyuiofwHyM9qsUu20k= 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=KMMJ13e9; arc=none smtp.client-ip=192.198.163.18 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="KMMJ13e9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714399287; x=1745935287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wJH0Mxm6yA9D40pR2pcIKMVid7B8zIpkjtcCxZdlAlw=; b=KMMJ13e9xQwgvG3upOXGzg05kasLj4uv1FKaGouAQkGOQvUTjYAx9Hmz F4FJyMkIGBk0cjwQAFgIjBqRBcaVWlTRaoxZBlpZpCFdjb1P6HTFeIUhM M51TQgk7EXMPT8ZtIkitp4l1EKoAMnVzb4eOr0Py0fmSWF+A3oU/OsrX+ ocqvRRo6mwxBiuQbhAhCDwmHMCULIEQkNA+cMTEpIBb5cBB2sN5RnMjJQ QsK1Kr8GbqWnjff0H4EHd7w04/9eAtMwRuWHF8DQR+KwOevlFN/OBZkz0 OubZ7RZl0u4V5DtbrRpglvFTaeh46ICR3gcw2l0eZKvBaVE6AGEXSU62J g==; X-CSE-ConnectionGUID: 2BUuQKT1TwO5oATKP+xwvA== X-CSE-MsgGUID: Pa3kqLwJTp2izYVgKis6nA== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="9911558" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="9911558" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 07:01:27 -0700 X-CSE-ConnectionGUID: K/EY4BO9RUyvH4CFCBahfw== X-CSE-MsgGUID: SyRLAqrFTa+Nw1t1Yfu2GA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26521955" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orviesa006.jf.intel.com with ESMTP; 29 Apr 2024 07:01:25 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 18/18] usb: xhci: compact 'trb_in_td()' arguments Date: Mon, 29 Apr 2024 17:02:45 +0300 Message-Id: <20240429140245.3955523-19-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240429140245.3955523-1-mathias.nyman@linux.intel.com> References: <20240429140245.3955523-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 Pass pointer to the TD (struct xhci_td *) directly, instead of its components separately. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 38 +++++++++++++----------------------- drivers/usb/host/xhci.h | 5 ++--- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index a7423ed992ee..9e90d2952760 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1024,8 +1024,7 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep) td->urb->stream_id); hw_deq &= ~0xf; - if (td->cancel_status == TD_HALTED || - trb_in_td(xhci, td->start_seg, td->first_trb, td->last_trb, hw_deq, false)) { + if (td->cancel_status == TD_HALTED || trb_in_td(xhci, td, hw_deq, false)) { switch (td->cancel_status) { case TD_CLEARED: /* TD is already no-op */ case TD_CLEARING_CACHE: /* set TR deq command already queued */ @@ -1082,8 +1081,7 @@ static struct xhci_td *find_halted_td(struct xhci_virt_ep *ep) hw_deq = xhci_get_hw_deq(ep->xhci, ep->vdev, ep->ep_index, 0); hw_deq &= ~0xf; td = list_first_entry(&ep->ring->td_list, struct xhci_td, td_list); - if (trb_in_td(ep->xhci, td->start_seg, td->first_trb, - td->last_trb, hw_deq, false)) + if (trb_in_td(ep->xhci, td, hw_deq, false)) return td; } return NULL; @@ -2049,25 +2047,19 @@ static void handle_port_status(struct xhci_hcd *xhci, } /* - * This TD is defined by the TRBs starting at start_trb in start_seg and ending - * at end_trb, which may be in another segment. If the suspect DMA address is a - * TRB in this TD, this function returns that TRB's segment. Otherwise it - * returns 0. + * If the suspect DMA address is a TRB in this TD, this function returns that + * TRB's segment. Otherwise it returns 0. */ -struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, - struct xhci_segment *start_seg, - union xhci_trb *start_trb, - union xhci_trb *end_trb, - dma_addr_t suspect_dma, - bool debug) +struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, struct xhci_td *td, dma_addr_t suspect_dma, + bool debug) { dma_addr_t start_dma; dma_addr_t end_seg_dma; dma_addr_t end_trb_dma; struct xhci_segment *cur_seg; - start_dma = xhci_trb_virt_to_dma(start_seg, start_trb); - cur_seg = start_seg; + start_dma = xhci_trb_virt_to_dma(td->start_seg, td->first_trb); + cur_seg = td->start_seg; do { if (start_dma == 0) @@ -2076,7 +2068,7 @@ struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, end_seg_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[TRBS_PER_SEGMENT - 1]); /* If the end TRB isn't in this segment, this is set to 0 */ - end_trb_dma = xhci_trb_virt_to_dma(cur_seg, end_trb); + end_trb_dma = xhci_trb_virt_to_dma(cur_seg, td->last_trb); if (debug) xhci_warn(xhci, @@ -2110,7 +2102,7 @@ struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, } cur_seg = cur_seg->next; start_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[0]); - } while (cur_seg != start_seg); + } while (cur_seg != td->start_seg); return NULL; } @@ -2822,8 +2814,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, td_num--; /* Is this a TRB in the currently executing TD? */ - ep_seg = trb_in_td(xhci, td->start_seg, td->first_trb, - td->last_trb, ep_trb_dma, false); + ep_seg = trb_in_td(xhci, td, ep_trb_dma, false); /* * Skip the Force Stopped Event. The event_trb(event_dma) of FSE @@ -2870,8 +2861,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, !list_is_last(&td->td_list, &ep_ring->td_list)) { struct xhci_td *td_next = list_next_entry(td, td_list); - ep_seg = trb_in_td(xhci, td_next->start_seg, td_next->first_trb, - td_next->last_trb, ep_trb_dma, false); + ep_seg = trb_in_td(xhci, td_next, ep_trb_dma, false); if (ep_seg) { /* give back previous TD, start handling new */ xhci_dbg(xhci, "Missing TD completion event after mid TD error\n"); @@ -2890,8 +2880,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, "part of current TD ep_index %d " "comp_code %u\n", ep_index, trb_comp_code); - trb_in_td(xhci, td->start_seg, td->first_trb, - td->last_trb, ep_trb_dma, true); + trb_in_td(xhci, td, ep_trb_dma, true); + return -ESHUTDOWN; } } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 933f8a296014..30415158ed3c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1870,9 +1870,8 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci, /* xHCI ring, segment, TRB, and TD functions */ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb); -struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, - struct xhci_segment *start_seg, union xhci_trb *start_trb, - union xhci_trb *end_trb, dma_addr_t suspect_dma, bool debug); +struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, struct xhci_td *td, + dma_addr_t suspect_dma, bool debug); int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code); void xhci_ring_cmd_db(struct xhci_hcd *xhci); int xhci_queue_slot_control(struct xhci_hcd *xhci, struct xhci_command *cmd,