From patchwork Wed Jan 10 15:23:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 10155297 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 BCDE1601A1 for ; Wed, 10 Jan 2018 15:28:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADB3D28429 for ; Wed, 10 Jan 2018 15:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0E6D285CE; Wed, 10 Jan 2018 15:28:28 +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 132A828429 for ; Wed, 10 Jan 2018 15:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752835AbeAJP20 (ORCPT ); Wed, 10 Jan 2018 10:28:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:48870 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751293AbeAJP2Z (ORCPT ); Wed, 10 Jan 2018 10:28:25 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 08086AAC1; Wed, 10 Jan 2018 15:28:24 +0000 (UTC) Message-ID: <1515597815.2578.2.camel@suse.com> Subject: Re: [PATCH] uas: Unblock scsi-requests on failure to alloc streams in post_reset From: Oliver Neukum To: Hans de Goede , Alan Stern Cc: Greg Kroah-Hartman , linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, stable@vger.kernel.org Date: Wed, 10 Jan 2018 16:23:35 +0100 In-Reply-To: <20180110071323.3183-1-hdegoede@redhat.com> References: <20180110071323.3183-1-hdegoede@redhat.com> X-Mailer: Evolution 3.20.5 Mime-Version: 1.0 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 Am Mittwoch, den 10.01.2018, 08:13 +0100 schrieb Hans de Goede: > 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. Hi Hans, it seems to me that the diagnosis is spot on. But why do we keep different code paths at all in this case? I do not see the point of not reporting the reset to the SCSI subsystem, even if we are not operational afterwards. So how about something like this? From 4d1e26154bc5d09913bfba34d7adc39cce98d20a Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Wed, 10 Jan 2018 16:16:03 +0100 Subject: [PATCH] usb: uas: unconditionally bring back host after reset Quoting Hans: 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. ENDQUOTE However, if we do that we better drop any unconditional execution and report to the SCSI subsystem that we have undergone a reset but we are not operational now. Signed-off-by: Oliver Neukum Reported-by: Hans de Goede ---  Makefile                  | 2 +-  drivers/usb/storage/uas.c | 7 +++----  2 files changed, 4 insertions(+), 5 deletions(-)  static int uas_suspend(struct usb_interface *intf, pm_message_t message) --  2.13.6 diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 5d04c40ee40a..3b1b9695177a 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -1076,20 +1076,19 @@ static int uas_post_reset(struct usb_interface *intf)   return 0;     err = uas_configure_endpoints(devinfo); - if (err) { + if (err && err != ENODEV)   shost_printk(KERN_ERR, shost,        "%s: alloc streams error %d after reset",        __func__, err); - return 1; - }   + /* we must unblock the host in every case lest we deadlock */   spin_lock_irqsave(shost->host_lock, flags);   scsi_report_bus_reset(shost, 0);   spin_unlock_irqrestore(shost->host_lock, flags);     scsi_unblock_requests(shost);   - return 0; + return err ? 1 : 0;  }