Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs)

2018-03-06 Thread Bin Liu
On Mon, Mar 05, 2018 at 08:44:40PM +0100, Merlijn Wajer wrote:
> Hi Bin,
> 
> On 05/03/18 20:28, Bin Liu wrote:
> 
> > The musb udc driver sets the state to b_idle without checking a
> > gadget driver, this should be cleaned up. I have add this in my backlog.
> > But if this issue doesn't bother you much right now, I will make the
> > action low priority and address it later whenever I got time. (likely
> > not very soon, I have a hand full of musb driver bugs to fix...)
> 
> I can try to fix it this (or next) week. Do you have a pointer for me?

Quickly looking at the code, musb->xceiv->otg->state is set to OTG_STATE_B_IDLE
in musb_init_controller(), musb_gadget_setup(), musb_gadget_start(), and
musb_g_disconnect(). I am not sure if there is redundancy, and gadget
driver should be checked in some of them.

Regards,
-Bin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs)

2018-03-05 Thread Merlijn Wajer
Hi Bin,

On 05/03/18 20:28, Bin Liu wrote:

> The musb udc driver sets the state to b_idle without checking a
> gadget driver, this should be cleaned up. I have add this in my backlog.
> But if this issue doesn't bother you much right now, I will make the
> action low priority and address it later whenever I got time. (likely
> not very soon, I have a hand full of musb driver bugs to fix...)

I can try to fix it this (or next) week. Do you have a pointer for me?

Cheers,
Merlijn



signature.asc
Description: OpenPGP digital signature


Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs)

2018-03-05 Thread Bin Liu
Merlijn,

On Fri, Mar 02, 2018 at 05:54:39PM +0100, Pali Rohár wrote:
> On Friday 02 March 2018 17:47:52 Merlijn Wajer wrote:
> > >> I would expect it to state "b_idle" instead of "(null)".
> > > 
> > > Actually, I'd like to see (null) whenever a gadget driver is not loaded,
> > > which indicates a gadget is not bound to the udc.
> > 
> > Hm... Sounds fine to me. I'm using this mode in combination with the usb
> > phy (vbus property) to detect if the phone is detect to a 'dumb' charger
> > of a PC, but I can just always have a gadget loaded -- same as before,
> > really.
> 
> For detection if wallcharger or pc usb charger is connected, there is
> isp1704_charger driver. It uses some standard ULPI interface. It reports
> current_max and type (DCP - dedicated, CDP or just usb).

The musb udc driver sets the state to b_idle without checking a
gadget driver, this should be cleaned up. I have add this in my backlog.
But if this issue doesn't bother you much right now, I will make the
action low priority and address it later whenever I got time. (likely
not very soon, I have a hand full of musb driver bugs to fix...)

Regards,
-Bin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs)

2018-03-02 Thread Pali Rohár
On Friday 02 March 2018 17:47:52 Merlijn Wajer wrote:
> >> I would expect it to state "b_idle" instead of "(null)".
> > 
> > Actually, I'd like to see (null) whenever a gadget driver is not loaded,
> > which indicates a gadget is not bound to the udc.
> 
> Hm... Sounds fine to me. I'm using this mode in combination with the usb
> phy (vbus property) to detect if the phone is detect to a 'dumb' charger
> of a PC, but I can just always have a gadget loaded -- same as before,
> really.

For detection if wallcharger or pc usb charger is connected, there is
isp1704_charger driver. It uses some standard ULPI interface. It reports
current_max and type (DCP - dedicated, CDP or just usb).

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: PGP signature


Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs)

2018-03-02 Thread Merlijn Wajer
Hi,

On 02/03/18 16:27, Bin Liu wrote:
> Hi,
> 
> On Fri, Mar 02, 2018 at 12:47:07AM +0100, Merlijn Wajer wrote:
>> Hi,
>>
>> I found that the "mode" file in musb sys node will return "(null)" when
>> one would expect it show b_idle.
>>
>> Wrong /mode file:
>>
>> [Fresh boot, cable not connected yet]
>> root@n900devuan:~# modprobe g_nokia
>> [Insert cable connected to PC]
>> root@n900devuan:~# cat
>> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
>> b_peripheral
>> [Remove cable connected to PC]
>> root@n900devuan:~# cat
>> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
>> b_idle
>> root@n900devuan:~# rmmod g_nokia
>> root@n900devuan:~# cat
>> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
>> (null)
> 
> I can reproduce this on AM335x EVM,

