Commit da3033ea authored by Hans de Goede's avatar Hans de Goede Committed by Sarah Sharp
Browse files

uas: add uas_mark_cmd_dead helper function


Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
parent 61c09ce5
...@@ -146,6 +146,21 @@ static void uas_do_work(struct work_struct *work) ...@@ -146,6 +146,21 @@ static void uas_do_work(struct work_struct *work)
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, 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);
WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED);
cmdinfo->state |= COMMAND_ABORTED;
cmdinfo->state &= ~IS_IN_WORK_LIST;
list_del(&cmdinfo->inflight);
list_add_tail(&cmdinfo->dead, &devinfo->dead_list);
}
static void uas_abort_inflight(struct uas_dev_info *devinfo) static void uas_abort_inflight(struct uas_dev_info *devinfo)
{ {
struct uas_cmd_info *cmdinfo; struct uas_cmd_info *cmdinfo;
...@@ -154,17 +169,8 @@ static void uas_abort_inflight(struct uas_dev_info *devinfo) ...@@ -154,17 +169,8 @@ static void uas_abort_inflight(struct uas_dev_info *devinfo)
spin_lock_irqsave(&devinfo->lock, flags); spin_lock_irqsave(&devinfo->lock, flags);
list_for_each_entry_safe(cmdinfo, temp, &devinfo->inflight_list, list_for_each_entry_safe(cmdinfo, temp, &devinfo->inflight_list,
inflight) { inflight)
struct scsi_pointer *scp = (void *)cmdinfo; uas_mark_cmd_dead(devinfo, cmdinfo, __func__);
struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd,
SCp);
uas_log_cmd_state(cmnd, __func__);
WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED);
cmdinfo->state |= COMMAND_ABORTED;
cmdinfo->state &= ~IS_IN_WORK_LIST;
list_del(&cmdinfo->inflight);
list_add_tail(&cmdinfo->dead, &devinfo->dead_list);
}
spin_unlock_irqrestore(&devinfo->lock, flags); spin_unlock_irqrestore(&devinfo->lock, flags);
} }
...@@ -806,13 +812,8 @@ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) ...@@ -806,13 +812,8 @@ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
unsigned long flags; unsigned long flags;
int ret; int ret;
uas_log_cmd_state(cmnd, __func__);
spin_lock_irqsave(&devinfo->lock, flags); spin_lock_irqsave(&devinfo->lock, flags);
WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED); uas_mark_cmd_dead(devinfo, cmdinfo, __func__);
cmdinfo->state |= COMMAND_ABORTED;
cmdinfo->state &= ~IS_IN_WORK_LIST;
list_del(&cmdinfo->inflight);
list_add_tail(&cmdinfo->dead, &devinfo->dead_list);
if (cmdinfo->state & COMMAND_INFLIGHT) { if (cmdinfo->state & COMMAND_INFLIGHT) {
spin_unlock_irqrestore(&devinfo->lock, flags); spin_unlock_irqrestore(&devinfo->lock, flags);
ret = uas_eh_task_mgmt(cmnd, "ABORT TASK", TMF_ABORT_TASK); ret = uas_eh_task_mgmt(cmnd, "ABORT TASK", TMF_ABORT_TASK);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment