From patchwork Mon Oct 31 16:25:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 622033 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 3EDB3FA3741 for ; Mon, 31 Oct 2022 16:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231629AbiJaQZ4 (ORCPT ); Mon, 31 Oct 2022 12:25:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbiJaQZ4 (ORCPT ); Mon, 31 Oct 2022 12:25:56 -0400 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2BA12639; Mon, 31 Oct 2022 09:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1667233554; x=1698769554; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Oe6SAgVHvhyllaVSMJMPlFVIjI8mku2kauEtvEtytYM=; b=mZ67AAX4+3etVND9IlFar2dJzpHb0dMwdTCEK3mk1vq9fQOvRzd40FSf RtQbUW4nNNfGP0lt+1ohn1KLjfh6pRa7d6976bh9PSWYTSp/cWjsj0gWu 4XMpqceR2OxuFxeT2QCCdW7Xet5kOWVwH0Ph/bf9MwixULEGUlMFYMvh4 c5nG1+QAOIKQ1PAvnC+DryuDAlghIvnRGKeGT+GF96+hAxbzhtREWkhO+ Ijmso0RWD7iUkSqUExw0V7bnswcrs0GIpdmoF86yTk0HH4DlqRDugvWz4 g5XiBd+APVCxJJrq7RxlCFDJC6/4ZXVFzBPuVw6E0WrfToLFBUJlsFWle g==; X-IronPort-AV: E=Sophos;i="5.95,228,1661788800"; d="scan'208";a="215498904" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Nov 2022 00:25:54 +0800 IronPort-SDR: zUbksTBZZSpaOiov2cw7LzCBZG2D1/GDOiFeny6jDZ88XH6QOupxnEZL0clPp1vBOKHWXYd+8v 9271PuzbZvlWRzXu0W8lVSGVeKoDg+X9mPR17zRoxfyDB8yw5lEqf6NYP4+Hmh3V6f8Ab/Bns9 CEzLpp9iK4Hz1XBYI72NVj3oCPjLZ99U/t8j1qiyFAW4CIAoZIkzoJrom3uKIigUbjG6VACf5I 6KP8nb2ApxwSgiKDKczH4A8e/2w/hBPOGqETii05Ocy+FiDSwbOtsqlwE+9Zn8yg/gpxTrkh/Z OeLFHbH4dhhD4FxJkTdhHMax 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; 31 Oct 2022 08:39:26 -0700 IronPort-SDR: q0TT1b3sjpKIc0XLofY3oDrUqQswVd1EbTpg3h0DXMHEDDl3o3UYq36kslfVDuHU+3wqear+/j 37p0AB5rpiXpXkMcu06UmzlHdNwm9nYRyCia4aITEBqGVUsVENpOX8Qrlju1b/oK+y8PtOvBDE 5pdhLSUJnKqJmugPPhk37Vk26RWz2uQQHWbzDBvlLOMKuu584BGFRG3Tug256P2RBq6le9SoJ0 yXb1WhAsWcRS33oHFnxHhbsEJKLIDLODHX8VWat/QTsMpqV06NjgV60qIQ6JUIJW09/54g2hG6 Dw8= 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; 31 Oct 2022 09:25:51 -0700 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: avri.altman@wdc.com, Avi.Shchislowski@wdc.com, beanhuo@micron.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Arthur Simchaev Subject: [PATCH 1/4] ufs: core: Remove redundant wb check Date: Mon, 31 Oct 2022 18:25:21 +0200 Message-Id: <1667233524-13715-2-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1667233524-13715-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1667233524-13715-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 ee73d70..de4e7e7 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7574,10 +7574,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 Oct 31 16:25:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 620423 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 C89CCFA3741 for ; Mon, 31 Oct 2022 16:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231674AbiJaQ0E (ORCPT ); Mon, 31 Oct 2022 12:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbiJaQZ7 (ORCPT ); Mon, 31 Oct 2022 12:25:59 -0400 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C7512766; Mon, 31 Oct 2022 09:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1667233558; x=1698769558; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=bRKQ9sSqIIZS0Qkc9JECvRRYfZDd/bzOP/3pGDU3Yus=; b=kLZ/i8VssJw4aurIQ6/TGyEnGRz0O8O3PVhtxneudszoMBI8d5vpcKdR O8SrpVEuCeBrL8Tmlmm6nw6YcObXQVKwLKErZoxLjjBmBdmPoY271NoLi unbZUSKycKBxhKcEgAXPv38VW3HHogHvGThWIvzgsr4JyUL+1DvVLDOGU goffAFA09uIgMSQexvgAn2kl+qCNIj8mxYZWV6f5ra/CKFMK3TcqBiYJE StSoxwNeoAmOVlegZGgQl0oLW0V3UnQS3lxBsZS27dTs3I7rrfwO8fDA0 NauEOqwrl+Y5UpGYi7cpdFZz87mm0y3XGVmuXXzvdmZ3ZUaiIRJqbvYbZ Q==; X-IronPort-AV: E=Sophos;i="5.95,228,1661788800"; d="scan'208";a="215498916" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Nov 2022 00:25:58 +0800 IronPort-SDR: yD209zcjqBeHc+jCssz9nv+K0ZIQW5W4w/lvtCarF8gddX19tHcHyyXf+wE/KrrAXfqJ5I5iIT XPRPH/4qkANc5n/z7LYqUzKH3ld2rhqTY2HIwHJg6pmPBS6fhrC3jjUAEktjDnLf+NIXwCB0oJ 1TMU9utgg0k8/s5Spa1BIXRwEXR98VybwzRoB0X9vPIwmqgGBguoFjs8NrLFMcyTJkjrfkv917 2JwtSqMlsp/Xbh9VaKS1ppgUqVuQxRXfZ5C6mXvd0/fBTa9iTwhqd2hE0iIu6iy41Jyq1491qz xNyU2gr4gPHIu6Qdek3j83Wx 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; 31 Oct 2022 08:39:30 -0700 IronPort-SDR: UxlQ/zaQbgpj/p1m/kAkcQbTJ7mCZHZrfA+fLCc/sHZxLQ6rs434p+xL2PMMYHHv/zl4txyxPj +lI//WGikiIIHqqyXaAC/MmwVdDAUCzLy3XI8VSdJQEk2nQWwHeVIsMv6/EJTSa/YZetcOSkDn bi1kDOUeOLGSwqFHOlbS0TUDDYzhFM2k5M554VzGqOt349rOZmdfqBmd5tZZsrd5p1MNYHCVF2 VgGXbvxb5N8trSsl8J+Dd++EYqj3bMcPOxkvKUZwwNbcRE4JI6VVtcYUC/o6E8Gtbm07LweY+l Mzk= 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; 31 Oct 2022 09:25:56 -0700 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: avri.altman@wdc.com, Avi.Shchislowski@wdc.com, beanhuo@micron.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Arthur Simchaev Subject: [PATCH 2/4] ufs: core: Remove redundant desc_size variable from hba Date: Mon, 31 Oct 2022 18:25:22 +0200 Message-Id: <1667233524-13715-3-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1667233524-13715-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1667233524-13715-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/ufshcd.h | 1 - 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index de4e7e7..aa46292 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 */ @@ -4905,7 +4887,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; @@ -7446,25 +7428,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 = kmalloc(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, @@ -7688,7 +7669,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); @@ -7935,18 +7916,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); @@ -7958,7 +7937,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); @@ -8043,11 +8022,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/ufshcd.h b/include/ufs/ufshcd.h index 96538eb..c3a0875 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 Oct 31 16:25:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 622032 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 DFFB2ECAAA1 for ; Mon, 31 Oct 2022 16:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231673AbiJaQ0G (ORCPT ); Mon, 31 Oct 2022 12:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbiJaQ0D (ORCPT ); Mon, 31 Oct 2022 12:26:03 -0400 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D65FD1276B; Mon, 31 Oct 2022 09:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1667233562; x=1698769562; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=tcPZBpWAoPb3fJeuZ0FofoSwD+Q2agXunSV1QbOjiq0=; b=PMZ+rghl0cNOpjfRbB/EHFxT9FsSETEdiueMcm8ypvKIM3UKlMWPA6hO 8UooUE1+wFaqBzryMKdxDcpIVxw/jgKA4Jbc2p98+8hrEES60g2VZSD3t aNwhxZdmbvtqqDUGgBmtPF1Os5MyooCC43RTzuX6YBmbwKhTk+6dT2Pcb zHIQAfEpDVzBgWCxFVO7j43hUAPA80fBY9bHQVrJBPiS5oC/tzOaEJsUp JX27GcLcLwy6zCDKouU23/B9bQwr2QK6J9xQDlbcJ2vvfRS0ATxdpo/8+ onFtDlUQ7oc69NhEymMw8+cvgia+m6Vnx23JZGQpmO44Po/fT2oSwzBwm A==; X-IronPort-AV: E=Sophos;i="5.95,228,1661788800"; d="scan'208";a="215498921" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Nov 2022 00:26:02 +0800 IronPort-SDR: TBXdjP0WM5mXHs9DFZaDwUQjGuflEsM33iAam/9OYI2QpUCKGAznddviDYDwPDNTyRXveXMvQA Bvnt/GZ4vy8CwkV0UuEvrSu+xYpyK2ollFWDGZU0gGT6foqkXSzVTuklSrFDV3LjGjKbMViVzq xkcL1YitZxooTCEJM9+Pa9ttZFj/hPoswBITSBhOuhdpf7jC4DAxUhf1n7lgS8xjHWgGbYJAiw EDQagRvnS9Vb1rxmNrOjS7ds22KeXJqMmwPIlmPrlrZwX4iWccqe/LvjoQGb96/23NA0sNhWpz jBc0f9o9VHGp3dKHEKtK9OER 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; 31 Oct 2022 08:39:34 -0700 IronPort-SDR: 0zaRbmorWNHzQsm8Dl9wwwb9ecVUtMNPO4Pd7F6nZsa3ilzX7PB4qlDaQrG/9v+PK33Cia/ALT Z8kLWlu/pqZdAS2QbgYMkAIcx1Obj1/EWrt9pzE0P2bdPecqJdgZy1NaViKsUT/Ap66kK4dNmT 2FRUwJ/Ibn8Z1tTkM5nQJv/qbZnrsaoaKFZk9+fLRdn6ynLGGUhpNLQ4A6Hkkqg8DQHaORjqEV /31Y1uNdji1kTUrsHhT5DQ9QBFuOj/Wqk1vxstbUHSkugqSbtBhWxoiE9LIqmtEX7j79o8QIVm wJs= 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; 31 Oct 2022 09:26:00 -0700 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: avri.altman@wdc.com, Avi.Shchislowski@wdc.com, beanhuo@micron.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Arthur Simchaev Subject: [PATCH 3/4] ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl Date: Mon, 31 Oct 2022 18:25:23 +0200 Message-Id: <1667233524-13715-4-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1667233524-13715-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1667233524-13715-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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index aa46292..9cc3abd 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7386,7 +7386,7 @@ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, * 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; @@ -7444,8 +7444,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 Oct 31 16:25:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Simchaev X-Patchwork-Id: 620422 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 B66C1FA3741 for ; Mon, 31 Oct 2022 16:26:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbiJaQ0W (ORCPT ); Mon, 31 Oct 2022 12:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbiJaQ0T (ORCPT ); Mon, 31 Oct 2022 12:26:19 -0400 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3721312AA4; Mon, 31 Oct 2022 09:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1667233568; x=1698769568; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Mj7AY5j761Zq4jzbtHts5Ba1UjUflyJ/f0xmcurSyRk=; b=jB07cJAj+0isllSKSN/HZg0q/Lj/FnYp4CEZRQB2EvnVjbvUFaOP9N6T ZHT9mycIv2bihukDS2E1KC3IfBHHPMFFgpSTaB0BDBtSljiSk1D/5kIEo XLLTLpwCt8TqlyarlrigDCVUh9PRZcsImn0xIgVgIA1yfiiu6FuefHdLw H66PuGt4jlrca901Sh+/qAOO+9XKSJc+K1drbI3JTqY5XQwGFSU117BXN jInZY1WS6sOGAvYbW1ufFcaYaH7ltxZBNiUGKg446H5k9QD0oeeq/czZE O9S4/dOL1UATDpH1vAbTIoJ5lNPIjC66QnM/zSlqPjuBDKCjHZQgGQtSA w==; X-IronPort-AV: E=Sophos;i="5.95,228,1661788800"; d="scan'208";a="215498933" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Nov 2022 00:26:08 +0800 IronPort-SDR: I82/3JsYSkDGXDlgnPrj9P0e54VYdxOb0gdgp9VUnXB0nW056dBB9eY2yww0JRKqw/uCpgGR8T llRrUhe03xExiPjsyB0IrSJenfmJiupwgI6Io8ruIjK+LmQdbneKpBkeP4vcfqOilPGacHhzgy PhyAqpNAQZOOX7VJdToqlhRl8Sc/ZJebPtxrMxIyU0oJJQAvSNLZ7wN8Yq04tjE2zZtI7q1NpL Rx4CyoSvEOSnWiBHl+b8j1A+dpqASaq0oxMoRofJxbS9d5/rbW4+6Dww2Kjvi04ns5RtScFFrb cI/tnxYO/7QgabQjcNde28Oc 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; 31 Oct 2022 08:39:40 -0700 IronPort-SDR: Bh0mgGwTYC/LBUKJuvZft33sv5tLX6dpjy+vB5WEwpeMilZJd0RWAt7MlogEXdXA3CRt8aBte9 V6Ps5v+Vu7k/LF5Fo6wXtPg9/7d6WUtfb7VWZGkGE+TW7nTr8lWX0kxt0YDrrb/dasGVnaqyU2 RDOH+XpD7CE6eS9gruYY//lUuam7VnDcnbNDywQckp6Nezfu100GumokwynL20TkK7cPsj7bdE 7G6uZqk/5Wign5hjhDCL92hHlwcHNdBI9qYuPBdQY3R1MIxRs9QkkODv7Uenw8qv/5XfC6abFt bVw= 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; 31 Oct 2022 09:26:05 -0700 From: Arthur Simchaev To: martin.petersen@oracle.com Cc: avri.altman@wdc.com, Avi.Shchislowski@wdc.com, beanhuo@micron.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Arthur Simchaev Subject: [PATCH 4/4] ufs: core: Remove ufshcd_map_desc_id_to_length function Date: Mon, 31 Oct 2022 18:25:24 +0200 Message-Id: <1667233524-13715-5-git-send-email-Arthur.Simchaev@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1667233524-13715-1-git-send-email-Arthur.Simchaev@wdc.com> References: <1667233524-13715-1-git-send-email-Arthur.Simchaev@wdc.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org ufshcd_map_desc_id_to_length function is redundant. According to the spec the host can send any descriptor size, the device will return the actual size. Therefore always read the descriptors with QUERY_DESC_MAX_SIZE size 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 | 5 +---- 4 files changed, 14 insertions(+), 47 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 9cc3abd..fc0695f 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..053fd66 100644 --- a/drivers/ufs/core/ufshpb.c +++ b/drivers/ufs/core/ufshpb.c @@ -2382,16 +2382,13 @@ static int ufshpb_get_lu_info(struct ufs_hba *hba, int lun, { u16 max_active_rgns; u8 lu_enable; - int 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, - desc_buf, &size); + desc_buf, QUERY_DESC_MAX_SIZE); ufshcd_rpm_put_sync(hba); if (ret) {