Received: by 10.223.185.116 with SMTP id b49csp179360wrg; Fri, 2 Mar 2018 16:22:24 -0800 (PST) X-Google-Smtp-Source: AG47ELuahoY44dh89Vz6J9C91tdumIQvFnHhWp34tP09HBP2E8GEy1n4NnUs0hYyWuAjGgYwKVjs X-Received: by 10.101.98.17 with SMTP id d17mr5944871pgv.221.1520036544025; Fri, 02 Mar 2018 16:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520036543; cv=none; d=google.com; s=arc-20160816; b=HGkuWOpj9+XgliR6O86c+koECN9dey41KAWY8Lw/swPzTPrBIVmdT7Rcf2NaWmwQdl TaNvZZTsFlQFJxSOIFHf7JnUjk9UofhiV+dOhKtcAKZlSsmQcJR6iaGam1HeOU7r76kR 1pno3GF7yxwual9V0LGzTfS/xPY1GPTK7nIaXLrf1xNxhUga008ucNt3uSNiggwHwGW1 0sigusVcaFZloq1yB69y3WhJalca9793JkvbijRn1SB6ZgpVJsagrxeSVrE/ZSgb8f2i SDV+kpSlNv3WJTNH+zoOhqXZ9Ro5Yl52K6qOgEMvplEQ4sb7LvAe+zcAI4FuQbHBdP36 C53w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=8myOV1wom6nrpmrZQwxm+ernWpxs9e0PRgk+Hvbuz1Q=; b=ovYSHhgPyKtgb3hAuFZQL7alpmFWK38BfDqx7qRDffJSCaCzTQDNzv5rAX7QtfnBD4 UF2CgZ0J3QG/zc0+rCFd9kWPn/T1V/Srl51LKLwTAb8MJHGxnMZzyN7gGPKz2NC3O3OO baERSc7Ohxr6h55r0TT7xulyjNdA01sUOL08/6k7nWNYfTaRx/1jsP16Ocev74mPIKfe KgMT4GgZphpxzGwI0xY92IjAq7GzEcfdrUqHGzcH0fQkaMXgJx3QkDqfym02dTvGeB/S fWDlXFuaSLVeHEqV36n5x8JI2sYiAlEbrzXKLobyWSiZiLPxPHdeFI8RcGGhSbghbMUw HQLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69si5693995pfv.15.2018.03.02.16.22.09; Fri, 02 Mar 2018 16:22:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967942AbeCBQs1 (ORCPT + 99 others); Fri, 2 Mar 2018 11:48:27 -0500 Received: from nala.villavu.com ([188.165.243.101]:54489 "EHLO nala.villavu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934637AbeCBQsG (ORCPT ); Fri, 2 Mar 2018 11:48:06 -0500 Received: from a82-161-36-93.adsl.xs4all.nl ([82.161.36.93] helo=[0.0.0.0]) by nala.villavu.com with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.85) (envelope-from ) id 1ernql-0007aL-PW; Fri, 02 Mar 2018 17:48:03 +0100 Subject: Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs) To: Bin Liu , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Pali_Roh=c3=a1r?= , Ivaylo Dimitrov , linux-omap@vger.kernel.org References: <20180302152712.GA22262@uda0271908> From: Merlijn Wajer Message-ID: Date: Fri, 2 Mar 2018 17:47:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux armv7l; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180302152712.GA22262@uda0271908> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="czKtVf7VtiN2ETNudbl7RgFrMq5PxKP82" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --czKtVf7VtiN2ETNudbl7RgFrMq5PxKP82 Content-Type: multipart/mixed; boundary="YGYerZQA0vuWlSrKlrrQiatlbXLjkm5y5"; protected-headers="v1" From: Merlijn Wajer To: Bin Liu , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Pali_Roh=c3=a1r?= , Ivaylo Dimitrov , linux-omap@vger.kernel.org Message-ID: Subject: Re: usb: musb: "(null)" in sysfs mode file after disabling a gadget (and at other times, system hangs) References: <20180302152712.GA22262@uda0271908> In-Reply-To: <20180302152712.GA22262@uda0271908> --YGYerZQA0vuWlSrKlrrQiatlbXLjkm5y5 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable Hi, On 02/03/18 16:27, Bin Liu wrote: > Hi, >=20 > 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)" whe= n >> 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/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.aut= o/mode >> b_peripheral >> [Remove cable connected to PC] >> root@n900devuan:~# cat >> /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.aut= o/mode >> b_idle >> root@n900devuan:~# rmmod g_nokia >> root@n900devuan:~# cat >> /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.aut= o/mode >> (null) >=20 > I can reproduce this on AM335x EVM, >> [Insert cable connected to PC] >> root@n900devuan:~# cat >> /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.aut= o/mode >> b_idle >=20 > but not this, I still get (null). g_nokia is not loaded here, right? I don't think so: # cat /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/m= ode b_peripheral [unplug] # cat /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/m= ode b_idle # rmmod g_nokia # lsmod|grep nokia nokia_modem 16384 0 ssi_protocol 20480 2 nokia_modem,cmt_speech hsi 20480 5 hsi_char,omap_ssi,nokia_modem,cmt_speech,ssi_protocol # cat /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/m= ode (null) =2E.. 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=3Dm CONFIG_USB_CDC_COMPOSITE=3Dm 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/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/m= ode 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 agai= n. >> I would expect it to state "b_idle" instead of "(null)". >=20 > 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 --YGYerZQA0vuWlSrKlrrQiatlbXLjkm5y5-- --czKtVf7VtiN2ETNudbl7RgFrMq5PxKP82 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRM5LT7NbLF9yb6a/UGN09rynK8WgUCWpmAOQAKCRAGN09rynK8 WkrgAQDim6zwWYPYPTLgIBKGprQMAnsf4ja6Yu6bbka+gSg4rwEA7ns7Kpg2CBXf AeMU+QQWGtOT8tXiwNxXQMuMrhql4QU= =9VU0 -----END PGP SIGNATURE----- --czKtVf7VtiN2ETNudbl7RgFrMq5PxKP82--