Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp290880yba; Wed, 3 Apr 2019 08:48:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeYv5XJnLDxBw1ZZdGJ2s/MjsTxP8kZk4mZDSjPbPfwn2VXz4LgAroKDw94Lke5nofM9pj X-Received: by 2002:a63:4750:: with SMTP id w16mr379307pgk.256.1554306491138; Wed, 03 Apr 2019 08:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554306491; cv=none; d=google.com; s=arc-20160816; b=NJjojl74CEZxhvWIo2UPJhrwdNRDss+goCCyVEXr0UQsEb3mDzJFWkFON+JfS1hMBg OatKPVYjXwe6u+9VS6l4gF/n2WtYW1vB6DVAkHevo1+uJKp3c9dDNTdg9HuZA7WCeBHP iyErSLf+dC1s48c8Z84yUQ7+3lIFwRA9wwEiGP1DSWCCTCxFYpRQZ1AMonvboo+8PEqW gMEXtERZLG5b8PyT2IrG3lXvpWrH2dOhy6ACwkkipsSfnxocvQyRm5rxbFpyHfOMBdF1 523fNOsyuhds+TLrCFj48DuGBBvvVbA0MSe9qkPe2Osh59SvU6py0DaitIzvYToUpdiO NaZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=1SxRNBxXqrGOtmIugPdYV1xoiQbhgHjw6Z3uheGLN0M=; b=u7C/XWl2plUZgLp5e+Ht96nY+l6iOHcW1xqToOzqj7REH0TFpCnv2GY0qVJ7b0vyp3 bVWBC1zq0hwgLQpnt+ezbentEd9p/ZIcB2wdfjAca/jUHFnSsGEsJPoq7gJvEUg4znif dLTFS7tIWauJMC5lf6CSKmhrkwu7Ll8t/wZWXYhC5ofEX2cwd+4rBIb7YMfh0Ob0rpdJ FTq5ydE6C8PGYUZI2/3I0jsfBXP0zll9OH6sfT6wCPN9sXMeM8J87eV0HrO6xtH2geKz LufbqdlIa4bHqqJnOshtp0QtjgkFZhN+7Q1Kg5GVcrbOCCwnHIGe9jpKOfD7g3OxTcVy HhHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GZhXroXS; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26si14423504pgl.21.2019.04.03.08.47.55; Wed, 03 Apr 2019 08:48:11 -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=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GZhXroXS; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726561AbfDCPrB (ORCPT + 99 others); Wed, 3 Apr 2019 11:47:01 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:50964 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCPrB (ORCPT ); Wed, 3 Apr 2019 11:47:01 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x33FksBY006711; Wed, 3 Apr 2019 10:46:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1554306414; bh=1SxRNBxXqrGOtmIugPdYV1xoiQbhgHjw6Z3uheGLN0M=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=GZhXroXSkIwGPRUd2WxD35UEHVZwcGvE61vXpMJ7O0/3T/VIjbuFO6keo+tnEj/hH +8joeF2wN4CXgaMLsYwVdf14eSbq9j41qtaMHBdMR5bo/ZnQrCwHO3oKBuadAeWrd1 X5DantRXzgdyqTAjFnbUe4uUqBVkjugaZAmNRwTU= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x33Fkskb076745 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Apr 2019 10:46:54 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 3 Apr 2019 10:46:54 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 3 Apr 2019 10:46:54 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x33FksNF023012; Wed, 3 Apr 2019 10:46:54 -0500 Date: Wed, 3 Apr 2019 10:46:54 -0500 From: Bin Liu To: Paul Cercueil CC: , , Subject: Re: [PATCH] usb: musb: Force-disable pullup on shutdown Message-ID: <20190403154654.GR25852@uda0271908> Mail-Followup-To: Bin Liu , Paul Cercueil , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, od@zcrc.me 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> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1554305491.1177.0@crapouillou.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 03, 2019 at 05:31:31PM +0200, Paul Cercueil wrote: > > > Le mer. 3 avril 2019 ? 15:26, Bin Liu 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 a ?crit : > >> >On Mon, Apr 01, 2019 at 07:46:22PM +0200, Paul Cercueil wrote: > >> >> > >> >> > >> >> Le lun. 1 avril 2019 ? 19:17, Bin Liu 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] [] (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]) > >> > >> 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? > configfs gadget is never bound, then .pullup() is never called, and when > I unbind the driver the pullup is still enabled. Regards, -Bin.