public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Justin Chen <justinpopo6@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	mathias.nyman@intel.com, linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 5.15 05/47] usb: host: xhci-plat: suspend and resume clocks
Date: Wed, 12 Oct 2022 20:20:40 -0400	[thread overview]
Message-ID: <20221013002124.1894077-5-sashal@kernel.org> (raw)
In-Reply-To: <20221013002124.1894077-1-sashal@kernel.org>

From: Justin Chen <justinpopo6@gmail.com>

[ Upstream commit 8bd954c56197caf5e3a804d989094bc3fe6329aa ]

Introduce XHCI_SUSPEND_RESUME_CLKS quirk as a means to suspend and resume
clocks if the hardware is capable of doing so. We assume that clocks will
be needed if the device may wake.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Justin Chen <justinpopo6@gmail.com>
Link: https://lore.kernel.org/r/1660170455-15781-2-git-send-email-justinpopo6@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/host/xhci-plat.c | 16 +++++++++++++++-
 drivers/usb/host/xhci.h      |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index dc570ce4e831..2687662f26b6 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -447,7 +447,16 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
 	 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
 	 * to do wakeup during suspend.
 	 */
-	return xhci_suspend(xhci, device_may_wakeup(dev));
+	ret = xhci_suspend(xhci, device_may_wakeup(dev));
+	if (ret)
+		return ret;
+
+	if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) {
+		clk_disable_unprepare(xhci->clk);
+		clk_disable_unprepare(xhci->reg_clk);
+	}
+
+	return 0;
 }
 
 static int __maybe_unused xhci_plat_resume(struct device *dev)
@@ -456,6 +465,11 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	int ret;
 
+	if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) {
+		clk_prepare_enable(xhci->clk);
+		clk_prepare_enable(xhci->reg_clk);
+	}
+
 	ret = xhci_priv_resume_quirk(hcd);
 	if (ret)
 		return ret;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 10a4230d95c3..3b39501f26ea 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1903,6 +1903,7 @@ struct xhci_hcd {
 #define XHCI_NO_SOFT_RETRY	BIT_ULL(40)
 #define XHCI_BROKEN_D3COLD	BIT_ULL(41)
 #define XHCI_EP_CTX_BROKEN_DCS	BIT_ULL(42)
+#define XHCI_SUSPEND_RESUME_CLKS	BIT_ULL(43)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
-- 
2.35.1


  parent reply	other threads:[~2022-10-13  0:30 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13  0:20 [PATCH AUTOSEL 5.15 01/47] clk: zynqmp: Fix stack-out-of-bounds in strncpy` Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 02/47] media: cx88: Fix a null-ptr-deref bug in buffer_prepare() Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 03/47] media: platform: fix some double free in meson-ge2d and mtk-jpeg and s5p-mfc Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 04/47] clk: zynqmp: pll: rectify rate rounding in zynqmp_pll_round_rate Sasha Levin
2022-10-13  0:20 ` Sasha Levin [this message]
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 06/47] usb: host: xhci-plat: suspend/resume clks for brcm Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 07/47] dmaengine: ti: k3-udma: Reset UDMA_CHAN_RT byte counters to prevent overflow Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 08/47] scsi: 3w-9xxx: Avoid disabling device if failing to enable it Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 09/47] nbd: Fix hung when signal interrupts nbd_start_device_ioctl() Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 10/47] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Sasha Levin
2022-10-13  7:07   ` John Garry
2022-10-16 13:30     ` Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 11/47] staging: rtl8712: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 12/47] staging: rtl8192e: " Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 13/47] power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type() Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 14/47] staging: vt6655: fix potential memory leak Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 15/47] blk-throttle: prevent overflow while calculating wait time Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 16/47] gpiolib: of: do not ignore requested index when applying quirks Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 17/47] gpiolib: of: make Freescale SPI quirk similar to all others Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 18/47] gpiolib: rework quirk handling in of_find_gpio() Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 19/47] ata: libahci_platform: Sanity check the DT child nodes number Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 20/47] bcache: fix set_at_max_writeback_rate() for multiple attached devices Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 21/47] soundwire: cadence: Don't overwrite msg->buf during write commands Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 22/47] soundwire: intel: fix error handling on dai registration issues Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 23/47] hid: topre: Add driver fixing report descriptor Sasha Levin
2022-10-13  0:20 ` [PATCH AUTOSEL 5.15 24/47] habanalabs: remove some f/w descriptor validations Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 25/47] HID: roccat: Fix use-after-free in roccat_read() Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 26/47] HSI: ssi_protocol: fix potential resource leak in ssip_pn_open() Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 27/47] eventfd: guard wake_up in eventfd fs calls as well Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 28/47] md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 29/47] usb: host: xhci: Fix potential memory leak in xhci_alloc_stream_info() Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 30/47] usb: musb: Fix musb_gadget.c rxstate overflow bug Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 31/47] arm64: dts: imx8mp: Add snps,gfladj-refclk-lpm-sel quirk to USB nodes Sasha Levin
2022-10-13  5:57   ` [PATCH AUTOSEL 5.15 31/47] arm64: dts: imx8mp: Add snps, gfladj-refclk-lpm-sel " Alexander Stein
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 32/47] usb: dwc3: core: Enable GUCTL1 bit 10 for fixing termination error after resume bug Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 33/47] Revert "usb: storage: Add quirk for Samsung Fit flash" Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 34/47] tty: n_gsm: replace use of gsm_read_ea() with gsm_read_ea_val() Sasha Levin
2022-10-13  6:21   ` Jiri Slaby
2022-10-16 13:27     ` Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 35/47] staging: rtl8723bs: fix potential memory leak in rtw_init_drv_sw() Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 36/47] staging: rtl8723bs: fix a potential memory leak in rtw_init_cmd_priv() Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 37/47] staging: rtl8192u: Fix return type of ieee80211_xmit Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 38/47] staging: octeon: Fix return type of cvm_oct_xmit and cvm_oct_xmit_pow Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 39/47] scsi: tracing: Fix compile error in trace_array calls when TRACING is disabled Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 40/47] ext2: Use kvmalloc() for group descriptor array Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 41/47] nvme: copy firmware_rev on each init Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 42/47] nvmet-tcp: add bounds check on Transfer Tag Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 43/47] usb: idmouse: fix an uninit-value in idmouse_open Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 44/47] fsi: master-ast-cf: Fix missing of_node_put in fsi_master_acf_probe Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 45/47] sbitmap: fix lockup while swapping Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 46/47] clk: bcm2835: Make peripheral PLLC critical Sasha Levin
2022-10-13  0:21 ` [PATCH AUTOSEL 5.15 47/47] clk: bcm2835: Round UART input clock up Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221013002124.1894077-5-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=justinpopo6@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox