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

Commit 8c98552d 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: serialize h8 and device command contexts"

parents b1c1ac2d 01c94004
Loading
Loading
Loading
Loading
+37 −20
Original line number Diff line number Diff line
@@ -3445,18 +3445,6 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
	int tag;
	struct completion wait;
	unsigned long flags;
	bool has_read_lock = false;

	/*
	 * May get invoked from shutdown and IOCTL contexts.
	 * In shutdown context, it comes in with lock acquired.
	 * In error recovery context, it may come with lock acquired.
	 */

	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba)) {
		down_read(&hba->lock);
		has_read_lock = true;
	}

	/*
	 * Get free slot, sleep if slots are unavailable.
@@ -3489,8 +3477,6 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
out_put_tag:
	ufshcd_put_dev_cmd_tag(hba, tag);
	wake_up(&hba->dev_cmd.tag_wq);
	if (has_read_lock)
		up_read(&hba->lock);
	return err;
}

@@ -3565,10 +3551,15 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
	struct ufs_query_res *response = NULL;
	int err, index = 0, selector = 0;
	int timeout = QUERY_REQ_TIMEOUT;
	bool has_read_lock = false;

	BUG_ON(!hba);

	ufshcd_hold_all(hba);
	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba)) {
		down_read(&hba->lock);
		has_read_lock = true;
	}
	mutex_lock(&hba->dev_cmd.lock);
	ufshcd_init_query(hba, &request, &response, opcode, idn, index,
			selector);
@@ -3612,6 +3603,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,

out_unlock:
	mutex_unlock(&hba->dev_cmd.lock);
	if (has_read_lock)
		up_read(&hba->lock);
	ufshcd_release_all(hba);
	return err;
}
@@ -3634,6 +3627,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
	struct ufs_query_req *request = NULL;
	struct ufs_query_res *response = NULL;
	int err;
	bool has_read_lock = false;

	BUG_ON(!hba);

@@ -3645,6 +3639,16 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
		goto out;
	}

	/*
	 * May get invoked from shutdown and IOCTL contexts.
	 * In shutdown context, it comes in with lock acquired.
	 * In error recovery context, it may come with lock acquired.
	 */

	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba)) {
		down_read(&hba->lock);
		has_read_lock = true;
	}
	mutex_lock(&hba->dev_cmd.lock);
	ufshcd_init_query(hba, &request, &response, opcode, idn, index,
			selector);
@@ -3677,6 +3681,8 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,

out_unlock:
	mutex_unlock(&hba->dev_cmd.lock);
	if (has_read_lock)
		up_read(&hba->lock);
out:
	ufshcd_release_all(hba);
	return err;
@@ -3727,6 +3733,7 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
	struct ufs_query_req *request = NULL;
	struct ufs_query_res *response = NULL;
	int err;
	bool has_read_lock = false;

	BUG_ON(!hba);

@@ -3745,6 +3752,10 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
		goto out;
	}

	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba)) {
		down_read(&hba->lock);
		has_read_lock = true;
	}
	mutex_lock(&hba->dev_cmd.lock);
	ufshcd_init_query(hba, &request, &response, opcode, idn, index,
			selector);
@@ -3780,6 +3791,9 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,

out_unlock:
	mutex_unlock(&hba->dev_cmd.lock);
	if (has_read_lock)
		up_read(&hba->lock);

out:
	ufshcd_release_all(hba);
	return err;
@@ -5301,8 +5315,13 @@ static int ufshcd_verify_dev_init(struct ufs_hba *hba)
{
	int err = 0;
	int retries;
	bool has_read_lock = false;

	ufshcd_hold_all(hba);
	if (!ufshcd_is_shutdown_ongoing(hba) && !ufshcd_eh_in_progress(hba)) {
		down_read(&hba->lock);
		has_read_lock = true;
	}
	mutex_lock(&hba->dev_cmd.lock);
	for (retries = NOP_OUT_RETRIES; retries > 0; retries--) {
		err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_NOP,
@@ -5314,6 +5333,8 @@ static int ufshcd_verify_dev_init(struct ufs_hba *hba)
		dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, err);
	}
	mutex_unlock(&hba->dev_cmd.lock);
	if (has_read_lock)
		up_read(&hba->lock);
	ufshcd_release_all(hba);

	if (err)
@@ -10251,12 +10272,9 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
		 * e.g. link_recovery. Hence, release the rw_sem
		 * before hibern8.
		 */
		up_write(&hba->lock);
		ret = ufshcd_uic_hibern8_enter(hba);
		down_write(&hba->lock);
		if (ret)
			/* link will be bad state so no need to scale_up_gear */
			return ret;
			goto scale_up_gear;
		ufshcd_custom_cmd_log(hba, "Hibern8-entered");
	}

@@ -10268,8 +10286,7 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
	if (ufshcd_is_auto_hibern8_supported(hba)) {
		ret = ufshcd_uic_hibern8_exit(hba);
		if (ret)
			/* link will be bad state so no need to scale_up_gear */
			return ret;
			goto scale_up_gear;
		ufshcd_custom_cmd_log(hba, "Hibern8-Exited");
	}