Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp392323lqs; Tue, 5 Mar 2024 05:26:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWWZoMmzDI4gpplSEF02CSC0oeTXlX8NNaTdErFugAAkEb4+IZMnkZMk+o1yKd9SDyLU10MM9jt4MxjwtQMG0fEaevnM/2WEVk8xV4oeQ== X-Google-Smtp-Source: AGHT+IEi1GEn5EarGy0gJHZVtkWIVxb8XJAXyAShVQC+UA5JWg43pTFMtgzimZB0mmOHxAT7tg72 X-Received: by 2002:a05:6a00:99a:b0:6e5:faca:3683 with SMTP id u26-20020a056a00099a00b006e5faca3683mr10757034pfg.26.1709645173561; Tue, 05 Mar 2024 05:26:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709645173; cv=pass; d=google.com; s=arc-20160816; b=BNiD5V2w7Uu7pexw4/a9gu7bNKxkhMc9hSPHKEISSbeNXq6FWznL/mTPlVbMfw6gae XrhcyVComr7KXYPLlRDo5Ls4DX0j2Qv4s01MzvgkwBt9rMiu8VJo5j1lY5D0onhZr/A+ KFHh6HX2GO3qw3JFdIjHLT1k5eVxjvYxCtQN6RW9aVU5fM6HnrCCZJHaJl1Ih6XFJNVy mFz4Tim9K/Vw8FEt/9UsJfrjUokumElpetSJhDXGk4VgPLBpN95HFU/Q5rubdoY2tTvL XoQR7zIJdl3mksq4gimGhmK8CZ7MvsVHyu3xboF2/Gko2jv9Rp+033sDuJs3ZElMUPqy 6tug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+Ueu9IVSwZauPQCqWUnuucSx91Sg4MClpb4Qith+Ss0=; fh=SqsOK2HZy1Yj5Jgl7WYq4IaPLQuQA3om4y32ZlxvCr0=; b=sMj2g81/OF2ueAjxgT8RNruYJhfUtcTMshb62eKY1X1y6JSpCOA+blB049eHmbXbcI rL1TgeFxZz03WzqZfoRHNMV9DFF2TM/iPhO3mvi5wmB+LjRKa0jU+BstgMbvG5TftIy6 Xzj9ZmxlQ2pLzeh+/frC46G0t0bJTXk8kn8Hac8s15A4JUSD0l3HjqX2ThLHOmQRn1rM vY9H+Z8B7/u+qs6iR9YPUgcsD/mgtRB52fnVsWt1w+knyDV/+U9TJZXSBhkX/eV0v+vn mm9Ysj3pUBF+GglCFewKhwUBwiv5XW6c6jJT9xCh7gzj1me9Hhg2uUC0y8hRH1i6eFNr 6jMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Mv/7ew43"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-92430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w18-20020a056a0014d200b006e64772d362si5260pfu.399.2024.03.05.05.26.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 05:26:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Mv/7ew43"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-92430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 408122853E7 for ; Tue, 5 Mar 2024 13:26:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2877C85C69; Tue, 5 Mar 2024 13:26:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Mv/7ew43" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34CBE85645; Tue, 5 Mar 2024 13:25:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709645160; cv=none; b=k7yICnulDX26Woku98Xrk5NiSLZQ4yPCXd5v5BOociKSA6fHGIrXXt/SXrqNgJbsj6o6X9pZnjgMohjL3KzhoRsU8XHkAkAeeEhzQFGECSD5RlrotARBLZhjNo3mZB3ir9+PG9bT+rH2jMHe4KIn5Xk146tQAl1jxg8x5lFjaT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709645160; c=relaxed/simple; bh=qGUY1dxiZirRGSYHab1JAkhMGDJpARkMldpVYyOZWJQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PIjqGekwug37oM/1HuUJxaMzn+Jg5ajUdh7WFz6YD/E8+ZlT/SBLJR/t/HdQwcUnreKQlinSqSpRN3tG2rrNcJRqvyW4+cMB5Rr933e/VsW/E6t4ju80AeZHROTZL6GsCHCutBvOmP/dixnpteVKgPHCYK1fSzl37xvX1v8mKKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Mv/7ew43; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61595C433C7; Tue, 5 Mar 2024 13:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709645159; bh=qGUY1dxiZirRGSYHab1JAkhMGDJpARkMldpVYyOZWJQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Mv/7ew43kGKZfV6Z49esHWEbBa1oKgnsWW1B4+H2IITQG67n7G6Ij+is7AO4J7SqU FQV680h4TdMx7AP/lBCrzLDXMVWnguNQP+HKRtqJZnds1ZYSrVyQlb18wwqQ8vsn+p C1qdeOzt+sbS6Zj8dDEOZK8SwXR9CDnuLD1GCYCs= Date: Tue, 5 Mar 2024 13:25:55 +0000 From: Greg KH To: Weitao Wang Cc: oneukum@suse.com, stern@rowland.harvard.edu, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, WeitaoWang@zhaoxin.com, stable@vger.kernel.org Subject: Re: [PATCH v3] USB:UAS:return ENODEV when submit urbs fail with device not attached Message-ID: <2024030530-trinity-triangle-c334@gregkh> References: <20240229193349.5407-1-WeitaoWang-oc@zhaoxin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240229193349.5407-1-WeitaoWang-oc@zhaoxin.com> On Fri, Mar 01, 2024 at 03:33:49AM +0800, Weitao Wang wrote: > In the scenario of entering hibernation with udisk in the system, if the > udisk was gone or resume fail in the thaw phase of hibernation. Its state > will be set to NOTATTACHED. At this point, usb_hub_wq was already freezed > and can't not handle disconnect event. Next, in the poweroff phase of > hibernation, SYNCHRONIZE_CACHE SCSI command will be sent to this udisk > when poweroff this scsi device, which will cause uas_submit_urbs to be > called to submit URB for sense/data/cmd pipe. However, these URBs will > submit fail as device was set to NOTATTACHED state. Then, uas_submit_urbs > will return a value SCSI_MLQUEUE_DEVICE_BUSY to the caller. That will lead > the SCSI layer go into an ugly loop and system fail to go into hibernation. > > On the other hand, when we specially check for -ENODEV in function > uas_queuecommand_lck, returning DID_ERROR to SCSI layer will cause device > poweroff fail and system shutdown instead of entering hibernation. > > To fix this issue, let uas_submit_urbs to return original generic error > when submitting URB failed. At the same time, we need to translate -ENODEV > to DID_NOT_CONNECT for the SCSI layer. > > Suggested-by: Oliver Neukum > Cc: stable@vger.kernel.org > Signed-off-by: Weitao Wang > --- > v2->v3 > - Modify the description of this patch. > - An error is returned directly when submitting URB fails. This change breaks the build, please be more careful: drivers/usb/storage/uas.c: In function ‘uas_submit_urbs’: drivers/usb/storage/uas.c:559:21: error: unused variable ‘urb’ [-Werror=unused-variable] 559 | struct urb *urb; | ^~~ thanks, greg k-h