Skip to contentSkip to conversation

Fix "detection of high tier USB3 devices" patch in usb-linus

PATCH In review Mathias Nyman 4 participants 9 messages Jun 27, 2025 – Jun 30, 2025 USB

lore
Share & tools
lore
#0 lore raw

v3 cover Fix "detection of high tier USB3 devices" patch in usb-linus

Hi

This is the third attempt to fix "detection of hight tier USB3 devices".
It is rebased on top of the earlier fix attempt:
a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")

The original commit is:
8f5b7e2bec1c ("usb: hub: fix detection of high tier USB3 devices behind suspended hubs")

Both commits above are in Greg's usb-linus branch.

This is a rebased version of v2 with no other functional changes. v2 was tested by:

Any additional testing is appreciated

Thanks
Mathias

Mathias Nyman (1):
usb: hub: Fix flushing of delayed work used for post resume purposes

 drivers/usb/core/hub.c | 21 ++++++++-------------
 drivers/usb/core/hub.h |  1 +
 2 files changed, 9 insertions(+), 13 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/1 usb: hub: Fix flushing of delayed work used for post resume purposes

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()

Fixes a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")

---
v3:
- Rebase on top of a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
- Rewrite commit message

v2:
- Add and use dedicated delayed work struct for post resume work
- Add commit message section about dedicated work

 drivers/usb/core/hub.c | 21 ++++++++-------------
 drivers/usb/core/hub.h |  1 +
 2 files changed, 9 insertions(+), 13 deletions(-)
drivers/usb/core/hub.c +8 -13
index 08562711dcf2..3e1215f7a9a0 100644
@@ -1074,12 +1074,11 @@ int usb_remove_device(struct usb_device *udev)
 
 enum hub_activation_type {
 	HUB_INIT, HUB_INIT2, HUB_INIT3,		/* INITs must come first */
-	HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME, HUB_POST_RESUME,
+	HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME,
 };
 
 static void hub_init_func2(struct work_struct *ws);
 static void hub_init_func3(struct work_struct *ws);
-static void hub_post_resume(struct work_struct *ws);
 
 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
 {
@@ -1103,12 +1102,6 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
 		goto init3;
 	}
 
-	if (type == HUB_POST_RESUME) {
-		usb_autopm_put_interface_async(to_usb_interface(hub->intfdev));
-		hub_put(hub);
-		return;
-	}
-
 	hub_get(hub);
 
 	/* The superspeed hub except for root hub has to use Hub Depth
@@ -1362,8 +1355,8 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
 		usb_autopm_get_interface_no_resume(
 			to_usb_interface(hub->intfdev));
 
-		INIT_DELAYED_WORK(&hub->init_work, hub_post_resume);
-		queue_delayed_work(system_power_efficient_wq, &hub->init_work,
+		queue_delayed_work(system_power_efficient_wq,
+				   &hub->post_resume_work,
 				   msecs_to_jiffies(USB_SS_PORT_U0_WAKE_TIME));
 		return;
 	}
@@ -1388,9 +1381,10 @@ static void hub_init_func3(struct work_struct *ws)
 
 static void hub_post_resume(struct work_struct *ws)
 {
-	struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work);
+	struct usb_hub *hub = container_of(ws, struct usb_hub, post_resume_work.work);
 
-	hub_activate(hub, HUB_POST_RESUME);
+	usb_autopm_put_interface_async(to_usb_interface(hub->intfdev));
+	hub_put(hub);
 }
 
 enum hub_quiescing_type {
@@ -1418,7 +1412,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
 
 	/* Stop hub_wq and related activity */
 	timer_delete_sync(&hub->irq_urb_retry);
-	flush_delayed_work(&hub->init_work);
+	flush_delayed_work(&hub->post_resume_work);
 	usb_kill_urb(hub->urb);
 	if (hub->has_indicators)
 		cancel_delayed_work_sync(&hub->leds);
@@ -1977,6 +1971,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	hub->hdev = hdev;
 	INIT_DELAYED_WORK(&hub->leds, led_work);
 	INIT_DELAYED_WORK(&hub->init_work, NULL);
+	INIT_DELAYED_WORK(&hub->post_resume_work, hub_post_resume);
 	INIT_WORK(&hub->events, hub_event);
 	INIT_LIST_HEAD(&hub->onboard_devs);
 	spin_lock_init(&hub->irq_urb_lock);
drivers/usb/core/hub.h +1 -0
index e6ae73f8a95d..9ebc5ef54a32 100644
@@ -70,6 +70,7 @@ struct usb_hub {
 	u8			indicator[USB_MAXCHILDREN];
 	struct delayed_work	leds;
 	struct delayed_work	init_work;
+	struct delayed_work	post_resume_work;
 	struct work_struct      events;
 	spinlock_t		irq_urb_lock;
 	struct timer_list	irq_urb_retry;
Signature · 1 line
2.43.0
Tested-by on v3 1/1
#2 lore raw

Re: [RFT PATCH v3 1/1] usb: hub: Fix flushing of delayed work used for post resume purposes

Quoted 3 lines · Mathias Nyman

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.

on both the Raspberry Pi 3B+ and Libretech Alta.

Tested-by on v3 1/1
#3 lore raw

Re: [RFT PATCH v3 1/1] usb: hub: Fix flushing of delayed work used for post resume purposes

In reply to Mathias Nyman
Quoted 14 lines · Mathias Nyman

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()

Quoted 6 lines
Fixes a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")

---

Still no issues, thanks for working on this!

Konrad

maintainer
#4 lore raw

Re: [RFT PATCH v3 1/1] usb: hub: Fix flushing of delayed work used for post resume purposes

In reply to Mathias Nyman
Quoted 19 lines · Mathias Nyman

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()

Fixes a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
Quoted 8 lines

---
v3:
- Rebase on top of a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
- Rewrite commit message

v2:
- Add and use dedicated delayed work struct for post resume work
- Add commit message section about dedicated work

This seems to work, want me to take this, or are you going to submit another one? I'll hold off on sending the pull request to Linus for -rc4 because of this.

thanks,

greg k-h

#5 lore raw

Re: [RFT PATCH v3 1/1] usb: hub: Fix flushing of delayed work used for post resume purposes

Quoted 29 lines · Greg KH
Quoted 19 lines · Mathias Nyman

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()

Fixes a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
Quoted 8 lines

---
v3:
- Rebase on top of a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
- Rewrite commit message

v2:
- Add and use dedicated delayed work struct for post resume work
- Add commit message section about dedicated work

Quoted 7 lines

This seems to work, want me to take this, or are you going to submit another one? I'll hold off on sending the pull request to Linus for -rc4 because of this.

thanks,

greg k-h

Sorry about the response delay, was offline during weekend

I'll do some quick additional smoketests, suspending and disconnecting runtime suspended chained USB3 hubs. Shouldn't take more than a couple of hours

Thanks
Mathias

maintainer
#6 lore raw

Re: [RFT PATCH v3 1/1] usb: hub: Fix flushing of delayed work used for post resume purposes

Quoted 34 lines · Mathias Nyman
Quoted 33 lines · Greg KH
Quoted 19 lines · Mathias Nyman

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()

Fixes a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
Quoted 8 lines

---
v3:
- Rebase on top of a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
- Rewrite commit message

v2:
- Add and use dedicated delayed work struct for post resume work
- Add commit message section about dedicated work

This seems to work, want me to take this, or are you going to submit another one? I'll hold off on sending the pull request to Linus for -rc4 because of this.

Quoted 5 lines
Quoted 3 lines

thanks,

greg k-h

Sorry about the response delay, was offline during weekend

As one should be! :)

Quoted 2 lines

I'll do some quick additional smoketests, suspending and disconnecting runtime suspended chained USB3 hubs. Shouldn't take more than a couple of hours

Ok, no rush, thanks for letting me know.

greg k-h

#7 lore raw

Re: [RFT PATCH v3 1/1] usb: hub: Fix flushing of delayed work used for post resume purposes

Quoted 39 lines · Greg KH
Quoted 38 lines · Mathias Nyman
Quoted 36 lines · Greg KH
Quoted 19 lines · Mathias Nyman

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()

Fixes a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
Quoted 8 lines

---
v3:
- Rebase on top of a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
- Rewrite commit message

v2:
- Add and use dedicated delayed work struct for post resume work
- Add commit message section about dedicated work

This seems to work, want me to take this, or are you going to submit another one? I'll hold off on sending the pull request to Linus for -rc4 because of this.

thanks,

greg k-h

Quoted 9 lines
Quoted 1 line

Sorry about the response delay, was offline during weekend

As one should be! :)

Quoted 2 lines

I'll do some quick additional smoketests, suspending and disconnecting runtime suspended chained USB3 hubs. Shouldn't take more than a couple of hours

Ok, no rush, thanks for letting me know.

My additional smoktests passed as well.

Can you pick this RFT PATCH v3 as it is?
Or want a new one with all those "Tested-by" tags

Thanks
Mathias

maintainer
#8 lore raw

Re: [RFT PATCH v3 1/1] usb: hub: Fix flushing of delayed work used for post resume purposes

Quoted 47 lines · Mathias Nyman
Quoted 46 lines · Greg KH
Quoted 34 lines · Mathias Nyman
Quoted 33 lines · Greg KH
Quoted 19 lines · Mathias Nyman

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()

Fixes a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
Quoted 8 lines

---
v3:
- Rebase on top of a49e1e2e785f ("usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm")
- Rewrite commit message

v2:
- Add and use dedicated delayed work struct for post resume work
- Add commit message section about dedicated work

This seems to work, want me to take this, or are you going to submit another one? I'll hold off on sending the pull request to Linus for -rc4 because of this.

Quoted 5 lines
Quoted 3 lines

thanks,

greg k-h

Sorry about the response delay, was offline during weekend

As one should be! :)

Quoted 2 lines

I'll do some quick additional smoketests, suspending and disconnecting runtime suspended chained USB3 hubs. Shouldn't take more than a couple of hours

Quoted 7 lines
Quoted 2 lines

Ok, no rush, thanks for letting me know.

My additional smoktests passed as well.

Can you pick this RFT PATCH v3 as it is?
Or want a new one with all those "Tested-by" tags

I took it as-is, b4 grabbed the tested-by flags just fine.

thanks!

greg k-h