From patchwork Wed Nov 23 04:10:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 24685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2582690wrr; Tue, 22 Nov 2022 20:13:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf41Fhw3A6axSowdfSUgApu58knLExpmhZA2gKVT4kCjVLBdSobrwSHSKhOMEQdv8ySpWN3e X-Received: by 2002:a05:6402:1717:b0:461:8fbf:f607 with SMTP id y23-20020a056402171700b004618fbff607mr23460683edu.235.1669176818327; Tue, 22 Nov 2022 20:13:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669176818; cv=none; d=google.com; s=arc-20160816; b=uQvR0tQm0wJ8OH3uHTjTMMIKqkUnlWhMDBOefQbv6ygiMKxSldT47sqmZMyrAtzDLT FXpl48uVQR8w8iSbhks2XVpqydR2UGPIv6i3ZjPRXEkinzkMRRsmVgKExkMOwRaCDg01 JwF7ZMbv84cHG+NB1i7mvpeu9gMLAH7PLWPrDOby/vASoRY9G1ATgSclxULqpSWgloCF o0aNh7ba+Wu/sn9W+uC86ZNUkczgczBMnnU0vCbxRKCfZFdc/RV0bP/zUwG9dG8AeSWB HatLs4fo+LrkvBXajvtOrcDFpuXZUrUKSKgy5/5I0qNAObkUnCXiwxM5cTbahTLdQoZr 6hSg== 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=Ik4m/VT/09dGO465+mKeYJFS9UgG48PS7MZH7FxBJUY=; b=XXvcDY2EkyoOW86DYcIwxlfQTJ72v+MJf5oM/mamWh7L44LzX/REbRoJ1wnybOpsmz 0xBVqhPJmWCSoEnbhPtUFxHWC76lwZBfgirqjSAyR2jQ+t4c4hcQHSFfv3HNm/EI0SWv Br8WrRAgFPmFuTgCUs9DIGpKHwf5Q9yomYkPggbYuAl4gB8Mac4eG1txYK4d2H6y2gaO MOxKMq0tZc/AS2wH0miroVYsfJ/9UEZJN0bJUL5d3Y65aQWW/XOSrnshX9cm55PQTgql EoJhqcFqBfZwMR5qB+L9jRSWOvjXa8HVPp6K2P6rjk56XaCFQymNe2f3tjh5Y5jSGSGc 4dSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jPzPL4oN; 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 w18-20020a056402269200b00461e122a4e4si14172054edd.314.2022.11.22.20.13.11; Tue, 22 Nov 2022 20:13:38 -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=qcppdkim1 header.b=jPzPL4oN; 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 S235705AbiKWEMU (ORCPT + 99 others); Tue, 22 Nov 2022 23:12:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235689AbiKWEMK (ORCPT ); Tue, 22 Nov 2022 23:12:10 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20775725DD; Tue, 22 Nov 2022 20:12:07 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN3ibuG014621; Wed, 23 Nov 2022 04:11:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=Ik4m/VT/09dGO465+mKeYJFS9UgG48PS7MZH7FxBJUY=; b=jPzPL4oNAodOHk/z9I8sHEi2CWEI08VDd2oUzpHEKTNlGWUXfop63jb8YZwx5SbO/lTx kp42JbP0LiNBJn3KJQeMHizb1+z0WPIzrCbnyTaeN0H0KFTtWezQHRKDI/v+Z3/IpZIL 2BahLbha0hwne+yA1+taUCFWw+JjVBNc9yXgppsSvxGdX15vRl2+kcJJvRmBUNrNq8r9 uR6EJmBPMw36SBnAUceQe7qvssLiVUmbPEGun5qZwuxbjOPn9FLxw+wzHYwVm1iVPh2d wUkvYXhc1JGYDucC02NdBz378zH0Y1wPa030M4Uat/Z9VQfxoDjgvnEWKroWqnIDpHBI YQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m11bu1dch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 04:11:55 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2AN4BseQ030869 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 04:11:54 GMT 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; Tue, 22 Nov 2022 20:11:54 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v5 03/16] ufs: core: Introduce Multi-circular queue capability Date: Tue, 22 Nov 2022 20:10:16 -0800 Message-ID: <1a84dab482956b19cb513dc46e9689e07316e357.1669176158.git.quic_asutoshd@quicinc.com> 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-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: qK4iD4JkgMSFflhohQPJVQmyWKM-SEIo X-Proofpoint-ORIG-GUID: qK4iD4JkgMSFflhohQPJVQmyWKM-SEIo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-22_13,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 adultscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230030 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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?1750258751531257144?= X-GMAIL-MSGID: =?utf-8?q?1750258751531257144?= 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 | 31 +++++++++++++++++++++++++++++++ include/ufs/ufshcd.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 66b797f..08be8ad 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -89,6 +89,33 @@ /* 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 inline bool is_mcq_supported(struct ufs_hba *hba) +{ + return hba->mcq_sup && use_mcq_mode; +} + +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(mcq_mode, "Control MCQ mode for UFSHCI 4.0 controllers"); + #define ufshcd_toggle_vreg(_dev, _vreg, _on) \ ({ \ int _ret; \ @@ -2258,6 +2285,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 */