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

Commit 8c166e48 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "scsi: ufs: issue request sense before sending Start Stop Unit"

parents ed69d2f1 cc14c8db
Loading
Loading
Loading
Loading
+36 −1
Original line number Diff line number Diff line
@@ -4347,6 +4347,35 @@ static void ufshcd_hba_exit(struct ufs_hba *hba)
	}
}

static int
ufshcd_send_request_sense(struct ufs_hba *hba, struct scsi_device *sdp)
{
	unsigned char cmd[6] = {REQUEST_SENSE,
				0,
				0,
				0,
				SCSI_SENSE_BUFFERSIZE,
				0};
	char *buffer;
	int ret;

	buffer = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
	if (!buffer) {
		ret = -ENOMEM;
		goto out;
	}

	ret = scsi_execute_req_flags(sdp, cmd, DMA_FROM_DEVICE, buffer,
				SCSI_SENSE_BUFFERSIZE, NULL,
				msecs_to_jiffies(1000), 3, NULL, REQ_PM);
	if (ret)
		pr_err("%s: failed with err %d\n", __func__, ret);

	kfree(buffer);
out:
	return ret;
}

/**
 * ufshcd_set_dev_pwr_mode - sends START STOP UNIT command to set device
 *			     power mode
@@ -4367,6 +4396,12 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
	if (!sdp || !scsi_device_online(sdp))
		return -ENODEV;

	if (pwr_mode != UFS_ACTIVE_PWR_MODE) {
		ret = ufshcd_send_request_sense(hba, sdp);
		if (ret)
			goto out;
	}

	cmd[4] = pwr_mode << 4;

	/*
@@ -4388,7 +4423,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,

	if (!ret)
		hba->curr_dev_pwr_mode = pwr_mode;

out:
	return ret;
}