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: 23925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1671095wrr; Mon, 21 Nov 2022 07:55:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ftcXLTw4diVJq5c5aYvtFeRzaCPbNtP+JHCvVL7EANnWdTLS7WO5BWVGnFnjaeb+cYVrQ X-Received: by 2002:a17:906:1c12:b0:7b5:f9dd:2f4 with SMTP id k18-20020a1709061c1200b007b5f9dd02f4mr4915887ejg.243.1669046119080; Mon, 21 Nov 2022 07:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669046119; cv=none; d=google.com; s=arc-20160816; b=DEo5WikuPAVnzb5p6p/JqeY/bU07B26Rpqbp9/xodNHpa42ftRV2hUqLXdELXzE8rb PU/OmYB5shU7PuWVVLRs7yd39/LZJyyk0wxFZxORvIQR7O0MK+1kwF4S1ZoD6Ri67IBQ /tpDYCZZZzW3Oa8QefpaNhn5ZLx5cBiBV16zf5l3T/oaa7kQvk4iBCx92Wt3p14GecyC fedHpctuUUiU3ISaubwDaXXxiC99CUE28AnVOZAKHXl53oZ8wcUzltslpLdbyisYJmzC xXaZkDwvrLtQCrrmNWY8zYJ81/+T6YpOEFzUBF3wsdwp6EGxCTTdnasca32sOW7sa32+ e81w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=+vT77rwIZQmHdRJ7dZVhx6TOxL4jGtW0XGZbHX9l8co=; b=FJ3QK1Nd+oObq5vz0DMPI6XKCGvmyK8HzFqKGbXQ1vaFA0oNBpv1e8lkyL+lFQRZsD CyqVIvRluQ7NrUBebsc0qxy9MP/h5+J7TMv8g9L2gZKFRJr6/C+TI9bsMYe1F6rKFFps UfuOJACMggmYMGLwQReD7cgZpOs/SAN7ybYGAWt9BK1hYClIeXlILzYQHBFZLqwtGtl9 mAvLFZac0A+46yvGw3STM/qrDpSQJfbMb0SlXkKaQeE4gOlrB03soNRfmBxZL6ghyv44 5nUkMl/o2MQRKdX9lC/vKYH9GGl/iRqhcKxlcPC7FXs+H5hPgeEpoRw6ae730ZwYuYsH ozQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=LZpCYQj6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a056402350b00b0045c31d9643bsi10667334edd.2.2022.11.21.07.54.53; Mon, 21 Nov 2022 07:55:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=LZpCYQj6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbiKUPqp (ORCPT + 99 others); Mon, 21 Nov 2022 10:46:45 -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> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750121703223017707?= X-GMAIL-MSGID: =?utf-8?q?1750121703223017707?= 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 Reviewed-by: Bean Huo --- 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: 23928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1671733wrr; Mon, 21 Nov 2022 07:56:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6cGqNkycmi2RGHv1+L/GMaHt/PHTB5+XHKB8HH6eM24BHlaxKPsXhYVb7QNztkrT+6U0RJ X-Received: by 2002:a17:906:2854:b0:7ae:3684:84b0 with SMTP id s20-20020a170906285400b007ae368484b0mr7941425ejc.622.1669046196106; Mon, 21 Nov 2022 07:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669046196; cv=none; d=google.com; s=arc-20160816; b=Ii/nyWoMX/SVRmtw+e1jaZwrMH12BUSVsqzoDwWwZILf4iwgbySKmLW0pzWiptKLJD kwmAwS+vepWeRCZM429ZSD5jLni4dFTuOFIL00xsAGJG6wP4q3pZnSzg2j8l2Low4mCQ ZVi7NJfwmTasV3p3GAyZAMJUppj1YkbTQeP0yQdEkiE8c1RI0AvNkkVt8mzy2LJkPQ7l YMJtuJ7wcTD6rgx54slpX96HRUMOgRGBO5dR7mwX0zVvwFO45lVxVvqG06KxhVrrkvFw z3OSn6BFGaREeYMksWnTJ3QE023bNBhVFU18d1E7i6fnDFolHulg7PBJ0m2F6ELG2RMu xFJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=POaSG7H3Re5Y60Vl7LWlCvDXvfC9dlJqK1eRIqDAT9Q=; b=kMw7LGhxdHodaPh5VdKWTn7kwt58gqXzY+GvPCasU5GUJ5yxhXM0yZJ9tOqE2ABVOa x1/blVhwGKKsAa8AW8lMgLvS4M3ZGbj0WlccC/oCBDBQY180gACBYFjhllTAMfFecHwl fy/aK9Mld6nEexSmbCB5rXMFO86zUPAWiMaERiq6h2CUXWTw9c4IN8xghhki8fcBr/r/ l9EPX/VViS0QdywxEXqNvuyAfNcGckipdcw25ZS/LtPyQeAUa3oD2fk+4EyXl0nIo7eF fHhMqlCRfGaZFrhB0NMM5S9dskEt420de9RQIBW6RFc2l0hLBGNqPEHIyKxIWIGP67pt yY6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=nliDokLb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji16-20020a170907981000b0078d9d67841fsi9844350ejc.400.2022.11.21.07.56.12; Mon, 21 Nov 2022 07:56:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=nliDokLb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbiKUPrH (ORCPT + 99 others); Mon, 21 Nov 2022 10:47:07 -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> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750121783758021092?= X-GMAIL-MSGID: =?utf-8?q?1750121783758021092?= Always read the descriptor with QUERY_DESC_MAX_SIZE. According to the spec, the device returns the actual size Signed-off-by: Arthur Simchaev Reviewed-by: Bean Huo --- 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: 23922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1670647wrr; Mon, 21 Nov 2022 07:54:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf4OJgOOImIUyETMlxws5z7OXADzh9p5k/Achy5EBXOP/nTsBwGmdTnXXI2/VvKe7RA1z8jJ X-Received: by 2002:a05:6402:100b:b0:461:f1c6:1f22 with SMTP id c11-20020a056402100b00b00461f1c61f22mr2607990edu.95.1669046065540; Mon, 21 Nov 2022 07:54:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669046065; cv=none; d=google.com; s=arc-20160816; b=t+1iD1o86ZQmo8FPf9pZ26DMJ4mxSShGU4Q5iRycOK3pbJSfT6K1aN+7gocUq5N2BG fK/kV9RGwoM19eItbbv1xQA+zmFXW8spJmKf+HJv+1XFbKMM6zIZEiYK0E+Oo/5mFXJg OPRuUe1j8EB7+0HFZ9IxIxnDssEc2XdVI1dktDPk0txF82xos6iUyssR3+cYp6eDThSU PMG92SUUVue3TNYroPec0ZcGUvzHBGwgb+RV8lj3sl2A8XERygtnBVtWRUVm9H2gANmW lEgMXuH299ibdU3gbtmNCo5j3gBXQ1iYQ0GVD1I64sDuNnfjhBLPZDHYpsxGJwq3Qbcx 0DyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=3xbI3FqO1Pc5/OWOCcHLPAHmwOEC7W2voJ87MkMy7xA=; b=Jn5JxWlTYoJsQVTW35uRmhhnzivg0uFMdzc5mwbHUj5gzvHSt0hj7D7RN37sKkmfI+ fa9dxBZS6Pxy139FkJ7HVWOEOQhETdWrFwnBwRmHmIKJehHAYA9RqmS/92ElYm3giBzG vsJ2+gfMb2cG2tkkXCSHp33iXaCTRVJ1aOdtcWURkUgN9hE/VfJNqm8qhQ9QMN65Pcoe s77PN/h/FZfwEof8m+50SK52dLlpcTnqC5iVScZz7l2lq7VsEz6yoU+6T/DuGPxOHeiF I+X802B3nH5zviMN97PWQtTZNBELGhxaq+9CyGrpr7BUGQUdRrrCczG8hpJLTavnNlTg 8MMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=nNalnZ+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wb4-20020a170907d50400b0078dc7f7d0ebsi2545824ejc.822.2022.11.21.07.54.00; Mon, 21 Nov 2022 07:54:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=nNalnZ+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231784AbiKUPq7 (ORCPT + 99 others); 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> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750121646887289266?= X-GMAIL-MSGID: =?utf-8?q?1750121646887289266?= len argument is not used anymore in ufshcd_set_active_icc_lvl function. Signed-off-by: Arthur Simchaev Reviewed-by: Bean Huo --- 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: 23929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1671780wrr; Mon, 21 Nov 2022 07:56:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sYSRanUtZ1whSpwSg8KbRNczQeWt4NYUI+z7LjkM2ezwFHGxXFw1+eRa3rBpUwsnQHsfg X-Received: by 2002:a17:906:6417:b0:7ae:937f:2c38 with SMTP id d23-20020a170906641700b007ae937f2c38mr63322ejm.201.1669046201946; Mon, 21 Nov 2022 07:56:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669046201; cv=none; d=google.com; s=arc-20160816; b=yfjnvP5APF5srppS3TzPdZ9BVw4HmkIpkoY/3TAj7ezkcstxc61ipRKIPkXhDm98de yF0pMK9OnHx9t/+qDC+HCByreh33URQNzsLSkmLBuhczLqRsithvtSFkGa4BpFLSGmfS 8IoV/DUpxXSKJ8574WZYfEW5/nvXJzicIJGFHASEvmtYdyXzkA7OEMTA4VGZRRJygZYa EGSron8eLxZ3NxwBZyXUy9vwi8cvoy0cWXDhjFIIoqjq7XYCTfUxCIYPxB8iyTa4t501 knNcfYqd5mtRl5EZIUdiw9PGuNMFua4nRU1pSl8jjXg5q8hn4mU0XwLtBDBXMPucoVQF +BQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=pO9CIa1Eze42TLvVLEZjfhIj3jqJwHMDYCJFYxoya0c=; b=npOc7liFcERUGYPHXqypT4GgtkXMSaFj7UjXkqyFXcDKs5MUOmLwOwp6esbF3RK7x2 gTFykMUfc7dzqlv4WjwguDa6+NXivOK1tYBGC2ejgeHYP3/FkMIH3LBo9P6XymYZCxk0 biF0r6Hr9yRCC7690AQz2DYsnz9oqClQz64MleQBQ0K6pZhmz2gDCZOaVIptpsFhOC1d uyG5TgPIcL1KqA/zcnT5RAxEelSKrpntcDYEZHjPUG/gRgufF+F0OMQblAbtQAmVWZtB VFJii6XdLaAam5v6f5AxKmP3nFHyHJjrbRVDzuFerptEtRC76efltgbNZaEvGuYCGuYe IOdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=EDW3utCp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a50ef0b000000b00461d726439asi8846077eds.538.2022.11.21.07.56.15; Mon, 21 Nov 2022 07:56:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=EDW3utCp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbiKUPrO (ORCPT + 99 others); Mon, 21 Nov 2022 10:47:14 -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> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750121790178152991?= X-GMAIL-MSGID: =?utf-8?q?1750121790178152991?= 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 Reviewed-by: Bean Huo --- 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,