From patchwork Mon Nov 21 15:46:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 628206 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1015DC4332F for ; Mon, 21 Nov 2022 15:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbiKUPqm (ORCPT ); Mon, 21 Nov 2022 10:46:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbiKUPqj (ORCPT ); Mon, 21 Nov 2022 10:46:39 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46CD5B49; Mon, 21 Nov 2022 07:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1669045599; x=1700581599; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=P0JKaqQLlBDEhwnEa2zE84r6kTN62SJX3jVSRfcurYc=; b=LZpCYQj6vn068wHfvhcYTegN31FlOj1LR3gUvS5I7/5yjWv4cJLpR7cY ctRRzVHcdOEnoLdk+0UUmEYpnb1oBBLMWLmKRB0+TH3w0AU2ch0vGJ0lu Oh+7uxIFiaPzuQf+JngpigbMaYkEXwcNbTua/yWatv+ArsW43B4kB5AF9 zHWF/BkTMQySTIiOCHSAs2x/8yKoNJYWqiGDIMDN6EXSOgEd8hB7fYz5K NJLUQYb50iJ6jYKVr08IQ4GIwKG4L2cvwnTnwdoj1/mh9nkmEsWaeqbwP 0rIpTKx4/aUzgxlxB+M7LAZfs2bR67L99mx6AgH6lHkR6+8IpJJ1aaFG1 g==; X-IronPort-AV: E=Sophos;i="5.96,181,1665417600"; d="scan'208";a="215054343" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Nov 2022 23:46:39 +0800 IronPort-SDR: aSjkjFCODP7q8j80rqGo+w+jDQzBw9Gtg6whAkc1aFlb3FAblA6zWLSqW3gZb7z9SwKCSU/j49 GMMFS7mc4MBJvxbMjzyKrwii6u7I7+tAutnJkfY3DPx46occrLsujNEunxyZTxXhtpB5pm9222 R0sBMVZxDT0URs0vJygbne2GgPYivKOcYEVDPT6BICHuZxLaKsbaMTMFg2gKWgacplqpff3W9S 0T06CyNZuHc1VHezMEGwwi4zvN0+hhPMYjCObbwHJHUcQUtnu7H6cEMW1kVgwncal95jl6CzdF TgI= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2022 06:59:44 -0800 IronPort-SDR: jQ2VJ109PTVex2cBC3mAWMMToSs+gPICYly53T2m9suaUpuduGQbIDym2yvP5BSbUBWHr2HHeH jyLdzy/cVOvX/zZDyfGvdH4LH6nOhI0eBfsNApAZHvxmvtQX3DloEVXWgWbVNGUmfSHSGaUwn0 OXD0ZqA5UMroNdbC4VnrQFmvn/baZwxNx9oHbUV2hgNyxSn1w6XzLYRdfJBG1yJXEua05LCCNd dme6q3BesHVAs6jEdUNs64ABejyEr5zouZnefLynKtIVzlIVoeevj1ZstmBKTZ5NFanidgZcJu BW8= WDCIronportException: Internal Received: from ilb001078.ad.shared (HELO ilb001078.sdcorp.global.sandisk.com) ([10.45.31.219]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2022 07:46:38 -0800 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: beanhuo@micron.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Arthur Simchaev Subject: [PATCH v3 1/4] ufs: core: Remove redundant wb check Date: Mon, 21 Nov 2022 17:46:27 +0200 Message-Id: <1669045590-26101-2-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We used to use the extended-feature field in the device descriptor, as an indication that the device supports ufs2.2 or later. Remove that as this check is specifically done few lines above. Signed-off-by: Arthur Simchaev --- drivers/ufs/core/ufshcd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 768cb49..301fda0 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7584,10 +7584,6 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, const u8 *desc_buf) (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES))) goto wb_disabled; - if (hba->desc_size[QUERY_DESC_IDN_DEVICE] < - DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4) - goto wb_disabled; - ext_ufs_feature = get_unaligned_be32(desc_buf + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP); From patchwork Mon Nov 21 15:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 627475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69844C4332F for ; Mon, 21 Nov 2022 15:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbiKUPq6 (ORCPT ); Mon, 21 Nov 2022 10:46:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbiKUPqw (ORCPT ); Mon, 21 Nov 2022 10:46:52 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4403C12A88; Mon, 21 Nov 2022 07:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1669045603; x=1700581603; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=m2EI0A8j5GO9FwAffCeWUV/wel3lSP9BZI0pMLqWRaM=; b=nliDokLbJqwdnDjSPEOKDfs30f7F1qEfM5iiKEzFdvXbFXb80u4RPZw8 EFR7UbtkBs1TtZfA7A2rBJpxVyiH22Ve3ZMwnXE8hLMbm5yN/Vb+iow0s 7g6LbhO1LNEVWNqCp7oJBPTobij6jIcUxrlEUoiH5jnu88yq1x+hJJdeC +xv3uxq6kun+RQtL1Yw8rAVrSXeRH3+CyCJSChNI/GkkJoJ3UNxFx5ALq tXZ5ZRP4Cv34Y60iTgWHSqrQl5G9hssw/BbyLGJyXKljClYYhHV+7756I vTmeJsGqhi6TcThSWgxet3ZN4RvbOg3x2WZU+3E5ZMx05VwKhHLn2A1fT w==; X-IronPort-AV: E=Sophos;i="5.96,181,1665417600"; d="scan'208";a="215054344" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Nov 2022 23:46:41 +0800 IronPort-SDR: 3CYAyzZXDiX3mQSQJww8S+W4ArhnINVR862l5jYb0vcJXcTiV/A+jVr+RKOrcuRIlsYD886sON 85NXXG0TStt2ct5tRh6KpC59l1YpbaMBPl31HxgbC+nx8F3i97hvmFLsUYuHkSgYjviTmKFkoZ v88fpJHVCtnejxQbUgdBsYyJot+0pNKP+scLNFUhW29BHktvbgCZpipozW8U2W70QB/zVEwJt4 1w20Kp64JY0vKcv2wp6RjJjqkZSQLGKqvNUykWeJvqaihbUChg4Bt4TpjCkhqwGN6Qn2W+ylsA cxA= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2022 06:59:46 -0800 IronPort-SDR: I6XY4N2ZMyyazv9skCG91r4Rkf/AwsjyhkMvQ1EDQUV/lbMCrxclXG/0BujnQT7NT+jEisq1Px GO1V2C0vck/eL/aTlWwdA2dx0Uqbvc3RL0dZ5QUJB3wJ0sEVpaKasyIEQ9NdxYvumPQzqM08Nj 3nq+/kGChQL7h2V8xJop66AZ24sQAzZGrjcmSN5cwF7VfOxUIFRToR2+MWpQySsWmmRjM+o+zA Unlk7D2Zr1iGpUU4ruTP7/dXyDeaNM5oRCGewmdsACNYLSR/3HiOO7lonkmHSN8mq6QTl8lOTF 40U= WDCIronportException: Internal Received: from ilb001078.ad.shared (HELO ilb001078.sdcorp.global.sandisk.com) ([10.45.31.219]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2022 07:46:40 -0800 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: beanhuo@micron.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Arthur Simchaev Subject: [PATCH v3 2/4] ufs: core: Remove redundant desc_size variable from hba Date: Mon, 21 Nov 2022 17:46:28 +0200 Message-Id: <1669045590-26101-3-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Always read the descriptor with QUERY_DESC_MAX_SIZE. According to the spec, the device returns the actual size Signed-off-by: Arthur Simchaev --- drivers/ufs/core/ufshcd.c | 51 ++++++++++++----------------------------------- include/ufs/ufs.h | 1 - include/ufs/ufshcd.h | 1 - 3 files changed, 13 insertions(+), 40 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 301fda0..7456aa2 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3377,28 +3377,11 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, int *desc_len) { - if (desc_id >= QUERY_DESC_IDN_MAX || desc_id == QUERY_DESC_IDN_RFU_0 || - desc_id == QUERY_DESC_IDN_RFU_1) - *desc_len = 0; - else - *desc_len = hba->desc_size[desc_id]; + /*Always returns QUERY_DESC_MAX_SIZE*/ + *desc_len = QUERY_DESC_MAX_SIZE; } EXPORT_SYMBOL(ufshcd_map_desc_id_to_length); -static void ufshcd_update_desc_length(struct ufs_hba *hba, - enum desc_idn desc_id, int desc_index, - unsigned char desc_len) -{ - if (hba->desc_size[desc_id] == QUERY_DESC_MAX_SIZE && - desc_id != QUERY_DESC_IDN_STRING && desc_index != UFS_RPMB_UNIT) - /* For UFS 3.1, the normal unit descriptor is 10 bytes larger - * than the RPMB unit, however, both descriptors share the same - * desc_idn, to cover both unit descriptors with one length, we - * choose the normal unit descriptor length by desc_index. - */ - hba->desc_size[desc_id] = desc_len; -} - /** * ufshcd_read_desc_param - read the specified descriptor parameter * @hba: Pointer to adapter instance @@ -3470,7 +3453,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, /* Update descriptor length */ buff_len = desc_buf[QUERY_DESC_LENGTH_OFFSET]; - ufshcd_update_desc_length(hba, desc_id, desc_index, buff_len); if (is_kmalloc) { /* Make sure we don't copy more data than available */ @@ -4909,7 +4891,7 @@ static void ufshcd_setup_links(struct ufs_hba *hba, struct scsi_device *sdev) */ static void ufshcd_lu_init(struct ufs_hba *hba, struct scsi_device *sdev) { - int len = hba->desc_size[QUERY_DESC_IDN_UNIT]; + int len = QUERY_DESC_MAX_SIZE; u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); u8 lun_qdepth = hba->nutrs; u8 *desc_buf; @@ -7456,25 +7438,24 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba, static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba) { int ret; - int buff_len = hba->desc_size[QUERY_DESC_IDN_POWER]; u8 *desc_buf; u32 icc_level; - desc_buf = kmalloc(buff_len, GFP_KERNEL); + desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL); if (!desc_buf) return; ret = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_POWER, 0, 0, - desc_buf, buff_len); + desc_buf, QUERY_DESC_MAX_SIZE); if (ret) { dev_err(hba->dev, - "%s: Failed reading power descriptor.len = %d ret = %d", - __func__, buff_len, ret); + "%s: Failed reading power descriptor ret = %d", + __func__, ret); goto out; } icc_level = ufshcd_find_max_sup_active_icc_level(hba, desc_buf, - buff_len); + QUERY_DESC_MAX_SIZE); dev_dbg(hba->dev, "%s: setting icc_level 0x%x", __func__, icc_level); ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, @@ -7698,7 +7679,7 @@ static int ufs_get_device_desc(struct ufs_hba *hba) } err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_DEVICE, 0, 0, desc_buf, - hba->desc_size[QUERY_DESC_IDN_DEVICE]); + QUERY_DESC_MAX_SIZE); if (err) { dev_err(hba->dev, "%s: Failed reading Device Desc. err = %d\n", __func__, err); @@ -7945,18 +7926,16 @@ static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba) 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[QUERY_DESC_IDN_GEOMETRY]; - desc_buf = kmalloc(buff_len, GFP_KERNEL); + desc_buf = kmalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL); if (!desc_buf) { err = -ENOMEM; goto out; } err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_GEOMETRY, 0, 0, - desc_buf, buff_len); + desc_buf, QUERY_DESC_MAX_SIZE); if (err) { dev_err(hba->dev, "%s: Failed reading Geometry Desc. err = %d\n", __func__, err); @@ -7968,7 +7947,7 @@ static int ufshcd_device_geo_params_init(struct ufs_hba *hba) else if (desc_buf[GEOMETRY_DESC_PARAM_MAX_NUM_LUN] == 0) hba->dev_info.max_lu_supported = 8; - if (hba->desc_size[QUERY_DESC_IDN_GEOMETRY] >= + if (desc_buf[QUERY_DESC_LENGTH_OFFSET] >= GEOMETRY_DESC_PARAM_HPB_MAX_ACTIVE_REGS) ufshpb_get_geo_info(hba, desc_buf); @@ -8053,11 +8032,7 @@ static int ufshcd_set_dev_ref_clk(struct ufs_hba *hba) static int ufshcd_device_params_init(struct ufs_hba *hba) { bool flag; - int ret, i; - - /* Init device descriptor sizes */ - for (i = 0; i < QUERY_DESC_IDN_MAX; i++) - hba->desc_size[i] = QUERY_DESC_MAX_SIZE; + int ret; /* Init UFS geometry descriptor related parameters */ ret = ufshcd_device_geo_params_init(hba); diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h index 1bba3fe..2fc7107 100644 --- a/include/ufs/ufs.h +++ b/include/ufs/ufs.h @@ -38,7 +38,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_RPMB_UNIT 0xC4 /* WriteBooster buffer is available only for the logical unit from 0 to 7 */ #define UFS_UPIU_MAX_WB_LUN_ID 8 diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 5cf81df..7df2ce1 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -952,7 +952,6 @@ struct ufs_hba { bool is_urgent_bkops_lvl_checked; struct rw_semaphore clk_scaling_lock; - unsigned char desc_size[QUERY_DESC_IDN_MAX]; atomic_t scsi_block_reqs_cnt; struct device bsg_dev; From patchwork Mon Nov 21 15:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 628205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A3E4C43217 for ; Mon, 21 Nov 2022 15:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231829AbiKUPq7 (ORCPT ); Mon, 21 Nov 2022 10:46:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231767AbiKUPqw (ORCPT ); Mon, 21 Nov 2022 10:46:52 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50021275C; Mon, 21 Nov 2022 07:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1669045604; x=1700581604; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ppAPPKacSP3icl+8eBlb8o90BJjl+gGXwgHopEM8L4E=; b=nNalnZ+ED7F+24CJGOgO/9GE2cSx8tDl50/nVnh6/5WHFUBn3flsV7/I oq2+HrHuQjNwcYlyM+43dQfJkyWsuhpXE/8HnTGuanstsQrMNlv5fZmIr uBbXxuI9oVCNmN1wQlF56vy9spuu2/3IroxPDB7TrIqA38xOPqskBJvjm Z4o74Jg+pVW/GbRIJubS26sUSYqwqcu1yRSJZVAycw/rv7FKWMKTNP6Qd FnPRblDY5IDYFWrbEpfx3ouIc9HEViPHcO8l5c/A1JUo9Y6cKVtvhXLZN yWYVOurerPRpyQEJk3AwZ2x/RhpYiqXNRu9XopDzUPnoNukOQ4GCgjY0Z A==; X-IronPort-AV: E=Sophos;i="5.96,181,1665417600"; d="scan'208";a="215054346" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Nov 2022 23:46:44 +0800 IronPort-SDR: F79L/rt3muDvXzZxYQSTFGpsbZARSYDp4m4Z7ksEPOEL1JGqUVS5JqyuJHgoHELxMoeYaQZtSA 5q6yEbLbielUvL0fHEuK1JoAdWHRd4Ft/lNI+HS5GM7KlN+tJ/3P23S+XdmUtKnYZ4JrJByryU 0AHXr/mv7I6syc7DEaYLBguyPQR0crLdUyY1rXuP3kUg9KsIPDsEXXKtIGZtwno+qJXZoXI68g oS8NZxhWS/D0yNa8Auj5c+JdXvXCAq7jgoG+YFau2jqR0ud1l9Y2xa7sMfnvcYPJfu77cYHiRC EIg= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2022 06:59:49 -0800 IronPort-SDR: Wt+fqCqmMnTIdvV7BBHcyby2sLYPp5ADWYGOB80fhQSPnpevxHQld477puLcfdsXKCMNqA+GGS 2CT8w78IZ/AI2z4znk9OnwR6fyhJdGNJgWWCIuziGBLQ6+Wp0SVUFpsiqhNeTqDAkGLLORHeEa Abyro7uL9OmZHin7yDS0M+iCNGF1fqPIXPEBDdpu5DhkpeoEEkBwbJ1R1W6WyKu1N6wKS9S4bI PalNuaeh+Y1ocZewrd7pR0Sf2shJ3kjAgxrdPWnS0b6k8JP1HW+2pUjIb9I6oXQyRWgzbqvVmn wW8= WDCIronportException: Internal Received: from ilb001078.ad.shared (HELO ilb001078.sdcorp.global.sandisk.com) ([10.45.31.219]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2022 07:46:43 -0800 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: beanhuo@micron.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Arthur Simchaev Subject: [PATCH v3 3/4] ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl Date: Mon, 21 Nov 2022 17:46:29 +0200 Message-Id: <1669045590-26101-4-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org len argument is not used anymore in ufshcd_set_active_icc_lvl function. Signed-off-by: Arthur Simchaev --- drivers/ufs/core/ufshcd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 7456aa2..604348f 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7391,12 +7391,11 @@ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, * In case regulators are not initialized we'll return 0 * @hba: per-adapter instance * @desc_buf: power descriptor buffer to extract ICC levels from. - * @len: length of desc_buff * * Returns calculated ICC level */ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba, - const u8 *desc_buf, int len) + const u8 *desc_buf) { u32 icc_level = 0; @@ -7454,8 +7453,7 @@ static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba) goto out; } - icc_level = ufshcd_find_max_sup_active_icc_level(hba, desc_buf, - QUERY_DESC_MAX_SIZE); + icc_level = ufshcd_find_max_sup_active_icc_level(hba, desc_buf); dev_dbg(hba->dev, "%s: setting icc_level 0x%x", __func__, icc_level); ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, From patchwork Mon Nov 21 15:46:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 627474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF290C433FE for ; Mon, 21 Nov 2022 15:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbiKUPrD (ORCPT ); Mon, 21 Nov 2022 10:47:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbiKUPqz (ORCPT ); Mon, 21 Nov 2022 10:46:55 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 873D2205FB; Mon, 21 Nov 2022 07:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1669045607; x=1700581607; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yiM1yufWrsKiq6yVdSoRwS2PWUHBeXAhZCRxYu1y7wA=; b=EDW3utCpPTPUDtIIPiQ14UiZl24QtAaia0I5/ZZSXuE4JMqnY7w6xcJ8 bRbbt731ykgDb4/YwIu8uxdIS1w3QUX3wCR6v98Xtg5JoLtTf/MkgBlZa mcbndmgpaO1ycvfjTc9eosYedFRRbV3o3YlgUWuzuvM5989+tmx50On8y B4hY1/gbvT6EeBK9qBA44K7GPNpb3rLg842OlTSrwe0ZSrdr7IKXgYioZ tpANZIbLglJVWTrnlwKpkfTFgsSW61i7Gqh8nrvIXMcH6ff44y7JY1Klt e1O/1je8Z4ZE5S49RLkAsi59BxGADAfbXdQSdRqds92hwzMcPr/FhR/ct Q==; X-IronPort-AV: E=Sophos;i="5.96,181,1665417600"; d="scan'208";a="215054347" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Nov 2022 23:46:46 +0800 IronPort-SDR: saCNomazBVeDa3zmKjjQMNvR+9ZP0zxXzqaizBKVbYKgnotegrA659KJg2EYFV5vH5rfxQ04MV nghG2Ste+X4t8wjnDfey/l7tw8klUrKI+KHW12/8MaGfkPfpKi0XlqsIB38VHwlSWhAYp5ObZB l/X5UxdmpE62xmdoo7Q907x6kG2jDBkG6ZBDKjSxSDedO5QYNzs7FdE2iueehwqQkLwoJ8Htfn 7MbiQqhb3O/KUf8nw5mGozGRETsaw93dKYiI0KpNXWVs9TOMQVzI8ONPZU+vTJCdlI3kFyR7Hu 53A= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2022 06:59:52 -0800 IronPort-SDR: 0lXtwMYxoomeZSavH7aVr8AfbBP5QZhE4fBtoisYkkuGuqfw/Q8ZR0TEONY6cKlWYpzCHHzaet vSDu8vDMciUNee4G1bfN67fVkd4UjA09zOhlacex/3mOSOzHeLfXBPYbug1U9+7TwdvIpX9KpF x7iczukX1x2U74tqoV0kP6pYGu7EasHpko/vNTrtW4UbYkA6hp3v8UAgvY4K0O2ssUFQc8ZQwP i5qqN0d4CHuJmMHpnoqkt1o1Ng+KjaYdSQfBTRaFTTTe7KtvAPsnz48tzJK37ig8vtj1tP2bh/ YLo= WDCIronportException: Internal Received: from ilb001078.ad.shared (HELO ilb001078.sdcorp.global.sandisk.com) ([10.45.31.219]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2022 07:46:45 -0800 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: beanhuo@micron.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Arthur Simchaev Subject: [PATCH v3 4/4] ufs: core: Remove ufshcd_map_desc_id_to_length function Date: Mon, 21 Nov 2022 17:46:30 +0200 Message-Id: <1669045590-26101-5-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1669045590-26101-1-git-send-email-Arthur.Simchaev@wdc.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There shouldn't be any restriction of the descriptor size (not the descriptor id for that matter) up to QUERY_DESC_MAX_SIZE. According to the spec, the caller can use any descriptor size, and it is up to the device to return the actual size. Therefore there shouldn't be any sizes hardcoded in the kernel, nor any need to cache it, hence ufshcd_map_desc_id_to_length function is redundant. always read the descriptors with QUERY_DESC_MAX_SIZE size. Suggested-by: Bean Huo Signed-off-by: Arthur Simchaev --- drivers/ufs/core/ufs_bsg.c | 7 +------ drivers/ufs/core/ufshcd-priv.h | 3 --- drivers/ufs/core/ufshcd.c | 46 +++++++++++------------------------------- drivers/ufs/core/ufshpb.c | 4 +--- 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c index b99e3f3..dc441ac 100644 --- a/drivers/ufs/core/ufs_bsg.c +++ b/drivers/ufs/core/ufs_bsg.c @@ -16,16 +16,11 @@ static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len, struct utp_upiu_query *qr) { int desc_size = be16_to_cpu(qr->length); - int desc_id = qr->idn; if (desc_size <= 0) return -EINVAL; - ufshcd_map_desc_id_to_length(hba, desc_id, desc_len); - if (!*desc_len) - return -EINVAL; - - *desc_len = min_t(int, *desc_len, desc_size); + *desc_len = min_t(int, QUERY_DESC_MAX_SIZE, desc_size); return 0; } diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index a9e8e1f..c52e2f3 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -70,9 +70,6 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, int ufshcd_hold(struct ufs_hba *hba, bool async); void ufshcd_release(struct ufs_hba *hba); -void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, - int *desc_length); - int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd); int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 604348f..7990922 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3369,20 +3369,6 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, } /** - * ufshcd_map_desc_id_to_length - map descriptor IDN to its length - * @hba: Pointer to adapter instance - * @desc_id: descriptor idn value - * @desc_len: mapped desc length (out) - */ -void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, - int *desc_len) -{ - /*Always returns QUERY_DESC_MAX_SIZE*/ - *desc_len = QUERY_DESC_MAX_SIZE; -} -EXPORT_SYMBOL(ufshcd_map_desc_id_to_length); - -/** * ufshcd_read_desc_param - read the specified descriptor parameter * @hba: Pointer to adapter instance * @desc_id: descriptor idn value @@ -3402,26 +3388,13 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, { int ret; u8 *desc_buf; - int buff_len; + int buff_len = QUERY_DESC_MAX_SIZE; bool is_kmalloc = true; /* Safety check */ if (desc_id >= QUERY_DESC_IDN_MAX || !param_size) return -EINVAL; - /* Get the length of descriptor */ - ufshcd_map_desc_id_to_length(hba, desc_id, &buff_len); - if (!buff_len) { - dev_err(hba->dev, "%s: Failed to get desc length\n", __func__); - return -EINVAL; - } - - if (param_offset >= buff_len) { - dev_err(hba->dev, "%s: Invalid offset 0x%x in descriptor IDN 0x%x, length 0x%x\n", - __func__, param_offset, desc_id, buff_len); - return -EINVAL; - } - /* Check whether we need temp memory */ if (param_offset != 0 || param_size < buff_len) { desc_buf = kzalloc(buff_len, GFP_KERNEL); @@ -3434,15 +3407,23 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, /* Request for full descriptor */ ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, - desc_id, desc_index, 0, - desc_buf, &buff_len); - + desc_id, desc_index, 0, + desc_buf, &buff_len); if (ret) { dev_err(hba->dev, "%s: Failed reading descriptor. desc_id %d, desc_index %d, param_offset %d, ret %d\n", __func__, desc_id, desc_index, param_offset, ret); goto out; } + /* Update descriptor length */ + buff_len = desc_buf[QUERY_DESC_LENGTH_OFFSET]; + + if (param_offset >= buff_len) { + dev_err(hba->dev, "%s: Invalid offset 0x%x in descriptor IDN 0x%x, length 0x%x\n", + __func__, param_offset, desc_id, buff_len); + return -EINVAL; + } + /* Sanity check */ if (desc_buf[QUERY_DESC_DESC_TYPE_OFFSET] != desc_id) { dev_err(hba->dev, "%s: invalid desc_id %d in descriptor header\n", @@ -3451,9 +3432,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, goto out; } - /* Update descriptor length */ - buff_len = desc_buf[QUERY_DESC_LENGTH_OFFSET]; - if (is_kmalloc) { /* Make sure we don't copy more data than available */ if (param_offset >= buff_len) diff --git a/drivers/ufs/core/ufshpb.c b/drivers/ufs/core/ufshpb.c index 3d69a81c..11f8aa6 100644 --- a/drivers/ufs/core/ufshpb.c +++ b/drivers/ufs/core/ufshpb.c @@ -2382,12 +2382,10 @@ static int ufshpb_get_lu_info(struct ufs_hba *hba, int lun, { u16 max_active_rgns; u8 lu_enable; - int size; + int size = QUERY_DESC_MAX_SIZE; int ret; char desc_buf[QUERY_DESC_MAX_SIZE]; - ufshcd_map_desc_id_to_length(hba, QUERY_DESC_IDN_UNIT, &size); - ufshcd_rpm_get_sync(hba); ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_UNIT, lun, 0,