Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

uas: Avoid unnecessary unlock / lock calls around unlink_data_urbs



All callers of unlink_data_urbs drop devinfo->lock before calling it, and
then immediately take it again after the call. And the first thing
unlink_data_urbs does is take the lock again, and the last thing it does
is drop it. This commit removes all the unnecessary lock dropping and taking.

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
parent 6ce8213b
Loading
Loading
Loading
Loading
+7 −13
Original line number Original line Diff line number Diff line
@@ -93,28 +93,26 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo);
static void uas_free_streams(struct uas_dev_info *devinfo);
static void uas_free_streams(struct uas_dev_info *devinfo);
static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller);
static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller);


/* Must be called with devinfo->lock held, will temporary unlock the lock */
static void uas_unlink_data_urbs(struct uas_dev_info *devinfo,
static void uas_unlink_data_urbs(struct uas_dev_info *devinfo,
				 struct uas_cmd_info *cmdinfo)
				 struct uas_cmd_info *cmdinfo,
				 unsigned long *lock_flags)
{
{
	unsigned long flags;

	/*
	/*
	 * The UNLINK_DATA_URBS flag makes sure uas_try_complete
	 * The UNLINK_DATA_URBS flag makes sure uas_try_complete
	 * (called by urb completion) doesn't release cmdinfo
	 * (called by urb completion) doesn't release cmdinfo
	 * underneath us.
	 * underneath us.
	 */
	 */
	spin_lock_irqsave(&devinfo->lock, flags);
	cmdinfo->state |= UNLINK_DATA_URBS;
	cmdinfo->state |= UNLINK_DATA_URBS;
	spin_unlock_irqrestore(&devinfo->lock, flags);
	spin_unlock_irqrestore(&devinfo->lock, *lock_flags);


	if (cmdinfo->data_in_urb)
	if (cmdinfo->data_in_urb)
		usb_unlink_urb(cmdinfo->data_in_urb);
		usb_unlink_urb(cmdinfo->data_in_urb);
	if (cmdinfo->data_out_urb)
	if (cmdinfo->data_out_urb)
		usb_unlink_urb(cmdinfo->data_out_urb);
		usb_unlink_urb(cmdinfo->data_out_urb);


	spin_lock_irqsave(&devinfo->lock, flags);
	spin_lock_irqsave(&devinfo->lock, *lock_flags);
	cmdinfo->state &= ~UNLINK_DATA_URBS;
	cmdinfo->state &= ~UNLINK_DATA_URBS;
	spin_unlock_irqrestore(&devinfo->lock, flags);
}
}


static void uas_do_work(struct work_struct *work)
static void uas_do_work(struct work_struct *work)
@@ -361,9 +359,7 @@ static void uas_stat_cmplt(struct urb *urb)
			uas_sense(urb, cmnd);
			uas_sense(urb, cmnd);
		if (cmnd->result != 0) {
		if (cmnd->result != 0) {
			/* cancel data transfers on error */
			/* cancel data transfers on error */
			spin_unlock_irqrestore(&devinfo->lock, flags);
			uas_unlink_data_urbs(devinfo, cmdinfo, &flags);
			uas_unlink_data_urbs(devinfo, cmdinfo);
			spin_lock_irqsave(&devinfo->lock, flags);
		}
		}
		cmdinfo->state &= ~COMMAND_INFLIGHT;
		cmdinfo->state &= ~COMMAND_INFLIGHT;
		uas_try_complete(cmnd, __func__);
		uas_try_complete(cmnd, __func__);
@@ -787,9 +783,7 @@ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
		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);
	} else {
	} else {
		spin_unlock_irqrestore(&devinfo->lock, flags);
		uas_unlink_data_urbs(devinfo, cmdinfo, &flags);
		uas_unlink_data_urbs(devinfo, cmdinfo);
		spin_lock_irqsave(&devinfo->lock, flags);
		uas_try_complete(cmnd, __func__);
		uas_try_complete(cmnd, __func__);
		spin_unlock_irqrestore(&devinfo->lock, flags);
		spin_unlock_irqrestore(&devinfo->lock, flags);
		ret = SUCCESS;
		ret = SUCCESS;