From patchwork Thu Mar 3 10:26:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2778C4332F for ; Thu, 3 Mar 2022 10:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232318AbiCCK0M (ORCPT ); Thu, 3 Mar 2022 05:26:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231800AbiCCK0L (ORCPT ); Thu, 3 Mar 2022 05:26:11 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12573179A10; Thu, 3 Mar 2022 02:25:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303125; x=1677839125; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+XGuIpM+r+m/AeunvYr+GHU0lBtwG4Ax8Jpj4Gu8764=; b=XjvLFDNSPjW3AwRj1g9UssIRvMXK7/dHqNwQjv8V5i/Befk17o3grms/ AM3PmAGUUZJjWm4P5hRGBn3zV/GBusqU0V8sdrpIV1eicay7F9ELds1vZ 3zcaQCa75qUUr0ole9XSWyjzY11ybRzBXCLC61YC/3NdTXwgWeL3bW/pi QwaDPbmMTu2Xq5kWzH4yIFucCpjGgUxHH8dKnTTAKblM3i3WEvLQUgqN5 mm76xukMY9N5S/+0IUXwvkx6GiYAnqySBXy9Y5AT1PAb/jb3boS5eZQGy ZdJRGwjVY1tmbonMsv4HZ96ZIYYnQr/vZiUeNVOqGQPKtZgAs0OnYbdD2 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567113" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567113" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773300" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:22 -0800 From: Mathias Nyman To: Cc: , Mathias Nyman , Sergey Shtylyov , Pavan Kondeti , stable@vger.kernel.org Subject: [PATCH 1/9] xhci: make xhci_handshake timeout for xhci_reset() adjustable Date: Thu, 3 Mar 2022 12:26:48 +0200 Message-Id: <20220303102656.1661407-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org xhci_reset() timeout was increased from 250ms to 10 seconds in order to give Renesas 720201 xHC enough time to get ready in probe. xhci_reset() is called with interrupts disabled in other places, and waiting for 10 seconds there is not acceptable. Add a timeout parameter to xhci_reset(), and adjust it back to 250ms when called from xhci_stop() or xhci_shutdown() where interrupts are disabled, and successful reset isn't that critical. This solves issues when deactivating host mode on platforms like SM8450. For now don't change the timeout if xHC is reset in xhci_resume(). No issues are reported for it, and we need the reset to succeed. Locking around that reset needs to be revisited later. Additionally change the signed integer timeout parameter in xhci_handshake() to a u64 to match the timeout value we pass to readl_poll_timeout_atomic() Reported-by: Sergey Shtylyov Reported-by: Pavan Kondeti Fixes: 22ceac191211 ("xhci: Increase reset timeout for Renesas 720201 host.") Cc: stable@vger.kernel.org Tested-by: Pavan Kondeti Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci-mem.c | 2 +- drivers/usb/host/xhci.c | 20 +++++++++----------- drivers/usb/host/xhci.h | 7 +++++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index df3522dab31b..bb4f01ce90e3 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -762,7 +762,7 @@ static int xhci_exit_test_mode(struct xhci_hcd *xhci) } pm_runtime_allow(xhci_to_hcd(xhci)->self.controller); xhci->test_mode = 0; - return xhci_reset(xhci); + return xhci_reset(xhci, XHCI_RESET_SHORT_USEC); } void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port, diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index cb70d0b31e08..48114a462908 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2575,7 +2575,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) fail: xhci_halt(xhci); - xhci_reset(xhci); + xhci_reset(xhci, XHCI_RESET_SHORT_USEC); xhci_mem_cleanup(xhci); return -ENOMEM; } diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index a1c781f70d02..6b32f7e65d4c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -65,7 +65,7 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring) * handshake done). There are two failure modes: "usec" have passed (major * hardware flakeout), or the register reads as all-ones (hardware removed). */ -int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec) +int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, u64 timeout_us) { u32 result; int ret; @@ -73,7 +73,7 @@ int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec) ret = readl_poll_timeout_atomic(ptr, result, (result & mask) == done || result == U32_MAX, - 1, usec); + 1, timeout_us); if (result == U32_MAX) /* card removed */ return -ENODEV; @@ -162,7 +162,7 @@ int xhci_start(struct xhci_hcd *xhci) * Transactions will be terminated immediately, and operational registers * will be set to their defaults. */ -int xhci_reset(struct xhci_hcd *xhci) +int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us) { u32 command; u32 state; @@ -195,8 +195,7 @@ int xhci_reset(struct xhci_hcd *xhci) if (xhci->quirks & XHCI_INTEL_HOST) udelay(1000); - ret = xhci_handshake(&xhci->op_regs->command, - CMD_RESET, 0, 10 * 1000 * 1000); + ret = xhci_handshake(&xhci->op_regs->command, CMD_RESET, 0, timeout_us); if (ret) return ret; @@ -209,8 +208,7 @@ int xhci_reset(struct xhci_hcd *xhci) * xHCI cannot write to any doorbells or operational registers other * than status until the "Controller Not Ready" flag is cleared. */ - ret = xhci_handshake(&xhci->op_regs->status, - STS_CNR, 0, 10 * 1000 * 1000); + ret = xhci_handshake(&xhci->op_regs->status, STS_CNR, 0, timeout_us); xhci->usb2_rhub.bus_state.port_c_suspend = 0; xhci->usb2_rhub.bus_state.suspended_ports = 0; @@ -731,7 +729,7 @@ static void xhci_stop(struct usb_hcd *hcd) xhci->xhc_state |= XHCI_STATE_HALTED; xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; xhci_halt(xhci); - xhci_reset(xhci); + xhci_reset(xhci, XHCI_RESET_SHORT_USEC); spin_unlock_irq(&xhci->lock); xhci_cleanup_msix(xhci); @@ -784,7 +782,7 @@ void xhci_shutdown(struct usb_hcd *hcd) xhci_halt(xhci); /* Workaround for spurious wakeups at shutdown with HSW */ if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) - xhci_reset(xhci); + xhci_reset(xhci, XHCI_RESET_SHORT_USEC); spin_unlock_irq(&xhci->lock); xhci_cleanup_msix(xhci); @@ -1170,7 +1168,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) xhci_dbg(xhci, "Stop HCD\n"); xhci_halt(xhci); xhci_zero_64b_regs(xhci); - retval = xhci_reset(xhci); + retval = xhci_reset(xhci, XHCI_RESET_LONG_USEC); spin_unlock_irq(&xhci->lock); if (retval) return retval; @@ -5307,7 +5305,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) xhci_dbg(xhci, "Resetting HCD\n"); /* Reset the internal HC memory state and registers. */ - retval = xhci_reset(xhci); + retval = xhci_reset(xhci, XHCI_RESET_LONG_USEC); if (retval) return retval; xhci_dbg(xhci, "Reset complete\n"); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 8a0026ee9524..fce32f8ea9d0 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -229,6 +229,9 @@ struct xhci_op_regs { #define CMD_ETE (1 << 14) /* bits 15:31 are reserved (and should be preserved on writes). */ +#define XHCI_RESET_LONG_USEC (10 * 1000 * 1000) +#define XHCI_RESET_SHORT_USEC (250 * 1000) + /* IMAN - Interrupt Management Register */ #define IMAN_IE (1 << 1) #define IMAN_IP (1 << 0) @@ -2081,11 +2084,11 @@ void xhci_free_container_ctx(struct xhci_hcd *xhci, /* xHCI host controller glue */ typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); -int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec); +int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, u64 timeout_us); void xhci_quiesce(struct xhci_hcd *xhci); int xhci_halt(struct xhci_hcd *xhci); int xhci_start(struct xhci_hcd *xhci); -int xhci_reset(struct xhci_hcd *xhci); +int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us); int xhci_run(struct usb_hcd *hcd); int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); void xhci_shutdown(struct usb_hcd *hcd); From patchwork Thu Mar 3 10:26:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6565FC43217 for ; Thu, 3 Mar 2022 10:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232321AbiCCK0N (ORCPT ); Thu, 3 Mar 2022 05:26:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbiCCK0M (ORCPT ); Thu, 3 Mar 2022 05:26:12 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B42A175869; Thu, 3 Mar 2022 02:25:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303127; x=1677839127; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=74os4aT3i+C2SOidVvHvZZBWyvDlquCbqF5/mimla4Q=; b=h4ztEOMHprufTyQe+086I/bsyzr+Ohd8rj6w3xnp4rm/2tW6IDHEerxo IS/mFhFDUmaHWuPhGRL8noJKqvCOX+KMhizRhoHAQGSdkOBhOLblv4f3n PMv+k1joBtlKYpKk7TGf/fhRmHsZoule1SKAFssw0YZmMAh7K6BmYx3HB nM53TUzhntUi4y8LDMwxVaB+I+A1DDv86FSVze86mXtw/z7xAftv7EryN lzMPQgE7WF0WgagqcETlA208EIXGib0G3YlCfMW95gluGi4wG0Ct+0wj9 ogB3Ac6zkDihKZsujwTNLtYsipF3pzqt88AOlcDOFArggM0GmWfIOQVYW g==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567120" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567120" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773306" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:25 -0800 From: Mathias Nyman To: Cc: , Anssi Hannula , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 2/9] xhci: fix garbage USBSTS being logged in some cases Date: Thu, 3 Mar 2022 12:26:49 +0200 Message-Id: <20220303102656.1661407-3-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Anssi Hannula xhci_decode_usbsts() is expected to return a zero-terminated string by its only caller, xhci_stop_endpoint_command_watchdog(), which directly logs the return value: xhci_warn(xhci, "USBSTS:%s\n", xhci_decode_usbsts(str, usbsts)); However, if no recognized bits are set in usbsts, the function will return without having called any sprintf() and therefore return an untouched non-zero-terminated caller-provided buffer, causing garbage to be output to log. Fix that by always including the raw value in the output. Note that before commit 4843b4b5ec64 ("xhci: fix even more unsafe memory usage in xhci tracing") the result effect in the failure case was different as a static buffer was used here, but the code still worked incorrectly. Fixes: 9c1aa36efdae ("xhci: Show host status when watchdog triggers and host is assumed dead.") Cc: stable@vger.kernel.org Signed-off-by: Anssi Hannula Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index fce32f8ea9d0..1d83ddace482 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2625,8 +2625,11 @@ static inline const char *xhci_decode_usbsts(char *str, u32 usbsts) { int ret = 0; + ret = sprintf(str, " 0x%08x", usbsts); + if (usbsts == ~(u32)0) - return " 0xffffffff"; + return str; + if (usbsts & STS_HALT) ret += sprintf(str + ret, " HCHalted"); if (usbsts & STS_FATAL) From patchwork Thu Mar 3 10:26:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 198E8C433F5 for ; Thu, 3 Mar 2022 10:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232327AbiCCK0Q (ORCPT ); Thu, 3 Mar 2022 05:26:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232320AbiCCK0O (ORCPT ); Thu, 3 Mar 2022 05:26:14 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 326DF179A11; Thu, 3 Mar 2022 02:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303129; x=1677839129; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pGg06ebsLiDfXkPxKDe4uB84T4FY/Ti+rqN2epFlSGc=; b=nFcj5ISeGeaF3r1794ibstGcCewDpRinsJDo0lF5yrnOSjZNHPqejGGQ 8RbbOkXXdokJGnAPBectHeCNK8iNvGlxuv0+HNxZWxir9pjp5P0mvSJ+9 OmwV0o7FDkZ+FEEDX25E09dcaCGlpJPd88fyHiadRBWuK9PfXwHCc4TJt KThGyJdJZ1oBU5xtAVEHYoKs/jVk2c5tBTDNWp4qzr8JmLBIq7n8BDn9c yYvcdqz8J6UU8uRMxAfGERrMT+j51hnW72R9JxZFAH8aIlaqABcDWKzAs Rf1yiaXdk/2siSPQ0tR071kJ45XloAx1tGTHdWMdQ64TDy0Q+FYr+quAn g==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567126" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567126" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773314" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:27 -0800 From: Mathias Nyman To: Cc: , Anssi Hannula , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 3/9] xhci: fix uninitialized string returned by xhci_decode_ctrl_ctx() Date: Thu, 3 Mar 2022 12:26:50 +0200 Message-Id: <20220303102656.1661407-4-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Anssi Hannula xhci_decode_ctrl_ctx() returns the untouched buffer as-is if both "drop" and "add" parameters are zero. Fix the function to return an empty string in that case. It was not immediately clear from the possible call chains whether this issue is currently actually triggerable or not. Note that before commit 4843b4b5ec64 ("xhci: fix even more unsafe memory Cc: stable@vger.kernel.org usage in xhci tracing") the result effect in the failure case was different as a static buffer was used here, but the code still worked incorrectly. Fixes: 90d6d5731da7 ("xhci: Add tracing for input control context") Signed-off-by: Anssi Hannula Signed-off-by: Mathias Nyman commit 4843b4b5ec64 ("xhci: fix even more unsafe memory usage in xhci tracing") --- drivers/usb/host/xhci.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 1d83ddace482..473a33ce299e 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2468,6 +2468,8 @@ static inline const char *xhci_decode_ctrl_ctx(char *str, unsigned int bit; int ret = 0; + str[0] = '\0'; + if (drop) { ret = sprintf(str, "Drop:"); for_each_set_bit(bit, &drop, 32) From patchwork Thu Mar 3 10:26:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26D75C4332F for ; Thu, 3 Mar 2022 10:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232329AbiCCK0R (ORCPT ); Thu, 3 Mar 2022 05:26:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232324AbiCCK0P (ORCPT ); Thu, 3 Mar 2022 05:26:15 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC813175869; Thu, 3 Mar 2022 02:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303130; x=1677839130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iYkhn+N++G6Az23+XPrHAQS99KXmeNH6QCJYVOADOTE=; b=OBdHFDlRtqOQ/wEk7QY+UiX2ChMQg+0Y9ulDaMymt65YsnaB7jyADlMh gE9zeAYHwaiVaTT5p70A+Wv/JN9qm1K6asvcE1VC3GeSB9rp19kVN1jKz 5wK9GqxfO0avOlxa+KywLiRyl54ehe/XwfqKzL50n2qO8imBvVHgFLaQf uMxZAtxTuj4iBZCSrb/yiArytFWI1b2Hha3rWJt59EbZ3sK4A5lksY9+Y CcNfgTYaOZ9g+FiyID/3j3jS3L2qrPJqmGhwOadf3gRlCGalM1eqHIr5e bkllsiSl6BC9YkgQ8+UIgdDEq0qEkZ90LfeQ/Yb2RAwTjGNX6tSKcrcYP A==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567132" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567132" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773322" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:28 -0800 From: Mathias Nyman To: Cc: , Henry Lin , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 4/9] xhci: fix runtime PM imbalance in USB2 resume Date: Thu, 3 Mar 2022 12:26:51 +0200 Message-Id: <20220303102656.1661407-5-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Henry Lin A race between system resume and device-initiated resume may result in runtime PM imbalance on USB2 root hub. If a device-initiated resume starts and system resume xhci_bus_resume() directs U0 before hub driver sees the resuming device in RESUME state, device-initiated resume will not be finished in xhci_handle_usb2_port_link_resume(). In this case, usb_hcd_end_port_resume() call is missing. This changes calls usb_hcd_end_port_resume() if resuming device reaches U0 to keep runtime PM balance. Fixes: a231ec41e6f6 ("xhci: refactor U0 link state handling in get_port_status") Cc: stable@vger.kernel.org Signed-off-by: Henry Lin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-hub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index bb4f01ce90e3..1e7dc130c39a 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1088,6 +1088,9 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status, if (link_state == XDEV_U2) *status |= USB_PORT_STAT_L1; if (link_state == XDEV_U0) { + if (bus_state->resume_done[portnum]) + usb_hcd_end_port_resume(&port->rhub->hcd->self, + portnum); bus_state->resume_done[portnum] = 0; clear_bit(portnum, &bus_state->resuming_ports); if (bus_state->suspended_ports & (1 << portnum)) { From patchwork Thu Mar 3 10:26:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06000C433EF for ; Thu, 3 Mar 2022 10:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232328AbiCCK0S (ORCPT ); Thu, 3 Mar 2022 05:26:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232324AbiCCK0R (ORCPT ); Thu, 3 Mar 2022 05:26:17 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF60B179A11 for ; Thu, 3 Mar 2022 02:25:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303132; x=1677839132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jJCu2kTAbizusS27kv0h56CpQN3omVI3FloLm80zRek=; b=e78m7341Sa0dNqkCSu0I1fOZudVD1QuNdUDSK/zJvtt5ApKUBfQi3CGY lCfIa2FGPu4laS3X8OO/njMq95vBCQCjU7i6QQzPsD63SznDsYViXhro4 FK1YAPdL3p0vkbyvPht7LKW68jv3QlYetS5KBGi8NI5vITQEGWShc8lfr RRzK924ukBG35mf9jEaW9fEB6VZjUebo9OzERcb3sQER9jUhN/q5tX95a lGECA+lI2g9JumrgAp0Tq6kosE3hiBFjxhkrbvYPJxTb6TD6TCT88wFJ5 6pavmDiI4uB6dCZGG5MC3Dv9AOXsiGSe3ZFRQ4yrkMSVNVCSHtGyiO5b2 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567143" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567143" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773328" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:30 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH 5/9] usb: host: xhci: use ffs() in xhci_mem_init() Date: Thu, 3 Mar 2022 12:26:52 +0200 Message-Id: <20220303102656.1661407-6-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Linyu Yuan The for loop to find page size bit can be replaced with ffs(). Signed-off-by: Linyu Yuan Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 48114a462908..938eb2b907ab 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2391,11 +2391,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) page_size = readl(&xhci->op_regs->page_size); xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Supported page size register = 0x%x", page_size); - for (i = 0; i < 16; i++) { - if ((0x1 & page_size) != 0) - break; - page_size = page_size >> 1; - } + i = ffs(page_size); if (i < 16) xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Supported page size of %iK", (1 << (i+12)) / 1024); From patchwork Thu Mar 3 10:26:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CF36C433EF for ; Thu, 3 Mar 2022 10:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232331AbiCCK0V (ORCPT ); Thu, 3 Mar 2022 05:26:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232324AbiCCK0T (ORCPT ); Thu, 3 Mar 2022 05:26:19 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6A31179A20 for ; Thu, 3 Mar 2022 02:25:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303134; x=1677839134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qjgwhxrUkCs2Av9ADpFnLBwAeCuSk5H7PEXy1mrTLDI=; b=ZUk1eUlMFMGKSxVYg3TlE8wi39j2AdMoHXhvQVTsQ8dIxNBRi/xdzwm9 T5Hz0mwLMfEAhlWLhWKxgdVJ/KPU83m3ureDrjay4PVy+ethu51s/eKVY QiA92gT977n/mrIQgWOp50uGc2xLrMSsvi+b+uxeZkyf4v2WdeLpVO0ED twQ6LimRiYFkN9N7dNz0s0JztIpRI3416IPoL48yWQ4fDxjL1rt1SQAn1 1AOgkZHBNfCIKOdO6NP3dMcXN7KyBCro+IXRdZ6FIm5IyMMZWDmNJZk6M Q58S/mfK/7U7DBr+FrBEq7WRlzEQOIgH36jRlNsikIggiXUp2TN3059ne w==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567149" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567149" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773335" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:32 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH 6/9] usb: host: xhci: fix a comment typo in xhci_mem_init() Date: Thu, 3 Mar 2022 12:26:53 +0200 Message-Id: <20220303102656.1661407-7-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Linyu Yuan It should be Device Context, not doorbell. Signed-off-by: Linyu Yuan Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 938eb2b907ab..bbb27ee2c6a3 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2417,7 +2417,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) writel(val, &xhci->op_regs->config_reg); /* - * xHCI section 5.4.6 - doorbell array must be + * xHCI section 5.4.6 - Device Context array must be * "physically contiguous and 64-byte (cache line) aligned". */ xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma, From patchwork Thu Mar 3 10:26:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C968C433F5 for ; Thu, 3 Mar 2022 10:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232334AbiCCK0W (ORCPT ); Thu, 3 Mar 2022 05:26:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232333AbiCCK0U (ORCPT ); Thu, 3 Mar 2022 05:26:20 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00720179A12 for ; Thu, 3 Mar 2022 02:25:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303135; x=1677839135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eascq1DeoR3EyUxnIuH7kjEiV86srJGQixov3nOLtQA=; b=M86BG/0mL92EHml+TE58YshDmhiHUjjQAaCTd/Xv3iS9Qn2TutLnsX0/ 7qMGlnnZB8IdxPGZwTKpkW2o+qcfjlnITXLVQhsZwPLPzDb+1Oidlx8u+ Eu6Aawhd5le7Wy5iUV0+Jzs286lO+CMqqS+omv3erJhZb1m4swVpVg+LG RwVs31NpBP0C+qZuT5OpQPC+DqkevA6QswmARb49oeMByFYcX4uxYjtXh vRRKOTmUgITZ6mLzxKWWJnnC4B3g0yiYky2K9OiEazKxVndP3TSw0iU6s k6XF/3VMQxwxgodiACAzPyMQ5QUQlohNZ7tJhltpkuK3GVJm8OvEnYu0o w==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567150" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567150" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773341" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:34 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH 7/9] usb: host: xhci: update hci_version operation in xhci_gen_setup() Date: Thu, 3 Mar 2022 12:26:54 +0200 Message-Id: <20220303102656.1661407-8-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Linyu Yuan There is no need to store temperary value in hcc_params. Signed-off-by: Linyu Yuan Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6b32f7e65d4c..e17eef88e5d7 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5279,8 +5279,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) xhci->hcs_params1 = readl(&xhci->cap_regs->hcs_params1); xhci->hcs_params2 = readl(&xhci->cap_regs->hcs_params2); xhci->hcs_params3 = readl(&xhci->cap_regs->hcs_params3); - xhci->hcc_params = readl(&xhci->cap_regs->hc_capbase); - xhci->hci_version = HC_VERSION(xhci->hcc_params); + xhci->hci_version = HC_VERSION(readl(&xhci->cap_regs->hc_capbase)); xhci->hcc_params = readl(&xhci->cap_regs->hcc_params); if (xhci->hci_version > 0x100) xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2); From patchwork Thu Mar 3 10:26:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A4C7C433F5 for ; Thu, 3 Mar 2022 10:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232338AbiCCK0X (ORCPT ); Thu, 3 Mar 2022 05:26:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232324AbiCCK0W (ORCPT ); Thu, 3 Mar 2022 05:26:22 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DADC179A1B for ; Thu, 3 Mar 2022 02:25:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303137; x=1677839137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iQ/YV/TqRG9910eZ3a/U/TfxeBZRExu8F6yQfLablsg=; b=AWHRAOJjTMNNT25lHwC+VDR+RZRzeXu0cLMk7Vgb1jIP/o0rgSeymAQL aD/he4SIcU06IALVGDSbbXtasFh9o+z5V7H9MMCaoqBEY9yx/NgDi1Ho/ Gky6jeEg2YTAYOUM5JsT0SBqlU1fDG9H5ZKrhU5pjzu5Q73JoIvqIhWTa 1O2iGdjgx+Wi+KYvV+IsAAPxX/tMBmcAZ3UFdJE4PNHXlhjb278BKPZMN r2jHv/U+WnVI0p17XLVJqrFUuQMwg7bBmW0E2ZXxyagIvlvg9xbSTyq1y nPDYFZKcLFlR3gwV84CXx69FPVkTEygbiXHj1pa5ZGaC0spsPSY2QMt8J w==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567153" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567153" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773357" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:35 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH 8/9] usb: host: xhci: add blank line in xhci_halt() Date: Thu, 3 Mar 2022 12:26:55 +0200 Message-Id: <20220303102656.1661407-9-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Linyu Yuan It is more readable to add blank lines. Signed-off-by: Linyu Yuan Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index e17eef88e5d7..1aa10db23fbb 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -110,6 +110,7 @@ void xhci_quiesce(struct xhci_hcd *xhci) int xhci_halt(struct xhci_hcd *xhci) { int ret; + xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Halt the HC"); xhci_quiesce(xhci); @@ -119,8 +120,10 @@ int xhci_halt(struct xhci_hcd *xhci) xhci_warn(xhci, "Host halt failed, %d\n", ret); return ret; } + xhci->xhc_state |= XHCI_STATE_HALTED; xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; + return ret; } From patchwork Thu Mar 3 10:26:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BABEFC433EF for ; Thu, 3 Mar 2022 10:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232324AbiCCK00 (ORCPT ); Thu, 3 Mar 2022 05:26:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232335AbiCCK0Z (ORCPT ); Thu, 3 Mar 2022 05:26:25 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860D8179A12 for ; Thu, 3 Mar 2022 02:25:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646303139; x=1677839139; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fz/1LWz1fZQyoqkzlm5wht0AXSQuG+ooIXmsbArEh/w=; b=JuNdLdszRXbVbD8l11AifaNfRheC0ChyQ2u/BpQDWZvSS8SOPE+U51ZB k1SV+0jXWI10zRobSXhXl4zskizRNwG+OreqVw7FCS95k/cQjKwv+Wlq3 ZsrMHH5qKdSybUSQNpYgI9Xb9v/DSK72C4Hw1G5TxGkgOp1bKRjlaDQQn Qb5hRl7YUAwEduhq++VK58AFnHKjVtw61nVizXusl5cIT4PvPKJAAF8y3 DebJkwahPD1I/HnTZtjGItCewJqxzpQqwfeuFDXwjvReZzKdJgtMYsYxn e6TS2ERNjkaMyNcUN6pBCy8rZK4p1rz61sQat6iz1CjG2LMBZ+HCl4Nll w==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="253567162" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="253567162" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 02:25:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="535773374" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga007.jf.intel.com with ESMTP; 03 Mar 2022 02:25:37 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH 9/9] usb: host: xhci: Remove some unnecessary return value initializations Date: Thu, 3 Mar 2022 12:26:56 +0200 Message-Id: <20220303102656.1661407-10-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> References: <20220303102656.1661407-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Linyu Yuan The ret/retval will be set when it used, no need to init at definition. [modified subject line -Mathias] Signed-off-by: Linyu Yuan Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1aa10db23fbb..642610c78f58 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -325,7 +325,7 @@ static int xhci_setup_msi(struct xhci_hcd *xhci) */ static int xhci_setup_msix(struct xhci_hcd *xhci) { - int i, ret = 0; + int i, ret; struct usb_hcd *hcd = xhci_to_hcd(xhci); struct pci_dev *pdev = to_pci_dev(hcd->self.controller); @@ -579,7 +579,7 @@ static int xhci_all_ports_seen_u0(struct xhci_hcd *xhci) static int xhci_init(struct usb_hcd *hcd) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); - int retval = 0; + int retval; xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_init"); spin_lock_init(&xhci->lock); @@ -3975,7 +3975,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id) struct xhci_command *command; unsigned long flags; u32 state; - int ret = 0; + int ret; command = xhci_alloc_command(xhci, true, GFP_KERNEL); if (!command) @@ -4011,7 +4011,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id) xhci_free_command(xhci, command); - return ret; + return 0; } /*