From patchwork Thu Jan 16 21:59:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41AAE138D for ; Thu, 16 Jan 2020 21:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F9A220728 for ; Thu, 16 Jan 2020 21:59:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="viJNfGYw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389025AbgAPV7k (ORCPT ); Thu, 16 Jan 2020 16:59:40 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39931 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729380AbgAPV7k (ORCPT ); Thu, 16 Jan 2020 16:59:40 -0500 Received: by mail-wm1-f68.google.com with SMTP id 20so5429657wmj.4; Thu, 16 Jan 2020 13:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KBosvAPP0dc526ycXRN2g+Rfl+cHTJgFFbNFy4NrI8A=; b=viJNfGYwFB32ZRt0l4pEQ2Fyp+biAk29ltieVXdLrTDc2jBp+49xtqBh8AK7djE86/ Kj+1cHMlskFP5ET5gyUjXhQuarMx4+LzauUCJujdpZfEyPPKXZe6DKwju9geXB/ifPOo 0lu6tclQ0z31A7xL03pNBRe3XD+kg/k1imHelvSrBFNvWrvXcfJ7QDUwhPCpXvsBkwu/ EkV63JoO7A1GhJrDwSGELnFs/hSxUW7fjrxhznfbF+6HtSCWLwKkvYWHs5kX2dp8pvjY kFm5OaiPscsISNxq+6AflSc+g6lpiWvKZVUP4VhI8UL9iuaqD6TVAn2rDVS6UUIq1IUf tHjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KBosvAPP0dc526ycXRN2g+Rfl+cHTJgFFbNFy4NrI8A=; b=pQJRLWHuGy8hbhzCH4tiWsOqo7OpILnxAef3z9/A40GnOXr717ZAWO0PvJErW7yzlp L/yQy3kFGZsrmszBnntXLWC+0Kr1JzQn/lbuYei8GhRCmpHESNESvG8X1ThtySLYSRJP c6A6aEKjE7LAtUYZf9mWWamRwKpErHJADFPqmoGQgOY0LvV5j+RCj3UkWBl+8TV23Nkj qeig9/7jyF3QEj6OB/wYALICbvf6AVNC3nXoX/130VoreBQEP/sW0UEnBSR2L/CDUGbD qmuX8AcLsWKtCp+HWjeZ5gwf5uroue4sVYVVzO9gB9XQDGrOpyw/scjAvQOJkXRtRuRm 2GOQ== X-Gm-Message-State: APjAAAVa9kJJbysqPdfn0Pc17Lu9T9VGLz/wIWqGg2GMasMhH0/SIn5m E/t3SNrmfMhODkGlRNGJ1nk= X-Google-Smtp-Source: APXvYqwUVXPPwu6xRjCfdWdgR3BQl4fcvW0MM0FMUhh2YikI0+UXDAO3x6lPSa5BHGgNuYT+wMNz8g== X-Received: by 2002:a1c:ded6:: with SMTP id v205mr1175994wmg.86.1579211978883; Thu, 16 Jan 2020 13:59:38 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.13.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 13:59:38 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/9] scsi: ufs: goto with returned value while failed to add WL Date: Thu, 16 Jan 2020 22:59:06 +0100 Message-Id: <20200116215914.16015-2-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo This patch is to make goto statement with failure result in case of failure of adding well known LUs. Fixes: 2a8fa600445c ("ufs: manually add well known logical units") Signed-off-by: Bean Huo Reviewed-by: Asutosh Das --- drivers/scsi/ufs/ufshcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index bea036ab189a..9a9085a7bcc5 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7032,7 +7032,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) ufshcd_init_icc_levels(hba); /* Add required well known logical units to scsi mid layer */ - if (ufshcd_scsi_add_wlus(hba)) + ret = ufshcd_scsi_add_wlus(hba); + if (ret) goto out; /* Initialize devfreq after UFS device is detected */ From patchwork Thu Jan 16 21:59:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9BC1138D for ; Thu, 16 Jan 2020 21:59:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74EF5207E0 for ; Thu, 16 Jan 2020 21:59:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nsyhgY0L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388928AbgAPV7x (ORCPT ); Thu, 16 Jan 2020 16:59:53 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33785 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733113AbgAPV7x (ORCPT ); Thu, 16 Jan 2020 16:59:53 -0500 Received: by mail-wr1-f65.google.com with SMTP id b6so20754274wrq.0; Thu, 16 Jan 2020 13:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GrVfE0XbnVtTL3mxNuVcV0b8AJTGYMsjcTQc4nb5aug=; b=nsyhgY0LoqidZoWeSmMnz1yQdHRQfN/I1Cu/ZBIXa9OjK1ZfdqcY/GZqr5guxbGWO1 FPcF4WQajNKG7EAiAD0xeJloJwUrKxFzdQ8quyVvB9evnz2PFP7sFpWyQWid/eQxde6W eR/DKBps5++NI0zDqv39ZtPpT/fjn0MUudvRSO9Cd4Na/CfPsHLxtlyOfGhjgB5Gghll DTAKQ8S0vg58s+F3AE1vL8LySPu4R6mn3Mt+XZOKk2LumwwP95AUqNmJOLwG7LkMvRXo vTgwcZbISZ4yHoR+i1zlmm8ptwGWcZ2MJ10qbkJr8DNC8Q1j9TO6W9jSL7fUXQqN2QPu McwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GrVfE0XbnVtTL3mxNuVcV0b8AJTGYMsjcTQc4nb5aug=; b=cCWc4TTCp1alNG9qf8KmsnC+UuTIw2KDVfNOx8nMW8H1lcTpiwosFHUZqbp2eV+Kvc YFh48eSmKmNeuG7Az+LtOIxWgp7iNkQ/mX5e1YZl1aifU2+KOCpFREvtIfUVHGkaIN/8 5xJAcxv+9At11qxBnoUtUAPUjwDmWG7WbmVSfKYrcx5CBUZY344UONz0wdr5kmNAf2rd jcxblQ9tl6ptRDvcQv+j+d1Pk2hLVR4Oyc6TKjLFD8GBVhXnLUDsfiNUJL09mueooBCM ncXHjv3c2HnIZqFN5NGOO5zjiLvUVKCoxBHRBztRmbguxW5BSNDXQCTwceiahck09VmX msyA== X-Gm-Message-State: APjAAAVVWLR+HQzKtfdorZZDlWhyqan6BPkr7Fksua0NJUQcSSB7NF4p nJOipccmFEV5N2Dd+JnJ5dU= X-Google-Smtp-Source: APXvYqy5ixLfQcuhBS8ZGzxpz9d52sfOeTK56Qvu622mss24elHYtFH863gE+WL65d0EXlYGnvG0lQ== X-Received: by 2002:a5d:65c5:: with SMTP id e5mr5406341wrw.311.1579211990434; Thu, 16 Jan 2020 13:59:50 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.13.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 13:59:49 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/9] scsi: ufs: Delete struct ufs_dev_desc Date: Thu, 16 Jan 2020 22:59:07 +0100 Message-Id: <20200116215914.16015-3-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo In consideration of Host driver uses some certain UFS device properties, move parameters of struct ufs_dev_desc to struct ufs_dev_info, and delete struct ufs_dev_desc. Signed-off-by: Bean Huo Reviewed-by: Bart Van Assche Reviewed-by: Asutosh Das --- drivers/scsi/ufs/ufs-mediatek.c | 7 ++--- drivers/scsi/ufs/ufs-qcom.c | 6 ++--- drivers/scsi/ufs/ufs.h | 11 +------- drivers/scsi/ufs/ufs_quirks.h | 9 ++++--- drivers/scsi/ufs/ufshcd.c | 47 +++++++++++++++------------------ drivers/scsi/ufs/ufshcd.h | 7 +++-- 6 files changed, 38 insertions(+), 49 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 8d999c0e60fe..f8dd992b6f3a 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -406,10 +406,11 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) return 0; } -static int ufs_mtk_apply_dev_quirks(struct ufs_hba *hba, - struct ufs_dev_desc *card) +static int ufs_mtk_apply_dev_quirks(struct ufs_hba *hba) { - if (card->wmanufacturerid == UFS_VENDOR_SAMSUNG) + struct ufs_dev_info *dev_info = hba->dev_info; + + if (dev_info->wmanufacturerid == UFS_VENDOR_SAMSUNG) ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 6); return 0; diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index ebb5c66e069f..9c6a182b3ed9 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -949,12 +949,12 @@ static int ufs_qcom_quirk_host_pa_saveconfigtime(struct ufs_hba *hba) return err; } -static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba, - struct ufs_dev_desc *card) +static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba) { int err = 0; + struct ufs_dev_info *dev_info = hba->dev_info; - if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME) + if (dev_info->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME) err = ufs_qcom_quirk_host_pa_saveconfigtime(hba); return err; diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index c89f21698629..fcc9b4d4e56f 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -530,17 +530,8 @@ struct ufs_dev_info { bool f_power_on_wp_en; /* Keeps information if any of the LU is power on write protected */ bool is_lu_power_on_wp; -}; - -#define MAX_MODEL_LEN 16 -/** - * ufs_dev_desc - ufs device details from the device descriptor - * - * @wmanufacturerid: card details - * @model: card model - */ -struct ufs_dev_desc { u16 wmanufacturerid; + /*UFS device Product Name */ u8 *model; }; diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index fe6cad9b2a0d..16c324c61b6e 100644 --- a/drivers/scsi/ufs/ufs_quirks.h +++ b/drivers/scsi/ufs/ufs_quirks.h @@ -22,16 +22,17 @@ * @quirk: device quirk */ struct ufs_dev_fix { - struct ufs_dev_desc card; + u16 wmanufacturerid; + u8 *model; unsigned int quirk; }; -#define END_FIX { { 0 }, 0 } +#define END_FIX { 0 } /* add specific device quirk */ #define UFS_FIX(_vendor, _model, _quirk) { \ - .card.wmanufacturerid = (_vendor),\ - .card.model = (_model), \ + .wmanufacturerid = (_vendor),\ + .model = (_model), \ .quirk = (_quirk), \ } diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9a9085a7bcc5..58ef45b80cb0 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6583,16 +6583,13 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) return ret; } -static int ufs_get_device_desc(struct ufs_hba *hba, - struct ufs_dev_desc *dev_desc) +static int ufs_get_device_desc(struct ufs_hba *hba) { int err; size_t buff_len; u8 model_index; u8 *desc_buf; - - if (!dev_desc) - return -EINVAL; + struct ufs_dev_info *dev_info = &hba->dev_info; buff_len = max_t(size_t, hba->desc_size.dev_desc, QUERY_DESC_MAX_SIZE + 1); @@ -6613,12 +6610,12 @@ static int ufs_get_device_desc(struct ufs_hba *hba, * getting vendor (manufacturerID) and Bank Index in big endian * format */ - dev_desc->wmanufacturerid = desc_buf[DEVICE_DESC_PARAM_MANF_ID] << 8 | + dev_info->wmanufacturerid = desc_buf[DEVICE_DESC_PARAM_MANF_ID] << 8 | desc_buf[DEVICE_DESC_PARAM_MANF_ID + 1]; model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME]; err = ufshcd_read_string_desc(hba, model_index, - &dev_desc->model, SD_ASCII_STD); + &dev_info->model, SD_ASCII_STD); if (err < 0) { dev_err(hba->dev, "%s: Failed reading Product Name. err = %d\n", __func__, err); @@ -6636,23 +6633,25 @@ static int ufs_get_device_desc(struct ufs_hba *hba, return err; } -static void ufs_put_device_desc(struct ufs_dev_desc *dev_desc) +static void ufs_put_device_desc(struct ufs_hba *hba) { - kfree(dev_desc->model); - dev_desc->model = NULL; + struct ufs_dev_info *dev_info = &hba->dev_info; + + kfree(dev_info->model); + dev_info->model = NULL; } -static void ufs_fixup_device_setup(struct ufs_hba *hba, - struct ufs_dev_desc *dev_desc) +static void ufs_fixup_device_setup(struct ufs_hba *hba) { struct ufs_dev_fix *f; + struct ufs_dev_info *dev_info = &hba->dev_info; for (f = ufs_fixups; f->quirk; f++) { - if ((f->card.wmanufacturerid == dev_desc->wmanufacturerid || - f->card.wmanufacturerid == UFS_ANY_VENDOR) && - ((dev_desc->model && - STR_PRFX_EQUAL(f->card.model, dev_desc->model)) || - !strcmp(f->card.model, UFS_ANY_MODEL))) + if ((f->wmanufacturerid == dev_info->wmanufacturerid || + f->wmanufacturerid == UFS_ANY_VENDOR) && + ((dev_info->model && + STR_PRFX_EQUAL(f->model, dev_info->model)) || + !strcmp(f->model, UFS_ANY_MODEL))) hba->dev_quirks |= f->quirk; } } @@ -6804,8 +6803,7 @@ static int ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba) return ret; } -static void ufshcd_tune_unipro_params(struct ufs_hba *hba, - struct ufs_dev_desc *card) +static void ufshcd_tune_unipro_params(struct ufs_hba *hba) { if (ufshcd_is_unipro_pa_params_tuning_req(hba)) { ufshcd_tune_pa_tactivate(hba); @@ -6819,7 +6817,7 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba, if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE) ufshcd_quirk_tune_host_pa_tactivate(hba); - ufshcd_vops_apply_dev_quirks(hba, card); + ufshcd_vops_apply_dev_quirks(hba); } static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba) @@ -6945,7 +6943,6 @@ static int ufshcd_set_dev_ref_clk(struct ufs_hba *hba) */ static int ufshcd_probe_hba(struct ufs_hba *hba) { - struct ufs_dev_desc card = {0}; int ret; ktime_t start = ktime_get(); @@ -6974,16 +6971,15 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) /* Init check for device descriptor sizes */ ufshcd_init_desc_sizes(hba); - ret = ufs_get_device_desc(hba, &card); + ret = ufs_get_device_desc(hba); if (ret) { dev_err(hba->dev, "%s: Failed getting device info. err = %d\n", __func__, ret); goto out; } - ufs_fixup_device_setup(hba, &card); - ufshcd_tune_unipro_params(hba, &card); - ufs_put_device_desc(&card); + ufs_fixup_device_setup(hba); + ufshcd_tune_unipro_params(hba); /* UFS device is also active now */ ufshcd_set_ufs_dev_active(hba); @@ -7544,6 +7540,7 @@ static void ufshcd_hba_exit(struct ufs_hba *hba) ufshcd_setup_clocks(hba, false); ufshcd_setup_hba_vreg(hba, false); hba->is_powered = false; + ufs_put_device_desc(hba); } } diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index b1a1c65be8b1..32b6714f25a5 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -320,7 +320,7 @@ struct ufs_hba_variant_ops { void (*setup_task_mgmt)(struct ufs_hba *, int, u8); void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme, enum ufs_notify_change_status); - int (*apply_dev_quirks)(struct ufs_hba *, struct ufs_dev_desc *); + int (*apply_dev_quirks)(struct ufs_hba *hba); int (*suspend)(struct ufs_hba *, enum ufs_pm_op); int (*resume)(struct ufs_hba *, enum ufs_pm_op); void (*dbg_register_dump)(struct ufs_hba *hba); @@ -1054,11 +1054,10 @@ static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba, return hba->vops->hibern8_notify(hba, cmd, status); } -static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba, - struct ufs_dev_desc *card) +static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba) { if (hba->vops && hba->vops->apply_dev_quirks) - return hba->vops->apply_dev_quirks(hba, card); + return hba->vops->apply_dev_quirks(hba); return 0; } From patchwork Thu Jan 16 21:59:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337875 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B0DC109A for ; Thu, 16 Jan 2020 22:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E93CA2077B for ; Thu, 16 Jan 2020 22:00:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="esQkxX2u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389433AbgAPWAE (ORCPT ); Thu, 16 Jan 2020 17:00:04 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39557 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389429AbgAPWAE (ORCPT ); Thu, 16 Jan 2020 17:00:04 -0500 Received: by mail-wr1-f65.google.com with SMTP id y11so20712918wrt.6; Thu, 16 Jan 2020 14:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bdYdBnjYnrA8fyK1qEXxMeFlHHmBcKjIvnrC1RRgB88=; b=esQkxX2u2j7Vifqrwp9opy12YNQtjPoplsOofG5fkYLxmzQ7e4NKhOot/Z0IVt6R7D tO3P0Jx4qi+iJjeOjUKjjBoUbtVAaSNRWl3XEFZRkMmicTNtxya5p6dP7BQpPxgw/GZw pgKjCEBD54mI/H5DgUnCktdvahQDMQJa6wTfCRYkyAnOWVWkLWC65gEScSCeOBF9TPQ8 jDUvM5SHFjbPYuSTo0eCUgHl+Rs52S1Pt13B53f3Z6H3RVZMtV2AhodRLvwQPo+HDjKv pFzUWoqZQPDkRS00AnAK14fcfnB7ZfZ1x/F2N7z7o2p9Mkjq1heOKAF5cajLC1Ibe5S0 QRGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bdYdBnjYnrA8fyK1qEXxMeFlHHmBcKjIvnrC1RRgB88=; b=PGsuVPgqzZYFzmgG7I/v0PfBKy7bDp2+itYPIb5ythU+A6XFmEhJky3OZUMCbulS0G Gh0Y3qmNEH6HT/BPSR+zKBG15cZUaIu0q+7uvJHMTiSfjqz5WuoSglRN0fOPbW+1GBkB NVCWofmSBckuEbGyi6zzh2s92+6mU0/jOv8I59gYzsx0h1Y0Rw0+DmeHW6B8Dk1WkUSF E5fPB8uqafWtOvmfxZK8kROxQ/OeX5kJwDXCezxJn5uEUAq5U6trJpH+3skV10lNYeYu AWaszOjF6TfPTZxHXLLZpx+xtxp5H2IvWfXFZ540rqJN7PdshWSosbPzBgXhWmVMUZW/ z+tQ== X-Gm-Message-State: APjAAAWqCCg+K3qh8uae+RZWdVEcfvHSIsWIuFXKUXlOwoDFpO/5/G8C q4pllHVRfG+xr+bDtZ+3Jio= X-Google-Smtp-Source: APXvYqzAOex6lh8624N0zmJw+unZpOmIrKERzK3VY6tdo3wvSVl+TkNcslUp3Q8+qlPbXACKmX3ejA== X-Received: by 2002:a5d:68c5:: with SMTP id p5mr5512682wrw.193.1579212001060; Thu, 16 Jan 2020 14:00:01 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.14.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:00:00 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/9] scsi: ufs: Split ufshcd_probe_hba() based on its called flow Date: Thu, 16 Jan 2020 22:59:08 +0100 Message-Id: <20200116215914.16015-4-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo This patch has two major non-functionality changes: 1. Take scanning host if-statement out from ufshcd_probe_hba(), and move them into a new added function ufs_lu_add(). In this new function ufs_lu_add(), the main functionalitis include: ICC initialization, add well-known LUs, devfreq initialization, UFS bsg probe and scsi host scan. The reason for this change is that these functionalities only being called during booting stage flow ufshcd_init()->ufshcd_async_scan(). In the processes of error handling and power management ufshcd_suspend(), ufshcd_resume(), ufshcd_probe_hba() being called, but these functionalitis above metioned are not hit. 2. Move context of initialization of parameters associated with UFS device to a new added ufs_init_params(). The reason for this change is that all of these parameters are used by the driver and only need to be initialized once when booting. Combine them into an integral function. Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 167 +++++++++++++++++++++++--------------- 1 file changed, 101 insertions(+), 66 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 58ef45b80cb0..2cec0816632c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -246,7 +246,7 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba); static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd); static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag); static void ufshcd_hba_exit(struct ufs_hba *hba); -static int ufshcd_probe_hba(struct ufs_hba *hba); +static int ufshcd_probe_hba(struct ufs_hba *hba, bool async); static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, bool skip_ref_clk); static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on); @@ -6307,7 +6307,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) goto out; /* Establish the link again and restore the device */ - err = ufshcd_probe_hba(hba); + err = ufshcd_probe_hba(hba, false); if (!err && (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)) err = -EIO; @@ -6935,13 +6935,83 @@ static int ufshcd_set_dev_ref_clk(struct ufs_hba *hba) return err; } +static int ufs_init_params(struct ufs_hba *hba) +{ + bool flag; + int ret; + + /* Init check for device descriptor sizes */ + ufshcd_init_desc_sizes(hba); + + /* Check and apply UFS device quirks */ + ret = ufs_get_device_desc(hba); + if (ret) { + dev_err(hba->dev, "%s: Failed getting device info. err = %d\n", + __func__, ret); + goto out; + } + + 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; + +out: + return ret; +} + +/** + * ufs_lu_add - probe and add UFS logical units + * @hba: per-adapter instance + */ +static int ufs_lu_add(struct ufs_hba *hba) +{ + int ret; + + if (!hba->is_init_prefetch) + ufshcd_init_icc_levels(hba); + + /* Add required well known logical units to scsi mid layer */ + ret = ufshcd_scsi_add_wlus(hba); + if (ret) + goto out; + + /* Initialize devfreq after UFS device is detected */ + if (ufshcd_is_clkscaling_supported(hba)) { + memcpy(&hba->clk_scaling.saved_pwr_info.info, + &hba->pwr_info, + sizeof(struct ufs_pa_layer_attr)); + hba->clk_scaling.saved_pwr_info.is_valid = true; + if (!hba->devfreq) { + ret = ufshcd_devfreq_init(hba); + if (ret) + goto out; + } + + hba->clk_scaling.is_allowed = true; + } + + ufs_bsg_probe(hba); + scsi_scan_host(hba->host); + pm_runtime_put_sync(hba->dev); + + if (!hba->is_init_prefetch) + hba->is_init_prefetch = true; +out: + return ret; +} + /** * ufshcd_probe_hba - probe hba to detect device and initialize * @hba: per-adapter instance + * @async: asynchronous execution or not * * Execute link-startup and verify device initialization */ -static int ufshcd_probe_hba(struct ufs_hba *hba) +static int ufshcd_probe_hba(struct ufs_hba *hba, bool async) { int ret; ktime_t start = ktime_get(); @@ -6960,25 +7030,26 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) /* UniPro link is active now */ ufshcd_set_link_active(hba); + /* Verify device initialization by sending NOP OUT UPIU */ ret = ufshcd_verify_dev_init(hba); if (ret) goto out; + /* Initiate UFS initialization, and waiting until completion */ ret = ufshcd_complete_dev_init(hba); if (ret) goto out; - /* Init check for device descriptor sizes */ - ufshcd_init_desc_sizes(hba); - - ret = ufs_get_device_desc(hba); - if (ret) { - dev_err(hba->dev, "%s: Failed getting device info. err = %d\n", - __func__, ret); - goto out; + /* + * Initialize UFS device parameters used by driver, these + * parameters are associated with UFS descriptors. + */ + if (async) { + ret = ufs_init_params(hba); + if (ret) + goto out; } - ufs_fixup_device_setup(hba); ufshcd_tune_unipro_params(hba); /* UFS device is also active now */ @@ -7011,60 +7082,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) /* Enable Auto-Hibernate if configured */ ufshcd_auto_hibern8_enable(hba); - /* - * If we are in error handling context or in power management callbacks - * context, no need to scan the host - */ - if (!ufshcd_eh_in_progress(hba) && !hba->pm_op_in_progress) { - bool flag; - - /* 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; - - if (!hba->is_init_prefetch) - ufshcd_init_icc_levels(hba); - - /* Add required well known logical units to scsi mid layer */ - ret = ufshcd_scsi_add_wlus(hba); - if (ret) - goto out; - - /* Initialize devfreq after UFS device is detected */ - if (ufshcd_is_clkscaling_supported(hba)) { - memcpy(&hba->clk_scaling.saved_pwr_info.info, - &hba->pwr_info, - sizeof(struct ufs_pa_layer_attr)); - hba->clk_scaling.saved_pwr_info.is_valid = true; - if (!hba->devfreq) { - ret = ufshcd_devfreq_init(hba); - if (ret) - goto out; - } - hba->clk_scaling.is_allowed = true; - } - - ufs_bsg_probe(hba); - - scsi_scan_host(hba->host); - pm_runtime_put_sync(hba->dev); - } - - if (!hba->is_init_prefetch) - hba->is_init_prefetch = true; - out: - /* - * If we failed to initialize the device or the device is not - * present, turn off the power/clocks etc. - */ - if (ret && !ufshcd_eh_in_progress(hba) && !hba->pm_op_in_progress) { - pm_runtime_put_sync(hba->dev); - ufshcd_exit_clk_scaling(hba); - ufshcd_hba_exit(hba); - } trace_ufshcd_init(dev_name(hba->dev), ret, ktime_to_us(ktime_sub(ktime_get(), start)), @@ -7080,8 +7098,25 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) static void ufshcd_async_scan(void *data, async_cookie_t cookie) { struct ufs_hba *hba = (struct ufs_hba *)data; + int ret; - ufshcd_probe_hba(hba); + /* Initialize hba, detect and initialize UFS device */ + ret = ufshcd_probe_hba(hba, true); + if (ret) + goto out; + + /* Probe and add UFS logical units */ + ret = ufs_lu_add(hba); +out: + /* + * If we failed to initialize the device or the device is not + * present, turn off the power/clocks etc. + */ + if (ret) { + pm_runtime_put_sync(hba->dev); + ufshcd_exit_clk_scaling(hba); + ufshcd_hba_exit(hba); + } } static const struct attribute_group *ufshcd_driver_groups[] = { From patchwork Thu Jan 16 21:59:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337877 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39D5C6C1 for ; Thu, 16 Jan 2020 22:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 186BD207E0 for ; Thu, 16 Jan 2020 22:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C+/gJd1X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389474AbgAPWAL (ORCPT ); Thu, 16 Jan 2020 17:00:11 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36283 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730816AbgAPWAL (ORCPT ); Thu, 16 Jan 2020 17:00:11 -0500 Received: by mail-wm1-f66.google.com with SMTP id p17so5456518wma.1; Thu, 16 Jan 2020 14:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hIsYYM1tsKneNrgd2yUE9+XrcEkD0MuzrhyvDBfE4NE=; b=C+/gJd1XCusgb6Ajq2n1R3fBaeSyHr+kIXKR2Uo2dBn44BM8y4siOWP+/lNMY1WuKE JXPxXIDnTTy73p9pMkI8NhODCU6RFoFTZ+1KFXjUgYqV82jgUEKvEqVOTcfrDL53cHka mUaQhygHhRJtmdcGaPK413qpRJXmK2Vvt7f8m6h19cd/tiJytple49HTKZT6lQpWZm6d ivoiQ09K1axWmiIaYNSh5Uiq8DWwslNfkl7rWzMWbe8yP+5ZXFyUwmFPIzwc/Ia2+r5K G4A90OV8xY52whW0HDMlNlFqngkUp+BDQ1RJXNBggmTnj95o1oyWA6ZCHQ2mEkygPXxo ijnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hIsYYM1tsKneNrgd2yUE9+XrcEkD0MuzrhyvDBfE4NE=; b=NB212BHwsHk7UysBrb5HskJHEw8zWvOLvaf5MRIJ28zEroUBfJ61eOHptAZ2eUa6K1 mw53NS+6gta550bqrQmgEia/kTTJ4utebiypmpRpNUvF0d6kIg4XsNUQvOckbG4CBEIp +aTfApv1CdDdzKVqr06o9fPQKHhDb4N/1izb/I7kHuHjG9Ru2WQ05/FAa9ORxwvVAFAw 8SKtNGl7PTxUmC9VRQFqqGFpuF9zcpViXr7fk7Aj87yOi7/m03zNkFEys18oEO1UEe+W BXM0QF6CA7YJsAoiE5JWAYdQqI+C0wQ9lNXs+7x6Kl6/2yGclq+BbA6sHe1rYN+alrBo bBAA== X-Gm-Message-State: APjAAAWhNgP8/9l8HNE7nODNE72PheM7x2VEcJMtV21OWijMHkrK/RBI AcwcRS+9pMJSBGRmKc0tWBM= X-Google-Smtp-Source: APXvYqyoaCb9cjni/ywIjpyAlL0Gwmq23XZtFG8fhEjpigcv6DWLUTehQJ4XAr3Un/JFZFTgoHMdNg== X-Received: by 2002:a1c:1f51:: with SMTP id f78mr1157306wmf.60.1579212009005; Thu, 16 Jan 2020 14:00:09 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.14.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:00:08 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/9] scsi: ufs: Move ufshcd_get_max_pwr_mode() to ufs_init_params() Date: Thu, 16 Jan 2020 22:59:09 +0100 Message-Id: <20200116215914.16015-5-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo Take ufshcd_get_max_pwr_mode() out from ufshcd_probe_hba() and inline into ufs_init_params(). Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 2cec0816632c..087fd894a01b 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6959,6 +6959,11 @@ static int ufs_init_params(struct ufs_hba *hba) QUERY_FLAG_IDN_PWR_ON_WPE, &flag)) hba->dev_info.f_power_on_wp_en = flag; + /* Probe maximum power mode co-supported by both UFS host and device */ + if (ufshcd_get_max_pwr_mode(hba)) + dev_err(hba->dev, + "%s: Failed getting max supported power mode\n", + __func__); out: return ret; } @@ -7057,11 +7062,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool async) ufshcd_force_reset_auto_bkops(hba); hba->wlun_dev_clr_ua = true; - if (ufshcd_get_max_pwr_mode(hba)) { - dev_err(hba->dev, - "%s: Failed getting max supported power mode\n", - __func__); - } else { + /* Gear up to HS gear if supported */ + if (hba->max_pwr_info.is_valid) { /* * Set the right value to bRefClkFreq before attempting to * switch to HS gears. From patchwork Thu Jan 16 21:59:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337879 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7725109A for ; Thu, 16 Jan 2020 22:00:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95A8A20748 for ; Thu, 16 Jan 2020 22:00:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GtABQGCf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389505AbgAPWAR (ORCPT ); Thu, 16 Jan 2020 17:00:17 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33338 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730816AbgAPWAR (ORCPT ); Thu, 16 Jan 2020 17:00:17 -0500 Received: by mail-wm1-f68.google.com with SMTP id d139so8116196wmd.0; Thu, 16 Jan 2020 14:00:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x6sXuUhwD78rNMwCezwf2SJFMuo48cD5mQHoToWvu1I=; b=GtABQGCfpaKRoI5woC8t2sbkj2+IZczrtiwOMqw8JtdlNz9Dg8taQzlJcEcpW9AJv9 6s9jtxT1FMMyPqtMLlcNL8/ETc9x3+ab1TdT7l34kDOaMDR48QdTqzMG0dxL2PsU3zzK xnvi7PYOoDg5gDVT1C60Tv5UcP9gg54Cg7eObhtYMDbnFUT8FYWnzL3A6Ec+xq6sF2C8 BqBj9suGjLSOy9ndfMA22l1CETNnu7f0SLMOc0JQH/T3Achtdi9Wc1ofatLGk0Ws+sgC lx1t76aqqDt3uKy3tnmy8a2U5YSti3KLw/kiCDxyUEzf3f9iYms/ZbCV07Kwen2S0aI0 gtbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x6sXuUhwD78rNMwCezwf2SJFMuo48cD5mQHoToWvu1I=; b=p9wIxr6giRrkEoBeGsmFnI9ySMHSfIr8gWyjitWkMCY8hcNl2yhr6t93Bx9ljF+mfN Qpr8R8QcqoGu++hQG0tGIS/McuJKtcuvnkCLQ7uYdMPzZUe47D7gnnqubrz/T7c2z4Of q2RyQUwN1H8LCjRaJtL6If21G+LQhOeeTRdrvjdcGc5boVoRsF2y3k3EfnuR6ARHJuHo j85qvOoQih0MU55Y0L9k1my9voURBrtRVBqtS+sSrBgaKHo0uFJowKqpr3oYMaAuGK7/ vHwKr2GDB9N5qU6JTJIO7uuif9sAEFF3XtJF8CZmiKwcMMzcqa4Y0Z6VB19WlaecJpqK CkBA== X-Gm-Message-State: APjAAAXU/IL4ekXtsBDYDeIjkNWCuHozPwMmzDY0PaN1W3iebMSP64pg EphBVgrGD9BmdPre5EPFOjc= X-Google-Smtp-Source: APXvYqzZyuE5HX2fSiGO4yJ1gQ+1GFaTzyM+VZpbZ1g0gMSFlt0w+MbeEFYNLiRA0fz04c1YY2fgLA== X-Received: by 2002:a1c:23d7:: with SMTP id j206mr1166731wmj.39.1579212016105; Thu, 16 Jan 2020 14:00:16 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.14.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:00:15 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/9] scsi: ufs: Delete two unnecessary functions Date: Thu, 16 Jan 2020 22:59:10 +0100 Message-Id: <20200116215914.16015-6-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo Delete ufshcd_read_power_desc() and ufshcd_read_device_desc(), directly inline ufshcd_read_desc() into its callers. Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 087fd894a01b..44b7c0a44b8d 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3146,17 +3146,6 @@ static inline int ufshcd_read_desc(struct ufs_hba *hba, return ufshcd_read_desc_param(hba, desc_id, desc_index, 0, buf, size); } -static inline int ufshcd_read_power_desc(struct ufs_hba *hba, - u8 *buf, - u32 size) -{ - return ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0, buf, size); -} - -static int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size) -{ - return ufshcd_read_desc(hba, QUERY_DESC_IDN_DEVICE, 0, buf, size); -} /** * struct uc_string_id - unicode string @@ -6493,7 +6482,8 @@ static void ufshcd_init_icc_levels(struct ufs_hba *hba) if (!desc_buf) return; - ret = ufshcd_read_power_desc(hba, desc_buf, buff_len); + ret = ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0, + desc_buf, buff_len); if (ret) { dev_err(hba->dev, "%s: Failed reading power descriptor.len = %d ret = %d", @@ -6599,7 +6589,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba) goto out; } - err = ufshcd_read_device_desc(hba, desc_buf, hba->desc_size.dev_desc); + err = ufshcd_read_desc(hba, QUERY_DESC_IDN_DEVICE, 0, desc_buf, + hba->desc_size.dev_desc); if (err) { dev_err(hba->dev, "%s: Failed reading Device Desc. err = %d\n", __func__, err); From patchwork Thu Jan 16 21:59:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337881 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86666109A for ; Thu, 16 Jan 2020 22:00:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 654D82077B for ; Thu, 16 Jan 2020 22:00:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S7P2LqYN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389532AbgAPWA0 (ORCPT ); Thu, 16 Jan 2020 17:00:26 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39012 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389531AbgAPWA0 (ORCPT ); Thu, 16 Jan 2020 17:00:26 -0500 Received: by mail-wm1-f66.google.com with SMTP id 20so5431809wmj.4; Thu, 16 Jan 2020 14:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U/6r3jTv6/TdVEpoQsUJwaQM0ILgr42fKAvijPLEpt4=; b=S7P2LqYN1YayIOtXg5qoVWjCYl4aKil1O2WWLa8e9ywWG5d38XSvUVh+LiMpWWc1wg BPDd4QqsdfUfqFNUi1IG1dQIO38VQDgH0HamG2bJUnoza7acaJh72W+c2wjmLFl7NLRF 8Iwvps2Ao9lL1rQewneKoejnPKqChayl1+H5D7n0VfUYxbgXyYOXn1wWogfeK+lyvFam 6echBlIGv1ZsxIwIrvwPuqd9UYmKIOxdZQU790fkqFagptNz8omJwAUhlEN1JDTKsq+d jtS62/xF2rNNakmiud+k+CteXf25uljIpGKUlkM37R8kXCOl4SdzdX3ngq+X9mBB7Ccg RY8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U/6r3jTv6/TdVEpoQsUJwaQM0ILgr42fKAvijPLEpt4=; b=VW9nSgI4qUJUNCEM5GNMPX8OuyvjLYSYHOFP661bmsR+V8WY4a4qnRtVnhaQhdImAq 0Io5Yfwa+dletCGrvYNHiT6DjJ29PTIPJKZtOrupxkT2CnOKvCGfbGf4WylhYehnh81R 39lovBULaua7YKzUDhMj1GtoavPEcfUAD7tdFmUN/wP6hOxAaghnFEi/nlZrHvE+Du8N BX25WuLOAwi94zWKqk1a0q9Bsz5Um7AMDFBN7FYuufingayS+1TURyH7vsY1ngbPHqBE LvYSs8X7Foln0eVWPU9diOLPZZT93/IxcVekm+Se9s24EJk5g6gaV+4icRRyhWskwPBA rkdA== X-Gm-Message-State: APjAAAUmKL+6TrTVnGd0kGjnSxJC0kNFiYvueLcFrzPAFO7EspEN+V3F GurHzhoMtVCe0gUI3yfpDoY= X-Google-Smtp-Source: APXvYqwrE80ZmcxOSJcuZUEUfwOB+x/TX9GpQjCBu2Ztjn6Np9rNv+PhpuWi8kQDzYeOOfJ7zYfCBg== X-Received: by 2002:a1c:f218:: with SMTP id s24mr1206970wmc.128.1579212024492; Thu, 16 Jan 2020 14:00:24 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.14.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:00:24 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/9] scsi: ufs: Delete is_init_prefetch from struct ufs_hba Date: Thu, 16 Jan 2020 22:59:11 +0100 Message-Id: <20200116215914.16015-7-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo Without variable is_init_prefetch, the current logic can guarantee ufshcd_init_icc_levels() will execute only once, delete it now. Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 5 +---- drivers/scsi/ufs/ufshcd.h | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 44b7c0a44b8d..31b6e2a7c166 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6967,8 +6967,7 @@ static int ufs_lu_add(struct ufs_hba *hba) { int ret; - if (!hba->is_init_prefetch) - ufshcd_init_icc_levels(hba); + ufshcd_init_icc_levels(hba); /* Add required well known logical units to scsi mid layer */ ret = ufshcd_scsi_add_wlus(hba); @@ -6994,8 +6993,6 @@ static int ufs_lu_add(struct ufs_hba *hba) scsi_scan_host(hba->host); pm_runtime_put_sync(hba->dev); - if (!hba->is_init_prefetch) - hba->is_init_prefetch = true; out: return ret; } diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 32b6714f25a5..5c65d9fdeb14 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -501,7 +501,6 @@ struct ufs_stats { * @intr_mask: Interrupt Mask Bits * @ee_ctrl_mask: Exception event control mask * @is_powered: flag to check if HBA is powered - * @is_init_prefetch: flag to check if data was pre-fetched in initialization * @init_prefetch_data: data pre-fetched during initialization * @eh_work: Worker to handle UFS errors that require s/w attention * @eeh_work: Worker to handle exception events @@ -652,7 +651,6 @@ struct ufs_hba { u32 intr_mask; u16 ee_ctrl_mask; bool is_powered; - bool is_init_prefetch; struct ufs_init_prefetch init_prefetch_data; /* Work Queues */ From patchwork Thu Jan 16 21:59:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337883 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C3256C1 for ; Thu, 16 Jan 2020 22:00:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1AEF82077B for ; Thu, 16 Jan 2020 22:00:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X/S9G9vP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389564AbgAPWAc (ORCPT ); Thu, 16 Jan 2020 17:00:32 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39043 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733113AbgAPWAc (ORCPT ); Thu, 16 Jan 2020 17:00:32 -0500 Received: by mail-wm1-f65.google.com with SMTP id 20so5432169wmj.4; Thu, 16 Jan 2020 14:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VgoO/JemCCtHEcyOdPPD88fO64o+HNjcCaOaOMSoYgA=; b=X/S9G9vPtdjQFCMAbB5QoI9OZ0RlEOk5/4hQp0ehmqiu18vbnp3JbZCB0FjjbLtN/C gl6K6bz6j8CjEh1wXhE1jjoXuOiCAR9s/Ae8d4h0r1McEPOXuHcEdpBQdayvdMoJfJ25 /pT6Yi+mxYMt4+LxgHsHe62qIHG8amxwjktkEI4SP7VjB+CEoD8ZG6OT4fIAuYefrwUX eLc/TVczaKKWGmGiyxtrpyGJlNCzO/iEAe2rf7BcmCJSH6DSvcEeFnweQO1OCU3zQm5i Isvvhng+2yhNicShQlLYHAEqMSWiE7L7HXR1kssogTvtH2GgtzT71XpIqicwSZHTp2GX kZLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VgoO/JemCCtHEcyOdPPD88fO64o+HNjcCaOaOMSoYgA=; b=dngFYDfKHKURXEVJ1uKpDQl+b7vf+N1x1RMbTXW2ko6wSNJ/KsfCxrUKg8+iUu2WUG 57Yog4KRuxdkEoaxdjyEEAxCjNXSuHdajITbTimLy0uQMqkMj0PbvqaG+qvA9KQVaCRe 1+ig2CZXu9juQqfGWbRijPtg2bSHcFeITTpIQece1xNDXy4sZIVPEau8eBgnQ/EEJLzo ctWOBPrzMU/0wzmYgkjUEQ1aBkJA8EItJ0FmW5dHm6W7Jgytc7p0O4NKtRAovWlgf1Qx ug9useyw2mmkPuD5qX2AnkqlNJRAP7jukgdxnEX5m0x5aFT5QZleCJrsai7vGN7Wu/Bl Nygw== X-Gm-Message-State: APjAAAV3P8UHRdhhidq8qqwcKKhjJ7SAy+yfvVjNKtKxk/eBoImUrED2 JTCxYi5D5UsCrGdCXENRIvA= X-Google-Smtp-Source: APXvYqz5jrnjAR3QRpoLXO9Z5XePkFVS+1ZhDLd6rAvHssRz5LF8WVO462x1OQa0Otf11xp1bsI3gQ== X-Received: by 2002:a1c:7f4f:: with SMTP id a76mr1152839wmd.77.1579212030156; Thu, 16 Jan 2020 14:00:30 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.14.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:00:29 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/9] scsi: ufs: Add max_lu_supported in struct ufs_dev_info Date: Thu, 16 Jan 2020 22:59:12 +0100 Message-Id: <20200116215914.16015-8-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo 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. Reviewed-by: Bart Van Assche Reviewed-by: Asutosh Das Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index fcc9b4d4e56f..c982bcc94662 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -530,6 +530,8 @@ struct ufs_dev_info { bool f_power_on_wp_en; /* Keeps information if any of the LU is power on write protected */ bool is_lu_power_on_wp; + /* Maximum number of general LU supported by the UFS device */ + u8 max_lu_supported; u16 wmanufacturerid; /*UFS device Product Name */ u8 *model; From patchwork Thu Jan 16 21:59:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337885 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 329A8109A for ; Thu, 16 Jan 2020 22:00:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1186A2077B for ; Thu, 16 Jan 2020 22:00:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n7Gok1cd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389587AbgAPWAg (ORCPT ); Thu, 16 Jan 2020 17:00:36 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51650 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733113AbgAPWAf (ORCPT ); Thu, 16 Jan 2020 17:00:35 -0500 Received: by mail-wm1-f66.google.com with SMTP id d73so5396168wmd.1; Thu, 16 Jan 2020 14:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cvyBO8ofWpOor0eSM7A0Vaig+SAs1cZyp6W64LRJl1E=; b=n7Gok1cd/0ppWSxDVNQKPsBS3SFNYgIa0WqI0UeVT4y8AocCkJjNRZPATCp+LyzjgB kR/nMP1gshJLI6ja27/DrvvD/G9iIZ6mjt6qTUNOPGp3DXZA2ZQrgxWjooqFLQk8ZB/d +dGnW06ZCoYJfOiU2YqquA6iWZH9jaVQrJKs3lh3WvAq7jFh+qDmBW4274JoqJCRTmcf p+vG+NYv3/S/rAGvH8xpUdYbGw7Ok5jDv0xP2pG2dyAbkc1k2O5JtsBuee2DDNSP9t73 jJbMyipInDQwpCkXrgBwysrkpojNXiJw3D3/mop24ewjU3186uNgBHMyNdN4vwrjDAIK LO8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cvyBO8ofWpOor0eSM7A0Vaig+SAs1cZyp6W64LRJl1E=; b=LcjXA5HB10uE3Lf+ofkKvbEXCY6MGBmrfChoem2724XA43qn0BfT0+tRWSmFxwxbry qLrFxWp/v01bSY7B4gd3BJB6O4H/RgC8KU5uXVL+11NDNbR7gIv0i60KtI0jcoCURpNl zGbnzyHFs2ki3+L4YAoxDWsrXfuvqzXzdS9AHE4aiUzk9F61r4yMDywIRhjfdXUnpYo/ W1NB3vWjotuGZNJTnR5NvifCjO4dFjvOsEX14Q1h0MIzYUE51ofaa+2e8vRq56Eu+TVF PM8Ul4Dssm4ADfWfPUm4zVwk4/f2TWLtYd3FAOctqjG23Qgrjn+ruZHW+tGaiJjxEnp2 ruUw== X-Gm-Message-State: APjAAAUoINcJDydI4r12MjJ9hrkqYxTYxWfm5H1jHUmn714iZM3O/Gs7 PaI147B6Wto5Yk8Ve6xtzR8= X-Google-Smtp-Source: APXvYqxoocNxUQX6HqT1UK6MOSXDbzVmTp5Bq1l3ENddfoVQsCqfZBSE6dSEqTbHCNYKQ0O57HM0WQ== X-Received: by 2002:a7b:cc09:: with SMTP id f9mr1151471wmh.71.1579212033457; Thu, 16 Jan 2020 14:00:33 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.14.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:00:32 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/9] scsi: ufs: Initialize max_lu_supported Date: Thu, 16 Jan 2020 22:59:13 +0100 Message-Id: <20200116215914.16015-9-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo This patch is to initialize max_lu_supported, it also adds a new function ufshcd_init_device_geo_params() for initialization of UFS device geometry descriptor related parameters which are used by driver. In this version patch, there is only dev_info.max_lu_supported being initialized. Reviewed-by: Asutosh Das Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufshcd.c | 41 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 31b6e2a7c166..0c4fb5d447da 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6858,6 +6858,37 @@ static void ufshcd_init_desc_sizes(struct ufs_hba *hba) hba->desc_size.hlth_desc = QUERY_DESC_HEALTH_DEF_SIZE; } +static int ufshcd_init_device_geo_params(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}, @@ -6931,9 +6962,17 @@ static int ufs_init_params(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_init_device_geo_params(hba); + if (ret) + goto out; + /* Check and apply UFS device quirks */ ret = ufs_get_device_desc(hba); if (ret) { @@ -6944,8 +6983,6 @@ static int ufs_init_params(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; From patchwork Thu Jan 16 21:59:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11337887 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDB816C1 for ; Thu, 16 Jan 2020 22:00:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1BAB2053B for ; Thu, 16 Jan 2020 22:00:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NcAE1SH8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389639AbgAPWAn (ORCPT ); Thu, 16 Jan 2020 17:00:43 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:53333 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729503AbgAPWAm (ORCPT ); Thu, 16 Jan 2020 17:00:42 -0500 Received: by mail-wm1-f68.google.com with SMTP id m24so5381251wmc.3; Thu, 16 Jan 2020 14:00:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oIn+Jvngj5pWP7exdhrbj7B/VR3utuuUJaPI5QggeLQ=; b=NcAE1SH8vL4NAONhNeG3//w0M7GQVz0DiGsz3fshkybB7yDqnoQZYxTAbSfDKfXF8A A0bTHvade4wpI81k3lhLKM+eCzubM7WT/1gbfD/qoB0xxjCTpbnJCV/1+726JSy6Eef/ EgWKfViiYtxdqLFHMDD1MATTee5qvUEV+0jXQ2udUHWswG82cQQLVRlwReFLRh8WqWf5 xN8xBkAZSHnYnej8oJpE3nW00sH3N9FFAtWvMwUifgDodx1WfyAldA6wjmcElI6vE8L6 z5XS6nlwz2B7jAhVuyHZan5ssOg24naz7twy72uwvVanyslzOZGZFhYXNw+8vz1kjVA+ FW8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oIn+Jvngj5pWP7exdhrbj7B/VR3utuuUJaPI5QggeLQ=; b=ZjOd90H2wsrlTV1WC+/XDE+9Kc03jXVQrkAlE6wo3nde6P3KcS5LZTpocwblZJoHXo rbobTh2oYxjYeipefgg1k/tOI7iI32y2vyjVQQmguneynTgoLvb1nfCyUmdg6IuoEStf xNRHavfybTFVkxhtCDMsN95KOKsgNi9OvymSdUu/Jr5YSFUVU5T4K8wif71/nFk33cFc zv3yIN98VoSOL7JzlnS19pYbfy9xoesuNysWxY8nX34Y6UviuyMjaRwhMkAnvIPTWrvj Tv1MzzkmKqDS8S11L+GmCg+GL/faTVcTxuf8lXiGmiD2umMhOkbz7SwuZMScD955Y7sE y/Jw== X-Gm-Message-State: APjAAAWSpxTeUhiG5pAsbYIk3m48/3Fp0nM8dwmH7fE+6280bFPOhVBU ogRlWnqYTLqA35PGe0sP5oU= X-Google-Smtp-Source: APXvYqw6KydyP6gocEdkQdlORTHH7IwMM6gD5avULnOd8yG9XpYgcEHS59fdqBAmXXnGFgFhGaTNlQ== X-Received: by 2002:a7b:c5cd:: with SMTP id n13mr1148335wmk.172.1579212040835; Thu, 16 Jan 2020 14:00:40 -0800 (PST) Received: from localhost.localdomain (ip5f5bee3c.dynamic.kabel-deutschland.de. [95.91.238.60]) by smtp.gmail.com with ESMTPSA id a14sm32418131wrx.81.2020.01.16.14.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:00:40 -0800 (PST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 9/9] scsi: ufs: Use UFS device indicated maximum LU number Date: Thu, 16 Jan 2020 22:59:14 +0100 Message-Id: <20200116215914.16015-10-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116215914.16015-1-huobean@gmail.com> References: <20200116215914.16015-1-huobean@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bean Huo According to Jedec standard UFS 3.0 and UFS 2.1 Spec, the maximum number of logical units supported by the UFS device is indicated by parameter bMaxNumberLU in Geometry Descriptor. This patch is to delete current hard code macro definition of UFS_UPIU_MAX_GENERAL_LUN and switch to use device indicated number instead. Reviewed-by: Asutosh Das Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufs-sysfs.c | 2 +- drivers/scsi/ufs/ufs.h | 12 +++++++++--- drivers/scsi/ufs/ufshcd.c | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index 720be3f64be7..dbdf8b01abed 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -713,7 +713,7 @@ static ssize_t _pname##_show(struct device *dev, \ struct scsi_device *sdev = to_scsi_device(dev); \ struct ufs_hba *hba = shost_priv(sdev->host); \ u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); \ - if (!ufs_is_valid_unit_desc_lun(lun)) \ + if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun)) \ return -EINVAL; \ return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \ lun, _duname##_DESC_PARAM##_puname, buf, _size); \ diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index c982bcc94662..dde2eb02f76f 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -63,7 +63,6 @@ #define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F #define UFS_MAX_LUNS (SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID) #define UFS_UPIU_WLUN_ID (1 << 7) -#define UFS_UPIU_MAX_GENERAL_LUN 8 /* Well known logical unit id in LUN field of UPIU */ enum { @@ -539,12 +538,19 @@ struct ufs_dev_info { /** * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor + * @dev_info: pointer of instance of struct ufs_dev_info * @lun: LU number to check * @return: true if the lun has a matching unit descriptor, false otherwise */ -static inline bool ufs_is_valid_unit_desc_lun(u8 lun) +static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, + u8 lun) { - return lun == UFS_UPIU_RPMB_WLUN || (lun < UFS_UPIU_MAX_GENERAL_LUN); + if (!dev_info || !dev_info->max_lu_supported) { + pr_err("Max General LU supported by UFS isn't initilized\n"); + return false; + } + + return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported); } #endif /* End of Header */ diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 0c4fb5d447da..a942d5346793 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3270,7 +3270,7 @@ static inline int ufshcd_read_unit_desc_param(struct ufs_hba *hba, * Unit descriptors are only available for general purpose LUs (LUN id * from 0 to 7) and RPMB Well known LU. */ - if (!ufs_is_valid_unit_desc_lun(lun)) + if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun)) return -EOPNOTSUPP; return ufshcd_read_desc_param(hba, QUERY_DESC_IDN_UNIT, lun, @@ -4525,7 +4525,7 @@ static int ufshcd_get_lu_wp(struct ufs_hba *hba, * protected so skip reading bLUWriteProtect parameter for * it. For other W-LUs, UNIT DESCRIPTOR is not available. */ - else if (lun >= UFS_UPIU_MAX_GENERAL_LUN) + else if (lun >= hba->dev_info.max_lu_supported) ret = -ENOTSUPP; else ret = ufshcd_read_unit_desc_param(hba,