Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3308173imu; Sun, 11 Nov 2018 12:04:33 -0800 (PST) X-Google-Smtp-Source: AJdET5dHBu26AQSmp2LNj2VKuN1ufEyCoowa1qnqKWdAfXokYwbTeqCm2YJ3MUffNPXz/gzbaxQ+ X-Received: by 2002:a63:f30d:: with SMTP id l13mr15069319pgh.399.1541966673717; Sun, 11 Nov 2018 12:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966673; cv=none; d=google.com; s=arc-20160816; b=FE8To6YCdymyzKSYuepuapXsdQFX+Wy31Cmudwk+9cPwiCExxmRZXILaS1zyVCZlL6 mMgrPUSAqNZdDuYrpEW4RwgbcvtWpZBXLn7J5U5P7EN347174zcyTiNpDRzoKLki31HQ 7MW49PLGVOicdsCnsHjcQGGpse6DIsoFfdt2+MJn/+WLH6YvpbXlgbQkWNQ42MiSJe9X gu/gyyNwHiikWTN46zrYsMqVWQWfMND7ywaW3vdok9l05r0DZtuI7Xq9W5yX8aR1gQPT q80R0iIIHdG4B6jYjoJVvRBGryUucAga+VjvatGuEFIvkxHSbwLnQJs7P7E/Jz5Ywsn5 pNcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=p9/PH7yWxj6H3pt9KF94gTit3A4iseKovNaImG50ekI=; b=e/1S2cf0rPY9B6ZmYX045vgCj5irGccAxulwhDZuifzeg5ThAYKTeWUUEXy1w3AscE tBgS1VSfPe8/UwsleQA/LQxkD3RqdlksXWkdXHBqu4coTgRATHZRtkxxlAtvL86tygqx qXpU3VVnBh9pGrfNxYCYuSoD8JL1PpqumpxWVbQys1VKnJaWl1mhmpRiumxyoQWkeABJ 2yjMDXDcNKdSM+xek3d9vr1wQ+zqi8nh35f3fThReqQjBOy79e4B7a6yqrFkBSTmBDPg eoYp1dvQBQpLmCgSdHjShMRw0kSv48OeTTF2ONJMuiftSA4nEgWANszIWQQ5nHYYY20i vPYg== ARC-Authentication-Results: i=1; mx.google.com; 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 g2-v6si14717410plp.298.2018.11.11.12.04.18; Sun, 11 Nov 2018 12:04:33 -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; 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 S1730805AbeKLFwn (ORCPT + 99 others); Mon, 12 Nov 2018 00:52:43 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51140 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730709AbeKLFsb (ORCPT ); Mon, 12 Nov 2018 00:48:31 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsp-0000oP-0E; Sun, 11 Nov 2018 19:58:59 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsX-0001kp-F0; Sun, 11 Nov 2018 19:58:41 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Greg Kroah-Hartman" , "Alan Stern" , "Bin Liu" , "Alessandro Antenucci" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 273/366] usb: core: handle hub C_PORT_OVER_CURRENT condition In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Bin Liu commit 249a32b7eeb3edb6897dd38f89651a62163ac4ed upstream. Based on USB2.0 Spec Section 11.12.5, "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 let's check C_PORT_OVER_CURRENT too for over current condition. Fixes: 08d1dec6f405 ("usb:hub set hub->change_bits when over-current happens") Tested-by: Alessandro Antenucci Signed-off-by: Bin Liu Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/usb/core/hub.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1119,10 +1119,14 @@ static void hub_activate(struct usb_hub if (!udev || udev->state == USB_STATE_NOTATTACHED) { /* Tell khubd to disconnect the device or - * check for a new connection + * check for a new connection or over current condition. + * Based on USB2.0 Spec Section 11.12.5, + * C_PORT_OVER_CURRENT could be set while + * PORT_OVER_CURRENT is not. So check for any of them. */ 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) {