linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 61/78] xhci: Ensure link state is U3 after setting USB_SS_PORT_LS_U3
Date: Sat, 18 Apr 2020 10:40:30 -0400	[thread overview]
Message-ID: <20200418144047.9013-61-sashal@kernel.org> (raw)
In-Reply-To: <20200418144047.9013-1-sashal@kernel.org>

From: Kai-Heng Feng <kai.heng.feng@canonical.com>

[ Upstream commit eb002726fac7cefb98ff39ddb89e150a1c24fe85 ]

The xHCI spec doesn't specify the upper bound of U3 transition time. For
some devices 20ms is not enough, so we need to make sure the link state
is in U3 before further actions.

I've tried to use U3 Entry Capability by setting U3 Entry Enable in
config register, however the port change event for U3 transition
interrupts the system suspend process.

For now let's use the less ideal method by polling PLS.

[use usleep_range(), and shorten the delay time while polling -Mathias]
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200312144517.1593-7-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/host/xhci-hub.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index af92b2576fe91..712cd44f05ace 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1322,7 +1322,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			xhci_set_link_state(xhci, ports[wIndex], link_state);
 
 			spin_unlock_irqrestore(&xhci->lock, flags);
-			msleep(20); /* wait device to enter */
+			if (link_state == USB_SS_PORT_LS_U3) {
+				int retries = 16;
+
+				while (retries--) {
+					usleep_range(4000, 8000);
+					temp = readl(ports[wIndex]->addr);
+					if ((temp & PORT_PLS_MASK) == XDEV_U3)
+						break;
+				}
+			}
 			spin_lock_irqsave(&xhci->lock, flags);
 
 			temp = readl(ports[wIndex]->addr);
-- 
2.20.1


  parent reply	other threads:[~2020-04-18 14:53 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-18 14:39 [PATCH AUTOSEL 5.4 01/78] iommu/amd: Fix the configuration of GCR3 table root pointer Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 02/78] tools/testing/nvdimm: Fix compilation failure without CONFIG_DEV_DAX_PMEM_COMPAT Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 03/78] watchdog: reset last_hw_keepalive time at start Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 04/78] ovl: fix value of i_ino for lower hardlink corner case Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 05/78] iommu/vt-d: Fix page request descriptor size Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 06/78] acpi/nfit: improve bounds checking for 'func' Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 07/78] iommu/vt-d: Fix mm reference leak Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 08/78] scsi: lpfc: Fix kasan slab-out-of-bounds error in lpfc_unreg_login Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 09/78] scsi: lpfc: Fix crash after handling a pci error Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 10/78] scsi: lpfc: Fix crash in target side cable pulls hitting WAIT_FOR_UNREG Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 11/78] scsi: libfc: If PRLI rejected, move rport to PLOGI state Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 12/78] ceph: return ceph_mdsc_do_request() errors from __get_parent() Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 13/78] ceph: don't skip updating wanted caps when cap is stale Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 14/78] pwm: rcar: Fix late Runtime PM enablement Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 15/78] nvme-tcp: fix possible crash in write_zeroes processing Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 16/78] ASoC: dpcm: allow start or stop during pause for backend Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 17/78] scsi: iscsi: Report unbind session event when the target has been removed Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 18/78] tools/test/nvdimm: Fix out of tree build Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 19/78] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 20/78] nvme: fix deadlock caused by ANA update wrong locking Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 21/78] drm/amd/display: Update stream adjust in dc_stream_adjust_vmin_vmax Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 22/78] dma-direct: fix data truncation in dma_direct_get_required_mask() Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 23/78] dma-debug: fix displaying of dma allocation type Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 24/78] kernel/gcov/fs.c: gcov_seq_next() should increase position index Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 25/78] selftests: kmod: fix handling test numbers above 9 Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 26/78] ipc/util.c: sysvipc_find_ipc() should increase position index Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 27/78] kconfig: qconf: Fix a few alignment issues Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 28/78] lib/raid6/test: fix build on distros whose /bin/sh is not bash Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 29/78] KVM: s390: vsie: Fix possible race when shadowing region 3 tables Sasha Levin
