|
@@ -62,7 +62,6 @@ struct uas_dev_info {
|
|
spinlock_t lock;
|
|
spinlock_t lock;
|
|
struct work_struct work;
|
|
struct work_struct work;
|
|
struct list_head inflight_list;
|
|
struct list_head inflight_list;
|
|
- struct list_head dead_list;
|
|
|
|
};
|
|
};
|
|
|
|
|
|
enum {
|
|
enum {
|
|
@@ -130,35 +129,6 @@ out:
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
}
|
|
}
|
|
|
|
|
|
-static void uas_mark_cmd_dead(struct uas_dev_info *devinfo,
|
|
|
|
- struct uas_cmd_info *cmdinfo,
|
|
|
|
- int result, const char *caller)
|
|
|
|
-{
|
|
|
|
- struct scsi_pointer *scp = (void *)cmdinfo;
|
|
|
|
- struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, SCp);
|
|
|
|
-
|
|
|
|
- uas_log_cmd_state(cmnd, caller);
|
|
|
|
- lockdep_assert_held(&devinfo->lock);
|
|
|
|
- WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED);
|
|
|
|
- cmdinfo->state |= COMMAND_ABORTED;
|
|
|
|
- cmdinfo->state &= ~IS_IN_WORK_LIST;
|
|
|
|
- cmnd->result = result << 16;
|
|
|
|
- list_move_tail(&cmdinfo->list, &devinfo->dead_list);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static void uas_abort_inflight(struct uas_dev_info *devinfo, int result,
|
|
|
|
- const char *caller)
|
|
|
|
-{
|
|
|
|
- struct uas_cmd_info *cmdinfo;
|
|
|
|
- struct uas_cmd_info *temp;
|
|
|
|
- unsigned long flags;
|
|
|
|
-
|
|
|
|
- spin_lock_irqsave(&devinfo->lock, flags);
|
|
|
|
- list_for_each_entry_safe(cmdinfo, temp, &devinfo->inflight_list, list)
|
|
|
|
- uas_mark_cmd_dead(devinfo, cmdinfo, result, caller);
|
|
|
|
- spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static void uas_add_work(struct uas_cmd_info *cmdinfo)
|
|
static void uas_add_work(struct uas_cmd_info *cmdinfo)
|
|
{
|
|
{
|
|
struct scsi_pointer *scp = (void *)cmdinfo;
|
|
struct scsi_pointer *scp = (void *)cmdinfo;
|
|
@@ -170,7 +140,7 @@ static void uas_add_work(struct uas_cmd_info *cmdinfo)
|
|
schedule_work(&devinfo->work);
|
|
schedule_work(&devinfo->work);
|
|
}
|
|
}
|
|
|
|
|
|
-static void uas_zap_dead(struct uas_dev_info *devinfo)
|
|
|
|
|
|
+static void uas_zap_pending(struct uas_dev_info *devinfo, int result)
|
|
{
|
|
{
|
|
struct uas_cmd_info *cmdinfo;
|
|
struct uas_cmd_info *cmdinfo;
|
|
struct uas_cmd_info *temp;
|
|
struct uas_cmd_info *temp;
|
|
@@ -182,11 +152,11 @@ static void uas_zap_dead(struct uas_dev_info *devinfo)
|
|
struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd,
|
|
struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd,
|
|
SCp);
|
|
SCp);
|
|
uas_log_cmd_state(cmnd, __func__);
|
|
uas_log_cmd_state(cmnd, __func__);
|
|
- WARN_ON_ONCE(!(cmdinfo->state & COMMAND_ABORTED));
|
|
|
|
/* all urbs are killed, clear inflight bits */
|
|
/* all urbs are killed, clear inflight bits */
|
|
cmdinfo->state &= ~(COMMAND_INFLIGHT |
|
|
cmdinfo->state &= ~(COMMAND_INFLIGHT |
|
|
DATA_IN_URB_INFLIGHT |
|
|
DATA_IN_URB_INFLIGHT |
|
|
DATA_OUT_URB_INFLIGHT);
|
|
DATA_OUT_URB_INFLIGHT);
|
|
|
|
+ cmnd->result = result << 16;
|
|
uas_try_complete(cmnd, __func__);
|
|
uas_try_complete(cmnd, __func__);
|
|
}
|
|
}
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
@@ -765,11 +735,11 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
|
|
devinfo->resetting = 1;
|
|
devinfo->resetting = 1;
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
|
|
|
|
- uas_abort_inflight(devinfo, DID_RESET, __func__);
|
|
|
|
usb_kill_anchored_urbs(&devinfo->cmd_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->cmd_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->sense_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->sense_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->data_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->data_urbs);
|
|
- uas_zap_dead(devinfo);
|
|
|
|
|
|
+ uas_zap_pending(devinfo, DID_RESET);
|
|
|
|
+
|
|
err = usb_reset_device(udev);
|
|
err = usb_reset_device(udev);
|
|
|
|
|
|
spin_lock_irqsave(&devinfo->lock, flags);
|
|
spin_lock_irqsave(&devinfo->lock, flags);
|
|
@@ -952,7 +922,6 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
|
spin_lock_init(&devinfo->lock);
|
|
spin_lock_init(&devinfo->lock);
|
|
INIT_WORK(&devinfo->work, uas_do_work);
|
|
INIT_WORK(&devinfo->work, uas_do_work);
|
|
INIT_LIST_HEAD(&devinfo->inflight_list);
|
|
INIT_LIST_HEAD(&devinfo->inflight_list);
|
|
- INIT_LIST_HEAD(&devinfo->dead_list);
|
|
|
|
|
|
|
|
result = uas_configure_endpoints(devinfo);
|
|
result = uas_configure_endpoints(devinfo);
|
|
if (result)
|
|
if (result)
|
|
@@ -1080,11 +1049,11 @@ static void uas_disconnect(struct usb_interface *intf)
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
spin_unlock_irqrestore(&devinfo->lock, flags);
|
|
|
|
|
|
cancel_work_sync(&devinfo->work);
|
|
cancel_work_sync(&devinfo->work);
|
|
- uas_abort_inflight(devinfo, DID_NO_CONNECT, __func__);
|
|
|
|
usb_kill_anchored_urbs(&devinfo->cmd_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->cmd_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->sense_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->sense_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->data_urbs);
|
|
usb_kill_anchored_urbs(&devinfo->data_urbs);
|
|
- uas_zap_dead(devinfo);
|
|
|
|
|
|
+ uas_zap_pending(devinfo, DID_NO_CONNECT);
|
|
|
|
+
|
|
scsi_remove_host(shost);
|
|
scsi_remove_host(shost);
|
|
uas_free_streams(devinfo);
|
|
uas_free_streams(devinfo);
|
|
scsi_host_put(shost);
|
|
scsi_host_put(shost);
|