>> [Insert cable connected to PC]
>> root@n900devuan:~# cat
>> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
>> b_idle
> 
> but not this, I still get (null). g_nokia is not loaded here, right?

I don't think so:

# cat
/sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
b_peripheral
[unplug]
# cat
/sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
b_idle
# rmmod g_nokia
# lsmod|grep nokia
nokia_modem16384  0
ssi_protocol   20480  2 nokia_modem,cmt_speech
hsi20480  5
hsi_char,omap_ssi,nokia_modem,cmt_speech,ssi_protocol
# cat
/sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
(null)

... libcomposite is loaded, but nothing is in configfs (apart from the
empty usb_gadget):

root@n900devuan:~# zgrep COMPOSITE /proc/config.gz
# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
CONFIG_USB_LIBCOMPOSITE=m
CONFIG_USB_CDC_COMPOSITE=m
root@n900devuan:~# ls /sys/kernel/config/
usb_gadget
root@n900devuan:~# ls /sys/kernel/config/usb_gadget/

Do you have USB_LIBCOMPOSITE and USB_CONFIGFS enabled as module?

I tried to unload libcomposite and the usb_f_* modules:

# rmmod libcomposite
rmmod: ERROR: Module libcomposite is in use by: usb_f_ecm usb_f_phonet
usb_f_acm usb_f_mass_storage usb_f_obex
# rmmod usb_f_ecm usb_f_phonet usb_f_acm usb_f_mass_storage usb_f_obex
# rmmod libcomposite
# lsmod|grep libcom

Yet it now states this: (No change made in cable, was disconnected)

# cat
/sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
b_peripheral

And the mode doesn't change any more, even when I connect the cable.

Then, when I probe libcomposite and g_nokia again (in this order) the
mode changes to b_idle, with the cable plugged in. It doesn't change
when I plug the phone in again. When I remove g_nokia again, remove the
cable, modprobe it again, and connect the cable, it seems to work again
as expected and I can see some gadget.

I do not see any errors messages from the kernel.

Finally, when I issued 'rmmod g_nokia', the device hung and rebooted again.

>> I would expect it to state "b_idle" instead of "(null)".
> 
> Actually, I'd like to see (null) whenever a gadget driver is not loaded,
> which indicates a gadget is not bound to the udc.

Hm... Sounds fine to me. I'm using this mode in combination with the usb
phy (vbus property) to detect if the phone is detect to a 'dumb' charger
of a PC, but I can just always have a gadget loaded -- same as before,
really.

Cheers,
Merlijn



signature.asc
Description: OpenPGP digital signature


Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs)

2018-03-02 Thread Bin Liu
Hi,

On Fri, Mar 02, 2018 at 12:47:07AM +0100, Merlijn Wajer wrote:
> Hi,
> 
> I found that the "mode" file in musb sys node will return "(null)" when
> one would expect it show b_idle.
> 
> Wrong /mode file:
> 
> [Fresh boot, cable not connected yet]
> root@n900devuan:~# modprobe g_nokia
> [Insert cable connected to PC]
> root@n900devuan:~# cat
> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
> b_peripheral
> [Remove cable connected to PC]
> root@n900devuan:~# cat
> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
> b_idle
> root@n900devuan:~# rmmod g_nokia
> root@n900devuan:~# cat
> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
> (null)

I can reproduce this on AM335x EVM,

> [Insert cable connected to PC]
> root@n900devuan:~# cat
> /sys/devices/platform/6800.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/mode
> b_idle

but not this, I still get (null). g_nokia is not loaded here, right?

> 
> I would expect it to state "b_idle" instead of "(null)".

Actually, I'd like to see (null) whenever a gadget driver is not loaded,
which indicates a gadget is not bound to the udc.

Regards,
-Bin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html