Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp16800422ybl; Wed, 1 Jan 2020 14:10:31 -0800 (PST) X-Google-Smtp-Source: APXvYqy4XozQJ6cRjLUiD99pdUboM9lge45OA0Zdbd446JHqHg5m1/z6YHVVz6D1j+JJXNjL6cjV X-Received: by 2002:a05:6830:304c:: with SMTP id p12mr58029503otr.214.1577916630995; Wed, 01 Jan 2020 14:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577916630; cv=none; d=google.com; s=arc-20160816; b=tCzxTQqs63QlAHSn+I6WvucD0YJ+Pg57OHyerrHjSu8JVNc17rSXoS54dQIrJub/Ey 7Fy0tijDDUyNrznsJz7XsNf6cqF0P6i5SABJ0gDsTC/PLvyhyox1x65/FVFE7qrYP/tV 5jtjYjHt0gVGdvV9wr+E/yNhqzlP8XAYYOJqAiRiuiUi+YjTWynW7k+i3QSbrjqqLovt GWYNP8Ycy/CvXTMRbubPx+Ds5DxKEK9+9B5qq8Z2m5Dd7vzn3mE1tgbff9QDuiUEGG4N XGaBFRSdEFzQ5cDiAIRU1ZI/XZv1GKXWOp3xlMZybY/fFCsGFfXmD9OfKaKgnvBEHKbU 7NyQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=9cdgl502YwKvDfHVgw0H+MtAaSfZwpnZUROdexmqNFI=; b=Ux19CWYED/tHb3/sMMtWLFO5nwANZ4Bj5V1jijL/t83jMBY+8cYidgVWYaPfLHz+yj oxmLwNp14dS364y/X/EcBWuGmttmbke1jMcu/5qW4+dOTTc88V6HuMHgWGe6k6A8zK1f QEABmKHQH7LZS/+wZKJ42f9TxjO/JFeeiBTzXd9rmTBfJtoyWcK7s2qBhUmLoYmgFtNu 2+xhX9KS6wK2FSb6ECUt+hSRGwjaTVo1IxWHiMRXWdCUsY8NCPWm+14a0JryZqqbT/cm /D7d2O++IMIBSfcFDkGWVj0uJcIL9grB7A60WWkZ51uGpGVwG2uVm26jbFQNMMClR2G5 BCTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=sGf5efno; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z65si16382639oia.33.2020.01.01.14.10.18; Wed, 01 Jan 2020 14:10:30 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=sGf5efno; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727397AbgAAWJi (ORCPT + 99 others); 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-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)