From patchwork Tue Nov 29 18:53:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 27398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp512489wrr; Tue, 29 Nov 2022 10:57:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf5g+VeYmdjR43WtR4ZDWueQtkRXtCM/gpuC/gwU+kKPTLK7MIYpkqj0YDZgOQ/K13YjQhyo X-Received: by 2002:a17:906:6ac1:b0:7c0:9a3:87ff with SMTP id q1-20020a1709066ac100b007c009a387ffmr9542307ejs.505.1669748246155; Tue, 29 Nov 2022 10:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669748246; cv=none; d=google.com; s=arc-20160816; b=hrRLg49cddNt1RdvQNtZWiVIg31W6fZVZW8yEqzwIYaOTHEXH/AfRAt/yn0c6NXe/J 8ZL5OKiMHDRGg9kwXUqLcl13lBSm0FDxoY3JWZtD7gViF4L/CvnZMER+sUJ6nqsz3KQs DouPgyrQssg1VqG0Ws1FxAkz56kakYZV/QzVsWvrisiJ51YxiF44jJbo8DVz34YOjwwt NMLNIGEsEFJwiEtlsX025832MK0P0ZWWP1jb3djNOtap1XTUfgooqA39wGjKbJiBkQIG zSLiJzSu24lKwKZ9LtucJ96Fq6JPk894YvvKAgsf4IAKSYJkHcpzeVlBMhNVv/3gGXYA 4Vng== 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=cEc6d+rufE3TCn17bKb+V76iBS5kpOCf6SBQG15gSgA=; b=yFYE8ChWcNBOT3JtiC+SMXZRSBwvT7DkhVxsZ3sNtWZfLL/rXTUjS/UorM7ccoY6+2 qcGfoMIdcpWg30qpVHWTYH6BuhusJfKFoMOOlhEFuEcFVkGGUq0WORC8rF+Gg+rvtXtf j3jOGNFMCCYGHz2+JeRuVH1vpZLhhew3YsizyQBR+Q6nwpDeeanUvqpwcAPTucPNRooc Dj063vY89dIliLwYCruRkKYJ6po136cBuO8AVm98bMj643NGlq3c7KB5AL38NPVre5Ap YWrVGefmYOG4W5aZxY52V54Met7qlbTHiY2jdtaCsBo0cOCulns+CJcU9zsUjBI+wtF4 YurA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ccsRiYmo; 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 i20-20020a1709064fd400b00781dbeebeb1si3847165ejw.585.2022.11.29.10.57.02; Tue, 29 Nov 2022 10:57: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=qcppdkim1 header.b=ccsRiYmo; 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 S236278AbiK2SzC (ORCPT + 99 others); Tue, 29 Nov 2022 13:55:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235770AbiK2Sy6 (ORCPT ); Tue, 29 Nov 2022 13:54:58 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D315B5AC; Tue, 29 Nov 2022 10:54:48 -0800 (PST) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ATIMlYe011423; Tue, 29 Nov 2022 18:54:28 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=cEc6d+rufE3TCn17bKb+V76iBS5kpOCf6SBQG15gSgA=; b=ccsRiYmo/GJ/kZD43Wow8cnx7SIihJgbiv5ZvkNUFmyCG2AMMt/NzLkWpcbKklrsilw4 Oc8UjCmx8Lz2axIO9xw18rtZ6/POKZiAqTCL2qD2kezCKYpSz+yPmTAl5GZcCI0Hl6O3 0p9ElIM5p+WCCFtCmNPYlLqyeMrPlKcB5w3dO2/fOw/dI7UvGPRUV6XTlgeIRTOf5pMa D+m1bkwMu9zLaZOmsU7y+yFukfU2qb0ep3Av5ZxiZjyZ2Qe2jxrMCABZMwwV1tjc2e7L tATHecWNnD9xa4o5RLbYlCKrieJGAzkJkfYJ3sutUn9VADI+JpbGlrgfW6UdC1WzivGb RA== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m5dnea99p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 18:54:28 +0000 Received: from nasanex01a.na.qualcomm.com (corens_vlan604_snip.qualcomm.com [10.53.140.1]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2ATIsRI2027917 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 18:54:27 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, 29 Nov 2022 10:54:27 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v7 04/16] ufs: core: Defer adding host to scsi if mcq is supported Date: Tue, 29 Nov 2022 10:53:10 -0800 Message-ID: <0475898faf23cba385b9484b5823c1248b0e656a.1669747235.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: 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: AaMl822IFskd9YjT5yuNzhHWaCz-vf6b X-Proofpoint-ORIG-GUID: AaMl822IFskd9YjT5yuNzhHWaCz-vf6b 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-29_11,2022-11-29_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211290108 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?1750857937339859918?= X-GMAIL-MSGID: =?utf-8?q?1750857937339859918?= If MCQ support is present, enabling it after MCQ support has been configured would require reallocating tags and memory. It would also free up the already allocated memory in Single Doorbell Mode. So defer invoking scsi_add_host() until MCQ is configured. 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 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index eca15b0..3c2220c 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -92,6 +92,11 @@ /* UFSHC 4.0 compliant HC support this mode, refer param_set_mcq_mode() */ static bool use_mcq_mode = true; +static 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; @@ -8227,6 +8232,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) int ret; unsigned long flags; ktime_t start = ktime_get(); + struct Scsi_Host *host = hba->host; hba->ufshcd_state = UFSHCD_STATE_RESET; @@ -8261,6 +8267,14 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) ret = ufshcd_device_params_init(hba); if (ret) goto out; + + if (is_mcq_supported(hba)) { + ret = scsi_add_host(host, hba->dev); + if (ret) { + dev_err(hba->dev, "scsi_add_host failed\n"); + goto out; + } + } } ufshcd_tune_unipro_params(hba); @@ -9857,10 +9871,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) hba->is_irq_enabled = true; } - err = scsi_add_host(host, hba->dev); - if (err) { - dev_err(hba->dev, "scsi_add_host failed\n"); - goto out_disable; + if (!is_mcq_supported(hba)) { + err = scsi_add_host(host, hba->dev); + if (err) { + dev_err(hba->dev, "scsi_add_host failed\n"); + goto out_disable; + } } hba->tmf_tag_set = (struct blk_mq_tag_set) {