From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Subject: usb: uas: fix usb subsystem hang after power off hub port From: Bart Van Assche Message-Id: <1554823007.161891.6.camel@acm.org> Date: Tue, 09 Apr 2019 08:16:47 -0700 To: Alan Stern , "Martin K. Petersen" Cc: Kento.A.Kobayashi@sony.com, "James E.J. Bottomley" , Oliver Neukum , gregkh@linuxfoundation.org, USB Storage list , Jacky.Cao@sony.com, Kernel development list , SCSI development list , USB list List-ID: T24gVHVlLCAyMDE5LTA0LTA5IGF0IDEwOjQ0IC0wNDAwLCBBbGFuIFN0ZXJuIHdyb3RlOgo+IE9u IE1vbiwgOCBBcHIgMjAxOSwgTWFydGluIEsuIFBldGVyc2VuIHdyb3RlOgo+IAo+ID4gCj4gPiBB bGFuLAo+ID4gCj4gPiA+IFNvIGl0IGxvb2tzIGFzIHRob3VnaCB0aGUgU0NTSSBzdWJzeXN0ZW0g ZG9lc24ndCBsaWtlIHRvIGhhdmUgYSByZXNldCAKPiA+ID4gaGFuZGxlciBjYWxsIHNjc2lfcmVt b3ZlX2hvc3QuCj4gPiAKPiA+IEFyZSB5b3UgdGFsa2luZyBhYm91dCBhIFBDSSBkZXZpY2UgcmVt b3ZhbCBoYW5kbGVyIG9yIGEgU0NTSSBlcnJvcgo+ID4gaGFuZGxlcj8KPiAKPiBUaGUgY29udGV4 dCBvZiB0aGlzIGRpc2N1c3Npb24gaXMgYSBVU0IgbWFzcy1zdG9yYWdlIGRldmljZSB3aGVyZSB0 aGUKPiBkZXZpY2UncyBwb3J0IG9uIGl0cyB1cHN0cmVhbSBodWIgaGFzIGJlZW4gcG93ZXJlZCBv ZmYuICBUaGUKPiBwb3dlcmVkLW9mZiBwb3J0IGNhdXNlcyBhbiBleGVjdXRpbmcgY29tbWFuZCB0 byB0aW1lIG91dC4gIEFzIGEgcmVzdWx0Cj4gdGhlIFNDU0kgZXJyb3IgaGFuZGxlciBydW5zIGFu ZCBjYWxscyB0aGUgVVNCIHJlc2V0IHJvdXRpbmUsIGJ1dCB0aGUKPiByZXNldCBmYWlscyBiZWNh dXNlIHRoZSBrZXJuZWwgaXMgdW5hYmxlIHRvIGNvbW11bmljYXRlIHdpdGggdGhlIGRldmljZQo+ IHRocm91Z2ggdGhlIHBvd2VyZWQtb2ZmIHBvcnQuICBUaGlzIGNhdXNlcyB0aGUgVVNCIHJlc2V0 IHJvdXRpbmUgdG8KPiB1bmJpbmQgdGhlIGRldmljZSBmcm9tIGl0cyBVU0IgZHJpdmVyLCB3aGlj aCBpbiB0dXJuIGNhbGxzCj4gc2NzaV9yZW1vdmVfaG9zdCAtLSB3aGlsZSB0aGUgZXJyb3IgaGFu ZGxlciBpcyBzdGlsbCBydW5uaW5nLgoKRnJvbSB3aGljaCBjb250ZXh0IGRvZXMgdGhhdCB1bmJp bmQgaGFwcGVuPyBGcm9tIGluc2lkZSBhIFNDU0kgRUggY2FsbGJhY2sKb3IgZnJvbSB0aGUgY29u dGV4dCBvZiBhIHdvcmtxdWV1ZT8gSSB0aGluayB0aGUgZm9ybWVyIGlzIG5vdCBhbGxvd2VkIGJ1 dAp0aGF0IHRoZSBsYXR0ZXIgaXMgYWxsb3dlZC4gVGhlIFNSUCBpbml0aWF0b3IgZHJpdmVyIChp Yl9zcnAuYykgZm9sbG93cyB0aGUKbGF0dGVyIGFwcHJvYWNoLiBTZWUgYWxzbyBzcnBfcXVldWVf cmVtb3ZlX3dvcmsoKS4KCkJhcnQuCg== From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 349CCC10F0E for ; Tue, 9 Apr 2019 15:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0AC972084F for ; Tue, 9 Apr 2019 15:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbfDIPQv (ORCPT ); Tue, 9 Apr 2019 11:16:51 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36956 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbfDIPQv (ORCPT ); Tue, 9 Apr 2019 11:16:51 -0400 Received: by mail-pl1-f196.google.com with SMTP id w23so9592313ply.4; Tue, 09 Apr 2019 08:16:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=KyDoJ4EF4tKFatRTJIVOBt2T69QEP0WdD+xc0GB6Pf8=; b=sEb6V+GjGpX/adAxqjtR3ah3mJ5NNIR/J7jAVigYyPqa+Lb9uCNMWya45zHB9YPGWL kbpVGsu3nwzmgI/bNglWgr7PTpsXmMbdu/rl20ZsFyxHzleDptVgePn0Gz8Yc2SSn0Dl oLawAkzn9RAN108UPSblsxYAIgrQK2BIrG03OGvtl4rtQ0HZQNe5kPgk0IcPUdPwHaVI SuAN4IgkhZwWVl5D4yC6Tk7Dy/ZFsX0mPEDxh5SZu/luY+3Z6ZBI0l6Iyw9LArKxsAjg WxJ6cn0WS0S4VrNGgZRsM73qyh35EytCFGKB6U7elXMxrmDm630UZseS6QtkoAjJ8kCC UobQ== X-Gm-Message-State: APjAAAV/eJlVLKrwc7OVhqbSpOM/o3BNnCB3uD8QpKZ6HEs2oKTkpSTV qZ80rvFLQVXnlTdyRXI7+9s= X-Google-Smtp-Source: APXvYqzlwcZxQo5mq4WPr+YtES0+PQj+Skp4JMJiQoex8JslatADRapIFoX2ocQZY6cYV46JjVZt5g== X-Received: by 2002:a17:902:2ac3:: with SMTP id j61mr38121413plb.112.1554823010201; Tue, 09 Apr 2019 08:16:50 -0700 (PDT) Received: from ?IPv6:2620:15c:2cd:203:5cdc:422c:7b28:ebb5? ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id g73sm60597977pfd.185.2019.04.09.08.16.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2019 08:16:49 -0700 (PDT) Message-ID: <1554823007.161891.6.camel@acm.org> Subject: Re: [PATCH] usb: uas: fix usb subsystem hang after power off hub port From: Bart Van Assche To: Alan Stern , "Martin K. Petersen" Cc: Kento.A.Kobayashi@sony.com, "James E.J. Bottomley" , Oliver Neukum , gregkh@linuxfoundation.org, USB Storage list , Jacky.Cao@sony.com, Kernel development list , SCSI development list , USB list Date: Tue, 09 Apr 2019 08:16:47 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Message-ID: <20190409151647.NcpQHd-4S3ztFXsX_x2VWeIT_w9pfmiS5VeV448g9p4@z> On Tue, 2019-04-09 at 10:44 -0400, Alan Stern wrote: +AD4 On Mon, 8 Apr 2019, Martin K. Petersen wrote: +AD4 +AD4 +AD4 +AD4 +AD4 Alan, +AD4 +AD4 +AD4 +AD4 +AD4 So it looks as though the SCSI subsystem doesn't like to have a reset +AD4 +AD4 +AD4 handler call scsi+AF8-remove+AF8-host. +AD4 +AD4 +AD4 +AD4 Are you talking about a PCI device removal handler or a SCSI error +AD4 +AD4 handler? +AD4 +AD4 The context of this discussion is a USB mass-storage device where the +AD4 device's port on its upstream hub has been powered off. The +AD4 powered-off port causes an executing command to time out. As a result +AD4 the SCSI error handler runs and calls the USB reset routine, but the +AD4 reset fails because the kernel is unable to communicate with the device +AD4 through the powered-off port. This causes the USB reset routine to +AD4 unbind the device from its USB driver, which in turn calls +AD4 scsi+AF8-remove+AF8-host -- while the error handler is still running. >From which context does that unbind happen? From inside a SCSI EH callback or from the context of a workqueue? I think the former is not allowed but that the latter is allowed. The SRP initiator driver (ib+AF8-srp.c) follows the latter approach. See also srp+AF8-queue+AF8-remove+AF8-work(). Bart.