Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753943AbaKSCDN (ORCPT ); Tue, 18 Nov 2014 21:03:13 -0500 Received: from mail-oi0-f45.google.com ([209.85.218.45]:49498 "EHLO mail-oi0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753542AbaKSCDK (ORCPT ); Tue, 18 Nov 2014 21:03:10 -0500 MIME-Version: 1.0 In-Reply-To: <20141118164100.GD6179@saruman> References: <1416273684-11300-1-git-send-email-kever.yang@rock-chips.com> <20141118164100.GD6179@saruman> Date: Tue, 18 Nov 2014 18:03:09 -0800 X-Google-Sender-Auth: KCpbZNb2j_p2ONF8msm1nqKFCwE Message-ID: Subject: Re: [PATCH v2] usb: dwc2: resume root hub when device detect with suspend state From: Julius Werner To: Felipe Balbi Cc: Alan Stern , Mathias Nyman , Kever Yang , Paul Zimmerman , Dinh Nguyen , Romain Perier , Heiko Stuebner , Douglas Anderson , Sonny Rao , addy ke , Eddie Cai , wulf , Tao Huang , "open list:ARM/Rockchip SoC..." , Roy Li , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> You should be aware that it's not safe to use hcd->state for anything >> in a host controller driver. That field is owned by usbcore, not by >> the HCD, and it is not protected by any locks. >> >> Thus, for example, hcd->state does not get set to HC_STATE_SUSPENDED >> until some time after the bus_suspend routine has returned. A >> port-change interrupt might occur during that time interval. Looks like there is explicit code in hcd_bus_suspend() to check for that race condition right after setting hcd->state, or do I misinterpret that (the "Did we race with a root-hub wakeup event?" part)? Also, it seems xhci_bus_suspend() explicitly sets 'hcd->state = HC_STATE_SUSPENDED' before giving up the spinlock for some undocumented reason, maybe to avoid exactly this problem. We could just copy that trick if the hcd.c solution isn't enough (although the DWC2 bus_suspend/bus_resume in the other patch don't grab that spinlock right now, where I'm also not so sure if that's a good idea...). -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/