From: Paul Cercueil <paul@crapouillou.net>
To: Bin Liu <b-liu@ti.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, od@zcrc.me
Subject: usb: musb: Force-disable pullup on shutdown
Date: Wed, 03 Apr 2019 17:52:20 +0200 [thread overview]
Message-ID: <1554306740.1177.1@crapouillou.net> (raw)
Le mer. 3 avril 2019 à 17:46, Bin Liu <b-liu@ti.com> a écrit :
> On Wed, Apr 03, 2019 at 05:31:31PM +0200, Paul Cercueil wrote:
>>
>>
>> Le mer. 3 avril 2019 à 15:26, Bin Liu <b-liu@ti.com> a écrit :
>> >On Tue, Apr 02, 2019 at 09:58:42PM +0200, Paul Cercueil wrote:
>> >> Hi,
>> >>
>> >> Le lun. 1 avril 2019 à 20:20, Bin Liu <b-liu@ti.com> a écrit :
>> >> >On Mon, Apr 01, 2019 at 07:46:22PM +0200, Paul Cercueil wrote:
>> >> >>
>> >> >>
>> >> >> Le lun. 1 avril 2019 à 19:17, Bin Liu <b-liu@ti.com> a
>> écrit :
>> >> >> >On Thu, Mar 21, 2019 at 03:42:46PM +0100, Paul Cercueil
>> wrote:
>> >> >> >> When the musb is shutdown, for instance when the driver is
>> >> >>unloaded,
>> >> >> >> force-disable the pullup. Otherwise, the host will still
>> see
>> >> >> >>the gadget
>> >> >> >> device even after the shutdown.
>> >> >> >
>> >> >> >how would this happen?
>> >> >> >
>> >> >> >when musb-hdrc driver is unloaded, udc core removes the bound
>> >> >>gadget
>> >> >> >driver which calls musb_gadget_pullup() to disable the
>> pullup.
>> >> >>
>> >> >> I'm testing with the jz4740-musb driver. I don't unload the
>> >> >>module (it's
>> >> >> built-in) but unbind it from sysfs.
>> >> >
>> >> >I did unbind too.
>> >> >
>> >> >root@am335x-evm:/sys/bus/platform/drivers/musb-hdrc# echo
>> >> >musb-hdrc.0 > unbind
>> >> >
>> >> >or unbind the glue driver:
>> >> >
>> >> >root@am335x-evm:/sys/bus/platform/drivers/musb-dsps# echo
>> >> >47401400.usb > unbind
>> >> >
>> >> >musb_gadget_pullup() is called in both cases.
>> >> >
>> >> >[ 3880.597014] [<bf444ab0>] (musb_gadget_pullup [musb_hdrc])
>> from
>> >> >[<bf402cbc>] (usb_gadget_disconnect+0x3c/0xf4 [udc_core])
>> >> >[ 3880.607959] [<bf402cbc>] (usb_gadget_disconnect [udc_core])
>> >> >from [<bf403b28>] (usb_gadget_remove_driver+0x4c/0x90
>> [udc_core])
>> >> >[ 3880.619338] [<bf403b28>] (usb_gadget_remove_driver
>> [udc_core])
>> >> >from [<bf403d20>] (usb_del_gadget_udc+0x5c/0xc0 [udc_core])
>> >>
>> >> In my case this stops here, usb_del_gadget_udc() does not call
>> >> usb_gadget_remove_driver(), that's why the pullup is never
>> disabled.
>> >>
>> >> I guess that's because udc->driver is NULL; I'm testing with
>> >
>> >then the pullup should be disable by now.
>> >
>> >> CONFIG_USB_CONFIGFS,
>> >> and I don't configure anything in sysfs before unbinding the
>> driver.
>> >
>> >I didn't check on this, but I could imagine that
>> >- when a configfs gadget is bound to the udc, .pullup() is called;
>> >- when the configfs gadget is unbound from the udc, .pullup should
>> be
>> > called again to disable the pullup.
>>
>> An important thing that I did not mention, is that the SoC boots
>> from USB,
>> so the pullup is active before the musb driver loads. Since in my
>> case a
>
> It sounds to me that the musb driver should disable the pullup during
> init. Isn't it?
Yes. I can move it to musb_gadget_setup(). Should I still protect it
with
the spinlock then?
>> configfs gadget is never bound, then .pullup() is never called, and
>> when
>> I unbind the driver the pullup is still enabled.
>
> Regards,
> -Bin.
next reply other threads:[~2019-04-03 15:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 15:52 Paul Cercueil [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-04-03 18:54 usb: musb: Force-disable pullup on shutdown Bin Liu
2019-04-03 15:46 Bin Liu
2019-04-03 15:31 Paul Cercueil
2019-04-03 13:26 Bin Liu
2019-04-02 19:58 Paul Cercueil
2019-04-01 18:20 Bin Liu
2019-04-01 17:46 Paul Cercueil
2019-04-01 17:17 Bin Liu
2019-03-21 14:42 Paul Cercueil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1554306740.1177.1@crapouillou.net \
--to=paul@crapouillou.net \
--cc=b-liu@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=od@zcrc.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).