From 3933ba3d842d037269dff56a5c7454c9b21e863d Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Tue, 22 Sep 2020 01:29:15 +0530 Subject: [PATCH] scsi: ufs: Don't skip UFS probe in emmc based bootdevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As a part of sync-state callback feature introduced in 5.4, clocks which are enabled by default with the hold-state mechanism during bootloader will be automatically disabled when the clock provider’s i.e gcc sync-state callback triggers. So clocks enabled from boot will be cleaned up in sync-state call back. The sync-state callback is triggered when all consumers of a given supplier(gcc here) have successfully probed. In current implementation, in emmc based bootdevice, we return UFS platform driver probe failure with reason as ENODEV which will cause the GCC sync-state callback not getting fired and hence leaving the ufs clocks in enabled state. So for the gcc sync state to be successful so as to remove proxy vote for all gcc consumer ,we must not bail out and let UFS platform driver probes successfully. Later as a part of async scan, when UFS device detection and initialisation fails, we can turn off power/clocks as a part of hba exit. Change-Id: Icfcc8ceb76399f6e37454d356a5f9767f30dd4b3 Signed-off-by: Nitin Rawat --- drivers/scsi/ufs/ufs-qcom.c | 14 ++++++++------ drivers/scsi/ufs/ufshcd.c | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index d830784c5fa8..c6e51be47ee9 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -38,6 +38,9 @@ #define UFS_QCOM_DEFAULT_DBG_PRINT_EN \ (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN) +#define ANDROID_BOOT_DEV_MAX 30 +static char android_boot_dev[ANDROID_BOOT_DEV_MAX]; + enum { TSTBUS_UAWM, TSTBUS_UARM, @@ -975,9 +978,14 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba, int err = 0; struct ufs_qcom_host *host = ufshcd_get_variant(hba); struct phy *phy = host->generic_phy; + struct device *dev = hba->dev; switch (status) { case PRE_CHANGE: + if (strlen(android_boot_dev) && strcmp(android_boot_dev, dev_name(dev))) { + return -ENODEV; + } + if (ufs_qcom_cfg_timers(hba, UFS_PWM_G1, SLOWAUTO_MODE, 0, true)) { dev_err(hba->dev, "%s: ufs_qcom_cfg_timers() failed\n", @@ -2051,9 +2059,6 @@ static const struct reset_control_ops ufs_qcom_reset_ops = { .deassert = ufs_qcom_reset_deassert, }; -#define ANDROID_BOOT_DEV_MAX 30 -static char android_boot_dev[ANDROID_BOOT_DEV_MAX]; - #ifndef MODULE static int __init get_android_boot_dev(char *str) { @@ -2640,9 +2645,6 @@ static int ufs_qcom_init(struct ufs_hba *hba) struct ufs_qcom_host *host; struct resource *res; - if (strlen(android_boot_dev) && strcmp(android_boot_dev, dev_name(dev))) - return -ENODEV; - host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); if (!host) { err = -ENOMEM; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 6a3d365d3498..4cc818931f10 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4687,7 +4687,9 @@ static int ufshcd_link_startup(struct ufs_hba *hba) link_startup: do { - ufshcd_vops_link_startup_notify(hba, PRE_CHANGE); + ret = ufshcd_vops_link_startup_notify(hba, PRE_CHANGE); + if (ret == -ENODEV) + return ret; ret = ufshcd_dme_link_startup(hba);