linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>,
	Paul Zimmerman <pauldzim@gmail.com>,
	Peter Chen <peter.chen@nxp.com>
Subject: [PATCH 4.14 047/117] USB: hub: Fix handling of connect changes during sleep
Date: Fri,  1 May 2020 15:21:23 +0200	[thread overview]
Message-ID: <20200501131550.361609021@linuxfoundation.org> (raw)
In-Reply-To: <20200501131544.291247695@linuxfoundation.org>

From: Alan Stern <stern@rowland.harvard.edu>

commit 9f952e26295d977dbfc6fedeaf8c4f112c818d37 upstream.

Commit 8099f58f1ecd ("USB: hub: Don't record a connect-change event
during reset-resume") wasn't very well conceived.  The problem it
tried to fix was that if a connect-change event occurred while the
system was asleep (such as a device disconnecting itself from the bus
when it is suspended and then reconnecting when it resumes)
requiring a reset-resume during the system wakeup transition, the hub
port's change_bit entry would remain set afterward.  This would cause
the hub driver to believe another connect-change event had occurred
after the reset-resume, which was wrong and would lead the driver to
send unnecessary requests to the device (which could interfere with a
firmware update).

The commit tried to fix this by not setting the change_bit during the
wakeup.  But this was the wrong thing to do; it means that when a
device is unplugged while the system is asleep, the hub driver doesn't
realize anything has happened: The change_bit flag which would tell it
to handle the disconnect event is clear.

The commit needs to be reverted and the problem fixed in a different
way.  Fortunately an alternative solution was noted in the commit's
Changelog: We can continue to set the change_bit entry in
hub_activate() but then clear it when a reset-resume occurs.  That way
the the hub driver will see the change_bit when a device is
disconnected but won't see it when the device is still present.

That's what this patch does.

Reported-and-tested-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Fixes: 8099f58f1ecd ("USB: hub: Don't record a connect-change event during reset-resume")
Tested-by: Paul Zimmerman <pauldzim@gmail.com>
CC: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2004221602480.11262-100000@iolanthe.rowland.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/core/hub.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1195,6 +1195,11 @@ static void hub_activate(struct usb_hub
 #ifdef CONFIG_PM
 			udev->reset_resume = 1;
 #endif
+			/* Don't set the change_bits when the device
+			 * was powered off.
+			 */
+			if (test_bit(port1, hub->power_bits))
+				set_bit(port1, hub->change_bits);
 
 		} else {
 			/* The power session is gone; tell hub_wq */
@@ -3008,6 +3013,15 @@ static int check_port_resume_type(struct
 		if (portchange & USB_PORT_STAT_C_ENABLE)
 			usb_clear_port_feature(hub->hdev, port1,
 					USB_PORT_FEAT_C_ENABLE);
+
+		/*
+		 * Whatever made this reset-resume necessary may have
+		 * turned on the port1 bit in hub->change_bits.  But after
+		 * a successful reset-resume we want the bit to be clear;
+		 * if it was on it would indicate that something happened
+		 * following the reset-resume.
+		 */
+		clear_bit(port1, hub->change_bits);
 	}
 
 	return status;



  parent reply	other threads:[~2020-05-01 13:32 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 13:20 [PATCH 4.14 000/117] 4.14.178-rc1 review Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 001/117] ext4: fix extent_status fragmentation for plain files Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 002/117] net: ipv4: emulate READ_ONCE() on ->hdrincl bit-field in raw_sendmsg() Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 003/117] net: ipv4: avoid unused variable warning for sysctl Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 004/117] keys: Fix the use of the C++ keyword "private" in uapi/linux/keyctl.h Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 005/117] drm/msm: Use the correct dma_sync calls harder Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 006/117] crypto: mxs-dcp - make symbols sha1_null_hash and sha256_null_hash static Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 007/117] vti4: removed duplicate log message Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 008/117] watchdog: reset last_hw_keepalive time at start Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 009/117] scsi: lpfc: Fix kasan slab-out-of-bounds error in lpfc_unreg_login Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 010/117] ceph: return ceph_mdsc_do_request() errors from __get_parent() Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 011/117] ceph: dont skip updating wanted caps when cap is stale Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 012/117] pwm: rcar: Fix late Runtime PM enablement Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 013/117] scsi: iscsi: Report unbind session event when the target has been removed Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 014/117] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 015/117] kernel/gcov/fs.c: gcov_seq_next() should increase position index Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 016/117] selftests: kmod: fix handling test numbers above 9 Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 017/117] ipc/util.c: sysvipc_find_ipc() should increase position index Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 018/117] s390/cio: avoid duplicated ADD uevents Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 019/117] pwm: renesas-tpu: Fix late Runtime PM enablement Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 020/117] pwm: bcm2835: Dynamically allocate base Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 021/117] perf/core: Disable page faults when getting phys address Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 022/117] PCI/ASPM: Allow re-enabling Clock PM Greg Kroah-Hartman
