Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp232063rbe; Wed, 28 Feb 2024 19:20:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWVs1z5B5Cez5qmCO0jySPBuFnMX76+Ovyiq3ZYPA8KYGcX6mWDB836y42MmYeFnH3m0OCO8bowR31ASDv4Yj/CSXs7s+cLWwfnLhL8mA== X-Google-Smtp-Source: AGHT+IEhvmTHm2IDIqFCxat6WCFyEmhg+ToYqS6ozEnEaL3tEOZp+EM4JyT1TnR7ZctAZ+Ll0Pnk X-Received: by 2002:a05:6e02:11a8:b0:365:32db:ca6d with SMTP id 8-20020a056e0211a800b0036532dbca6dmr1235356ilj.22.1709176829757; Wed, 28 Feb 2024 19:20:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709176829; cv=pass; d=google.com; s=arc-20160816; b=j5O8Xef32+03uYm+kHXfouq/CO67W3fJ7G3/yQHX9sb65DDZs8VWgMG23g7gEo7Xhq rgHScxiQ0uavBR9aWbVc9Cg8qaZK7yEVztuECe4WBtefxKSD7jc+V0UpV4ulFEoudOfW 3VaRgqA0YDuudGr34ED7LS01YWQgQdkOh7ugGP+w+n95Ri2QE1wPaSj/0tXAdlenKpJs YPZLT9u6JURyQO2uOhQiPidGDzWW08AtT1eUk9uVls60z5xheW+SKyALSp8dp3WE3HBb 9JfLroy4lRBmdxU2QaGvmy6kwhIQzzRVZDehGb7GrI45Xp5E4o1Ilpe7e04sYI4QCNET 8KTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=eALlSA5hxjmAd9AZlgOzuws3efxnPjM0A7sBDWdHbIY=; fh=hwX5t5PcD+jXX93Xi9/7Tzv6Ie72BywNC5lT+QukDD4=; b=BU4M1ZCvFpn9mGe5ndbmB3ZYHq4r2zLkdJuxBgfzU7F/KFOLvw6Xbp6+tVcQJOlJnO 5PGWRqtzz0mu/z0LO2AzweQD4SFqc9AUq71rOQcP+wyxAtodoa0TU8f4c4JJD51/3dab WCMFMyTQCeqdZooWz8N9u3bPv4rrq1J5SqiRUkkSBBL2sl0MFzSNeWqtyAaPHUbxtMGx 60PIzNsnGfsYjpXt1ZzKG/2SQNNBYXOJCSNoOwupHwRFy4gU3YN+PZ1Wv6c6Eip5YsHD ZINQ8h5vhVBG7lRZhdDv8mKNLFa1tIWQMwTulM31wlEMwrbqsWHOCVl8gpA6xUwaXEvw QWcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zhaoxin.com); spf=pass (google.com: domain of linux-kernel+bounces-86086-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86086-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v67-20020a632f46000000b005d8b69f8844si458880pgv.498.2024.02.28.19.20.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 19:20:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86086-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zhaoxin.com); spf=pass (google.com: domain of linux-kernel+bounces-86086-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86086-linux.lists.archive=gmail.com@vger.kernel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5F02FB22C6A for ; Thu, 29 Feb 2024 03:20:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D953B37165; Thu, 29 Feb 2024 03:20:07 +0000 (UTC) Received: from mx1.zhaoxin.com (MX1.ZHAOXIN.COM [210.0.225.12]) (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 787FC36B16 for ; Thu, 29 Feb 2024 03:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.0.225.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709176807; cv=none; b=Dskdg9enNZbF5DI9FTZGhE6ODDXKtxEDw1j16jAGdi0CwtK3zWhj0asf20NcGa2CB7WOKJKSc7NcDG5l8DBHDhCAQg5MpsSnuNAR3PJmY/OquOMt6lOcuh09B7iK65z2c/rqjzAdgGiW2ACQDmFSaR0WYnS3o64x5R01JNMYPiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709176807; c=relaxed/simple; bh=nWI0xfyfsyOczyWzPno9G0ANgOD4EpWps6XT4tWG26c=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=WaIC/pfUcrAjQUq5klxXx6vx5uocXF46QO6O+Qgf9wMPloFMqRfmYlq7twZRxWaQXEl9vaBcOPf/Ldf0rB7n271ckeUnjdpkOrxTR+tm00bFEuKZXoix8aTqhuFYpsVEyi4kfsLnN2f6yGLLoFcrq45+n9nxg3m1f3LfVw2ieYQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zhaoxin.com; spf=pass smtp.mailfrom=zhaoxin.com; arc=none smtp.client-ip=210.0.225.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zhaoxin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zhaoxin.com X-ASG-Debug-ID: 1709176794-086e2316ed02390001-xx1T2L Received: from ZXSHMBX2.zhaoxin.com (ZXSHMBX2.zhaoxin.com [10.28.252.164]) by mx1.zhaoxin.com with ESMTP id 1NWDjwmQUgYZ1sxI (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Thu, 29 Feb 2024 11:19:54 +0800 (CST) X-Barracuda-Envelope-From: WeitaoWang-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.164 Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHMBX2.zhaoxin.com (10.28.252.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 29 Feb 2024 11:19:54 +0800 Received: from [10.29.8.21] (10.29.8.21) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 29 Feb 2024 11:19:52 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.164 Message-ID: <0b0eefa5-71b6-dc08-d103-72b9aebd9237@zhaoxin.com> X-Barracuda-RBL-Trusted-Forwarder: 10.29.8.21 Date: Thu, 29 Feb 2024 19:19:49 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2] USB:UAS:return ENODEV when submit urbs fail with device not attached. Content-Language: en-US X-ASG-Orig-Subj: Re: [PATCH v2] USB:UAS:return ENODEV when submit urbs fail with device not attached. To: Oliver Neukum , , , , , , CC: , References: <20240228111521.3864-1-WeitaoWang-oc@zhaoxin.com> <07e80d55-d766-1781-ffc9-fab9ddcd33e3@zhaoxin.com> <49a365a7-199a-42cd-b8d3-86d72fe5bca6@suse.com> From: "WeitaoWang-oc@zhaoxin.com" In-Reply-To: <49a365a7-199a-42cd-b8d3-86d72fe5bca6@suse.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: ZXSHCAS2.zhaoxin.com (10.28.252.162) To zxbjmbx1.zhaoxin.com (10.29.252.163) X-Barracuda-Connect: ZXSHMBX2.zhaoxin.com[10.28.252.164] X-Barracuda-Start-Time: 1709176794 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.35:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 1699 X-Barracuda-BRTS-Status: 0 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: 1.09 X-Barracuda-Spam-Status: No, SCORE=1.09 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests=DATE_IN_FUTURE_06_12, DATE_IN_FUTURE_06_12_2 X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.121467 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.01 DATE_IN_FUTURE_06_12 Date: is 6 to 12 hours after Received: date 3.10 DATE_IN_FUTURE_06_12_2 DATE_IN_FUTURE_06_12_2 On 2024/2/28 22:47, Oliver Neukum wrote: >> I'm not sure I fully understand what your mean. >> Whether the above code is more reasonable? If not,could you give me some >> suggestion? Thanks for your help! > > You want to change uas_submit_urbs() to return the reason for > errors, because -ENODEV needs to be handled differently. That > is good. > But why don't you just do > > return err; > > unconditionally? There is no point in using SCSI_MLQUEUE_DEVICE_BUSY I got it, Thanks. New patch would like this sample: @@ -562,9 +561,9 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, lockdep_assert_held(&devinfo->lock); if (cmdinfo->state & SUBMIT_STATUS_URB) { - urb = uas_submit_sense_urb(cmnd, GFP_ATOMIC); - if (!urb) - return SCSI_MLQUEUE_DEVICE_BUSY; + err = uas_submit_sense_urb(cmnd, GFP_ATOMIC); + if (err) + return err; cmdinfo->state &= ~SUBMIT_STATUS_URB; } @@ -582,7 +581,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, if (err) { usb_unanchor_urb(cmdinfo->data_in_urb); uas_log_cmd_state(cmnd, "data in submit err", err); - return SCSI_MLQUEUE_DEVICE_BUSY; + return err; } When alloc urb fail in the same function uas_submit_urbs, whether we should replace SCSI_MLQUEUE_DEVICE_BUSY with generic error code -ENOMEM? Such like this: @@ -572,7 +571,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, GFP_ATOMIC, cmnd, DMA_FROM_DEVICE); if (!cmdinfo->data_in_urb) - return SCSI_MLQUEUE_DEVICE_BUSY; + return -ENOMEM; cmdinfo->state &= ~ALLOC_DATA_IN_URB; } Thanks and Best regards, Weitao