From patchwork Fri Jul 13 19:22:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Liu X-Patchwork-Id: 10524031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B4A660245 for ; Fri, 13 Jul 2018 19:22:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A22B29F50 for ; Fri, 13 Jul 2018 19:22:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F077729F5B; Fri, 13 Jul 2018 19:22:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A9DB29F50 for ; Fri, 13 Jul 2018 19:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731555AbeGMTib (ORCPT ); Fri, 13 Jul 2018 15:38:31 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:56382 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731484AbeGMTib (ORCPT ); Fri, 13 Jul 2018 15:38:31 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w6DJMXiS103090 for ; Fri, 13 Jul 2018 14:22:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1531509753; bh=3B3HBwdzmQGsio1PqvEl4nQ0fWhEglPr6y9CQ3fmPyA=; h=Date:From:To:Subject; b=l0cdZ0qPndCi+0/uqeajl+K8dCTLBSYuimzzDimZBHhlhbg6gt2xoVIAx1LKF+MOk aStJH/UnMqIfIkke7syuczTLVbDgsKQwIOsdpl4kej3s4cy17yCQ7G+ICy5rubi8LG Hwf1CaAfxA34gtORqrncI92JTpKQRRP8zrQdpoz0= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w6DJMX3Y016732 for ; Fri, 13 Jul 2018 14:22:33 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 13 Jul 2018 14:22:32 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 13 Jul 2018 14:22:32 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w6DJMWZ2032173; Fri, 13 Jul 2018 14:22:32 -0500 Date: Fri, 13 Jul 2018 14:22:32 -0500 From: Bin Liu To: Subject: usb hub driver bug in overcurrent handling? Message-ID: <20180713192232.GA3949@uda0271908> Mail-Followup-To: Bin Liu , linux-usb@vger.kernel.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, I got a report saying that when overcurrent happens in one of the hub downstream ports, USB_PORT_STAT_OVERCURRENT is not set in portstatus, instead USB_PORT_STAT_C_OVERCURRENT is set in portchange, then the overcurrent condition is not handled in hub_event(). The following patch solves the issue. t a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 442be7f312f6..118557acc74b 100644 The usb2.0 spec section 11.12.5 states "If a hub has per-port power switching and per-port current limiting, an over-current on one port may still cause the power on another port to fall below specific minimums. In this case, the affected port is placed in the Power-Off state and C_PORT_OVER_CURRENT is set for the port, but PORT_OVER_CURRENT is not set." So is the patch above a proper fix? or something else might be missing? Thanks, -Bin. --- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1144,7 +1144,8 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) * check for a new connection */ if (udev || (portstatus & USB_PORT_STAT_CONNECTION) || - (portstatus & USB_PORT_STAT_OVERCURRENT)) + (portstatus & USB_PORT_STAT_OVERCURRENT) || + (portchange & USB_PORT_STAT_C_OVERCURRENT)) set_bit(port1, hub->change_bits); } else if (portstatus & USB_PORT_STAT_ENABLE) {