Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp295287yba; Wed, 3 Apr 2019 08:53:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY0rTPOTqwAh7XWc3mmEwwBNJ3SDlYVJ5KbO0J9w3Nxa8b+W2nfcYpW6GSD6Zr1T9dLqKS X-Received: by 2002:a17:902:a5ca:: with SMTP id t10mr666706plq.234.1554306814126; Wed, 03 Apr 2019 08:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554306814; cv=none; d=google.com; s=arc-20160816; b=tBW40b1Ud14BnuvZj7m6y+LRKpPLtoQx5pK9l/ruzF2sZ/HzyRiZTRwQc75d//Zp0s NF6iDfopWT2M5ITm3Z740YOAPucoj3LRwUAk/hhsiR84lflntpKbcfLieyjMe34Tw/gJ C3boTuhaPpQleG5BdZJstCvyFHPpziZ9+pdotCflItwpCY/lj3Wnue6RLs2vIxfFIrp1 02QrGMjAHAjr12bpjfnlD8TrXL4XIuzlRrCIB/C31CJ8fz/M27sCdWvfA85EO+Yh/BTz Pcv+33urK5zbE64x4VAwF6x3bSZZMF0FDVpQRCJ6hHuxTMakqTRmV6+OLL+IbpVvR99Z TSLA== 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=hCtHr8Int/M+XOTrbONnCRwTC5/kxayL/eNDSpPX30k=; b=X/hu7cLELULVCiYFhr43Jf6yUPAlVLBWLZ3Jkgg8Q4RvarYFD/7IAFkqwl9o37bVzC dRsF9EVeVfcUEwedKEDoDOFSCs0XNDjy7+m2Yuz+6VlHq0JjBKAoGpE4w0b3MPXDuMjM WJDisHiP5EY48N8ubXR1zDsMHc7DcZhQbHmW0kHCJak9VMs71sOONf4qncj6Vi/sdfMl dlYAIweE5rWbCSxLHMMZ1chByR5QDDbqASFE+op9XGMqCuQtXuxd/QOVJWRIWT5dwSJV dfpwiqp7/9KhMjTo1R+ic7oIJxvJN5Bfpdto3gwcU5E2VMqEQ2Afxv2YIVT/a+3C7FSC nuYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=BTM3kLNL; 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 a63si15089882pfb.267.2019.04.03.08.53.18; Wed, 03 Apr 2019 08:53:34 -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=BTM3kLNL; 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 S1727415AbfDCPw1 (ORCPT + 99 others); Wed, 3 Apr 2019 11:52:27 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:34260 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfDCPw0 (ORCPT ); Wed, 3 Apr 2019 11:52:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1554306744; 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=hCtHr8Int/M+XOTrbONnCRwTC5/kxayL/eNDSpPX30k=; b=BTM3kLNL280YmMRgmo/WpOVQs1mReDubNMw4sKiUkTOywFUEDXtqWvmu3k+z4K3HcvJj/q sVgQ4iTYHcPwOdGoufakSVvtNzA+5w96aSuAcaVmGOBTlErBceVsWwaBZDUSbueJ+GxK7p O4DNnbHvaM329V3wh36JNskkXOyyLvA= Date: Wed, 03 Apr 2019 17:52:20 +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: <1554306740.1177.1@crapouillou.net> In-Reply-To: <20190403154654.GR25852@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> <1554305491.1177.0@crapouillou.net> <20190403154654.GR25852@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 17:46, Bin Liu a =E9crit : > On Wed, Apr 03, 2019 at 05:31:31PM +0200, Paul Cercueil wrote: >>=20 >>=20 >> 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, >> >> >> >> 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=20 >> =E9crit : >> >> >> >On Thu, Mar 21, 2019 at 03:42:46PM +0100, Paul Cercueil=20 >> wrote: >> >> >> >> When the musb is shutdown, for instance when the driver is >> >> >>unloaded, >> >> >> >> force-disable the pullup. Otherwise, the host will still=20 >> 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=20 >> 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])=20 >> from >> >> >[] (usb_gadget_disconnect+0x3c/0xf4 [udc_core]) >> >> >[ 3880.607959] [] (usb_gadget_disconnect [udc_core]) >> >> >from [] (usb_gadget_remove_driver+0x4c/0x90=20 >> [udc_core]) >> >> >[ 3880.619338] [] (usb_gadget_remove_driver=20 >> [udc_core]) >> >> >from [] (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=20 >> 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=20 >> 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=20 >> be >> > called again to disable the pullup. >>=20 >> 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=20 >> case a >=20 > 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=20 with the spinlock then? >> configfs gadget is never bound, then .pullup() is never called, and=20 >> when >> I unbind the driver the pullup is still enabled. >=20 > Regards, > -Bin. =