From patchwork Thu Oct 20 18:03:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 6332 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp251486wrr; Thu, 20 Oct 2022 11:06:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4VGiAusTPWNnS0Tv8YVf8pp9RWB/iy+SQoDn4cFrCi9wEgvlxOKYOqzFGBlU6HBwHbA7td X-Received: by 2002:a05:6402:550e:b0:456:f79f:2bed with SMTP id fi14-20020a056402550e00b00456f79f2bedmr13629642edb.106.1666289207645; Thu, 20 Oct 2022 11:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666289207; cv=none; d=google.com; s=arc-20160816; b=XPY3f8UwTMVugdnTU9SPjRpitRlcFdydS2KdWdDcDKuNo4E0eW918rmNYRDaT0dHHz jLAWbfNUrAtxk4inz0tNdla2UVMQEOTD64DlqECEAPlUJCPjDrx2C7tLoXO40F7uyzPV 4sUDvWK/vH6IU2xMtJnam9QWzkGdKvChrYShjgVHTIg6QPO2J9TqxnA32e/OWfYYlpuC nfTvk/rhjgHywCUihG6uH8Xuj0DU+N6VLMsziTYafeDN4/xaDDirreD55O/lY4aO0zRH 8Smh7mw2wg7SM9X5HWrpqGcGbGaW0AMmTE8Mg+jr1i3lozq5Wbt3Bz6vEtxC8ia/6eBv ljZw== 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=60C3i8FnmTlwBmAMQf1qCwvcyt+KQjOOY6Qz3n3rThA=; b=xcM/7gLzJyU9Y3Lp1WvSzxUa+6XUI54l7lJ0GPhPra5n4CdamUsS1szHiU/uD1on94 na6AXZnpX8nfw/lvEIFNqPC/tNk7Cz09aS93KdLxvIXKWKPch/Gq4LOVy7FUa9+1RVOo JtI+KC7uNVFOqbyVHkOhueW892eplrsmDZwmDEu5nyOdVgqfmG1gxdbv/YE/Pdz1NZi9 qlhvUa9On9yAgBQUchGIXWDkfyQdfpOAnpQ9Gwo+xM90qvLiPjBLcSdCvu3JXFkG005d EADt/yfJv5OCMhtmIzxoCEBE03W99il4r6o+thLUy5eDV2aBTvhNrDM2nR38s2eo4Uyv Z91w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=TsVQcaJd; 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 d2-20020a50ea82000000b0045fb7a04ce0si2657794edo.148.2022.10.20.11.06.22; Thu, 20 Oct 2022 11:06:47 -0700 (PDT) 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=TsVQcaJd; 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 S229980AbiJTSF2 (ORCPT + 99 others); Thu, 20 Oct 2022 14:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229802AbiJTSFO (ORCPT ); Thu, 20 Oct 2022 14:05:14 -0400 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 C08048111A; Thu, 20 Oct 2022 11:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1666289112; x=1697825112; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=60C3i8FnmTlwBmAMQf1qCwvcyt+KQjOOY6Qz3n3rThA=; b=TsVQcaJdYCW+GwMH3XTBwE6XxUt3p2gDwon7ndHzrIBx4ErjV/3S+8T0 RPqLYRJcZVPlfXrcPR8QLTmQ7H1o0v6l0GHWnEIBE8SWmzT4q9C0ouuMA 0xdSdidD5jXN/g9TolfT41Bb4QUVRhqB2SWBXUS3yBVGJ2zW/6fCuheyR 4=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 20 Oct 2022 11:05:11 -0700 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; 20 Oct 2022 11:05:11 -0700 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; Thu, 20 Oct 2022 11:05:10 -0700 From: Asutosh Das To: , , CC: , , , , , , , , , , "Asutosh Das" , , Alim Akhtar , "James E.J. Bottomley" , "open list" Subject: [PATCH v3 04/17] ufs: core: Defer adding host to scsi if mcq is supported Date: Thu, 20 Oct 2022 11:03:33 -0700 Message-ID: <052c9049e4f3f6dc60e1254fbc67ee374f28a621.1666288432.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-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,URIBL_BLOCKED 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?1747230871896880225?= X-GMAIL-MSGID: =?utf-8?q?1747230871896880225?= If MCQ support is present, then enabling it would need 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 --- drivers/ufs/core/ufshcd.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 8d93797..fe4b683 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8187,6 +8187,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; @@ -8221,6 +8222,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); @@ -9767,10 +9776,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) {