2020-05-01 13:20 ` [PATCH 4.14 023/117] mm, slub: restore the original intention of prefetch_freepointer() Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 024/117] cxgb4: fix large delays in PTP synchronization Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 025/117] ipv6: fix restrict IPV6_ADDRFORM operation Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 026/117] macsec: avoid to set wrong mtu Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 027/117] macvlan: fix null dereference in macvlan_device_event() Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 028/117] net: bcmgenet: correct per TX/RX ring statistics Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 029/117] net: netrom: Fix potential nr_neigh refcnt leak in nr_add_node Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 030/117] net/x25: Fix x25_neigh refcnt leak when receiving frame Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 031/117] tcp: cache line align MAX_TCP_HEADER Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 032/117] team: fix hang in team_mode_get() Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 033/117] net: dsa: b53: Fix ARL register definitions Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 034/117] xfrm: Always set XFRM_TRANSFORMED in xfrm{4,6}_output_finish Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 035/117] vrf: Check skb for XFRM_TRANSFORMED flag Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 036/117] KEYS: Avoid false positive ENOMEM error on key read Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 037/117] ALSA: hda: Remove ASUS ROG Zenith from the blacklist Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 038/117] iio: adc: stm32-adc: fix sleep in atomic context Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 039/117] iio: xilinx-xadc: Fix ADC-B powerdown Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 040/117] iio: xilinx-xadc: Fix clearing interrupt when enabling trigger Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 041/117] iio: xilinx-xadc: Fix sequencer configuration for aux channels in simultaneous mode Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 042/117] fs/namespace.c: fix mountpoint reference counter race Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 043/117] USB: sisusbvga: Change port variable from signed to unsigned Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 044/117] USB: Add USB_QUIRK_DELAY_CTRL_MSG and USB_QUIRK_DELAY_INIT for Corsair K70 RGB RAPIDFIRE Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 045/117] USB: early: Handle AMDs spec-compliant identifiers, too Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 046/117] USB: core: Fix free-while-in-use bug in the USB S-Glibrary Greg Kroah-Hartman
2020-05-01 13:21 ` Greg Kroah-Hartman [this message]
2020-05-01 13:21 ` [PATCH 4.14 048/117] overflow.h: Add arithmetic shift helper Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 049/117] vmalloc: fix remap_vmalloc_range() bounds checks Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 050/117] mm/hugetlb: fix a addressing exception caused by huge_pte_offset Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 051/117] mm/ksm: fix NULL pointer dereference when KSM zero page is enabled Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 052/117] tools/vm: fix cross-compile build Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 053/117] ALSA: usx2y: Fix potential NULL dereference Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 054/117] ALSA: hda/realtek - Add new codec supported for ALC245 Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 055/117] ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 056/117] ALSA: usb-audio: Filter out unsupported sample rates on Focusrite devices Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 057/117] tpm/tpm_tis: Free IRQ if probing fails Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 058/117] tpm: ibmvtpm: retry on H_CLOSED in tpm_ibmvtpm_send() Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 059/117] KVM: Check validity of resolved slot when searching memslots Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 060/117] KVM: VMX: Enable machine check support for 32bit targets Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 061/117] tty: hvc: fix buffer overflow during hvc_alloc() Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 062/117] tty: rocket, avoid OOB access Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 063/117] usb-storage: Add unusual_devs entry for JMicron JMS566 Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 064/117] audit: check the length of userspace generated audit records Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 065/117] ASoC: dapm: fixup dapm kcontrol widget Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 066/117] iwlwifi: pcie: actually release queue memory in TVQM Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 067/117] ARM: imx: provide v7_cpu_resume() only on ARM_CPU_SUSPEND=y Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 068/117] powerpc/setup_64: Set cache-line-size based on cache-block-size Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 069/117] staging: comedi: dt2815: fix writing hi byte of analog output Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 070/117] staging: comedi: Fix comedi_device refcnt leak in comedi_open Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 071/117] vt: dont hardcode the mem allocation upper bound Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 072/117] staging: vt6656: Dont set RCR_MULTICAST or RCR_BROADCAST by default Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 073/117] staging: vt6656: Fix calling conditions of vnt_set_bss_mode Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 074/117] staging: vt6656: Fix drivers TBTT timing counter Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 075/117] staging: vt6656: Fix pairwise key entry save Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 076/117] staging: vt6656: Power save stop wake_up_count wrap around Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 077/117] cdc-acm: close race betrween suspend() and acm_softint Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 078/117] cdc-acm: introduce a cool down Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 079/117] UAS: no use logging any details in case of ENODEV Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 080/117] UAS: fix deadlock in error handling and PM flushing work Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 081/117] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 082/117] serial: sh-sci: Make sure status register SCxSR is read in correct sequence Greg Kroah-Hartman
2020-05-01 13:21 ` [PATCH 4.14 083/117] xfs: validate sb_logsunit is a multiple of the fs blocksize Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 084/117] xfs: Fix deadlock between AGI and AGF with RENAME_WHITEOUT Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 085/117] remoteproc: Fix wrong rvring index computation Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 086/117] mtd: cfi: fix deadloop in cfi_cmdset_0002.c do_write_buffer Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 087/117] include/uapi/linux/swab.h: fix userspace breakage, use __BITS_PER_LONG for swap Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 088/117] binder: take read mode of mmap_sem in binder_alloc_free_page() Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 089/117] usb: dwc3: gadget: Do link recovery for SS and SSP Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 090/117] usb: gadget: udc: bdc: Remove unnecessary NULL checks in bdc_req_complete Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 091/117] iio:ad7797: Use correct attribute_group Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 092/117] nfsd: memory corruption in nfsd4_lock() Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 093/117] i2c: altera: use proper variable to hold errno Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 094/117] net/cxgb4: Check the return from t4_query_params properly Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 095/117] ARM: dts: bcm283x: Disable dsi0 node Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 096/117] perf/core: fix parent pid/tid in task exit events Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 097/117] mm: shmem: disable interrupt when acquiring info->lock in userfaultfd_copy path Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 098/117] bpf, x86: Fix encoding for lower 8-bit registers in BPF_STX BPF_B Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 099/117] x86: hyperv: report value of misc_features Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 100/117] xfs: fix partially uninitialized structure in xfs_reflink_remap_extent Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 101/117] scsi: target: fix PR IN / READ FULL STATUS for FC Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 102/117] objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 103/117] objtool: Support Clang non-section symbols in ORC dump Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 104/117] xen/xenbus: ensure xenbus_map_ring_valloc() returns proper grant status Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 105/117] arm64: Delete the space separator in __emit_inst Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 106/117] ext4: use matching invalidatepage in ext4_writepage Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 107/117] ext4: increase wait time needed before reuse of deleted inode numbers Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 108/117] ext4: convert BUG_ONs to WARN_ONs in mballoc.c Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 109/117] of: unittest: kmemleak on changeset destroy Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 110/117] hwmon: (jc42) Fix name to have no illegal characters Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 111/117] ext4: avoid declaring fs inconsistent due to invalid file handles Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 112/117] ext4: protect journal inodes blocks using block_validity Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 113/117] ext4: dont perform block validity checks on the journal inode Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 114/117] ext4: fix block validity checks for journal inodes using indirect blocks Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 115/117] ext4: unsigned int compared against zero Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 116/117] qed: Fix use after free in qed_chain_free Greg Kroah-Hartman
2020-05-01 13:22 ` [PATCH 4.14 117/117] ext4: check for non-zero journal inum in ext4_calculate_overhead Greg Kroah-Hartman
2020-05-01 15:16 ` [PATCH 4.14 000/117] 4.14.178-rc1 review Jon Hunter
2020-05-01 21:59 ` Guenter Roeck
2020-05-02  5:55   ` Greg Kroah-Hartman
2020-05-01 22:26 ` Naresh Kamboju
2020-05-02 23:17 ` shuah

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=20200501131550.361609021@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pauldzim@gmail.com \
    --cc=peter.chen@nxp.com \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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).