Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1649218yba; Tue, 2 Apr 2019 13:01:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkDuY6Ec77qZGIP3WjB61KiO/uoKqm4wzazrmsQe9JH2CtYc6DLrEMiV8tHd5zUh6MTqAp X-Received: by 2002:a63:fa54:: with SMTP id g20mr13499014pgk.242.1554235273732; Tue, 02 Apr 2019 13:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554235273; cv=none; d=google.com; s=arc-20160816; b=Mbcek8W1UA2+4t5Jwn8Q9yA4/MXPEma134Kxhkn4jXNGIu0ej9iuDF8RQoNB9Dipf5 mzePfeuPkh3KXZwC2+BMa/7mpbTrCSwJO1EkiDCL2LZoqeQr6uufus0j4lj577LQ+jEE 3VNi0JGMX15Tz2t/B3o5QQLD+hjyok0b5OFuEVS6p0ot7Wx31lC7m9blMl2rZTLCgr7/ GeIo49du1c+KAWiBg3POpOgMlqeoJ21zdP/dqF+yDFr09LIRrvec47Is7Mr3nNM9/Cbo co8XDy37KxUXY1GrOLflYkvo4W6StOLGNuQlO8VCLfbL98cMW1tJdkLbx0RZloLspaOl 1WJg== 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=ucqDwDOGXGI6jS55GyrdLlnLrH9n9y70DM1gv/tM+j4=; b=dOEVX38CujQiZvI0JwoKznAtsIKua/hHTD+nTo7ccGkHeXUvLD31UFWIpXHpk90yu6 DPp0cXxv0M7RRv8bcdLhlJeqnCDTHH+wFqIseJ+EEywnRvYl7qzau333n+zK8LoGHYGH Aifu0pfnUt7rX6uyslrcY2qIsJfH/RzVXecluWL4xSG0F12xfUmVGG0rmZryJLxV9Wo+ pir8Lp3dBfK3LiDv/zReS3mZcAWMPAVSjP3+ZsMy17tH60LZ4t+LDkaRKI3G6erV6gVY 6N3O/h/CoL7qBB3Eu7Fjuq0WdHEGsMeELY+0aw7NAE625Pgy0Cxls8LtsD79SH6ezxTn kSMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="tHKcp/Lw"; 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 v3si5925174pgo.433.2019.04.02.13.00.57; Tue, 02 Apr 2019 13:01:13 -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="tHKcp/Lw"; 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 S1726444AbfDBT6u (ORCPT + 99 others); Tue, 2 Apr 2019 15:58:50 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:54406 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfDBT6t (ORCPT ); Tue, 2 Apr 2019 15:58:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1554235126; 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=ucqDwDOGXGI6jS55GyrdLlnLrH9n9y70DM1gv/tM+j4=; b=tHKcp/LwO71VA7bEx18TlOOCfjcigi+S5URmbFK/D9cr7GCT0T9J1oxMOrbTSpjHjP+03x zk7y03IVDM9yMPJHQNAEzG2yZfV9lAUmcgKUWEidtVByyjv0O8bux9WF0V6jWjXREmkb0W SOzYn8E94m9lqY+HzCSOcd7FIrXI8BY= Date: Tue, 02 Apr 2019 21:58:42 +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: <1554235122.13181.0@crapouillou.net> In-Reply-To: <20190401182008.GL25852@uda0271908> References: <20190321144246.3547-1-paul@crapouillou.net> <20190401171725.GK25852@uda0271908> <1554140782.10471.0@crapouillou.net> <20190401182008.GL25852@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 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: >>=20 >>=20 >> 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=20 >> 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=20 >> gadget >> >driver which calls musb_gadget_pullup() to disable the pullup. >>=20 >> I'm testing with the jz4740-musb driver. I don't unload the module=20 >> (it's >> built-in) but unbind it from sysfs. >=20 > I did unbind too. >=20 > root@am335x-evm:/sys/bus/platform/drivers/musb-hdrc# echo musb-hdrc.0=20 > > unbind >=20 > or unbind the glue driver: >=20 > root@am335x-evm:/sys/bus/platform/drivers/musb-dsps# echo=20 > 47401400.usb > unbind >=20 > musb_gadget_pullup() is called in both cases. >=20 > [ 3880.597014] [] (musb_gadget_pullup [musb_hdrc]) from=20 > [] (usb_gadget_disconnect+0x3c/0xf4 [udc_core]) > [ 3880.607959] [] (usb_gadget_disconnect [udc_core]) from=20 > [] (usb_gadget_remove_driver+0x4c/0x90 [udc_core]) > [ 3880.619338] [] (usb_gadget_remove_driver [udc_core])=20 > 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=20 CONFIG_USB_CONFIGFS, and I don't configure anything in sysfs before unbinding the driver. > [ 3880.630471] [] (usb_del_gadget_udc [udc_core]) from=20 > [] (musb_remove+0x50/0x134 [musb_hdrc]) > [ 3880.640648] [] (musb_remove [musb_hdrc]) from=20 > [] (platform_drv_remove+0x28/0x48) > [ 3880.649831] [] (platform_drv_remove) from []=20 > (device_release_driver_internal+0xe4/0x1b4) > [ 3880.659708] [] (device_release_driver_internal) from=20 > [] (bus_remove_device+0xe0/0x140) > [ 3880.669409] [] (bus_remove_device) from []=20 > (device_del+0x140/0x374) > [ 3880.677455] [] (device_del) from []=20 > (platform_device_del.part.3+0x18/0x80) > [ 3880.686110] [] (platform_device_del.part.3) from=20 > [] (platform_device_unregister+0x24/0x30) > [ 3880.696170] [] (platform_device_unregister) from=20 > [] (dsps_remove+0x1c/0x38 [musb_dsps]) > [ 3880.706010] [] (dsps_remove [musb_dsps]) from=20 > [] (platform_drv_remove+0x28/0x48) > [ 3880.715190] [] (platform_drv_remove) from []=20 > (device_release_driver_internal+0xe4/0x1b4) > [ 3880.725065] [] (device_release_driver_internal) from=20 > [] (unbind_store+0x64/0xd8) > [ 3880.734253] [] (unbind_store) from []=20 > (kernfs_fop_write+0xf4/0x1cc) >=20 > Regards, > -Bin. >=20 >=20 =