All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>, Henry Lin <henryl@nvidia.com>,
	stable@vger.kernel.org,
	Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [PATCH v2 4/9] xhci: fix runtime PM imbalance in USB2 resume
Date: Thu,  3 Mar 2022 13:08:58 +0200	[thread overview]
Message-ID: <20220303110903.1662404-5-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com>

From: Henry Lin <henryl@nvidia.com>

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 <henryl@nvidia.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 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)) {
-- 
2.25.1


  parent reply	other threads:[~2022-03-03 11:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 11:08 [PATCH v2 0/9] xhci cleanups and fixes for usb-next Mathias Nyman
2022-03-03 11:08 ` [PATCH v2 1/9] xhci: make xhci_handshake timeout for xhci_reset() adjustable Mathias Nyman
2022-03-03 11:08 ` [PATCH v2 2/9] xhci: fix garbage USBSTS being logged in some cases Mathias Nyman
2022-03-03 11:08 ` [PATCH v2 3/9] xhci: fix uninitialized string returned by xhci_decode_ctrl_ctx() Mathias Nyman
2022-03-03 11:08 ` Mathias Nyman [this message]
2022-03-03 11:08 ` [PATCH v2 5/9] usb: host: xhci: use ffs() in xhci_mem_init() Mathias Nyman
2022-03-03 11:09 ` [PATCH v2 6/9] usb: host: xhci: fix a comment typo " Mathias Nyman
2022-03-03 11:09 ` [PATCH v2 7/9] usb: host: xhci: update hci_version operation in xhci_gen_setup() Mathias Nyman
2022-03-03 11:09 ` [PATCH v2 8/9] usb: host: xhci: add blank line in xhci_halt() Mathias Nyman
2022-03-03 11:09 ` [PATCH v2 9/9] usb: host: xhci: Remove some unnecessary return value initializations Mathias Nyman

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=20220303110903.1662404-5-mathias.nyman@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=henryl@nvidia.com \
    --cc=linux-usb@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.