From patchwork Wed Nov 9 19:41:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 17780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp527322wru; Wed, 9 Nov 2022 11:44:49 -0800 (PST) X-Google-Smtp-Source: AMsMyM5/Z/6lX2ls+EAnmSY/DwtiCMziztzSbRGR1XrGZhdovwKPgL5TjVCsXfYzS8c7K+fmrn7r X-Received: by 2002:a05:6402:754:b0:463:67da:3dc with SMTP id p20-20020a056402075400b0046367da03dcmr51822643edy.386.1668023089385; Wed, 09 Nov 2022 11:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668023089; cv=none; d=google.com; s=arc-20160816; b=j+clHEh6XCDFqeR/RFc9C9pZMiMWu6FdqRkzEVkyGI7KoNBEx5pQcnNUaWcr8cOa1t pvoLupC+u1Jr1Flj3pqeP5WF+ndjY8r3O7aE+Q5umfzqRKUPo8HoIkUDS90kq22gkeqc FXA1qHaG9E/Myo4t53MUMCxOCT6JCk5xtDCFTF98bLKRzMdSthfp4lTThOIavLjOZDBo j446C8lyxaEt9btWEiXCwvaZy+OusBw1XWk399ByyO78vCFLcEMq5O/pP3T+op0HhT79 WFQZSn3zYjoYUMWjWlEflgMAf1f1U4nG03cfk0Unp2So1iHG/NRymukH9TrJ/SZrcDQF EMaw== 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=moWiMdb/B93rijqFbs30H5stZY7YoxeIqrKiwTyFdfc=; b=m9YiGMH6aZgZ2ChCiZAquKNswXXBrWE6creE1omjPoQU3tgv+Do5DJItEiYeH98obz yEsadVAK34wY3iQVvgC6j6AIbH+UqaxvaSZknxHheAVWFQMVV6RyBX7/gYqD6WJo4+uC GgUoc7sGn31gtRFPPNizKLbHQf2O5KW4T4H/SWC7L3TuJCkVKckeMC17kZnOD8l4G9Q7 0hzYMcx0+XEP99BIZEiDbpFdSdOjJtomBcCJtuRa0RP+b/fMZ44DyFg6Xn2WtzQskvpK EKOGrZFoqNWpmYU6+4ZqyqdtXb2LIG5Xz38Ir0Kw7sSNwyJdRkr4BhQNLj9cYIdgAoCn dhag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IC58+VZB; 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 e11-20020a17090658cb00b0079a9eed8c1bsi18591862ejs.894.2022.11.09.11.44.26; Wed, 09 Nov 2022 11:44:49 -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=IC58+VZB; 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 S231838AbiKITnl (ORCPT + 99 others); Wed, 9 Nov 2022 14:43:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbiKITnc (ORCPT ); Wed, 9 Nov 2022 14:43:32 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716382AF7; Wed, 9 Nov 2022 11:43:30 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2A9Gm4CD024707; Wed, 9 Nov 2022 19:43:19 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=moWiMdb/B93rijqFbs30H5stZY7YoxeIqrKiwTyFdfc=; b=IC58+VZBnKdQHxlqWZS+o0ETe6g3pdKKSIpQ/BliCGNoABu+z0u0mRhmvKb3Ej9NtiXk Yh3sfALP6BDRYyFcfzbE2uX6WUXyuQhWCxUaAx2ELUJv52acfeDW/GTWidHC5zUwfO6a +BGJMQwWN4iq5mExsu+hzgA6xAZBZoTvb/t68JTSkkIuv+HBeVfWUFxJvNPI+ueQqs2C Xyyz3POxKmj/tm/uqBHVZE2Us5o2QnCEQp/izyPBjVfnMMycHr6PdOAAMeUowEKuye2t Mpzo+VyO0OWqYOVManpHdQSkjRXZEW7qZRgxYjxpKOyuczfXqTgw+IDntH++yKoxuPq0 nw== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3krg1y8j76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Nov 2022 19:43:19 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2A9JhJV2000362 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 9 Nov 2022 19:43:19 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.29; Wed, 9 Nov 2022 11:43:18 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v4 03/16] ufs: core: Introduce Multi-circular queue capability Date: Wed, 9 Nov 2022 11:41:28 -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: nasanex01a.na.qualcomm.com (10.52.223.231) 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: rsYeGvWAdYVktNHFF7UxzUURUS2GjIJ9 X-Proofpoint-ORIG-GUID: rsYeGvWAdYVktNHFF7UxzUURUS2GjIJ9 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-09_06,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211090148 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?1749048979156942163?= X-GMAIL-MSGID: =?utf-8?q?1749048979156942163?= 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 --- 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..55cd0cd 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 mcq_mode = true; + +static inline bool is_mcq_supported(struct ufs_hba *hba) +{ + return hba->mcq_sup && 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(mcq_mode, &mcq_mode_ops, &mcq_mode, 0644); +MODULE_PARM_DESC(mcq_mode, "Disable 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 */