From patchwork Wed Dec 7 20:46:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 31033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp397238wrr; Wed, 7 Dec 2022 12:48:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4bwSiTMJJV/O6jX2W5RjrjyV0br0oS/5JYYWH40fEjUkyRDJdEjdhY7YvnFUxXt3mdeiR+ X-Received: by 2002:a17:90a:b38e:b0:218:79d8:1a2d with SMTP id e14-20020a17090ab38e00b0021879d81a2dmr96787828pjr.229.1670446106423; Wed, 07 Dec 2022 12:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670446106; cv=none; d=google.com; s=arc-20160816; b=vgCPgAR4+tvpK+lTUoVTz6ROBzKL6XUL5n5FhBNxdQDzUqrWTArz2fOuNrYMnzGkD/ 8+eHxFWjVibb54H7Qb4Z1RQ1/QmmRXkYzwaDog5f7YTf1ek+mT0KPdSi0YjFySE8qPXb Zfa4eJyyEddV5BkVEBZnLWnU2SVJglfZeTs/H1ySkFog8P50dNpQm60Ruri9MUQtnqgk ToWc+NdmySV++uoSNmRxRkddos6UOzWdMFvQIiPWDYnI1XLZCFkwcmpcPEYfXl5eQ98d 0BQq1P5POWMA1LuPW/ZIQFYAojXUDVXXOnGt/uHN+y6foSLmJ6y/LExe/Snd5OPOGtWX FN6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JJLSbebFw9qNK2ogzbe+/HZ6FO1nbhq42JbF/wiwgGA=; b=qel2lll7Mbq4eMbLHVjzSQDMSv0OyVmkDJVXAA8UjGcgcjeqcCI8HqWHXbRQ0j2iiY fKFKWzjBTTE8mgJl81KIscwV5wC7aExUYfVUMfyRGzWDf/zhwiLzByTUlsh5nMfYz/JT R8te3tthRx4yWDv4b3Y67yPagoKjtkPp/rwZic5CzKaY95ag5eOcnvZzhwEl7GER3cau Dsrh//YJqlXKKRUgRPVV4ifyBjh/rWH4KzS/jjl/ky1BPqNVV2rYYsjVq/wlfVvoSPZB pxuWnoC0e2Ib3KVEkCBze2zqnlK3i9NWTFCBiVqV1H7zgEdEFRjMLi1ueM2f28wkcIAC KpFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xhRn1Kmf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a170902748400b00186c3727109si8792804pll.41.2022.12.07.12.48.13; Wed, 07 Dec 2022 12:48:26 -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=pass header.i=@quicinc.com header.s=qcdkim header.b=xhRn1Kmf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbiLGUrL (ORCPT + 99 others); Wed, 7 Dec 2022 15:47:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiLGUrE (ORCPT ); Wed, 7 Dec 2022 15:47:04 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D888286CE; Wed, 7 Dec 2022 12:47:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1670446023; x=1701982023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JJLSbebFw9qNK2ogzbe+/HZ6FO1nbhq42JbF/wiwgGA=; b=xhRn1Kmfcrml4EQlotNpqvIUIVEOvAW082up6hTPexBrUuX1bjMDaCCM sczV3SvoU9TYoI1NbLXI0BdyAWOVr4UrO2oLZRXnaUrpSTAsZhlumVlfv vZC8aFdnUXU7+VyrvwtWyMI63Wa7JXhJUvYapXYomlk60kPmVQ1FsH/9u E=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 07 Dec 2022 12:47:03 -0800 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2022 12:47:02 -0800 Received: from asutoshd-linux1.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 7 Dec 2022 12:47:01 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , Keoseong Park , Yoshihiro Shimoda , open list Subject: [PATCH v10 03/16] ufs: core: Introduce Multi-circular queue capability Date: Wed, 7 Dec 2022 12:46:14 -0800 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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?1751589696450618048?= X-GMAIL-MSGID: =?utf-8?q?1751589696450618048?= Add support to check for MCQ capability in the UFSHC. Add a module parameter to disable MCQ if needed. Co-developed-by: Can Guo Signed-off-by: Can Guo Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 26 ++++++++++++++++++++++++++ include/ufs/ufshcd.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 595fd3c..eca15b0 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -89,6 +89,28 @@ /* Polling time to wait for fDeviceInit */ #define FDEVICEINIT_COMPL_TIMEOUT 1500 /* millisecs */ +/* UFSHC 4.0 compliant HC support this mode, refer param_set_mcq_mode() */ +static bool use_mcq_mode = true; + +static int param_set_mcq_mode(const char *val, const struct kernel_param *kp) +{ + int ret; + + ret = param_set_bool(val, kp); + if (ret) + return ret; + + return 0; +} + +static const struct kernel_param_ops mcq_mode_ops = { + .set = param_set_mcq_mode, + .get = param_get_bool, +}; + +module_param_cb(use_mcq_mode, &mcq_mode_ops, &use_mcq_mode, 0644); +MODULE_PARM_DESC(use_mcq_mode, "Control MCQ mode for controllers starting from UFSHCI 4.0. 1 - enable MCQ, 0 - disable MCQ. MCQ is enabled by default"); + #define ufshcd_toggle_vreg(_dev, _vreg, _on) \ ({ \ int _ret; \ @@ -2258,6 +2280,10 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) if (err) dev_err(hba->dev, "crypto setup failed\n"); + hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities); + if (!hba->mcq_sup) + return err; + hba->mcq_capabilities = ufshcd_readl(hba, REG_MCQCAP); hba->ext_iid_sup = FIELD_GET(MASK_EXT_IID_SUPPORT, hba->mcq_capabilities); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index aec37cb9..70c0f9f 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -832,6 +832,7 @@ struct ufs_hba_monitor { * @complete_put: whether or not to call ufshcd_rpm_put() from inside * ufshcd_resume_complete() * @ext_iid_sup: is EXT_IID is supported by UFSHC + * @mcq_sup: is mcq supported by UFSHC */ struct ufs_hba { void __iomem *mmio_base; @@ -982,6 +983,7 @@ struct ufs_hba { u32 luns_avail; bool complete_put; bool ext_iid_sup; + bool mcq_sup; }; /* Returns true if clocks can be gated. Otherwise false */