Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2585978rbb; Wed, 28 Feb 2024 06:33:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUrCcFc5gsSN3WoZpbWqJVF8DQl/CThSX/NkcAU1nPZOSrzSjAEmH+uyMo+UxvqBWsm8EMi6vjNeNGGw5Iw/n+WnPfVHTdOwEC31rpenA== X-Google-Smtp-Source: AGHT+IE4gt6eGGlJz/FTHI5LVEKRVqle4UFRRBbY4nw0woNxKrl6fjwqCmuzXOSsHl1ucRrWqTlY X-Received: by 2002:a05:620a:2285:b0:787:f097:43bc with SMTP id o5-20020a05620a228500b00787f09743bcmr1689069qkh.74.1709130790031; Wed, 28 Feb 2024 06:33:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709130790; cv=pass; d=google.com; s=arc-20160816; b=sPsG0871nMjinErlIOhxoJ56M1TKxwogjft87S7xBqo6ZjY+MqUXS/v2EYfS9/mlzA ycFUt3LHb8+jl8lAueIgXbWHr6wUP62adRoXtVxEeqnBEq5QsuxDqBpi1DJXKWoenttZ msx913NuB+GUo878n8Q8kYf+PyJSK4mKX0FSM0fN3uwtHQ+CKw4vV9HTvX3VYde1hZZF DlvrPtkejb1YrE+wLzj5oBm2SvxbTY4o4xrbeLwmJj+8jdPOzu6cM4vaEqwdYjWPvW1W McDuALcGM7eJVkGIX5TIx99gCZLOfvCK4VVPgBjJalO3A2T6e/hyypBG7ZzpXGSRvvt1 CYYA== 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=s7hSgssM8O5XI5NlxQWfFBY9vCS1WtlMEDv6EiV7ayI=; fh=hwX5t5PcD+jXX93Xi9/7Tzv6Ie72BywNC5lT+QukDD4=; b=lr0zqnQIO6Bb3BCppxOQynH4UseL3EL5j60fdiDchkoZA4LbeDPzK9Ols695jcpCrU TaOzcS9tBoNyqTC7OSrGKTZQEIh2DBS3ppFcSGySAuLWbtCEW6T1wOORBbqEcKvN1nmF zfZ5wzCjsF0P0vpgjnLGiAZa+m5WkPm/DL04Cgnl+QyWDLvfOpEQopOri8fueB2SQTC3 PWeXTGkeO1jmTLF0MTouQ0cs8qr41GYP5nEpHTrQDaoS/wSDZfhV78NUmDmqDKoclrJx T2ncvSrncak1C55eAbAWYvoSAfQ+i0o0EkxK0XTC8OmXmuJx0eQdGC07ruBThSCH2yDL A6Pw==; 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-85187-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85187-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id vr10-20020a05620a55aa00b00787f75251a3si101204qkn.7.2024.02.28.06.33.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 06:33:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85187-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zhaoxin.com); spf=pass (google.com: domain of linux-kernel+bounces-85187-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85187-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C660C1C2154B for ; Wed, 28 Feb 2024 14:33:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD1AC15A488; Wed, 28 Feb 2024 14:33:02 +0000 (UTC) Received: from mx2.zhaoxin.com (mx2.zhaoxin.com [203.110.167.99]) (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 AEEC237140 for ; Wed, 28 Feb 2024 14:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.110.167.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709130782; cv=none; b=Ut0ZuNbeZb7wYsMNKNhXX5PSxu6FAiogX0PuVuO8JRx9G44jQBNFtuyi/whLYTfDf6d04XyBejv58AXQpTWhsMyuJQEIuMU6ro5O1oJ84iqXVhYACuGgoUrqwRfz438WyxCyERBtt9+ksnDJddQTf4ismjhpz5da23JpEdEVHhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709130782; c=relaxed/simple; bh=wqoB8zcfxjW73Uldj3tr5z78Zp+ZJv8D2kVrXyMTshI=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Xie9Elhqnal/n2f2jpGSMTAkSZ9w2dVT2eoo6JfGQhfJ6XFz6osn5LB4Pyt6F9IBne7YsjmV9MOU36zAiwIvICGYrbVuysOILc+K8Kd9sa89EHyXhRW5NKuB1E3cErh73rgq8FDSoOcY8hOGr6/O2lC99Ad9v2LEfhQo+Dc1T4M= 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=203.110.167.99 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: 1709130771-1eb14e0c7e4c120001-xx1T2L Received: from ZXSHMBX2.zhaoxin.com (ZXSHMBX2.zhaoxin.com [10.28.252.164]) by mx2.zhaoxin.com with ESMTP id wblIV0teK9jWjlKG (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 28 Feb 2024 22:32:51 +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; Wed, 28 Feb 2024 22:32:51 +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; Wed, 28 Feb 2024 22:32:50 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.164 Message-ID: <07e80d55-d766-1781-ffc9-fab9ddcd33e3@zhaoxin.com> X-Barracuda-RBL-Trusted-Forwarder: 10.29.8.21 Date: Thu, 29 Feb 2024 06:32:48 +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> From: "WeitaoWang-oc@zhaoxin.com" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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: 1709130771 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.36:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 2490 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.121446 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 16:00, Oliver Neukum wrote: > >> @@ -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 == -ENODEV) ? -ENODEV : SCSI_MLQUEUE_DEVICE_BUSY; > > Either we ought to use SCSI error codes or generic error codes. > There is no need to translate all but one error condition here. > static int uas_submit_urbs(struct scsi_cmnd *cmnd, @@ -562,10 +561,13 @@ 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) + err = uas_submit_sense_urb(cmnd, GFP_ATOMIC); + if (!err) + cmdinfo->state &= ~SUBMIT_STATUS_URB; + else if (err == -ENODEV) + return -ENODEV; + else return SCSI_MLQUEUE_DEVICE_BUSY; - cmdinfo->state &= ~SUBMIT_STATUS_URB; } if (cmdinfo->state & ALLOC_DATA_IN_URB) { @@ -582,6 +584,8 @@ 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); + if (err == -ENODEV) + return -ENODEV; return SCSI_MLQUEUE_DEVICE_BUSY; } cmdinfo->state &= ~SUBMIT_DATA_IN_URB; @@ -602,6 +606,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, if (err) { usb_unanchor_urb(cmdinfo->data_out_urb); uas_log_cmd_state(cmnd, "data out submit err", err); + if (err == -ENODEV) + return -ENODEV; return SCSI_MLQUEUE_DEVICE_BUSY; } cmdinfo->state &= ~SUBMIT_DATA_OUT_URB; @@ -621,6 +627,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, if (err) { usb_unanchor_urb(cmdinfo->cmd_urb); uas_log_cmd_state(cmnd, "cmd submit err", err); + if (err == -ENODEV) + return -ENODEV; return SCSI_MLQUEUE_DEVICE_BUSY; } 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! Weitao