diff options
author | Bean Huo <beanhuo@micron.com> | 2020-01-20 14:08:19 +0100 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2020-01-20 19:16:10 -0500 |
commit | 731f06216df3d605c466571a1c89222b4cca2fbc (patch) | |
tree | dbec5ce107aeff6dd30be7939d6ab88bbcef368a /drivers/scsi/ufs/ufshcd.c | |
parent | 046c1e6f2707890a2e64f3f15388ca389aaebcbf (diff) | |
download | linux-731f06216df3d605c466571a1c89222b4cca2fbc.tar.bz2 |
scsi: ufs: Add max_lu_supported in struct ufs_dev_info
Add one new parameter max_lu_supported in struct ufs_dev_info, which will
be used to express exactly how many general LUs being supported by UFS
device, and initialize it during booting stage. This patch also adds a new
function ufshcd_device_geo_params_init() for initialization of UFS device
geometry descriptor related parameters.
Link: https://lore.kernel.org/r/20200120130820.1737-8-huobean@gmail.com
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/ufs/ufshcd.c')
-rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 80e2261fc144..7e710ff47b67 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6861,6 +6861,37 @@ static void ufshcd_init_desc_sizes(struct ufs_hba *hba) hba->desc_size.hlth_desc = QUERY_DESC_HEALTH_DEF_SIZE; } +static int ufshcd_device_geo_params_init(struct ufs_hba *hba) +{ + int err; + size_t buff_len; + u8 *desc_buf; + + buff_len = hba->desc_size.geom_desc; + desc_buf = kmalloc(buff_len, GFP_KERNEL); + if (!desc_buf) { + err = -ENOMEM; + goto out; + } + + err = ufshcd_read_desc(hba, QUERY_DESC_IDN_GEOMETRY, 0, + desc_buf, buff_len); + if (err) { + dev_err(hba->dev, "%s: Failed reading Geometry Desc. err = %d\n", + __func__, err); + goto out; + } + + if (desc_buf[GEOMETRY_DESC_PARAM_MAX_NUM_LUN] == 1) + hba->dev_info.max_lu_supported = 32; + else if (desc_buf[GEOMETRY_DESC_PARAM_MAX_NUM_LUN] == 0) + hba->dev_info.max_lu_supported = 8; + +out: + kfree(desc_buf); + return err; +} + static struct ufs_ref_clk ufs_ref_clk_freqs[] = { {19200000, REF_CLK_FREQ_19_2_MHZ}, {26000000, REF_CLK_FREQ_26_MHZ}, @@ -6934,9 +6965,17 @@ static int ufshcd_device_params_init(struct ufs_hba *hba) bool flag; int ret; + /* Clear any previous UFS device information */ + memset(&hba->dev_info, 0, sizeof(hba->dev_info)); + /* Init check for device descriptor sizes */ ufshcd_init_desc_sizes(hba); + /* Init UFS geometry descriptor related parameters */ + ret = ufshcd_device_geo_params_init(hba); + if (ret) + goto out; + /* Check and apply UFS device quirks */ ret = ufs_get_device_desc(hba); if (ret) { @@ -6947,8 +6986,6 @@ static int ufshcd_device_params_init(struct ufs_hba *hba) ufs_fixup_device_setup(hba); - /* Clear any previous UFS device information */ - memset(&hba->dev_info, 0, sizeof(hba->dev_info)); if (!ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG, QUERY_FLAG_IDN_PWR_ON_WPE, &flag)) hba->dev_info.f_power_on_wp_en = flag; |