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

Commit ad17e926 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: fix deadlock between clock scaling and clock ungating work"

parents df9c2094 ded1a563
Loading
Loading
Loading
Loading
+12 −19
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
 *
 * This code is based on drivers/scsi/ufs/ufshcd.c
 * Copyright (C) 2011-2013 Samsung India Software Operations
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 *
 * Authors:
 *	Santosh Yaraganavi <santosh.sy@samsung.com>
@@ -183,15 +183,9 @@ void ufshcd_update_query_stats(struct ufs_hba *hba,
#define NOP_OUT_TIMEOUT    30 /* msecs */

/* Query request retries */
#define QUERY_REQ_RETRIES 10
#define QUERY_REQ_RETRIES 3
/* Query request timeout */
#define QUERY_REQ_TIMEOUT 100 /* msec */
/*
 * Query request timeout for fDeviceInit flag
 * fDeviceInit query response time for some devices is too large that default
 * QUERY_REQ_TIMEOUT may not be enough for such devices.
 */
#define QUERY_FDEVICEINIT_REQ_TIMEOUT 600 /* msec */
#define QUERY_REQ_TIMEOUT 1500 /* 1.5 seconds */

/* Task management command timeout */
#define TM_CMD_TIMEOUT	100 /* msecs */
@@ -2985,9 +2979,6 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
		goto out_unlock;
	}

	if (idn == QUERY_FLAG_IDN_FDEVICEINIT)
		timeout = QUERY_FDEVICEINIT_REQ_TIMEOUT;

	err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_QUERY, timeout);

	if (err) {
@@ -8620,17 +8611,18 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
{
	int ret = 0;

	/* let's not get into low power until clock scaling is completed */
	ufshcd_hold_all(hba);

	ret = ufshcd_clock_scaling_prepare(hba);
	if (ret)
		return ret;
		goto out;

	/* let's not get into low power until clock scaling is completed */
	ufshcd_hold_all(hba);
	/* scale down the gear before scaling down clocks */
	if (!scale_up) {
		ret = ufshcd_scale_gear(hba, false);
		if (ret)
			goto out;
			goto clk_scaling_unprepare;
	}

	ret = ufshcd_scale_clks(hba, scale_up);
@@ -8642,7 +8634,7 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
		ret = ufshcd_scale_gear(hba, true);
		if (ret) {
			ufshcd_scale_clks(hba, false);
			goto out;
			goto clk_scaling_unprepare;
		}
	}

@@ -8656,13 +8648,14 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
				hba->clk_gating.delay_ms_pwr_save;
	}

	goto out;
	goto clk_scaling_unprepare;

scale_up_gear:
	if (!scale_up)
		ufshcd_scale_gear(hba, true);
out:
clk_scaling_unprepare:
	ufshcd_clock_scaling_unprepare(hba);
out:
	ufshcd_release_all(hba);
	return ret;
}