2020-04-18 14:39 ` [PATCH AUTOSEL 5.4 30/78] drm/nouveau: workaround runpm fail by disabling PCI power management on certain intel bridges Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 31/78] s390/cio: generate delayed uevent for vfio-ccw subchannels Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 32/78] s390/cio: avoid duplicated 'ADD' uevents Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 33/78] loop: Better discard support for block devices Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 34/78] pwm: pca9685: Fix PWM/GPIO inter-operation Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 35/78] Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled" Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 36/78] powerpc/pseries: Fix MCE handling on pseries Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 37/78] drm/amdkfd: kfree the wrong pointer Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 38/78] nvme: fix compat address handling in several ioctls Sasha Levin
2020-04-28  4:53   ` Naresh Kamboju
2020-04-28  5:23     ` Nick Bowler
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 39/78] pwm: renesas-tpu: Fix late Runtime PM enablement Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 40/78] pwm: bcm2835: Dynamically allocate base Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 41/78] drm/vc4: Fix HDMI mode validation Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 42/78] iommu/virtio: Fix freeing of incomplete domains Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 43/78] iommu/vt-d: Silence RCU-list debugging warning in dmar_find_atsr() Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 44/78] platform/chrome: cros_ec_rpmsg: Fix race with host event Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 45/78] libnvdimm: Out of bounds read in __nd_ioctl() Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 46/78] ocfs2: no need try to truncate file beyond i_size Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 47/78] hfsplus: fix crash and filesystem corruption when deleting files Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 48/78] ALSA: hda: Add driver blacklist Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 49/78] ALSA: hda/realtek - Add quirk for MSI GL63 Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 50/78] perf/core: Disable page faults when getting phys address Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 51/78] libata: Return correct status in sata_pmp_eh_recover_pm() when ATA_DFLAG_DETACH is set Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 52/78] drm/amd/display: Calculate scaling ratios on every medium/full update Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 53/78] ALSA: ice1724: Fix invalid access for enumerated ctl items Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 54/78] ALSA: hda: Fix potential access overflow in beep helper Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 55/78] KVM: s390: vsie: Fix delivery of addressing exceptions Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 56/78] ASoC: Intel: bytcr_rt5640: Add quirk for MPMAN MPWIN895CL tablet Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 57/78] ipmi: fix hung processes in __get_guid() Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 58/78] ALSA: usb-audio: Add Pioneer DJ DJM-250MK2 quirk Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 59/78] ALSA: hda/realtek - Add quirk for Lenovo Carbon X1 8th gen Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 60/78] scsi: mpt3sas: Fix kernel panic observed on soft HBA unplug Sasha Levin
2020-04-18 14:40 ` Sasha Levin [this message]
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 62/78] xhci: Wait until link state trainsits to U0 after setting USB_SS_PORT_LS_U0 Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 63/78] xhci: Finetune host initiated USB3 rootport link suspend and resume Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 64/78] drm/amd/display: Not doing optimize bandwidth if flip pending Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 65/78] PCI/PM: Add pcie_wait_for_link_delay() Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 66/78] libbpf: Fix readelf output parsing on powerpc with recent binutils Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 67/78] PCI: pciehp: Prevent deadlock on disconnect Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 68/78] ASoC: SOF: trace: fix unconditional free in trace release Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 69/78] powerpc/powernv/ioda: Fix ref count for devices with their own PE Sasha Levin
2020-04-21 11:02   ` Frederic Barrat
2020-04-25 15:00     ` Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 70/78] pci/hotplug/pnv-php: Remove erroneous warning Sasha Levin
2020-04-21 11:03   ` Frederic Barrat
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 71/78] ocxl: Add PCI hotplug dependency to Kconfig Sasha Levin
2020-04-21 11:05   ` Frederic Barrat
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 72/78] tracing/selftests: Turn off timeout setting Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 73/78] virtio-blk: improve virtqueue error to BLK_STS Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 74/78] scsi: smartpqi: fix controller lockup observed during force reboot Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 75/78] scsi: smartpqi: fix call trace in device discovery Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 76/78] scsi: smartpqi: fix problem with unique ID for physical device Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 77/78] PCI/ASPM: Allow re-enabling Clock PM Sasha Levin
2020-04-18 14:40 ` [PATCH AUTOSEL 5.4 78/78] PCI/PM: Add missing link delays required by the PCIe spec 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=20200418144047.9013-61-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.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;
as well as URLs for NNTP newsgroup(s).