Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp276283yba; Wed, 3 Apr 2019 08:32:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyD6OcOxqwb8hN3vUFV9aJSYXotG5IXvz6hOviWvv/nw2UfLUlgQuhCbOQfDmE6TA2WnbVR X-Received: by 2002:a62:571b:: with SMTP id l27mr48342692pfb.195.1554305552342; Wed, 03 Apr 2019 08:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554305552; cv=none; d=google.com; s=arc-20160816; b=ohh2wQMnHJpeYm1QmBsXc9hvqFElvvptnUnmnkc0XUWWmoTTpOKm4m3m3K4WuimCcc 1poPKtui1b1IkzG4Pqui/IS0FvdNWOTvmyLYra/9JEVQ3ZgaDgVgLzVZUsyEZP9xnDm+ aEbCwvwlQg0MsCDMmO8R81O0wl0pEhPuEzO3MvBl+sqzGzFcOtRFOzyoRbP0JM9GTO7R m9jss18ca8n+mgyJ40lErQSROVPYYT10Mrot52f4jDIE71k3sQq2OB2iHFeiQoUUxQ+r 2/Ar6QPCEwIfkexuadOjaSnjxIVEI52QybT6lzEr97GporZgbk8c3EqUWXAnA2RG2/Y3 E7eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date :dkim-signature; bh=28XImi+Bp9I9pF6FT2i90FcrcKEdvt/D5NO3ZjWScyA=; b=tK3V2i9EdTBd+6ZjwsD/doLIdLtqAkRbLtwvjQWxzt3UCxEomRQnVsKLp16yPw4aSI Qps4rcZqs+6P08Kx8jRhHE/jlfQscjzA9msieH2km/wxvswinYzNCAJmyiTeO2vX9XON uGhyp7CFJkqT/3HBvZeZSV6cy59JqFCvRREiGYx1OyXa36gTU1F8yakUq5H5BHJfqssA 7mIg+b+9nyge9v0RK69fulg6FYdwD8em/y5JGewAXHuc1UnwLCgCjUJahnzrH+ue2NRP BD7m8BSKJp8U8Pdmc1gjboUK/MLcexBqLXWeSjG0huqd3ak/le/On/x6DsMs30maTsmH YAAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=MqDEGB9S; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g30si14459480plg.102.2019.04.03.08.32.16; Wed, 03 Apr 2019 08:32:32 -0700 (PDT) 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; dkim=fail header.i=@crapouillou.net header.s=mail header.b=MqDEGB9S; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbfDCPbk (ORCPT + 99 others); Wed, 3 Apr 2019 11:31:40 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:43772 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCPbk (ORCPT ); Wed, 3 Apr 2019 11:31:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1554305496; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=28XImi+Bp9I9pF6FT2i90FcrcKEdvt/D5NO3ZjWScyA=; b=MqDEGB9SnrGrgSJrtyYZeKnct1xJ519myFX5BqxUbKAZTroXbV2+07Q4Eye0TwcIXiszS3 NiYW0pvdiAouEh2xSNwwhhfcjag0jH5P9HG2vs4hwKT0ueb+/cjQJj3bMvB1oXLwcB+oy/ X+t6ksyeryauUWCLY1uGYd6H98rzeQ4= Date: Wed, 03 Apr 2019 17:31:31 +0200 From: Paul Cercueil Subject: Re: [PATCH] usb: musb: Force-disable pullup on shutdown To: Bin Liu Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, od@zcrc.me Message-Id: <1554305491.1177.0@crapouillou.net> In-Reply-To: <20190403132600.GQ25852@uda0271908> References: <20190321144246.3547-1-paul@crapouillou.net> <20190401171725.GK25852@uda0271908> <1554140782.10471.0@crapouillou.net> <20190401182008.GL25852@uda0271908> <1554235122.13181.0@crapouillou.net> <20190403132600.GQ25852@uda0271908> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le mer. 3 avril 2019 =E0 15:26, Bin Liu a =E9crit : > On Tue, Apr 02, 2019 at 09:58:42PM +0200, Paul Cercueil wrote: >> Hi, >>=20 >> Le lun. 1 avril 2019 =E0 20:20, Bin Liu a =E9crit : >> >On Mon, Apr 01, 2019 at 07:46:22PM +0200, Paul Cercueil wrote: >> >> >> >> >> >> Le lun. 1 avril 2019 =E0 19:17, Bin Liu a =E9crit : >> >> >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] [] (musb_gadget_pullup [musb_hdrc]) from >> >[] (usb_gadget_disconnect+0x3c/0xf4 [udc_core]) >> >[ 3880.607959] [] (usb_gadget_disconnect [udc_core]) >> >from [] (usb_gadget_remove_driver+0x4c/0x90 [udc_core]) >> >[ 3880.619338] [] (usb_gadget_remove_driver [udc_core]) >> >from [] (usb_del_gadget_udc+0x5c/0xc0 [udc_core]) >>=20 >> 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. >>=20 >> I guess that's because udc->driver is NULL; I'm testing with >=20 > then the pullup should be disable by now. >=20 >> CONFIG_USB_CONFIGFS, >> and I don't configure anything in sysfs before unbinding the driver. >=20 > 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=20 USB, so the pullup is active before the musb driver loads. Since in my case a configfs gadget is never bound, then .pullup() is never called, and when I unbind the driver the pullup is still enabled. -Paul =