Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1270406img; Tue, 19 Mar 2019 04:15:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqw74cAXF6SExrKA/c6OhRsFD7kXZafKzRRjjFiYeof5mE2HpizNtlZxShXieWDnbPbOkWxm X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr1781761plq.293.1552994131087; Tue, 19 Mar 2019 04:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552994131; cv=none; d=google.com; s=arc-20160816; b=KP7wR8i7+Me7JRnv4l7mY5+E5pzDKN9hYpr+VZX8bYjwNy/SsIxFWZW+0Xl8/J74Hl 1MxqYQmtrjd2jDaH9SneMfozQC8tXR5EdQzVTRqFvlUmuebpeSRf1vOt3rg9/vDyFoUe zsCwzm7uRfD1ISb5UB10djGS3rTHBLwanAQjBfJ58yFcG9WTjykdzDDlT6Cyufv/Lbvr l6p5HVlfoYkHj61ku70d970JSgbkul/bstkEsprx3unZnzEgluvgWi7bgXvsrp2J3G9r seaZzcsR8NILEgOEG6nqDDjkQf1l87lhkiEPPgIYlkRMQLwFSNlqsSNhjCX3+6nVt6F6 T8tg== 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:date:cc:to:from:subject:message-id; bh=weoNY7AuNuCU8OWVN27+rRieMMK2fYNi3nUqP/0VbtY=; b=kTXsIm9V5P7291Ao4Fh0TF4zFb3nbA/e38CYdzqJzauz7a0UZkOnNE0Q+m1YBjaZc5 LD6Z/bEcBCi6cDDwK4q81ChQM83J0QZSYoMNON7NM6owV515XYJveS29Frk1k+JQRhfO D7ZuOgU08lIYrLskU4EcC9ZjBvWQMzG/HSuqJCsEbtLkg0zNgX1Ln2yh4MUuGTmSD6MO NgBE86VrT2bXAFQTVjLv8wsfDQvAzqJt7d0n8ZEYyqN95XFU7h/BJcSaxLJKRo0akInU hOVxmIAlgW2nH0qQt15R95N8hIXVFYJMro3Ib2v1du8kH4tl5VAClQskVaJnZ6m+1VH0 4XsA== 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 k18si12100649pls.25.2019.03.19.04.15.15; Tue, 19 Mar 2019 04:15:31 -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; 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 S1727375AbfCSLNM (ORCPT + 99 others); Tue, 19 Mar 2019 07:13:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:44310 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725934AbfCSLNM (ORCPT ); Tue, 19 Mar 2019 07:13:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A0945B028; Tue, 19 Mar 2019 11:13:10 +0000 (UTC) Message-ID: <1552993288.14757.23.camel@suse.com> Subject: Re: [RFC] xhci: clear port_remote_wakeup on device disconnection From: Oliver Neukum To: Nicolas Saenz Julienne , Mathias Nyman Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Date: Tue, 19 Mar 2019 12:01:28 +0100 In-Reply-To: <20190318170038.23914-1-nsaenzjulienne@suse.de> References: <20190318170038.23914-1-nsaenzjulienne@suse.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mo, 2019-03-18 at 18:00 +0100, Nicolas Saenz Julienne wrote: > > This patch clears "port_remote_wakeup" upon detecting a device > disconnection. Making sure the above mentioned situation doesn't trigger > a PM busyloop. Hi, that is an interesting race condition. > > Signed-off-by: Nicolas Saenz Julienne > --- > drivers/usb/host/xhci-hub.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c > index e2eece693655..bea853f45aec 100644 > --- a/drivers/usb/host/xhci-hub.c > +++ b/drivers/usb/host/xhci-hub.c > @@ -942,6 +942,9 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status, > bus_state->suspended_ports &= ~(1 << portnum); > } > > + if (!(portsc & PORT_CONNECT)) > + bus_state->port_remote_wakeup &= ~(1 << portnum); > + > xhci_hub_report_usb3_link_state(xhci, status, portsc); > xhci_del_comp_mod_timer(xhci, portsc, portnum); > } Why are you putting that logic into xhci_get_usb3_port_status()? It looks to me like there is already something related in the caller /* USB2 and USB3 specific bits, including Port Link State */ if (hcd->speed >= HCD_USB3) xhci_get_usb3_port_status(port, &status, raw_port_status); else xhci_get_usb2_port_status(port, &status, raw_port_status, flags); /* * Clear stale usb2 resume signalling variables in case port changed * state during resume signalling. For example on error */ if ((bus_state->resume_done[wIndex] || test_bit(wIndex, &bus_state->resuming_ports)) && (raw_port_status & PORT_PLS_MASK) != XDEV_U3 && (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) { bus_state->resume_done[wIndex] = 0; clear_bit(wIndex, &bus_state->resuming_ports); usb_hcd_end_port_resume(&hcd->self, wIndex); } Otherwise very good catch! Regards Oliver