From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BFC2C2D0DE for ; Wed, 1 Jan 2020 22:09:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7E4120722 for ; Wed, 1 Jan 2020 22:09:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sGf5efno" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727425AbgAAWJi (ORCPT ); Wed, 1 Jan 2020 17:09:38 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:40822 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727290AbgAAWJi (ORCPT ); Wed, 1 Jan 2020 17:09:38 -0500 Received: by mail-pj1-f68.google.com with SMTP id bg7so2556348pjb.5; Wed, 01 Jan 2020 14:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=9cdgl502YwKvDfHVgw0H+MtAaSfZwpnZUROdexmqNFI=; b=sGf5efnoItF7FgjSqmc0IRbZAYG9oEccARElQkBdonnNrA/iqpQ53+SD4wGRCYmcH2 07oruHYgJAzwKVX4nwwXYTn0QBggbq2pH1f/vszfP4irES5WmQ8EQoCS6iWRMpOLXy82 QGOthBpl6sOEFEItfoHAcyd+AJ0IppJE6qh2eXItRws92jtP1no5x/e0WbrWfaR5kbRv t7CtzFYzmJiKL//M6lCkw52xlmjvImjDgOA/BIb1HJaXjGcc32soFSwr0N117m1IYsf2 BOw8X8heyeQbWmnFlv0RKIkEPdaJMaHyv4t7Uv1cSZEvMkuqrYGitapOLHvN1wWvQKBv rBzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9cdgl502YwKvDfHVgw0H+MtAaSfZwpnZUROdexmqNFI=; b=WT9MDjXZp/eka4bvkr5PA6JZtUNzq+uCafInSnZxpg31sOtd1yhFb5MRAs5h9eU5BG b6O6HnSpvAfC9HIeudLvFZMR+6FPrzBYnpJCPZEnLPTBjTWPADjYpYvvI3Ycrn7p7+m3 cwZL52q1PkhSMiy2TNJmQbi0RS/obRkFx9BQT3V8tKPc+pD/V7tYEChbs5Nvnz7F3QCO P35EsGPQM7iL6Nge7SHxIi4gHLo4SBBk+cjbNkIfgaRz4MBrK6g0Nj9ckPjSWXcxxhqP wsmbxMibkTfOxE8IU7uwrOYsgC+5zXiFAX3R82tZDUL4VGH1eN82QAiNqqz1kgVtnHeA SozA== X-Gm-Message-State: APjAAAXMrmFUqDY0N0pGTApeohN8S0uzKe7RjuZgaVIxnLAgf9gZPAKt Cq8WW5FlWZ4Ya79UeuUgOv8CSJb+ X-Google-Smtp-Source: APXvYqzHOIgnfBYhFwq/vuLOSK6OcQY1qVy7GdZ45Basskuon2Dl7ezQYajlH8vez7vMBBCgSlPjyw== X-Received: by 2002:a17:90a:ab0c:: with SMTP id m12mr15469694pjq.81.1577916577258; Wed, 01 Jan 2020 14:09:37 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u12sm39081895pfm.165.2020.01.01.14.09.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jan 2020 14:09:36 -0800 (PST) Subject: Re: [PATCH] usb: chipidea: host: Disable port power only if previously enabled To: Alan Stern Cc: Greg Kroah-Hartman , USB list , Kernel development list , Michael Grzeschik , stable@vger.kernel.org References: From: Guenter Roeck Message-ID: <1fd709ce-04a3-4183-da39-c1921ec69ce7@roeck-us.net> Date: Wed, 1 Jan 2020 14:09:35 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/29/19 8:40 AM, Alan Stern wrote: > On Sun, 29 Dec 2019, Guenter Roeck wrote: > >> On Sat, Dec 28, 2019 at 02:33:01PM -0500, Alan Stern wrote: >>> >>> Let's try a slightly different approach. What happens with this patch? >>> >>> Alan Stern >>> >>> >>> Index: usb-devel/drivers/usb/core/hub.c >>> =================================================================== >>> --- usb-devel.orig/drivers/usb/core/hub.c >>> +++ usb-devel/drivers/usb/core/hub.c >>> @@ -1065,6 +1065,7 @@ static void hub_activate(struct usb_hub >>> if (type == HUB_INIT) { >>> delay = hub_power_on_good_delay(hub); >>> >>> + hub->power_bits[0] = ~0UL; /* All ports on */ >>> hub_power_on(hub, false); >>> INIT_DELAYED_WORK(&hub->init_work, hub_init_func2); >>> queue_delayed_work(system_power_efficient_wq, >>> >> >> That doesn't make a difference - the traceback is still seen with this patch >> applied. > > Can you trace what's going on? Does this code pathway now end up > calling ehci_port_power() for each root-hub port, and from there down > into the chipidea driver? If not, can you find where it gets > sidetracked? > A complete traceback is attached below, so, yes, I think it is safe to say that ehci_port_power() is called unconditionally for each root-hub port on shutdown. The only mystery to me was why ehci_port_power() isn't called to enable port power when the port comes up. As it turns out, HCS_PPC(ehci->hcs_params) is false on my simulated hardware, and thus ehci_port_power(..., true) is not called from ehci_hub_control(). Given that, it may well be that the problem is not seen on "real" hardware, at least not with real mcimx7d-sabre hardware, if the hub on that hardware does support power control. To test this idea, I modified qemu to claim hub power control support by setting the "power control support" capability bit. With that, the traceback is gone. Any suggestion how to proceed ? Thanks, Guenter --- [ 31.916567] ------------[ cut here ]------------ [ 31.917178] WARNING: CPU: 0 PID: 182 at drivers/regulator/core.c:2598 _regulator_disable+0x1a8/0x210 [ 31.917331] unbalanced disables for usb_otg2_vbus [ 31.917468] Modules linked in: [ 31.917877] CPU: 0 PID: 182 Comm: init Not tainted 5.4.8-rc1-00003-gb8e36d27e314 #1 [ 31.918032] Hardware name: Freescale i.MX7 Dual (Device Tree) [ 31.918246] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 31.918397] [] (show_stack) from [] (dump_stack+0xe0/0x10c) [ 31.918522] [] (dump_stack) from [] (__warn+0xf4/0x10c) [ 31.918641] [] (__warn) from [] (warn_slowpath_fmt+0x78/0xbc) [ 31.918768] [] (warn_slowpath_fmt) from [] (_regulator_disable+0x1a8/0x210) [ 31.918900] [] (_regulator_disable) from [] (regulator_disable+0x38/0xe8) [ 31.919032] [] (regulator_disable) from [] (ehci_ci_portpower+0x38/0xdc) ehci_ci_portpower() calls regulator_enable() or regulator_disable() if priv->reg_vbus is not NULL [ 31.919166] [] (ehci_ci_portpower) from [] (ehci_port_power+0x50/0xa4) ehci_port_power() calls hcd->driver->port_power(), which is ehci_ci_portpower() [ 31.919296] [] (ehci_port_power) from [] (ehci_silence_controller+0x5c/0xc4) ehci_silence_controller() calls ehci_turn_off_all_ports(), which calls ehci_port_power() for each port [ 31.919430] [] (ehci_silence_controller) from [] (ehci_stop+0x3c/0xcc) ehci_silence_controller() called unconditionally from ehci_stop() [ 31.919560] [] (ehci_stop) from [] (usb_remove_hcd+0xe0/0x19c) ehci_stop() called unconditionally from usb_remove_hcd() with hcd->driver->stop(hcd); [ 31.919685] [] (usb_remove_hcd) from [] (host_stop+0x38/0xa8) [ 31.919809] [] (host_stop) from [] (ci_hdrc_remove+0x44/0xe4) [ 31.919932] [] (ci_hdrc_remove) from [] (platform_drv_remove+0x20/0x40) [ 31.920062] [] (platform_drv_remove) from [] (device_release_driver_internal+0xe8/0x1b8) [ 31.920210] [] (device_release_driver_internal) from [] (bus_remove_device+0xd0/0xfc) [ 31.920351] [] (bus_remove_device) from [] (device_del+0x140/0x374) [ 31.920477] [] (device_del) from [] (platform_device_del.part.3+0x10/0x74) [ 31.920608] [] (platform_device_del.part.3) from [] (platform_device_unregister+0x1c/0x28) [ 31.920758] [] (platform_device_unregister) from [] (ci_hdrc_remove_device+0xc/0x20) [ 31.920898] [] (ci_hdrc_remove_device) from [] (ci_hdrc_imx_remove+0x28/0x110) [ 31.921033] [] (ci_hdrc_imx_remove) from [] (device_shutdown+0x180/0x224) [ 31.921166] [] (device_shutdown) from [] (kernel_restart+0xc/0x50) [ 31.921292] [] (kernel_restart) from [] (__do_sys_reboot+0x15c/0x1ec) [ 31.921444] [] (__do_sys_reboot) from [] (ret_fast_syscall+0x0/0x28) [ 31.921595] Exception stack(0xc93c1fa8 to 0xc93c1ff0)