usb: musb: fix MUSB_QUIRK_B_DISCONNECT_99 handling
Subsystems (3)
PATCH 1/1 usb: musb: fix MUSB_QUIRK_B_DISCONNECT_99 handling
In commit 92af4fc6ec33 ("usb: musb: Fix suspend with devices connected for a64"), the logic to support the MUSB_QUIRK_B_DISCONNECT_99 quirk was modified to only conditionally schedule the musb->irq_work delayed work.
This commit badly breaks ECM Gadget on AM335X. Indeed, with this commit, one can observe massive packet loss:
$ ping 192.168.0.100 ... 15 packets transmitted, 3 received, 80% packet loss, time 14316ms
Reverting this commit brings back a properly functioning ECM Gadget. An analysis of the commit seems to indicate that a mistake was
made: the previous code was not falling through into the MUSB_QUIRK_B_INVALID_VBUS_91, but now it is, unless the condition is taken.
Changing the logic to be as it was before the problematic commit *and* only conditionally scheduling musb->irq_work resolves the regression:
$ ping 192.168.0.100 ... 64 packets transmitted, 64 received, 0% packet loss, time 64475ms
--- drivers/usb/musb/musb_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/musb/musb_core.c +1 -2
@@ -2009,9 +2009,8 @@ static void musb_pm_runtime_check_session(struct musb *musb)schedule_delayed_work (&musb->irq_work,msecs_to_jiffies (1000 )); musb->quirk_retries--; -break ; } - fallthrough; +break ;case MUSB_QUIRK_B_INVALID_VBUS_91 :if (musb->quirk_retries && !musb->flush_irq_work) { musb_dbg(musb,
Signature · 1 line
2.31.1
Quoted 21 lines · Thomas Petazzoni
In commit
92af4fc6ec33("usb: musb: Fix suspend with devices connected for a64"), the logic to support theMUSB_QUIRK_B_DISCONNECT_99quirk was modified to only conditionally schedule themusb->irq_workdelayed work.This commit badly breaks ECM Gadget on AM335X. Indeed, with this commit, one can observe massive packet loss:
$ ping 192.168.0.100 ... 15 packets transmitted, 3 received, 80% packet loss, time 14316msReverting this commit brings back a properly functioning ECM Gadget. An analysis of the commit seems to indicate that a mistake was
made: the previous code was not falling through into theMUSB_QUIRK_B_INVALID_VBUS_91, but now it is, unless the condition is taken.Changing the logic to be as it was before the problematic commit *and* only conditionally scheduling
musb->irq_workresolves the regression:
Quoted 6 lines
$ ping 192.168.0.100 ... 64 packets transmitted, 64 received, 0% packet loss, time 64475msFixes 92af4fc6ec33 ("usb: musb: Fix suspend with devices connected for a64")Signed-off-by Thomas Petazzoni <[email protected]>
Quoted 23 lines
--- drivers/usb/musb/musb_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/usb/musb/musb_core.c +1
-2@@ -2009,9 +2009,8 @@ static void musb_pm_runtime_check_session(struct musb *musb)schedule_delayed_work (&musb->irq_work,msecs_to_jiffies (1000 )); musb->quirk_retries--; -break ; } - fallthrough; +break ;case MUSB_QUIRK_B_INVALID_VBUS_91 :if (musb->quirk_retries && !musb->flush_irq_work) { musb_dbg(musb,Signature · 1 line
2.31.1
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Tony Lindgren
Acked-byQuoted 22 lines · Alexandre Belloni
Quoted 21 lines · Thomas Petazzoni
In commit
92af4fc6ec33("usb: musb: Fix suspend with devices connected for a64"), the logic to support theMUSB_QUIRK_B_DISCONNECT_99quirk was modified to only conditionally schedule themusb->irq_workdelayed work.This commit badly breaks ECM Gadget on AM335X. Indeed, with this commit, one can observe massive packet loss:
$ ping 192.168.0.100 ... 15 packets transmitted, 3 received, 80% packet loss, time 14316msReverting this commit brings back a properly functioning ECM Gadget. An analysis of the commit seems to indicate that a mistake was
made: the previous code was not falling through into theMUSB_QUIRK_B_INVALID_VBUS_91, but now it is, unless the condition is taken.Changing the logic to be as it was before the problematic commit *and* only conditionally scheduling
musb->irq_workresolves the regression:
Quoted 7 lines
Quoted 6 lines
$ ping 192.168.0.100 ... 64 packets transmitted, 64 received, 0% packet loss, time 64475msFixes 92af4fc6ec33 ("usb: musb: Fix suspend with devices connected for a64")Signed-off-by Thomas Petazzoni <[email protected]>Tested-by Alexandre Belloni <[email protected]>
Ouch, sorry about that one. And thanks for fixing it:
Quoted 49 lines · Thomas Petazzoni
In commit
92af4fc6ec33("usb: musb: Fix suspend with devices connected for a64"), the logic to support theMUSB_QUIRK_B_DISCONNECT_99quirk was modified to only conditionally schedule themusb->irq_workdelayed work.This commit badly breaks ECM Gadget on AM335X. Indeed, with this commit, one can observe massive packet loss:
$ ping 192.168.0.100 ... 15 packets transmitted, 3 received, 80% packet loss, time 14316msReverting this commit brings back a properly functioning ECM Gadget. An analysis of the commit seems to indicate that a mistake was
made: the previous code was not falling through into theMUSB_QUIRK_B_INVALID_VBUS_91, but now it is, unless the condition is taken.Changing the logic to be as it was before the problematic commit *and* only conditionally scheduling
musb->irq_workresolves the regression:$ ping 192.168.0.100 ... 64 packets transmitted, 64 received, 0% packet loss, time 64475msFixes 92af4fc6ec33 ("usb: musb: Fix suspend with devices connected for a64")Signed-off-by Thomas Petazzoni <[email protected]>--- drivers/usb/musb/musb_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/usb/musb/musb_core.c +1
-2@@ -2009,9 +2009,8 @@ static void musb_pm_runtime_check_session(struct musb *musb)schedule_delayed_work (&musb->irq_work,msecs_to_jiffies (1000 )); musb->quirk_retries--; -break ; } - fallthrough; +break ;case MUSB_QUIRK_B_INVALID_VBUS_91 :if (musb->quirk_retries && !musb->flush_irq_work) { musb_dbg(musb,Signature · 1 line
2.31.1
This patches fixes the problem on the BeagleBone Black (AM3358) where the USB gadget interfaces would frequently reset. For example:
configfs-gadget gadget: init rndis
configfs-gadget gadget: RNDIS RX/TX early activation ...
usb0: qlen 10
configfs-gadget gadget: rndis_open
rndis_set_param_medium: 0 4259840
usb0: eth_start
rndis_set_param_dev:
configfs-gadget gadget: set_config: interface 2 (Mass Storage Function) requested delayed status configfs-gadget gadget: delayed_status count 1
configfs-gadget gadget: reset ncm control 3
configfs-gadget gadget: init ncm ctrl 3
configfs-gadget gadget: notify speed 425984000
configfs-gadget gadget: reset acm ttyGS0
configfs-gadget gadget: activate acm ttyGS0
configfs-gadget gadget: acm ttyGS0 serial state 0000
configfs-gadget gadget: usb_composite_setup_continue
configfs-gadget gadget: usb_composite_setup_continue: Completing delayed status configfs-gadget gadget: rndis req21.00 v0000 i0000 l24
rndis_msg_parser: RNDIS_MSG_INIT
configfs-gadget gadget: rndis reqa1.01 v0000 i0000 l1025
configfs-gadget gadget: rndis req21.00 v0000 i0000 l32
gen_ndis_query_resp: RNDIS_OID_GEN_PHYSICAL_MEDIUM
configfs-gadget gadget: rndis reqa1.01 v0000 i0000 l1025
configfs-gadget gadget: rndis req21.00 v0000 i0000 l76
gen_ndis_query_resp: RNDIS_OID_802_3_PERMANENT_ADDRESS
configfs-gadget gadget: rndis reqa1.01 v0000 i0000 l1025
configfs-gadget gadget: rndis req21.00 v0000 i0000 l32
gen_ndis_set_resp: RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0000002d
configfs-gadget gadget: rndis reqa1.01 v0000 i0000 l1025
configfs-gadget gadget: init ncm
configfs-gadget gadget: activate ncm
usb1: qlen 10
configfs-gadget gadget: ncm_open
usb1: eth_start
configfs-gadget gadget: reset ncm
usb1: gether_disconnect
configfs-gadget gadget: ncm reqa1.80 v0000 i0003 l28
configfs-gadget gadget: non-CRC mode selected
configfs-gadget gadget: ncm req21.8a v0000 i0003 l0
configfs-gadget gadget: NCM16 selected
configfs-gadget gadget: ncm req21.84 v0000 i0003 l0
configfs-gadget gadget: init ncm
configfs-gadget gadget: activate ncm
usb1: qlen 10
configfs-gadget gadget: ncm_open
usb1: eth_start
configfs-gadget gadget: acm ttyGS0 req21.20 v0000 i0005 l7
configfs-gadget gadget: notify speed 425984000
configfs-gadget gadget: notify connect true
I have posted dmesg log without the patch [1] where this happens often and the dmesg log with the patch [2] where it does happen at all.
Thank you for fixing this!
Drew
[1] https://gist.github.com/pdp7/bd61e5f78545de182605992254d3eeee
[2] https://gist.github.com/pdp7/95b0f34fa1d423d4764984b400c562cf