From patchwork Wed Nov 30 20:27:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 28001 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1137445wrr; Wed, 30 Nov 2022 12:34:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7X0ERPZ6ckUx26IiE6Br3Ng9TUnYNDODDxdDPshANutHc4ricwPSg74FGv5HydNgvW4X8X X-Received: by 2002:a17:906:2a9a:b0:7bb:e82a:83d with SMTP id l26-20020a1709062a9a00b007bbe82a083dmr26243079eje.612.1669840497066; Wed, 30 Nov 2022 12:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669840497; cv=none; d=google.com; s=arc-20160816; b=imy5kF/bkk5acw8QQ/1zCBh8VFU8EdVRj/i3MT1LJGh0IaALXVHWEaBExqOd26YBSg Nvq7Ps/Jb3iOR0KJBy+OBKFRER28VKe1Meirgc/eCQ2FEHvig62XSF0sJ1UT0Hfjxsl1 EamwiV63vglKsYtPmbUCX1CgxOAuZmVyeEaBe9/l4voqZ58QkdsEaxM2evmpaH3FLoSq 6r8WTXN0HrgBZl5X88r3vWiYw6tJCJVb122kxydvQt2RimmE+dnLUXH3bik00KVCLx+4 s+xI8eQT2PhbREvTWogM1oJNYpbno/X8CdTpfuC3PsNZzHr82x+IppYTcymZcPq4HfKF 9NTw== 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=GNi0SQNQIZAsvbrIE0BrUQelaM5ToKMC8+8upJmai8hyzy8GhCnYJkOCK/bxR6+diO HTTmDXa14VPXx7bt9vyzD77/40a2lp1KpscTPEhhLgoGlrDgpriVOI5nMh6h0dp7akXG AZNnkZ2veE8jFIMv+JntzwrcHIzXo1Fv7nTGmomOgdl03J8l8tShjHfFeSU0QAmpQw7O 4OOUzdLuJY4PTvgKC7TYV7t9kV0fc8jBpiy0xghxTtc1yRcogTsZsAjek+VVSnjQp9vs O1WE2/x/W6neQni9+1JLetuP3CyXxUyQ5F9s57qjPglT+On5dxHgzvrAIEoK5QRlpAXe znRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=F1mQk+I9; 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 go30-20020a1709070d9e00b0078797f6668fsi2315616ejc.364.2022.11.30.12.34.33; Wed, 30 Nov 2022 12:34:57 -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=F1mQk+I9; 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 S229634AbiK3U2d (ORCPT + 99 others); Wed, 30 Nov 2022 15:28:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiK3U2c (ORCPT ); Wed, 30 Nov 2022 15:28:32 -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 808EC4B9BD; Wed, 30 Nov 2022 12:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1669840111; x=1701376111; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=cEc6d+rufE3TCn17bKb+V76iBS5kpOCf6SBQG15gSgA=; b=F1mQk+I9eduytlxdtzwyjg7nHkoPEGtnLgXmq3+t/C2o9VrfYIEPoUeW 84t+rfn/gP3eEI/hGqaWuBUt7QVqIJLVZFWcgAd8/OIxjv9PK3/C5ImXw x3M2AxB+EeUabcO6JMrNk5Wir3sLZmZcKureLMBd4bK5BSQD98Li1V1vf Q=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 30 Nov 2022 12:28:30 -0800 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 12:28:29 -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, 30 Nov 2022 12:28:28 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v8 04/16] ufs: core: Defer adding host to scsi if mcq is supported Date: Wed, 30 Nov 2022 12:27:45 -0800 Message-ID: <0475898faf23cba385b9484b5823c1248b0e656a.1669839847.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-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?1750954669107937230?= X-GMAIL-MSGID: =?utf-8?q?1750954669107937230?= 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) {