usb: dwc2: Disable all EP's on disconnect
A message that is not in the archive (sent off-list or not yet received): git-mailbomb-linux-master-dccf1bad4be7eaa096c1f3697bd37883f9a08ecb@kernel.org
Hi Minas,
Quoted 18 lines · Linux Kernel Mailing List
Commit: dccf1bad4be7eaa096c1f3697bd37883f9a08ecb Parent: 4c19cc14064d99ef0a20fb5ba0d45c94dbedb13c Refname: refs/heads/master Web: https://git.kernel.org/torvalds/c/dccf1bad4be7eaa096c1f3697bd37883f9a08ecb Author: Minas Harutyunyan <[email protected]> AuthorDate: Wed Sep 19 18:13:52 2018 +0400 Committer: Felipe Balbi <[email protected]> CommitDate: Tue Oct 2 10:33:15 2018 +0300usb: dwc2: Disable all EP's on disconnect
Disabling all EP's allow to reset EP's to initial state. On disconnect disable all EP's instead of just killing all requests. Because of some platform didn't catch disconnect event, same stuff added to
dwc2_hsotg_core_init_disconnected()function when USB reset detected on the bus.
Quoted 3 lines
Changed from version 1:
Changed lock acquire flow indwc2_hsotg_ep_disable()function.
Dan had some comments on v1, and requested to document why the locking games you're playing are safe, cfr.
https://lists.01.org/pipermail/kbuild/2018-September/002945.html
Unfortunately you didn't CC him for v2...
Quoted 12 lines
drivers/usb/dwc2/gadget.c +1
-0@@ -3993,6 +4004,7 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)unsigned long flags;u32 epctrl_reg;u32 ctrl; +int locked;dev_dbg (hsotg->dev,"%s(ep %p)\n" , __func__, ep);
drivers/usb/dwc2/gadget.c static int dwc2_hsotg_ep_disable(struct usb_ep *ep) · line 4025
Quoted 7 lines
drivers/usb/dwc2/gadget.c +3
-1@@ -4008,7 +4020,9 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) epctrl_reg = dir_in ?DIEPCTL (index) :DOEPCTL (index); -spin_lock_irqsave (&hsotg->lock, flags); + locked =spin_is_locked (&hsotg->lock); +if (!locked) +spin_lock_irqsave (&hsotg->lock, flags);
This looks really fishy to me.
What if another CPU takes the lock in between?
Can you please explain, and fix if necessary?
Thanks!
drivers/usb/dwc2/gadget.c static int dwc2_hsotg_ep_disable(struct usb_ep *ep) · line 4053
Quoted 13 lines
drivers/usb/dwc2/gadget.c +3
-1ctrl =dwc2_readl (hsotg, epctrl_reg);@@ -4032,7 +4046,9 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) hs_ep->fifo_index =0 ; hs_ep->fifo_size =0 ; -spin_unlock_irqrestore (&hsotg->lock, flags); +if (!locked) +spin_unlock_irqrestore (&hsotg->lock, flags); +return 0 ; }
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds