Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp449405yba; Wed, 3 Apr 2019 11:55:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7TBtCa/gQ/mU1wNB+s4gtVdfmblpNHmE1kXFoP8K+T9b4FyRYg0kPtZzunMq6KE7hDVh+ X-Received: by 2002:a63:41c4:: with SMTP id o187mr1296210pga.73.1554317732294; Wed, 03 Apr 2019 11:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554317732; cv=none; d=google.com; s=arc-20160816; b=mXo8DpBAHkZaXeWBEOcOqL3ie3H+Dr2j6uEnkdyx7SD+QflDGeVjgtArwlnk0EiaLr lA1+U09Vp82vlre942OAZg9AmPZllbAJ3jVNV9dDBaMJS6qmcSjjI3vtgF25VnafdC82 9eo4jdHfDMBI2gWifvHqKNHnlDHOqnP3u6yY13Q/lTLdRge5vJLu0+7bWFjRm2JF9WMB P/MhlOBiR/Pj+VC9XYNxU+1CwwOUv44nEdSYd8KEuMSle0DpG/+k6mZr4FzyfOQPgNl6 AgrY939zxz5TXBOOt3e6eXqktVjhugaTkzZxnSKmwikcSBYxkfc3YDf2huXwVHKI0MFm YprQ== 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=8ja4jQk473PWfS3bvTNVH8/cLMGVdPkw04qDoaKXOlA=; b=WVxk2biGAb2Rym20xryEIzCSHYr3a/WJlnT1g4l5Xqh/RC4IPZFueZFWxLOlxtar/c xFuJgMNtPaGa/5YLq429aJdi2xfZ2Nw/MhKL7IxHMv+fIK4qwfS3VStm09iBmPr+5jP/ BhRsyYJNu7yoHsyFw8ooVQSnqpOPlssfdTeRHIP4Tci9Lul6dorr/PoMLHIonDE2oO5i JEXvMMSHiQ2kTig/7zQxzjBmcm8xmBlKWXjCr9GJb4wS7IGGSD4Um94qkoM1u7bKh4+F w67oDUqAYAnBFJTlJrxYZ0P3C9NpOQhYRIF7AfznyHEIKBkaeGysI+IGAhjtpxLNqv8L EO7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bVYVxQgC; 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 n9si14506974pfi.193.2019.04.03.11.55.17; Wed, 03 Apr 2019 11:55: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=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bVYVxQgC; 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 S1726510AbfDCSya (ORCPT + 99 others); Wed, 3 Apr 2019 14:54:30 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:37780 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbfDCSya (ORCPT ); Wed, 3 Apr 2019 14:54:30 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x33IsNbQ087492; Wed, 3 Apr 2019 13:54:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1554317664; bh=8ja4jQk473PWfS3bvTNVH8/cLMGVdPkw04qDoaKXOlA=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=bVYVxQgCb5k7nXga1ivUWdmQyredobK0JqvUjPEOWu48xR2Mt0TsiLcH2HK4wYRln pvOU4XnNwsoRUeSK4Yyv5vQNOGXFGO3Ih+K/bi92Z1K4ZEaUbrgqsOAjKb6QfK8r6S 8kfUZxTl+u+YOjRi727o9Q+LORn04yDNorRpgAaU= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x33IsN3a075306 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Apr 2019 13:54:24 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE102.ent.ti.com (157.170.170.32) 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 13:54:23 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE109.ent.ti.com (157.170.170.41) 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 13:54:23 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x33IsNV6060964; Wed, 3 Apr 2019 13:54:23 -0500 Date: Wed, 3 Apr 2019 13:54:23 -0500 From: Bin Liu To: Paul Cercueil CC: , , Subject: Re: [PATCH] usb: musb: Force-disable pullup on shutdown Message-ID: <20190403185423.GS25852@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> <20190403154654.GR25852@uda0271908> <1554306740.1177.1@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1554306740.1177.1@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:52:20PM +0200, Paul Cercueil wrote: > > > Le mer. 3 avril 2019 ? 17:46, Bin Liu a ?crit : > >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? > > Yes. I can move it to musb_gadget_setup(). Should I still protect it > with > the spinlock then? Thanks. I don't think spinlock is necessary here. -Bin.