From patchwork Wed Dec 7 20:46:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 31038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp397530wrr; Wed, 7 Dec 2022 12:49:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UlTbAiUrlEUvv11d66e3EBE8tEtcTMgrAcpNOfBWXAV0fszc4VZlHJA//SjonEDSGyPzU X-Received: by 2002:a63:1915:0:b0:477:3803:674f with SMTP id z21-20020a631915000000b004773803674fmr64221794pgl.469.1670446168608; Wed, 07 Dec 2022 12:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670446168; cv=none; d=google.com; s=arc-20160816; b=ikrhpi5Drm2HMqQWBHJd813xmIjWn2Z1d9ZB/8ZRPtaItlxT3ybEHABVD1hk3CLcvE c8JYcWr+Anwg0CSF4KS/6Sj8Z9Yh9n5IGijevEA2Fm7rP41wPRMLJ3TIY1ylowDJdYIr EiInCFtFkTv9/FNjobZv+dAmfC3B598dQPpQzHqpgDKa5ljF14IG5Q+kuDr54qDhAZ/Y p/l6y88sacffD4CcVZLl7ShTrERDvUHNkCwWs/bhBU2ZG/1Hmdkh0qIYYp9KoXwfTTKs t7iiehHyYazgc6DYhjGNi8tQpW5VfY5vs905NU93JHB1QM0h0BPN4+eSXSSwd0UoC8wI 7m9w== 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=ccwtESWD8h1lTF0+gK4lHm3h5Venp14KqFPByj1NaaqmCZRQQD5BYxFvD3UPdD3dlo RlzlPVgbqyWwVVHFaHQ26ias7M07E7B/tKxs5uleh56XuRqttKoLj2ZKT6Ifw0TNgKBT z1xhZh2X4OKSiII+FZL4hYVFDQzegAfzJYPCDn5kDqh59KRwSO9H4CX91VOWnDtDjS6e thcLBM4WsY0JUJERyYtCHo5XcSBS7H8OWY0O8yrpBvrsjKzUs7Zj+5/hcwuWLQ987cFa yzOMWW5QWQysTy6rnpst1iQTyDehwKIJpDgjyie9khOXX2gvAiewtByF21cPowNlNqVz mMZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GOuRrunS; 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 g9-20020a1709026b4900b00189acbf164dsi20036138plt.21.2022.12.07.12.49.15; Wed, 07 Dec 2022 12:49:28 -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=GOuRrunS; 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 S229702AbiLGUrx (ORCPT + 99 others); Wed, 7 Dec 2022 15:47:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229895AbiLGUrb (ORCPT ); Wed, 7 Dec 2022 15:47:31 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93BF66CAD; Wed, 7 Dec 2022 12:47:26 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B7IUOgh021148; Wed, 7 Dec 2022 20:47:06 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=XoJjdTNXumk8Uumod1/jhp8Wj2FhsoysZ80e4BVp310=; b=GOuRrunS9qEC/+bBh2u08GblPdSdI6ZC9H1WkKmf2telGWb9ryCMRQlfFaQXuQqWsdSi 6D0VTmSRrPCIL1/Xz5/NpYtUTTwK7MKQ4r4TZrkYaXsM448Y8fUvml2JWPEx4S0jh7nX S1/VGVKxKnjP677qy5B/O2rRsUVDf0YSqY5g4GF//1/P9gomtUK969hanPkF3+C65kea /byrM2Wm40RD8AkQqrFNwagM1E42lPB+KnPRAuBuJeQwFbMsjqymzr75Poas5p3mqRuI SUWYNghDkRsEYumJJq16L6n9a5OkndNHeD87+YnvHA/M7KmDado90jTckCXGPPH7CLwn DQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3maww68r84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Dec 2022 20:47:06 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2B7Kl5Kh004022 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Dec 2022 20:47:05 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; Wed, 7 Dec 2022 12:47:04 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v10 04/16] ufs: core: Defer adding host to scsi if mcq is supported Date: Wed, 7 Dec 2022 12:46:15 -0800 Message-ID: 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-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: kX4lhPboR2UHgm54t2485f9ddGntK4eD X-Proofpoint-ORIG-GUID: kX4lhPboR2UHgm54t2485f9ddGntK4eD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-07_09,2022-12-07_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 suspectscore=0 bulkscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212070174 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1751589762005778621?= X-GMAIL-MSGID: =?utf-8?q?1751589762005778621?= 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) {