From: "WeitaoWang-oc@zhaoxin.com" <WeitaoWang-oc@zhaoxin.com>
To: Oliver Neukum <oneukum@suse.com>, <stern@rowland.harvard.edu>,
<gregkh@linuxfoundation.org>, <linux-usb@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<usb-storage@lists.one-eyed-alien.net>
Cc: <WeitaoWang@zhaoxin.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH v2] USB:UAS:return ENODEV when submit urbs fail with device not attached.
Date: Thu, 29 Feb 2024 06:32:48 +0800 [thread overview]
Message-ID: <07e80d55-d766-1781-ffc9-fab9ddcd33e3@zhaoxin.com> (raw)
In-Reply-To: <e8c4e8a3-bfc3-463f-afce-b9f600b588b2@suse.com>
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
next prev parent reply other threads:[~2024-02-28 14:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 11:15 [PATCH v2] USB:UAS:return ENODEV when submit urbs fail with device not attached Weitao Wang
2024-02-28 8:00 ` Oliver Neukum
2024-02-28 22:32 ` WeitaoWang-oc [this message]
2024-02-28 14:47 ` Oliver Neukum
2024-02-29 11:19 ` WeitaoWang-oc
2024-02-29 8:08 ` Oliver Neukum
2024-02-29 16:40 ` WeitaoWang-oc
2024-02-29 10:14 ` Oliver Neukum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=07e80d55-d766-1781-ffc9-fab9ddcd33e3@zhaoxin.com \
--to=weitaowang-oc@zhaoxin.com \
--cc=WeitaoWang@zhaoxin.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox