From patchwork Thu Dec 8 23:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 31527 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp473437wrr; Thu, 8 Dec 2022 15:22:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf6nsKYW+DGGjzeXCPpxabljNzNAHjc00924FByrLc4+sdI85ip1WVOVKlWVnT9n1718a9K6 X-Received: by 2002:a05:6a20:690d:b0:9d:efbe:e601 with SMTP id q13-20020a056a20690d00b0009defbee601mr5583636pzj.29.1670541739733; Thu, 08 Dec 2022 15:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670541739; cv=none; d=google.com; s=arc-20160816; b=jGAQ/Vm/5NipgymfFAh6jhyuwAf+n47cTsmq0loK9e6Dkb7ex1BceCFjXAG+WSWd32 mXUJhnzknEc81qVq6iCp7FfeoLEcti7mZm5jvWi++fEMP2keQrlOVc4dSujClTPz0OxK +2VJJ1zGLiNuAlnbU0/d326h3OPmufg4SxfL8wVI10qYKP+DqYe2eQLYR/wyvXVo7Zp5 9viOHBzY0wQN7txwIMRxOr/Bhw8Ea+yM4VzK5zsmYQ1F5JUmTYzFPQc8jR2xjMG124XB DyQDCUcYttvA33nSIVIRatsYDDpY3HHN2ZiWnm2X7WmCvJqoJVYAbQF4IpvaiY3MOKjH n3Vw== 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=XoJjdTNXumk8Uumod1/jhp8Wj2FhsoysZ80e4BVp310=; b=aAzXNqCjGb/e7MRe3K82w3wnrcjEt5IFJ6qW3j1NVnmsRqG2QfaNtG3jz5aBlzHKD1 jn2NqHspR+yBZoX1uayhSmAkepQ9ulEnU787l+jx6hS3ZN2d4tjxXSjZTaXzqKxSE6f+ wyIynbQNBPeZEdq0iLh28hGy2c/moYai/Q5njAqvpHn72pItQla++uHfZSPyYwd6w719 dhXWAgU0O3C4jONXCPiFMuP8bcdoDrlWXqKtllkJXEoigCCq5U9foLwHwRTCNNHszQrj Qhu0hrUOZnadLXWwt3/mNR49UihtLXRf3NZOLv1JuRx9KtEowHOH3iEremufU7Jq271o mLIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=x3l6ErR7; 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 w63-20020a638242000000b00478bf0b11b1si11494634pgd.752.2022.12.08.15.22.06; Thu, 08 Dec 2022 15:22:19 -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=x3l6ErR7; 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 S230097AbiLHXTq (ORCPT + 99 others); Thu, 8 Dec 2022 18:19:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbiLHXTQ (ORCPT ); Thu, 8 Dec 2022 18:19:16 -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 547E99E464; Thu, 8 Dec 2022 15:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1670541554; x=1702077554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=XoJjdTNXumk8Uumod1/jhp8Wj2FhsoysZ80e4BVp310=; b=x3l6ErR761IQ8O9rJP/blvI0eL5/lUeT35/QzE9SESXdvKH22q4wnNQF YGnSa6pV5RHOv83jXO5gnS0E62gf5U5NzAOs9bWTurHeav8WbFB19VFz6 QX1eo5YLIMBBdg6kgdfKWAK8Fsy5KzD14dtu9QTFK4WHGNOEDjKGGlLTv k=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 08 Dec 2022 15:19:14 -0800 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 15:19:13 -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; Thu, 8 Dec 2022 15:19:13 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v11 04/16] ufs: core: Defer adding host to scsi if mcq is supported Date: Thu, 8 Dec 2022 15:18:30 -0800 Message-ID: <1e64cece4de5f01c05a3d157f7afcdffa5044e04.1670541364.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?1751689975143994455?= X-GMAIL-MSGID: =?utf-8?q?1751689975143994455?= 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..869e495 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) {