lkml.org 
[lkml]   [2024]   [Feb]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH v2] USB:UAS:return ENODEV when submit urbs fail with device not attached.
From
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



\
 
 \ /
  Last update: 2024-05-27 15:26    [W:0.064 / U:1.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site