usb: cdc-wdm: fix reading stuck on device close
Subsystems (3)
PATCH 1/1 usb: cdc-wdm: fix reading stuck on device close
cdc-wdm tracks whether a response reading request is in-progress and blocks the next request from being sent until the previous request is completed. As soon as last user closes the cdc-wdm device file, the driver cancels any ongoing requests, resets the pending response counter, but leaves the response reading in-progress flag (WDM_RESPONDING) untouched.
So if the user closes the device file during the response receive request is being performed, no more data will be obtained from the modem. The request will be cancelled, effectively preventing the WDM_RESPONDING flag from being reseted. Keeping the flag set will prevent a new response receive request from being sent, permanently blocking the read path. The read path will staying blocked until the module will be reloaded or till the modem will be re-attached.
This stuck has been observed with a Huawei E3372 modem attached to an OpenWrt router and using the comgt utility to set up a network connection.
Fix this issue by clearing the WDM_RESPONDING flag on the device file close.
Without this fix, the device reading stuck can be easily reproduced in a few connection establishing attempts. With this fix, a load test for modem connection re-establishing worked for several hours without any issues.
reading from the device")
---
Technically, cdc-wdm belongs to the USB subsystem even though it serves WWAN devices. I think this fix should be applied (backported) to LTS versions too. So I targeted it to the 'net' tree, but send it to both lists to get a feedback. Greg, Jakub, what is the best tree for this fix?
--- drivers/usb/class/cdc-wdm.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/class/cdc-wdm.c +1 -0
@@ -774,6 +774,7 @@ static int wdm_release(struct inode *inode, struct file *file)poison_urbs (desc);spin_lock_irq (&desc->iuspin); desc->resp_count =0 ; +clear_bit (WDM_RESPONDING , &desc->flags);spin_unlock_irq (&desc->iuspin); desc->manage_power (desc->intf,0 );unpoison_urbs (desc);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerQuoted 22 lines · Sergey Ryazanov
cdc-wdm tracks whether a response reading request is in-progress and blocks the next request from being sent until the previous request is completed. As soon as last user closes the cdc-wdm device file, the driver cancels any ongoing requests, resets the pending response counter, but leaves the response reading in-progress flag (
WDM_RESPONDING) untouched.So if the user closes the device file during the response receive request is being performed, no more data will be obtained from the modem. The request will be cancelled, effectively preventing the
WDM_RESPONDINGflag from being reseted. Keeping the flag set will prevent a new response receive request from being sent, permanently blocking the read path. The read path will staying blocked until the module will be reloaded or till the modem will be re-attached.This stuck has been observed with a Huawei E3372 modem attached to an OpenWrt router and using the comgt utility to set up a network connection.
Fix this issue by clearing the
WDM_RESPONDINGflag on the device file close.
Quoted 7 lines
Without this fix, the device reading stuck can be easily reproduced in a few connection establishing attempts. With this fix, a load test for modem connection re-establishing worked for several hours without any issues.
Fixes 922a5eadd5a3 ("usb: cdc-wdm: Fix race between autosuspend andreading from the device")
Nit, Fixes: lines should only be one line, I'll fix this up when applying it.
Quoted 9 lines
Signed-off-by Sergey Ryazanov <[email protected]>---
Technically, cdc-wdm belongs to the USB subsystem even though it serves WWAN devices. I think this fix should be applied (backported) to LTS versions too. So I targeted it to the 'net' tree, but send it to both lists to get a feedback. Greg, Jakub, what is the best tree for this fix?
Quoted 3 lines
--- drivers/usb/class/cdc-wdm.c | 1 + 1 file changed, 1 insertion(+)
scripts/get_maintainer.pl is pretty clear this goes through the USB tree. I'll queue it up in a few days, thanks,
greg k-h
Quoted 28 lines · Greg Kroah-Hartman
Quoted 27 lines · Sergey Ryazanov
cdc-wdm tracks whether a response reading request is in-progress and blocks the next request from being sent until the previous request is completed. As soon as last user closes the cdc-wdm device file, the driver cancels any ongoing requests, resets the pending response counter, but leaves the response reading in-progress flag (
WDM_RESPONDING) untouched.So if the user closes the device file during the response receive request is being performed, no more data will be obtained from the modem. The request will be cancelled, effectively preventing the
WDM_RESPONDINGflag from being reseted. Keeping the flag set will prevent a new response receive request from being sent, permanently blocking the read path. The read path will staying blocked until the module will be reloaded or till the modem will be re-attached.This stuck has been observed with a Huawei E3372 modem attached to an OpenWrt router and using the comgt utility to set up a network connection.
Fix this issue by clearing the
WDM_RESPONDINGflag on the device file close.Without this fix, the device reading stuck can be easily reproduced in a few connection establishing attempts. With this fix, a load test for modem connection re-establishing worked for several hours without any issues.
Quoted 5 lines
Quoted 2 lines
Fixes 922a5eadd5a3 ("usb: cdc-wdm: Fix race between autosuspend andreading from the device")
Nit, Fixes: lines should only be one line, I'll fix this up when applying it.
Ouch. Sorry.
Quoted 9 lines
Quoted 9 lines
Signed-off-by Sergey Ryazanov <[email protected]>---
Technically, cdc-wdm belongs to the USB subsystem even though it serves WWAN devices. I think this fix should be applied (backported) to LTS versions too. So I targeted it to the 'net' tree, but send it to both lists to get a feedback. Greg, Jakub, what is the best tree for this fix?
Quoted 6 lines
Quoted 3 lines
--- drivers/usb/class/cdc-wdm.c | 1 + 1 file changed, 1 insertion(+)
scripts/get_maintainer.plis pretty clear this goes through the USB tree. I'll queue it up in a few days, thanks,
Thank you for your clarification, will keep in mind.
Signature · 1 line
Sergey
Quoted 22 lines · Sergey Ryazanov
cdc-wdm tracks whether a response reading request is in-progress and blocks the next request from being sent until the previous request is completed. As soon as last user closes the cdc-wdm device file, the driver cancels any ongoing requests, resets the pending response counter, but leaves the response reading in-progress flag (
WDM_RESPONDING) untouched.So if the user closes the device file during the response receive request is being performed, no more data will be obtained from the modem. The request will be cancelled, effectively preventing the
WDM_RESPONDINGflag from being reseted. Keeping the flag set will prevent a new response receive request from being sent, permanently blocking the read path. The read path will staying blocked until the module will be reloaded or till the modem will be re-attached.This stuck has been observed with a Huawei E3372 modem attached to an OpenWrt router and using the comgt utility to set up a network connection.
Fix this issue by clearing the
WDM_RESPONDINGflag on the device file close.
Quoted 9 lines
Without this fix, the device reading stuck can be easily reproduced in a few connection establishing attempts. With this fix, a load test for modem connection re-establishing worked for several hours without any issues.
Fixes 922a5eadd5a3 ("usb: cdc-wdm: Fix race between autosuspend andreading from the device")
Signed-off-by Sergey Ryazanov <[email protected]>