Skip to content

Commit f093ff8

Browse files
matnymangregkh
authored andcommitted
usb: hub: Fix flushing of delayed work used for post resume purposes
commit 9bd9c8026341f75f25c53104eb7e656e357ca1a2 upstream. Delayed work that prevents USB3 hubs from runtime-suspending too early needed to be flushed in hub_quiesce() to resolve issues detected on QC SC8280XP CRD board during suspend resume testing. This flushing did however trigger new issues on Raspberry Pi 3B+, which doesn't have USB3 ports, and doesn't queue any post resume delayed work. The flushed 'hub->init_work' item is used for several purposes, and is originally initialized with a 'NULL' work function. The work function is also changed on the fly, which may contribute to the issue. Solve this by creating a dedicated delayed work item for post resume work, and flush that delayed work in hub_quiesce() Cc: stable <[email protected]> Fixes: a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm") Reported-by: Mark Brown <[email protected]> Closes: https://lore.kernel.org/linux-usb/[email protected] Signed-off-by: Mathias Nyman <[email protected]> Tested-by: Konrad Dybcio <[email protected]> # SC8280XP CRD Tested-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 60c929c commit f093ff8

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

drivers/usb/core/hub.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,12 +1044,11 @@ int usb_remove_device(struct usb_device *udev)
10441044

10451045
enum hub_activation_type {
10461046
HUB_INIT, HUB_INIT2, HUB_INIT3, /* INITs must come first */
1047-
HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME, HUB_POST_RESUME,
1047+
HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME,
10481048
};
10491049

10501050
static void hub_init_func2(struct work_struct *ws);
10511051
static void hub_init_func3(struct work_struct *ws);
1052-
static void hub_post_resume(struct work_struct *ws);
10531052

10541053
static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
10551054
{
@@ -1073,12 +1072,6 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
10731072
goto init3;
10741073
}
10751074

1076-
if (type == HUB_POST_RESUME) {
1077-
usb_autopm_put_interface_async(to_usb_interface(hub->intfdev));
1078-
hub_put(hub);
1079-
return;
1080-
}
1081-
10821075
hub_get(hub);
10831076

10841077
/* The superspeed hub except for root hub has to use Hub Depth
@@ -1332,8 +1325,8 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
13321325
usb_autopm_get_interface_no_resume(
13331326
to_usb_interface(hub->intfdev));
13341327

1335-
INIT_DELAYED_WORK(&hub->init_work, hub_post_resume);
1336-
queue_delayed_work(system_power_efficient_wq, &hub->init_work,
1328+
queue_delayed_work(system_power_efficient_wq,
1329+
&hub->post_resume_work,
13371330
msecs_to_jiffies(USB_SS_PORT_U0_WAKE_TIME));
13381331
return;
13391332
}
@@ -1358,9 +1351,10 @@ static void hub_init_func3(struct work_struct *ws)
13581351

13591352
static void hub_post_resume(struct work_struct *ws)
13601353
{
1361-
struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work);
1354+
struct usb_hub *hub = container_of(ws, struct usb_hub, post_resume_work.work);
13621355

1363-
hub_activate(hub, HUB_POST_RESUME);
1356+
usb_autopm_put_interface_async(to_usb_interface(hub->intfdev));
1357+
hub_put(hub);
13641358
}
13651359

13661360
enum hub_quiescing_type {
@@ -1388,7 +1382,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
13881382

13891383
/* Stop hub_wq and related activity */
13901384
del_timer_sync(&hub->irq_urb_retry);
1391-
flush_delayed_work(&hub->init_work);
1385+
flush_delayed_work(&hub->post_resume_work);
13921386
usb_kill_urb(hub->urb);
13931387
if (hub->has_indicators)
13941388
cancel_delayed_work_sync(&hub->leds);
@@ -1947,6 +1941,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
19471941
hub->hdev = hdev;
19481942
INIT_DELAYED_WORK(&hub->leds, led_work);
19491943
INIT_DELAYED_WORK(&hub->init_work, NULL);
1944+
INIT_DELAYED_WORK(&hub->post_resume_work, hub_post_resume);
19501945
INIT_WORK(&hub->events, hub_event);
19511946
INIT_LIST_HEAD(&hub->onboard_hub_devs);
19521947
spin_lock_init(&hub->irq_urb_lock);

drivers/usb/core/hub.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct usb_hub {
6969
u8 indicator[USB_MAXCHILDREN];
7070
struct delayed_work leds;
7171
struct delayed_work init_work;
72+
struct delayed_work post_resume_work;
7273
struct work_struct events;
7374
spinlock_t irq_urb_lock;
7475
struct timer_list irq_urb_retry;

0 commit comments

Comments
 (0)