From patchwork Thu Mar 3 11:08: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: 12767313 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 B96CDC43217 for ; Thu, 3 Mar 2022 11:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232637AbiCCLIX (ORCPT ); Thu, 3 Mar 2022 06:08:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231783AbiCCLIT (ORCPT ); Thu, 3 Mar 2022 06:08:19 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0157CB59; Thu, 3 Mar 2022 03:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646305652; x=1677841652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+XGuIpM+r+m/AeunvYr+GHU0lBtwG4Ax8Jpj4Gu8764=; b=gjJADbYwJTuC3Cgm1jgGkzRb5kFjwxfcdq5VzfOEP6fWsW/PCVbCxuH7 IBbg6gQ7XyV+mqXxrznf8aLifhlKoullhOUduVhjv1AWW8M7lwQAxCHO8 ejS08LhFpBaAKirlriilHcumE9l/f3JdMLnpLZKPTqbSMakQ6FJ3K1/i/ mFNcv95pHVI6Fopum20vn/V/sAVsVap5v5Lbwk2ObOxc9fzna84eYNJCP ZtN2+4pgPFowgkSm020GAB7/PBcICv+S9+izWeUqgtQgxQrAkS3W0Kh/C Q++XpA72YoPYbojmXMVsFJG8Lezomw0j61BlLd2PWHzVVQROzw+4xRd0V Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219875" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219875" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452348" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:29 -0800 From: Mathias Nyman To: Cc: , Mathias Nyman , Sergey Shtylyov , Pavan Kondeti , stable@vger.kernel.org Subject: [PATCH v2 1/9] xhci: make xhci_handshake timeout for xhci_reset() adjustable Date: Thu, 3 Mar 2022 13:08:55 +0200 Message-Id: <20220303110903.1662404-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 11:08: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: 12767312 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 E817BC433FE for ; Thu, 3 Mar 2022 11:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232633AbiCCLIW (ORCPT ); Thu, 3 Mar 2022 06:08:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbiCCLIT (ORCPT ); Thu, 3 Mar 2022 06:08:19 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A778817AAA; Thu, 3 Mar 2022 03:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646305653; x=1677841653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=74os4aT3i+C2SOidVvHvZZBWyvDlquCbqF5/mimla4Q=; b=QY3rr1Sip08jAL0EYdj0bl7LTwbomToklSw3GT6ap++YxjI6vwYL3P8/ ytOXkWUMv3hQOlPaaAm+L65T0+y91w3rA8l4JqrtLf+UAIC+gPoM0gWbH b78H6VzdjVsxfkxORprnYDco7vJFjCbOnGlhg0aD851KiQh0iT6r7HGzm 45VSAROBYdL9yS2h+ZIJ+EjaRmqKhdiitw8PHkkI0GiB4gT/Wu8aliWQw EadqVqW3Jr+smEi+RusPIJEQ4+i/K2xWsqZlrQx0k8GzUzDoGp2CJ1XG8 VFtPdL90efyWvAJcc50BkVl6kToUNoaTABXM+G705YCNH+Xs6M8z6kdAp Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219879" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219879" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452357" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:31 -0800 From: Mathias Nyman To: Cc: , Anssi Hannula , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH v2 2/9] xhci: fix garbage USBSTS being logged in some cases Date: Thu, 3 Mar 2022 13:08:56 +0200 Message-Id: <20220303110903.1662404-3-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 11:08:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767314 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 C597EC433F5 for ; Thu, 3 Mar 2022 11:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232640AbiCCLIY (ORCPT ); Thu, 3 Mar 2022 06:08:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232626AbiCCLIW (ORCPT ); Thu, 3 Mar 2022 06:08:22 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3545B59; Thu, 3 Mar 2022 03:07: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=1646305655; x=1677841655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IVlmjCWFleFaQIZOFMVVi1fmFAsE8fignO+22Fs7Fvk=; b=H0+PQM1rT5PemajYuYMPAeRQC7cV/6tO2S30EryPvR5meamCYeET0rBf KQlQrp4HZc2oNsmtR/whNuoe6L7XVH6uvqLaJMRfF/raCTsO7l6WSt/Ij xWb+/wXc5LTNmlpjd/+j1zQ4BrR0pjMeDjtfhYcYFztrgpDqQqJ7S8rZa AkeRBeOBX/hgnfArWmgR0ZZILYt8IvqbbEW1pAG8lZ/DBhSNRTNdy2Jd6 vI4Jgpq/LUFxsHEeRySSqpVaV4vBHHiDD6ic5M8kE0X5MqZe5nB+x7Qyk uWcgmodjp4j+rcWG3/NyehS7yZdNxXTxlcRDuav8Slh+oMKLEwhQGPk6T Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219885" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219885" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452371" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:33 -0800 From: Mathias Nyman To: Cc: , Anssi Hannula , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH v2 3/9] xhci: fix uninitialized string returned by xhci_decode_ctrl_ctx() Date: Thu, 3 Mar 2022 13:08:57 +0200 Message-Id: <20220303110903.1662404-4-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 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") Cc: stable@vger.kernel.org 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 11:08:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767315 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 21C7BC433FE for ; Thu, 3 Mar 2022 11:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232642AbiCCLIY (ORCPT ); Thu, 3 Mar 2022 06:08:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232638AbiCCLIX (ORCPT ); Thu, 3 Mar 2022 06:08:23 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98209FD37; Thu, 3 Mar 2022 03:07: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=1646305657; x=1677841657; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iYkhn+N++G6Az23+XPrHAQS99KXmeNH6QCJYVOADOTE=; b=ECAXf5ReldDriZDcAQGvNpkE3lIvxyuuafUwMk/da2zG6TwiTisnwHK6 YmKEO4MQdbO6L3OWCoCs8apVISHW1tDr8+EAQ3XUZ0LUJPtoh+VCxhqMl 13aaF2pkmURSMKgPeQV8oYat8SAAuEytCvs3fVnby+/n/827Txon0uFBa IZN55SPQu82O1r9vXpCqU7YJ7CtZAVA/kEAeEwu+I7+t/wiqJa1nnS8iK V3+3AsD3SQtrOM00bIo5YPRrqQHAQ5qOfb8E0JTO3pEs3X0r5b7vTSjNk OeWZtIw85CbVvmb0nR5E6olLt61+lP9PiYn+SOCrEpK1Fwq8UScnGhHPe w==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219891" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219891" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452380" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:35 -0800 From: Mathias Nyman To: Cc: , Henry Lin , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH v2 4/9] xhci: fix runtime PM imbalance in USB2 resume Date: Thu, 3 Mar 2022 13:08:58 +0200 Message-Id: <20220303110903.1662404-5-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 11:08:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767316 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 6F1E5C433EF for ; Thu, 3 Mar 2022 11:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232647AbiCCLI2 (ORCPT ); Thu, 3 Mar 2022 06:08:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232638AbiCCLI2 (ORCPT ); Thu, 3 Mar 2022 06:08:28 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A23D1AF1A for ; Thu, 3 Mar 2022 03:07: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=1646305660; x=1677841660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jJCu2kTAbizusS27kv0h56CpQN3omVI3FloLm80zRek=; b=S55tGkkQUe6dUv9LJE6xZRujvE/KO1wLu8rUMtB2+rYlD81SJOf1DGq9 zXNG10KAMHaBAQzC3y0UMkbye2IgndGjpWrMxJ5c+CaW33IVrC+jLu2z4 nDH0RXIHEfU6jx0zr6sIshUwJ1Jh2e1gb06CNKMIx04Ea5XifCJkMCefy GJYADyRki61H044r0qTLsiurNojFfhZkl1FpvKckkAI7ym5ADHvNKlBiP otisQOddchhj2IacGzc88WW7gLIWmOpU4vf4MfWXGFCsOjq78xT/vtLsm 3d8ToatdOl+3R/UipFxi89sHWRy6I690N1Ougcqs0iv1WR4pG+coBWZ6O w==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219894" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219894" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452387" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:37 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH v2 5/9] usb: host: xhci: use ffs() in xhci_mem_init() Date: Thu, 3 Mar 2022 13:08:59 +0200 Message-Id: <20220303110903.1662404-6-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 11:09:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767317 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 CBEC3C433FE for ; Thu, 3 Mar 2022 11:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232638AbiCCLI3 (ORCPT ); Thu, 3 Mar 2022 06:08:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232646AbiCCLI2 (ORCPT ); Thu, 3 Mar 2022 06:08:28 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D843A28999 for ; Thu, 3 Mar 2022 03:07:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646305660; x=1677841660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qjgwhxrUkCs2Av9ADpFnLBwAeCuSk5H7PEXy1mrTLDI=; b=WfTyfdkeRFmD6L59PMGpAiI0d9/2fFlE0HLxNnVBXgrqCmp+R2gaS09A S7kamnYmcjNgVrtuVpPHQpa9eWDMFpOnvVOolc5aIFPbl8JBb7U3QLUSR Jak6B4XM7kYhJqw8DBXFCfzyAa6FsnK1VKw0iXjSZNmmOGeoHfbivr+2w AkhDPwmTYwJPY6PlDd9AVm6L9RczXm1Dk+7IrblmpP0o7A7qsVuIi24ZQ 6CiDUVIZ159P62F5Mq4i6yBDitnNJCBmRtmQ7X5q1hM9VOQ0udKLW9Y45 9sP8tLOAI8UhZTerAZbu0tGOHvBzLwS8Uk3pRDq6A+bNEqGpuVMOFxSSj g==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219904" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219904" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452395" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:39 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH v2 6/9] usb: host: xhci: fix a comment typo in xhci_mem_init() Date: Thu, 3 Mar 2022 13:09:00 +0200 Message-Id: <20220303110903.1662404-7-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 11:09:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767318 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 641FDC4332F for ; Thu, 3 Mar 2022 11:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232649AbiCCLI3 (ORCPT ); Thu, 3 Mar 2022 06:08:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232651AbiCCLI2 (ORCPT ); Thu, 3 Mar 2022 06:08:28 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28EF54FA3 for ; Thu, 3 Mar 2022 03:07:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646305662; x=1677841662; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eascq1DeoR3EyUxnIuH7kjEiV86srJGQixov3nOLtQA=; b=II/QPshN2HePtb0XNlsMLU2CZBQgbo73jM6Dk65pPNZhx4YsRi0h4Adz HhiWsPRbGQxrobRrf8U4EjSKDvOfiymnEMkZu7IJnqS2L9EP6M0GuTc1Z jr2D1BSgoiU/2dDce3MdPif0mR54rd0rJ6Y4RsjgMjiZwWVGxzolLHlGv uovd5GtuWNs5vOyNgnYdN1ZxA8SzXUeF5kGEZ8/FHdkesB6nFIGGub9og yzZcgVRKPFv32c1PjgIqH1+ITisMMWE4ttTyn8ynv5qQcztr5gfNtRMpR eCJR3ILV6CbziWxMtjoOTJpgIoeGA/WR4un1Y5fP1Aus9nguBOhC9aKIs A==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219913" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219913" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452403" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:40 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH v2 7/9] usb: host: xhci: update hci_version operation in xhci_gen_setup() Date: Thu, 3 Mar 2022 13:09:01 +0200 Message-Id: <20220303110903.1662404-8-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 11:09:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767319 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 06370C433F5 for ; Thu, 3 Mar 2022 11:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232651AbiCCLIa (ORCPT ); Thu, 3 Mar 2022 06:08:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232648AbiCCLI3 (ORCPT ); Thu, 3 Mar 2022 06:08:29 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63CF855210 for ; Thu, 3 Mar 2022 03:07:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646305664; x=1677841664; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iQ/YV/TqRG9910eZ3a/U/TfxeBZRExu8F6yQfLablsg=; b=KTFGpGoL0hUsUlpA71kjH8Jb1G+eSFomwQPWbN0EqgS8ra1Arfmlln0E 2hAuey1L5QZfeHPs8tPPgqqg0FG7jlCjLQ2uHM0nYlfBp/u15K5XN0eA/ oVA3MgUaiN1He0g6/B+oCLzDUX3U+L6UZlERaCCQURZCa9Lsrga6PA5by SbSLb/BIWwc9lel1VHqijGJnz6naao+9pCxRVhlMUPN5BNeJvbFNzbuW4 VOu5dI6+JNHHRwyHnIlELixdEuxkYuZJytSRlkO0wC2iqbJIrcSEgto29 apNjnbDZgJYVtL1FSnRnsVJrybmTHzi+fL5PJM1vLo3NVITjg1TWqB9WC Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219920" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219920" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452417" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:42 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH v2 8/9] usb: host: xhci: add blank line in xhci_halt() Date: Thu, 3 Mar 2022 13:09:02 +0200 Message-Id: <20220303110903.1662404-9-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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 11:09:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767320 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 456D1C433EF for ; Thu, 3 Mar 2022 11:07:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232660AbiCCLId (ORCPT ); Thu, 3 Mar 2022 06:08:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbiCCLIb (ORCPT ); Thu, 3 Mar 2022 06:08:31 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19A1F25C6E for ; Thu, 3 Mar 2022 03:07:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646305666; x=1677841666; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fz/1LWz1fZQyoqkzlm5wht0AXSQuG+ooIXmsbArEh/w=; b=jRUsHDzicNkYCkm9VHfc8lRHoCNCwIQKNsiEKLw9AMmU3a18SN1q/KQS X+nRcbjUdw1AteVaG5oa/HO8mbXK4KJgddK0Lw8AuWRJHFIwXmoUJAznP jwKmRSdpBI6IAZgy5RTnMP2iRucvS52wOXqoxecYDLDnFsS8zbYB5UOl0 TvR17csBB640ff+s9NGqGImSGJ9looIp0pXG4cg3HWTjfcLvoy6dX3bJJ fxTj4Mf+4PpWXUZ3zZle7fkLGEniOoRJSvt5EYLSy/L0Fn+Pod2/uhgLC XX+lOnl6/QcooPFvUMo9P9HgcH8e9JQqQFJvgExQS5ioofvcVi9oXDJns A==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219927" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219927" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452426" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:44 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH v2 9/9] usb: host: xhci: Remove some unnecessary return value initializations Date: Thu, 3 Mar 2022 13:09:03 +0200 Message-Id: <20220303110903.1662404-10-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-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; } /*