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

Commit 3ffa80f9 authored by Yaniv Gardi's avatar Yaniv Gardi
Browse files

scsi: ufs: fix inconsistency of power mode when error is injected



There is an inconsistency between the actual power mode of the
UFS controller (and UFS device), to the power mode informed to upper
layers in case an error is injected during ERR_INJECT_PWR_CHANGE
scenario. Meaning, power change error is reported although the power
mode has actually changed successfully in the controller and in the
device. This change fixes this inconsistency.

Also, this change fixes a bug where a pointer to u8 is sent as
a pointer to int, which results undesired behavior.

Also, this change removes unused error injection scenarios:
- ERR_INJECT_HIBERN8_ENTER
- ERR_INJECT_HIBERN8_EXIT

Change-Id: I14116656862e3db8f5d6a93b5c798a1470a6b716
Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
parent f738a338
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -106,16 +106,6 @@ static struct ufsdbg_err_scenario err_scen_arr[] = {
		err_inject_intr_err_codes,
		ARRAY_SIZE(err_inject_intr_err_codes),
	},
	{
		"ERR_INJECT_HIBERN8_ENTER",
		NULL,
		0,
	},
	{
		"ERR_INJECT_HIBERN8_EXIT",
		NULL,
		0,
	},
	{
		"ERR_INJECT_PWR_CHANGE",
		err_inject_pwr_change_err_codes,
@@ -287,8 +277,6 @@ void ufsdbg_error_inject_dispatcher(struct ufs_hba *hba,

		ufsdbg_intr_fail_request(hba, (u32 *)&opt_ret);
		/* fall through */
	case ERR_INJECT_HIBERN8_ENTER:
	case ERR_INJECT_HIBERN8_EXIT:
	case ERR_INJECT_PWR_CHANGE:
	case ERR_INJECT_UIC:
	case ERR_INJECT_DME_ATTR:
+0 −2
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@

enum ufsdbg_err_inject_scenario {
	ERR_INJECT_INTR,
	ERR_INJECT_HIBERN8_ENTER,
	ERR_INJECT_HIBERN8_EXIT,
	ERR_INJECT_PWR_CHANGE,
	ERR_INJECT_UIC,
	ERR_INJECT_DME_ATTR,
+17 −10
Original line number Diff line number Diff line
@@ -2845,8 +2845,11 @@ static inline void ufshcd_init_query(struct ufs_hba *hba,
		struct ufs_query_req **request, struct ufs_query_res **response,
		enum query_opcode opcode, u8 idn, u8 index, u8 selector)
{
	int idn_t = (int)idn;

	ufsdbg_error_inject_dispatcher(hba,
		ERR_INJECT_QUERY, idn, (int *)&idn);
		ERR_INJECT_QUERY, idn_t, (int *)&idn_t);
	idn = idn_t;

	*request = &hba->dev_cmd.query.request;
	*response = &hba->dev_cmd.query.response;
@@ -2939,7 +2942,7 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
	if (err) {
		dev_err(hba->dev,
			"%s: Sending flag query for idn %d failed, err = %d\n",
			__func__, idn, err);
			__func__, request->upiu_req.idn, err);
		goto out_unlock;
	}

@@ -3005,7 +3008,8 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,

	if (err) {
		dev_err(hba->dev, "%s: opcode 0x%.2x for idn %d failed, index %d, err = %d\n",
				__func__, opcode, idn, index, err);
				__func__, opcode,
				request->upiu_req.idn, index, err);
		goto out_unlock;
	}

@@ -3106,7 +3110,8 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,

	if (err) {
		dev_err(hba->dev, "%s: opcode 0x%.2x for idn %d failed, index %d, err = %d\n",
				__func__, opcode, idn, index, err);
				__func__, opcode,
				request->upiu_req.idn, index, err);
		goto out_unlock;
	}

@@ -4047,7 +4052,7 @@ static int ufshcd_get_max_pwr_mode(struct ufs_hba *hba)
int ufshcd_change_power_mode(struct ufs_hba *hba,
			     struct ufs_pa_layer_attr *pwr_mode)
{
	int ret;
	int ret = 0;

	/* if already configured to the requested pwr_mode */
	if (pwr_mode->gear_rx == hba->pwr_info.gear_rx &&
@@ -4061,6 +4066,10 @@ int ufshcd_change_power_mode(struct ufs_hba *hba,
		return 0;
	}

	ufsdbg_error_inject_dispatcher(hba, ERR_INJECT_PWR_CHANGE, 0, &ret);
	if (ret)
		return ret;

	/*
	 * Configure attributes for power mode change with below.
	 * - PA_RXGEAR, PA_ACTIVERXDATALANES, PA_RXTERMINATION,
@@ -4121,9 +4130,6 @@ int ufshcd_change_power_mode(struct ufs_hba *hba,
			sizeof(struct ufs_pa_layer_attr));
	}

	ufsdbg_error_inject_dispatcher(hba,
		ERR_INJECT_PWR_CHANGE, 0, &ret);

	return ret;
}

@@ -8400,10 +8406,11 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up)
	ret = ufshcd_change_power_mode(hba, &new_pwr_info);

	if (ret)
		dev_err(hba->dev, "%s: failed err %d, old gear: (tx %d rx %d), new gear: (tx %d rx %d)",
		dev_err(hba->dev, "%s: failed err %d, old gear: (tx %d rx %d), new gear: (tx %d rx %d), scale_up = %d",
			__func__, ret,
			hba->pwr_info.gear_tx, hba->pwr_info.gear_rx,
			new_pwr_info.gear_tx, new_pwr_info.gear_rx);
			new_pwr_info.gear_tx, new_pwr_info.gear_rx,
			scale_up);

	return ret;
}