Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3934381yba; Tue, 9 Apr 2019 07:46:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfzFqmYwEPqsIy7CRCCFm0IPvlbCpVOpu4pzA5nD6KqdseUJGta6DD/kluNlAKLHrNTax2 X-Received: by 2002:a17:902:848d:: with SMTP id c13mr37465445plo.279.1554821212698; Tue, 09 Apr 2019 07:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554821212; cv=none; d=google.com; s=arc-20160816; b=RIaf76JWXYx9aRyfarmAenYUGkvpG7OUe3guoX/hNbbnsc0Ebag8iTpHkSxWfgsL62 3rDl7C6pKYcl5/DJI55pU2E0J/ZOkDWTRcL2rqXDam+t0XR1YBI4dtCCIgv8YYmEZeSP aTqjefnQhyCo+OzezYxDnRi1t6oKnUBoQkKPDACBZTTNf+WaFQrd6I22BWEE3ddB+jly 4fMpk45DD+wnjAIeC+3i57966cgoAx0lILuWLBdPWyQbIMhyG/HwXw3HOILbGHgjbMSD aWjiWYcM/TPET5eiUguUpzlftiqcQYukztdZ7iRck7Wr6f3RQwjPovLW+wWf6FBM9V/y NEPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=rZpDqUJLiBuDeHndaVuYDslfeUXG8gWEFEtDe5uIzjI=; b=1E139B0igQT2tXq5vEeL7OpQSKermA63kYVtS4tfDesVmU/3e7BXzeYn9NsoPQG2df qvxSn81JHAVgx+6ljl0vEQkh+iMowhF8sKxbu2A2sfUF0rzN17cNJxLzs+5kWp0URsZU pUeJdFySk1TxHXMFp1S3jeZvuWb+hjLbcokEv1jAXSFxVKUUpTzNOoKp6VUwxF7pHCWV adu47j9OvYGoAzE18b2ezHoyZbAYcgiyAOy3/dsVWml3RgTLMhdMoJcZL0Rfz1G1t8IU 6RGgW0Lfg7t1drQJJECdoWSxeUPM2RTHZBxWkT7unaxKg946WXBIKGmuyJoSFGxe/anb 6SxA== 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 j21si20226874pgm.232.2019.04.09.07.46.37; Tue, 09 Apr 2019 07:46:52 -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 S1726850AbfDIOoG (ORCPT + 99 others); Tue, 9 Apr 2019 10:44:06 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:46054 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726492AbfDIOoF (ORCPT ); Tue, 9 Apr 2019 10:44:05 -0400 Received: (qmail 2837 invoked by uid 2102); 9 Apr 2019 10:44:04 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 9 Apr 2019 10:44:04 -0400 Date: Tue, 9 Apr 2019 10:44:04 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Martin K. Petersen" cc: Kento.A.Kobayashi@sony.com, "James E.J. Bottomley" , Oliver Neukum , , USB Storage list , , Kernel development list , SCSI development list , USB list Subject: Re: [PATCH] usb: uas: fix usb subsystem hang after power off hub port In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 8 Apr 2019, Martin K. Petersen wrote: > > Alan, > > > So it looks as though the SCSI subsystem doesn't like to have a reset > > handler call scsi_remove_host. > > Are you talking about a PCI device removal handler or a SCSI error > handler? The context of this discussion is a USB mass-storage device where the device's port on its upstream hub has been powered off. The powered-off port causes an executing command to time out. As a result the SCSI error handler runs and calls the USB reset routine, but the reset fails because the kernel is unable to communicate with the device through the powered-off port. This causes the USB reset routine to unbind the device from its USB driver, which in turn calls scsi_remove_host -- while the error handler is still running. > > Commands dispatched by the removal routines are forced to wait for the > > reset recovery to finish, which won't happen until those commands have > > been completed. > > > > Is this a bug in the SCSI core? If not, we need to know what is the > > right way to do things when a reset handler detects that the SCSI host > > has been hot-unplugged. > > PCI surprise removal should generally work. But it's somewhat unusual > for a SCSI host to evaporate in the middle of error handling. After all, > the main purpose of eh is to leverage the interfaces provided by the > host to try to reconnect to a target that tripped and fell off the > bus... Still, it's not impossible for a SCSI host to evaporate in the middle of error handling, given an appropriately mistimed hot-unplug event. How does the SCSI layer expect this to be handled? Should the low-level driver wait to call scsi_remove_host until after the error handling is finished? What about races? In theory, scsi_remove_host could be called just as the error handler is starting up. Alan Stern