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

Commit 982af549 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: add power param check to avoid illegal value configuration"

parents 2287593f 386af664
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -2173,6 +2173,12 @@ static int ufshcd_config_max_pwr_mode(struct ufs_hba *hba)
	ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDRXDATALANES), &lanes[RX]);
	ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES), &lanes[TX]);

	if (!lanes[RX] || !lanes[TX]) {
		dev_err(hba->dev, "%s: invalid connected lanes value. rx=%d, tx=%d\n",
				__func__, lanes[RX], lanes[TX]);
		return -EINVAL;
	}

	/*
	 * First, get the maximum gears of HS speed.
	 * If a zero value, it means there is no HSGEAR capability.
@@ -2181,6 +2187,11 @@ static int ufshcd_config_max_pwr_mode(struct ufs_hba *hba)
	ufshcd_dme_get(hba, UIC_ARG_MIB(PA_MAXRXHSGEAR), &gear[RX]);
	if (!gear[RX]) {
		ufshcd_dme_get(hba, UIC_ARG_MIB(PA_MAXRXPWMGEAR), &gear[RX]);
		if (!gear[RX]) {
			dev_err(hba->dev, "%s: invalid rx gear read = %d\n",
				__func__, gear[RX]);
			return -EINVAL;
		}
		pwr[RX] = SLOWAUTO_MODE;
	}

@@ -2188,6 +2199,11 @@ static int ufshcd_config_max_pwr_mode(struct ufs_hba *hba)
	if (!gear[TX]) {
		ufshcd_dme_peer_get(hba, UIC_ARG_MIB(PA_MAXRXPWMGEAR),
				    &gear[TX]);
		if (!gear[TX]) {
			dev_err(hba->dev, "%s: invalid tx gear read = %d\n",
				__func__, gear[TX]);
			return -EINVAL;
		}
		pwr[TX] = SLOWAUTO_MODE;
	}

@@ -4005,7 +4021,10 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
	ufshcd_force_reset_auto_bkops(hba);
	hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;

	ufshcd_config_max_pwr_mode(hba);
	if (ufshcd_config_max_pwr_mode(hba))
		dev_err(hba->dev,
			"%s: Failed configuring max supported power mode\n",
			__func__);

	/*
	 * If we are in error handling context or in power management callbacks