Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 6AA82318B9B for ; Tue, 17 Mar 2026 14:56:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773759372; cv=none; b=QXdexas6RH6CqESvQDC5C/C3kmxMHBt0mvOlizJMwoYV2ya3MWXK6K1FTn+hIY7W73MsrN0MHJCpb3WeXYNJk8xkpK/EK6zlAcCCU/smcPVzRKQbCT6zhYmVd2gFTpW+IdoFRCTgU8TVAUjcQDNr9ycd/SQ5mVJ4nQdhhZjh7vA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773759372; c=relaxed/simple; bh=AkqDQbEdsXJINCi/E9JaB25gxpoBhfA4ZaGolwPWlLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JcdmeTM9YyuRJIEf6GhWHM1TCyCMohTn69AK+mZE5GVOpbGXXxJs9+fX3W5Nnni7BgTiwhr17DC80f90ryS9eP2owoAoeO8Al/f9FrAicvAmmkcrGZXoehKLDNXFCS/po4Xaqn0yhmXxPjwnjlQWII+X40KGO2PV7mdsWPPepAk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OjQMgpu9; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass 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="OjQMgpu9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773759371; x=1805295371; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AkqDQbEdsXJINCi/E9JaB25gxpoBhfA4ZaGolwPWlLA=; b=OjQMgpu9pS8wVoXGvqIHmgSZOnVjGn/gkvUVraj8/VvBTq5tVUQdiysW Y+CY4dIyBrM+NP/Fo78bGz4j0NyEDVIRyoDAd3CF1YkR2FkHYpa4PNQ+C Y6ek2bvAwDAenPaHw5LzdM8LzgXKklow4KHEWzVX8RJR3r1ZvRYOBOBdc TQ4mORoKZARe/KUyU+peRjJ0pKenAJyXH5i9N3l4mT/X++tIj9V5UQhDI SMo6ra+V9994JPzhcXsgId13/6Gs/zMKHk53xlVRHUwQtdaaU4FmL3i/a ol4VO7PfBMUSKhxTMAgq+hkg1D7Jxg//7WDepKajcStXL5INV3WxjXnU4 A==; X-CSE-ConnectionGUID: SOPLYZ3IT6ywwLY0Q2eX6A== X-CSE-MsgGUID: UhchmMPSQB+W3waPby6zbw== X-IronPort-AV: E=McAfee;i="6800,10657,11732"; a="85491164" X-IronPort-AV: E=Sophos;i="6.23,126,1770624000"; d="scan'208";a="85491164" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2026 07:56:11 -0700 X-CSE-ConnectionGUID: YodZbSwtR2S3zx/MYI7viA== X-CSE-MsgGUID: usKAzxyrS4+BaDgHN4Kfkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,126,1770624000"; d="scan'208";a="219394904" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa007.fm.intel.com with ESMTP; 17 Mar 2026 07:56:09 -0700 Received: by black.igk.intel.com (Postfix, from userid 1058) id 7235199; Tue, 17 Mar 2026 15:56:08 +0100 (CET) From: Niklas Neronin To: mathias.nyman@linux.intel.com Cc: linux-usb@vger.kernel.org, raoxu@uniontech.com, michal.pecio@gmail.com, Niklas Neronin , Andy Shevchenko Subject: [RFC PATCH v2 1/9] usb: xhci: simplify CMRT initialization logic Date: Tue, 17 Mar 2026 15:55:36 +0100 Message-ID: <20260317145544.2076387-2-niklas.neronin@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260317145544.2076387-1-niklas.neronin@linux.intel.com> References: <20260317145544.2076387-1-niklas.neronin@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The function compliance_mode_recovery_timer_init() is called from xhci_init() because the Compliance Mode Recovery Timer (CMRT) must be set up before xhci_run() when the xhci driver is re-initialized. To handle this case, the boolean flag 'comp_timer_running' was introduced to track whether xhci_run() had already been called, ensuring that xhci_resume() would not invoke compliance_mode_recovery_timer_init() a second time. This can be simplified by moving the 'done' label in xhci_resume() to after the compliance_mode_recovery_timer_init() call. With this change, the timer initialization runs only when the xhci driver has not been re-initialized, making the 'comp_timer_running' flag unnecessary and allowing it to be removed. Reviewed-by: Andy Shevchenko Signed-off-by: Niklas Neronin --- drivers/usb/host/xhci.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ef6d8662adec..810905b824d3 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1084,7 +1084,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool power_lost, bool is_auto_resume) u32 command, temp = 0; struct usb_hcd *hcd = xhci_to_hcd(xhci); int retval = 0; - bool comp_timer_running = false; bool pending_portevent = false; bool suspended_usb3_devs = false; @@ -1196,7 +1195,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool power_lost, bool is_auto_resume) retval = xhci_init(hcd); if (retval) return retval; - comp_timer_running = true; xhci_dbg(xhci, "Start the primary HCD\n"); retval = xhci_run(hcd); @@ -1265,16 +1263,16 @@ int xhci_resume(struct xhci_hcd *xhci, bool power_lost, bool is_auto_resume) usb_hcd_resume_root_hub(hcd); } } -done: + /* * If system is subject to the Quirk, Compliance Mode Timer needs to * be re-initialized Always after a system resume. Ports are subject * to suffer the Compliance Mode issue again. It doesn't matter if * ports have entered previously to U0 before system's suspension. */ - if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !comp_timer_running) + if (xhci->quirks & XHCI_COMP_MODE_QUIRK) compliance_mode_recovery_timer_init(xhci); - +done: if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL) usb_asmedia_modifyflowcontrol(to_pci_dev(hcd->self.controller)); -- 2.50.1