Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp993744rwb; Tue, 29 Nov 2022 07:44:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ZrjSdc3SMjRkamv1s+Qn9ZmJJsPTqYiE3V0XNPDg9PM4vb6klCbGy9LzczbQYqOAL41BI X-Received: by 2002:a17:90b:1942:b0:219:42d8:bd3a with SMTP id nk2-20020a17090b194200b0021942d8bd3amr7838577pjb.177.1669736683688; Tue, 29 Nov 2022 07:44:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669736683; cv=none; d=google.com; s=arc-20160816; b=L2z4ya83I+JaeGxwYQ76mPHZdgHo77VG/EvDGw4nbdk3d1bjE8q79GXN1D89Fw6WZt PR6EhpYRslJ8LdcKM12sLJCXvv+x2XyX3iN4mez1F7t7uNlyB3LcwKEfesaeV354XNuG SCHJMu/UDGtjzE0Sp0G5XMv5T/lBR1l/3cfOuK4Mwa5U3lQyL2QVU0/49cC9YLdII3/d HF0EnmOqX0Da/qcBvU6VTxGM2GchmssKxQJW0FhUZOGIwB7fHqewKDwNyF1/C9g/SGVQ l+D1LFKq2PNOP/yRhD8fpVmuY11o0y6NrjJkM7Mi/SkFbRJ0CcAwBrEAQBHjbGEoPUd2 PXVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=tr0tt+nh7GF57tK4Qb5MEpukpUC/PhlYjPj1mQVdelc=; b=COKGyg3L7F1t5wFjCrOMTpCNCacpgXFp0B5V5zJ+D9aGc7hBacajVGI+3GK1opsSCX OQcxz/cQXPPYuQ7uSO/LczUX4adbBWWOntsT8Eaw6xduuaDdvWfsab6cJUqTNuR2dzxh TCTsg0KnRRfTXSKZJBjh3FKbNrFug22Ijrufs7TRsA14UaiWGftiTajMOWA3xJRaxPb+ k09A0x2S4Fu09mRtxq/DWyQarhpjn9+dl7EsHAPJOFHF2l8rdYDxY79uH+kBssSakyq5 fn/VS4d6EJtphJz5G/0GrJL72uCbGqT6q4TwPOdTgzyz2OK7z0Azx7kupPiA1zcHWH0r 9DBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WO0ik+5Q; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 76-20020a62154f000000b0056b86567ce9si13058482pfv.347.2022.11.29.07.44.31; Tue, 29 Nov 2022 07:44:43 -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=@kernel.org header.s=k20201202 header.b=WO0ik+5Q; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235863AbiK2P1W (ORCPT + 84 others); Tue, 29 Nov 2022 10:27:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235914AbiK2P1M (ORCPT ); Tue, 29 Nov 2022 10:27:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 465C1D4C; Tue, 29 Nov 2022 07:27:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D0E61615F6; Tue, 29 Nov 2022 15:27:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18C8FC433D6; Tue, 29 Nov 2022 15:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669735630; bh=05TN/ChYDsZNJQMqNeZeVjm48CGMgr/zwbKgDJxJOfg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WO0ik+5QqM1KtqV5MV3NWG/JLhOv1JfbJ9/uP6h8+w4gS7gxYmbQ0oJMikVEK+VSf LVxYbTawRmhLu+pfSw9gu8qCKiQVhhtxp+jlVG1KXrORGDTRcTjEW2x0tPjzJra3vi ZPvceIl0GN544j8w9psdOs1KVFzXH1DQt7AOi4P8vC0SBpHaMS46A2I9A2gvAfwb+T /3pjI8qEak4UNRDbs2fkPir0KpHRKDY9pKEMTUjaWFKY9mK8QlHFNIG1VMkLHUZOg3 FRqtNxNLdqeiK+Gd94f5fdiwygbkWYgmpH3Gf8lwVaAZZ9EmheEQ4eBwSgyLz7qJtx pdTXRia5RvkEg== Date: Tue, 29 Nov 2022 20:56:56 +0530 From: Manivannan Sadhasivam To: Asutosh Das Cc: quic_cang@quicinc.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, quic_nguyenb@quicinc.com, quic_xiaosenh@quicinc.com, stanley.chu@mediatek.com, eddie.huang@mediatek.com, daejun7.park@samsung.com, bvanassche@acm.org, avri.altman@wdc.com, beanhuo@micron.com, linux-arm-msm@vger.kernel.org, Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: Re: [PATCH v6 04/16] ufs: core: Defer adding host to scsi if mcq is supported Message-ID: <20221129152656.GD4931@workstation> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Mon, Nov 28, 2022 at 05:20:45PM -0800, Asutosh Das wrote: > 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: Manivannan Sadhasivam Thanks, Mani > Reviewed-by: Bart Van Assche > --- > 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) { > -- > 2.7.4 >