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

Commit ae89f176 authored by Can Guo's avatar Can Guo
Browse files

scsi: ufs-qti: Remove the second init in hba probe path



As Lahaina is PORed with UFS ver 3.0, UFS PHY is initialized with G4
settings by default, thus no need to do the second init after find out
the connected UFS is a ver 3.0 device.

Change-Id: I1a1819c4938e40e669a1aed62309a8004c3164b9
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
parent 278cc639
Loading
Loading
Loading
Loading
+2 −45
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2013-2019, Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2020, Linux Foundation. All rights reserved.
 */

#include <linux/async.h>
@@ -8246,25 +8246,6 @@ static int ufs_read_device_desc_data(struct ufs_hba *hba)
	return err;
}

static inline bool ufshcd_needs_reinit(struct ufs_hba *hba)
{
	bool reinit = false;

	if (hba->dev_info.w_spec_version < 0x300 && hba->phy_init_g4) {
		dev_warn(hba->dev, "%s: Using force-g4 setting for a non-g4 device, re-init\n",
				  __func__);
		hba->phy_init_g4 = false;
		reinit = true;
	} else if (hba->dev_info.w_spec_version >= 0x300 && !hba->phy_init_g4) {
		dev_warn(hba->dev, "%s: Re-init UFS host to use proper PHY settings for the UFS device. This can be avoided by setting the force-g4 in DT\n",
				  __func__);
		hba->phy_init_g4 = true;
		reinit = true;
	}

	return reinit;
}

/**
 * ufshcd_probe_hba - probe hba to detect device and initialize
 * @hba: per-adapter instance
@@ -8278,7 +8259,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
	ktime_t start = ktime_get();

	dev_err(hba->dev, "*** This is %s ***\n", __FILE__);
reinit:

	ret = ufshcd_link_startup(hba);
	if (ret)
		goto out;
@@ -8318,27 +8299,6 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
		goto out;
	}

	if (ufshcd_needs_reinit(hba)) {
		unsigned long flags;
		int err;

		err = ufshcd_reset_device(hba);
		if (err)
			dev_warn(hba->dev, "%s: device reset failed. err %d\n",
				 __func__, err);

		/* Reset the host controller */
		spin_lock_irqsave(hba->host->host_lock, flags);
		ufshcd_hba_stop(hba, false);
		spin_unlock_irqrestore(hba->host->host_lock, flags);

		err = ufshcd_hba_enable(hba);
		if (err)
			goto out;

		goto reinit;
	}

	ufs_fixup_device_setup(hba, &card);
	ufshcd_tune_unipro_params(hba);

@@ -10032,9 +9992,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
		dev_warn(hba->dev, "%s: device reset failed. err %d\n",
			 __func__, err);

	if (hba->force_g4)
		hba->phy_init_g4 = true;

	/* Init crypto */
	err = ufshcd_hba_init_crypto(hba);
	if (err) {
+1 −3
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
 *
 * This code is based on drivers/scsi/ufs/ufshcd.h
 * Copyright (C) 2011-2013 Samsung India Software Operations
 * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
 *
 * Authors:
 *	Santosh Yaraganavi <santosh.sy@samsung.com>
@@ -918,7 +918,6 @@ struct ufs_hba {
#define UFSHCD_CAP_POWER_COLLAPSE_DURING_HIBERN8 (1 << 7)
	/* Allow standalone Hibern8 enter on idle */
#define UFSHCD_CAP_HIBERN8_ENTER_ON_IDLE (1 << 5)
	bool phy_init_g4;
	struct rw_semaphore lock;
	struct pinctrl *pctrl;
	/* Bitmask for enabling debug prints */
@@ -939,7 +938,6 @@ struct ufs_hba {
	bool auto_h8_err;
	struct work_struct rls_work;
	u32 dev_ref_clk_gating_wait;
	bool force_g4;
#endif
	struct devfreq *devfreq;
	struct ufs_clk_scaling clk_scaling;