From patchwork Wed Jan 10 07:13:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10154117 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 BC9DC601A1 for ; Wed, 10 Jan 2018 07:13:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99F1726E7B for ; Wed, 10 Jan 2018 07:13:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E15F27480; Wed, 10 Jan 2018 07:13:33 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 2FBB526E7B for ; Wed, 10 Jan 2018 07:13:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbeAJHN1 (ORCPT ); Wed, 10 Jan 2018 02:13:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33124 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750852AbeAJHN1 (ORCPT ); Wed, 10 Jan 2018 02:13:27 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03CEDC0587F9; Wed, 10 Jan 2018 07:13:27 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79EF85885E; Wed, 10 Jan 2018 07:13:25 +0000 (UTC) From: Hans de Goede To: Oliver Neukum , Alan Stern Cc: Hans de Goede , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-scsi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] uas: Unblock scsi-requests on failure to alloc streams in post_reset Date: Wed, 10 Jan 2018 08:13:23 +0100 Message-Id: <20180110071323.3183-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 10 Jan 2018 07:13:27 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we return 1 from our post_reset handler, then our disconnect handler will be called immediately afterwards. Since pre_reset blocks all scsi requests our disconnect handler will then hang in the scsi_remove_host call. This is esp. bad because our disconnect handler hanging for ever also stops the USB subsys from enumerating any new USB devices, causes commands like lsusb to hang, etc. In practice this happens when unplugging some uas devices because the hub code may see the device as needing a warm-reset and calls usb_reset_device before seeing the disconnect. In this case uas_configure_endpoints fails with -ENODEV. We do not want to print an error for this, so this commit also silences the shost_printk for -ENODEV. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1531966 Cc: stable@vger.kernel.org Fixes: 8d51444cdd06 ("uas: Not being able to alloc streams ... is an error") Signed-off-by: Hans de Goede --- drivers/usb/storage/uas.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 5d04c40ee40a..5471422aa1ab 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -1077,9 +1077,13 @@ static int uas_post_reset(struct usb_interface *intf) err = uas_configure_endpoints(devinfo); if (err) { - shost_printk(KERN_ERR, shost, - "%s: alloc streams error %d after reset", - __func__, err); + if (err != -ENODEV) { + shost_printk(KERN_ERR, shost, + "%s: alloc streams error %d after reset", + __func__, err); + } + /* So that scsi_remove_host in uas_disconnect does not hang */ + scsi_unblock_requests(shost); return 1; }