From patchwork Thu Sep 5 22:01:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 826418 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41DE48F54 for ; Thu, 5 Sep 2024 22:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573753; cv=none; b=RZ3axbBBIMKrS3xa+XrMR5ON/NSJlpy5PJYl71oQfNU5m2KOSxHRujyb/GVDtjFqLT+Jl93JKxb8lO/KiA9ZQMFvVbv3M/TELL5TvPVc9DoOCsjpk7fTAMx9zGYCTZ4DdDO5d3Md2dSQ7+fho1ai/xw1kwfvuZzORUOk/znJTdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573753; c=relaxed/simple; bh=d4oJrsnnBysAtLRGPv8qu7rAoamGCy1ovmdhdg8mrNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uFrK3ZVSJY5Ch/wXhMZpr9RNVFlzMHwRrsB6wxHpMGHPnQbQd1xbI1MD1YTuoprlhabF6AyFDpvY82z2Ec2meQPh7kJ8eJAm90qHIJa2WbKrVwx8IjmfN/2RWtg5u4R3zXQ325/CoPPvndLWPAgDfn+9YHih+5p/pmdUrFeKGuk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=s7PIkuzn; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="s7PIkuzn" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0Cyb4rGbz6ClY8x; Thu, 5 Sep 2024 22:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573745; x=1728165746; bh=Zuoa0 e4USR6mDk4LznfikraMwh3U/3ox6PEqvn5zBTA=; b=s7PIkuznjkh0ho9qE0a5d 7fBFJZAEnBcEfpHHQB3s+z5+sTCU6Xqdh22eZRdmJIRAMD68y19G92sSkVYFGN2d rHkEfM01QzCoczQ9HVd7KaKBGNy4ybkzug9ascf/L9YXEK7IoY7+H64P/1X0vmUy YkJdW8eEK4WStxOsxolFpoSyKtfWU9xEu6cfd9NrTbb5YCCK9/gRErJNgN23nye9 OOOvQ0elKryrCbvNR/hXUSNe8fQzRAXJzcfR82uM0/YX1BRfHeMVy1TIUCqjm5rd rr7bAeoQcLT1dFGJ9kbFGMDyas5+Jmli7CTf9Imbl2Qe/KN2goprAW+rxn7aiPVg g== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id d570y-ygMVE1; Thu, 5 Sep 2024 22:02:25 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0CyT0zYQz6ClY8w; Thu, 5 Sep 2024 22:02:25 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Avri Altman , Bean Huo , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Andrew Halaney Subject: [PATCH v4 01/10] scsi: ufs: core: Introduce ufshcd_add_scsi_host() Date: Thu, 5 Sep 2024 15:01:27 -0700 Message-ID: <20240905220214.738506-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the code for adding a SCSI host and also the code for managing TMF tags from ufshcd_init() into a new function called ufshcd_add_scsi_host(). This patch prepares for combining the two scsi_add_host() calls into a single call. No functionality has been changed. Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 84 ++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 8ea5a82503a9..ecf6da2efed1 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10357,6 +10357,56 @@ static const struct blk_mq_ops ufshcd_tmf_ops = { .queue_rq = ufshcd_queue_tmf, }; +static int ufshcd_add_scsi_host(struct ufs_hba *hba) +{ + int err; + + if (!is_mcq_supported(hba)) { + err = scsi_add_host(hba->host, hba->dev); + if (err) { + dev_err(hba->dev, "scsi_add_host failed\n"); + return err; + } + hba->scsi_host_added = true; + } + + hba->tmf_tag_set = (struct blk_mq_tag_set) { + .nr_hw_queues = 1, + .queue_depth = hba->nutmrs, + .ops = &ufshcd_tmf_ops, + .flags = BLK_MQ_F_NO_SCHED, + }; + err = blk_mq_alloc_tag_set(&hba->tmf_tag_set); + if (err < 0) + goto remove_scsi_host; + hba->tmf_queue = blk_mq_alloc_queue(&hba->tmf_tag_set, NULL, NULL); + if (IS_ERR(hba->tmf_queue)) { + err = PTR_ERR(hba->tmf_queue); + goto free_tmf_tag_set; + } + hba->tmf_rqs = devm_kcalloc(hba->dev, hba->nutmrs, + sizeof(*hba->tmf_rqs), GFP_KERNEL); + if (!hba->tmf_rqs) { + err = -ENOMEM; + goto free_tmf_queue; + } + + return 0; + +free_tmf_queue: + blk_mq_destroy_queue(hba->tmf_queue); + blk_put_queue(hba->tmf_queue); + +free_tmf_tag_set: + blk_mq_free_tag_set(&hba->tmf_tag_set); + +remove_scsi_host: + if (hba->scsi_host_added) + scsi_remove_host(hba->host); + + return err; +} + /** * ufshcd_init - Driver initialization routine * @hba: per-adapter instance @@ -10488,35 +10538,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) hba->is_irq_enabled = true; } - 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->scsi_host_added = true; - } - - hba->tmf_tag_set = (struct blk_mq_tag_set) { - .nr_hw_queues = 1, - .queue_depth = hba->nutmrs, - .ops = &ufshcd_tmf_ops, - .flags = BLK_MQ_F_NO_SCHED, - }; - err = blk_mq_alloc_tag_set(&hba->tmf_tag_set); - if (err < 0) - goto out_remove_scsi_host; - hba->tmf_queue = blk_mq_alloc_queue(&hba->tmf_tag_set, NULL, NULL); - if (IS_ERR(hba->tmf_queue)) { - err = PTR_ERR(hba->tmf_queue); - goto free_tmf_tag_set; - } - hba->tmf_rqs = devm_kcalloc(hba->dev, hba->nutmrs, - sizeof(*hba->tmf_rqs), GFP_KERNEL); - if (!hba->tmf_rqs) { - err = -ENOMEM; - goto free_tmf_queue; - } + err = ufshcd_add_scsi_host(hba); + if (err) + goto out_disable; /* Reset the attached device */ ufshcd_device_reset(hba); @@ -10574,9 +10598,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) free_tmf_queue: blk_mq_destroy_queue(hba->tmf_queue); blk_put_queue(hba->tmf_queue); -free_tmf_tag_set: blk_mq_free_tag_set(&hba->tmf_tag_set); -out_remove_scsi_host: if (hba->scsi_host_added) scsi_remove_host(hba->host); out_disable: From patchwork Thu Sep 5 22:01:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 825825 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 464568F54 for ; Thu, 5 Sep 2024 22:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573756; cv=none; b=lbQbzSrDGcz23EQuViBXWCL6kBvG2wuQuN/IYQKM0N5Vkxn1ml5cxUNrXJyNnkzejHBF8ecshuAp94aUasbwaVlTArjcL5lntGDWNkA5qgI/WEStS6qWFr7zewhI+WAXMwZ1C/D9DqXFyOYNIL6f0OLMhIc3ihCEdF4eY5QTy7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573756; c=relaxed/simple; bh=mqupfqSVdnCk4qZBAuYXce9mvrcxrMDg6Q0xyxPruP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mpLwPeiuTePWEfiLFbZ3NxZQlw/HBMQ+CD6BSpOcUXLhgyl8GjfgHdol+wdIt5RKMVE3Q3ixpcdZjd9DV1bQPvTQfBlz1/qsz4QlF1TKB1FSv3lMs2y9Bhs11/spW7eT1ZK9rI0gdVfIc6dfzdLXSlZJV4swwW5LZlE8PTf6rlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=AyxnMvX/; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="AyxnMvX/" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0Cyf5ZKtz6ClY8x; Thu, 5 Sep 2024 22:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573750; x=1728165751; bh=Nu151 KQ2+rioKfJaJQxIXRlDPr6ltJfirvCDt5MReOs=; b=AyxnMvX/xnDefDjGIm6AZ f/l+nPW65pkAO2XkRk/dW3o1mKLiBu7AK+tgaZBw7DG181ZlD4OplYjm4b3uWAlL XCu7O+foK7JPn9pz09hlUZO5G0kkbOVUBDRZDoIh8BLWJ7+TX114GhtT4b6uYcNx jUprN+1J7b1FJwsGVtwfE2AI18ven+V6LuG6rJJt3HMiV12W3pkRzuXv+W3nLhST c5EH3opFQX4xSyTQuowTZsf+8f1lbN9maukG6dy9mgx8j/MvIgN62U9QgB1xils4 1gswvjFpQOIZ5zxq3ZSXFF+ykL8/zEtouXWPbHKNROjXKjIaG8YKKWGj90EiDjOT g== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id L6alzBOwZOv2; Thu, 5 Sep 2024 22:02:30 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0CyY6Hj4z6Cnk98; Thu, 5 Sep 2024 22:02:29 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Avri Altman , Manivannan Sadhasivam , Bean Huo , "James E.J. Bottomley" , Peter Wang , Andrew Halaney Subject: [PATCH v4 02/10] scsi: ufs: core: Introduce ufshcd_activate_link() Date: Thu, 5 Sep 2024 15:01:28 -0700 Message-ID: <20240905220214.738506-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prepare for introducing a second caller by moving the code for activating the link between UFS controller and device into a new function. No functionality has been changed. Reviewed-by: Avri Altman Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index ecf6da2efed1..4cfa8dd5500a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8709,10 +8709,9 @@ static void ufshcd_config_mcq(struct ufs_hba *hba) hba->nutrs); } -static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) +static int ufshcd_activate_link(struct ufs_hba *hba) { int ret; - struct Scsi_Host *host = hba->host; hba->ufshcd_state = UFSHCD_STATE_RESET; @@ -8729,6 +8728,18 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) /* UniPro link is active now */ ufshcd_set_link_active(hba); + return 0; +} + +static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) +{ + struct Scsi_Host *host = hba->host; + int ret; + + ret = ufshcd_activate_link(hba); + if (ret) + return ret; + /* Reconfigure MCQ upon reset */ if (hba->mcq_enabled && !init_dev_params) { ufshcd_config_mcq(hba); From patchwork Thu Sep 5 22:01:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 826417 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B289B1B12CA for ; Thu, 5 Sep 2024 22:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573762; cv=none; b=sc4zQFOgp0sqvWOWQ0cAzLKCUl0HOhua7RC3rqzd+i2ND1gRpzRQxrD+YfYuPj6DFM+Hbbx9Aqm0c85ChlZw+nxo+Dh1mHlvPkI9KR+FRQUr6vABZx/fbp+OTF2HBAe9jNB1bjQGdd/GWiT2zlgpP8rtWZlAIgW/Iudzjd9+Jz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573762; c=relaxed/simple; bh=BE1uL7eMYfQ6UYMZI/SPaFGrlVEe4iLM4MAk78614Mw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ej/6Ms44PG7NCe0tvRsGzvHJJ12iX8chCXzCkAs8Ju60br/kLx2bLkPoT3HlMeSx8680bTIFpU8ROY8GJBBbXEWm3ddOicnM6KfKgvDUccx6lyMKQxyPrs3x5LZUHmqz8v1Fcs5RkYstPWKayB+WWNtNv/whHn/ivuQTVEDNLX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=NbngpEUQ; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="NbngpEUQ" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0Cym1YXdz6ClY8x; Thu, 5 Sep 2024 22:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573755; x=1728165756; bh=xfMH2 4IquzGoqShpch38Gy8uJsMsbw2Sq0NtFpwk2kY=; b=NbngpEUQTjy3IkEsYN0kG tgVOipvP5pcvqrpGIX5oW0lS9E6uKWUjUDZ7+BZRZFyt1sxsuPlB5MU9iK9sApgj YdSDyGJSt71H8ADq0dxHbwLKVuZV57yPA8cJAndMnMrd27lS39ZkAIbatPLKYocj DvkWaSYfDB8JTAruuD/HIFUlNK1BNeo0NW1dXHhx3HDVNNu/xw7XLQLpJc9YqWlx /VhIFJAI9Cjxe4NBxMW32Fm50y4MLuKWlj2zYxu/If/MUV9oRt9hV0tDNnrreoNH vQAdJcSQX7hUeWfz83Xu4cwuXetvVveGHCSxONPMZ1CfKB78JYjAbrmL9qq5RMGT A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id A3K05IIMcLQ9; Thu, 5 Sep 2024 22:02:35 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0Cyf3dLLz6ClY8w; Thu, 5 Sep 2024 22:02:34 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Avri Altman , Manivannan Sadhasivam , "James E.J. Bottomley" , Peter Wang , Andrew Halaney , Bean Huo Subject: [PATCH v4 03/10] scsi: ufs: core: Introduce ufshcd_post_device_init() Date: Thu, 5 Sep 2024 15:01:29 -0700 Message-ID: <20240905220214.738506-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prepare for introducing a second caller by moving more code from ufshcd_device_init() into a new function. Reviewed-by: Avri Altman Reviewed-by: Manivannan Sadhasivam Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 63 ++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 4cfa8dd5500a..916da4c054be 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8731,6 +8731,41 @@ static int ufshcd_activate_link(struct ufs_hba *hba) return 0; } +static int ufshcd_post_device_init(struct ufs_hba *hba) +{ + int ret; + + ufshcd_tune_unipro_params(hba); + + /* UFS device is also active now */ + ufshcd_set_ufs_dev_active(hba); + ufshcd_force_reset_auto_bkops(hba); + + ufshcd_set_timestamp_attr(hba); + schedule_delayed_work(&hba->ufs_rtc_update_work, + msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); + + if (!hba->max_pwr_info.is_valid) + return 0; + + /* + * Set the right value to bRefClkFreq before attempting to + * switch to HS gears. + */ + if (hba->dev_ref_clk_freq != REF_CLK_FREQ_INVAL) + ufshcd_set_dev_ref_clk(hba); + /* Gear up to HS gear. */ + ret = ufshcd_config_pwr_mode(hba, &hba->max_pwr_info.info); + if (ret) { + dev_err(hba->dev, + "%s: Failed setting power mode, err = %d\n", + __func__, ret); + return ret; + } + + return 0; +} + static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) { struct Scsi_Host *host = hba->host; @@ -8789,33 +8824,7 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) } } - ufshcd_tune_unipro_params(hba); - - /* UFS device is also active now */ - ufshcd_set_ufs_dev_active(hba); - ufshcd_force_reset_auto_bkops(hba); - - ufshcd_set_timestamp_attr(hba); - schedule_delayed_work(&hba->ufs_rtc_update_work, - msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); - - /* Gear up to HS gear if supported */ - if (hba->max_pwr_info.is_valid) { - /* - * Set the right value to bRefClkFreq before attempting to - * switch to HS gears. - */ - if (hba->dev_ref_clk_freq != REF_CLK_FREQ_INVAL) - ufshcd_set_dev_ref_clk(hba); - ret = ufshcd_config_pwr_mode(hba, &hba->max_pwr_info.info); - if (ret) { - dev_err(hba->dev, "%s: Failed setting power mode, err = %d\n", - __func__, ret); - return ret; - } - } - - return 0; + return ufshcd_post_device_init(hba); } /** From patchwork Thu Sep 5 22:01:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 825824 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF77F15532A for ; Thu, 5 Sep 2024 22:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573766; cv=none; b=rkaBN3Z+mbCjvWXR4lFaGJIoBzX5naMDSNL0L331NGyVsQ1a+RQ5VIwlECkIIVpaTd0yXiUYKweNbdnMNTAzZMc6kIl8BtL0gyP4AFyvP0WAiUt9p7FyPfpdMLFRsp3X/Jo7wJLvi+U97LY1F/Tb9mU45ODk7KDc4V/fB+g758U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573766; c=relaxed/simple; bh=Y8h0p1VIW05/oj6rm1hd2eyj8F9k94ol2MTF/wnnXeE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gLa+NxbEpgbBMC9ODHecEI1+m4iiL7q0l6b81UcpRWQn7lFuHSDLiyeEkd9xCTXEuglZc6CREuA1eUwlsD3SnMvOgEPKqWhduPT5WbOGpwNKvnu5WTF5z1T+3yIskxLPD+E69Kj9boGoR/KRFLgbhNO08rSsq3foDzVsKBtegdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=ct9EccVx; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="ct9EccVx" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0Cyr2hklz6ClY8x; Thu, 5 Sep 2024 22:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573760; x=1728165761; bh=zW7dx 286Gkb9lhuBYiFuiaZzA2lPOFmNf/CG3iIDeJQ=; b=ct9EccVxavM1lndqRI6Kp wMM7agmGHMkc4iakZjNfePoP/TeHmom5sC7DtsWGW6DGPl1g1Ji5JPSxAvLSq5Fg +xuXTP1HEYtUZ8+JDur7Q6hedQv4oOAkHLee9q9SVJpsclKs03ksEJvpJMddZ6Cg H+zZJkPAiqlsIbiAPTfBiZa6Y3ui2EubPCCCcD6cc6DH828RwTIHQ6R52FKhHQE4 9E3qFE46HMBj066gUQCM/GpA6l0GEfRCSw6S9W7r4ex738QSLoRtcnonZC3eVODm vWqDlZFA+0IY6XMmdMEX+rRWDvlUoK62nM+P8GRf2AArx0De6cKLVX+ckquuTY08 A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id De0Z9CjpXFlR; Thu, 5 Sep 2024 22:02:40 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0Cyl1sXTz6Cnk98; Thu, 5 Sep 2024 22:02:39 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Manivannan Sadhasivam , Bean Huo , "James E.J. Bottomley" , Peter Wang , Avri Altman , Andrew Halaney Subject: [PATCH v4 04/10] scsi: ufs: core: Call ufshcd_add_scsi_host() later Date: Thu, 5 Sep 2024 15:01:30 -0700 Message-ID: <20240905220214.738506-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Call ufshcd_add_scsi_host() after host controller initialization has completed. This is possible because no code between the old and new ufshcd_add_scsi_host() call site depends on the scsi_add_host() call. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Reviewed-by: Bao D. Nguyen --- drivers/ufs/core/ufshcd.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 916da4c054be..e2137bcf3de7 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10558,10 +10558,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) hba->is_irq_enabled = true; } - err = ufshcd_add_scsi_host(hba); - if (err) - goto out_disable; - /* Reset the attached device */ ufshcd_device_reset(hba); @@ -10573,7 +10569,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) dev_err(hba->dev, "Host controller enable failed\n"); ufshcd_print_evt_hist(hba); ufshcd_print_host_state(hba); - goto free_tmf_queue; + goto out_disable; } /* @@ -10608,6 +10604,10 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) */ ufshcd_set_ufs_dev_active(hba); + err = ufshcd_add_scsi_host(hba); + if (err) + goto out_disable; + async_schedule(ufshcd_async_scan, hba); ufs_sysfs_add_nodes(hba->dev); @@ -10615,12 +10615,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) ufshcd_pm_qos_init(hba); return 0; -free_tmf_queue: - blk_mq_destroy_queue(hba->tmf_queue); - blk_put_queue(hba->tmf_queue); - blk_mq_free_tag_set(&hba->tmf_tag_set); - if (hba->scsi_host_added) - scsi_remove_host(hba->host); out_disable: hba->is_irq_enabled = false; ufshcd_hba_exit(hba); From patchwork Thu Sep 5 22:01:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 826416 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF27B15532A for ; Thu, 5 Sep 2024 22:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573772; cv=none; b=eMIHZcuI+sqxalF/JEJV29QME2dNo02HI7LLL9zLP5r2DyZURLR7jrqr/EozOVv8/p2f9Cgdq36gn7GYhHQMO3sXfpnhc9Ct7FTr4BfW+DHovzYQkPtBFLD6yVIZ3SlB4/StxyVOcNuinLBf8CEfetWP/WBXjSu84yyouliQBUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573772; c=relaxed/simple; bh=yaiEjDXaCGspBEv6pBjCdhxiwZFpKYpSP2JiONQXnTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JhE4E596fcJf+7tb2I/w6cCOzKNgbjyLbDqkWh4CFU4usq05evn8w0tQKC7h3sK5t317fFH9ogFwh4BiU4qBZTa1KXGw2f5QPTwrGJjcCHSy51L+cph3COI/r9mNUzpyF033VuX0YYlGKSAs1T6YwvL1qsXGlepCPeEfTb09uws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=M++y0Dj6; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="M++y0Dj6" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0Cyy3K07z6ClY8x; Thu, 5 Sep 2024 22:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573764; x=1728165765; bh=238ED FcsWeAvzUXHT436aBiy5ZfGiIv7+fgB6GaIDTE=; b=M++y0Dj6O1aQ8OBAEcRIM Lj3RIUcdubf3flN1Kp8ongWaDTMwtsaD4PAEFvBnVGgo+DihlwfapxCDxNps0UBu 4hQeXvplpuGrEAbuhBGE/4Kb17C1cGls1OBEg6e30b+UX2XUcGcqL8aFGOVSQWPO dtdnqwjOLMfMiGB1BDKG7hQuBPQkVIyjlRdh1fptj70fUL5OWpauPtzJI6PEdNDu Gy+OFRq43PegareqG+fnTjA0VIWP9u8R/E9AJnU5GKVo/kWCjB2O3Rwp7DLOckB6 3TqxsjLQ0QVjuDJjieJoIL6wVYTIOYJQcQk09nh4Q01SZwxj1H3Peiy8L6Tq7aZ6 g== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 2Ih3h0skY6I8; Thu, 5 Sep 2024 22:02:44 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0Cyq6sVYz6ClY8w; Thu, 5 Sep 2024 22:02:43 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v4 05/10] scsi: ufs: core: Move the ufshcd_device_init() call Date: Thu, 5 Sep 2024 15:01:31 -0700 Message-ID: <20240905220214.738506-6-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the ufshcd_device_init() call to the ufshcd_probe_hba() callers and remove the 'init_dev_params' argument of ufshcd_probe_hba(). This change refactors the code without modifying the behavior of the UFSHCI driver. This change prepares for moving one ufshcd_device_init() call into ufshcd_init(). Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index e2137bcf3de7..6e3cffcdf9a6 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -298,7 +298,8 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba); static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd); static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag); static void ufshcd_hba_exit(struct ufs_hba *hba); -static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params); +static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params); +static int ufshcd_probe_hba(struct ufs_hba *hba); static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on); static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba); static int ufshcd_host_reset_and_restore(struct ufs_hba *hba); @@ -7693,8 +7694,11 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) err = ufshcd_hba_enable(hba); /* Establish the link again and restore the device */ - if (!err) - err = ufshcd_probe_hba(hba, false); + if (!err) { + err = ufshcd_device_init(hba, /*init_dev_params=*/false); + if (!err) + err = ufshcd_probe_hba(hba); + } if (err) dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err); @@ -8830,21 +8834,16 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) /** * ufshcd_probe_hba - probe hba to detect device and initialize it * @hba: per-adapter instance - * @init_dev_params: whether or not to call ufshcd_device_params_init(). * * Execute link-startup and verify device initialization * * Return: 0 upon success; < 0 upon failure. */ -static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) +static int ufshcd_probe_hba(struct ufs_hba *hba) { ktime_t start = ktime_get(); unsigned long flags; - int ret; - - ret = ufshcd_device_init(hba, init_dev_params); - if (ret) - goto out; + int ret = 0; if (!hba->pm_op_in_progress && (hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH)) { @@ -8862,7 +8861,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) } /* Reinit the device */ - ret = ufshcd_device_init(hba, init_dev_params); + ret = ufshcd_device_init(hba, /*init_dev_params=*/false); if (ret) goto out; } @@ -8910,7 +8909,9 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie) down(&hba->host_sem); /* Initialize hba, detect and initialize UFS device */ - ret = ufshcd_probe_hba(hba, true); + ret = ufshcd_device_init(hba, /*init_dev_params=*/true); + if (ret == 0) + ret = ufshcd_probe_hba(hba); up(&hba->host_sem); if (ret) goto out; From patchwork Thu Sep 5 22:01:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 825823 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD0C715532A for ; Thu, 5 Sep 2024 22:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573775; cv=none; b=lELp7lR+SUELsejdv/B0pxzashrb13ln9sU8EpSIHpEFaNEDJx26RQdwkmpDcHBmRdXyOCqOK/koId9uqEvSoz+GpnOTjPrSrUuryO4M7C01xYqR361KhVV5AhbKLyfHNOHSjK+x5rfgt8GhtvvFGBNEb7Lgr8ngbJCviTdQvbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573775; c=relaxed/simple; bh=lJLyFb/Ul7zIMEsfZ77b26BRegm9VVp/upjwjQk3K2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QIxh3spgz2Ek5QWHAl1ZGe9kWn63dZrw1uhqWOdRVAcWoFHTWvw5tAXBY/b5tJeqPSO2JeT7w/4axFxfPNejvbcWH+MOUCjbNJ4X1BgTHY3yuEDENobD09NdUv1eZ2BGM3DOc3J55S8iiM8R8+0GHte64ym0ProIC61Hr3gSS5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=hF7+jVMD; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="hF7+jVMD" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0Cz11Kndz6ClY8w; Thu, 5 Sep 2024 22:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573769; x=1728165770; bh=zELt5 g5uvvRisZ9et/+0oyEiHnto9XLPei+vOKt6r7w=; b=hF7+jVMDlqFSjaitUJ8sS FPeD6zsfFp04a8I9Bc0Q9vdwJ05+JiaXMLVBO+A7fcw6iBO+T+U2l3PSixXZXoAV SoswlWLrEqbdf4khlkofssDzRG4b3zE4zawTtpCAx4AOWbkvi8oaWEjWexm1lGax eQj33J8y6ODgOgzCtLMt8+7a22UmAqMNouUW5+P/nYjpC5VxgYRA7QDLmiT0twwv 5pyX7HdNN9qOKepeI7y33NBWmxOxOUtakDJbYxCucIIFLXt/mP8lWss059m4JAbk PvjKhYghS8QtniRxsEix/FHKtvVpXVa6xu5jSJ8Lt6VxRi/SeUOsk/vHjzR/RP36 A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id qUSBhOzOntAG; Thu, 5 Sep 2024 22:02:49 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0Cyw3dw7z6Cnk98; Thu, 5 Sep 2024 22:02:48 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v4 06/10] scsi: ufs: core: Move the ufshcd_device_init(hba, true) call Date: Thu, 5 Sep 2024 15:01:32 -0700 Message-ID: <20240905220214.738506-7-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the ufshcd_device_init(hba, true) call from ufshcd_async_scan() into ufshcd_init(). This patch prepares for moving both scsi_add_host() calls into ufshcd_add_scsi_host(). Calling ufshcd_device_init() from ufshcd_init() without holding hba->host_sem is safe. This is safe because hba->host_sem serializes core code and sysfs callbacks. The ufshcd_device_init() call is moved before the scsi_add_host() call and hence happens before any SCSI sysfs attributes are created. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 6e3cffcdf9a6..843566720afa 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8908,10 +8908,7 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie) int ret; down(&hba->host_sem); - /* Initialize hba, detect and initialize UFS device */ - ret = ufshcd_device_init(hba, /*init_dev_params=*/true); - if (ret == 0) - ret = ufshcd_probe_hba(hba); + ret = ufshcd_probe_hba(hba); up(&hba->host_sem); if (ret) goto out; @@ -10605,6 +10602,10 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) */ ufshcd_set_ufs_dev_active(hba); + err = ufshcd_device_init(hba, /*init_dev_params=*/true); + if (err) + goto out_disable; + err = ufshcd_add_scsi_host(hba); if (err) goto out_disable; From patchwork Thu Sep 5 22:01:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 826415 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 770F71AD5D7 for ; Thu, 5 Sep 2024 22:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573779; cv=none; b=HT3+mtP7PEZ0YuIEWDEQI9Mn7zUTYvmg+h3NNHJE+yaGn8a0dQqAnWzR7SYVx8DsdCBJnN/w4zRNnt2g5kLb+6sC/bKE+CjBbC8gCBGTkMyiPhZpYTFkdjblgw1zrDHzh/QCmBF0bBa+E/wbz+iAx5iZqyZPpLv25BvcRzbF8Pk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573779; c=relaxed/simple; bh=qQHyoO3C/r0mgT6UM+SLGNsnVfkQUuYr1haCYK6U9Vw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P3vlKsqnQifQ1IsaLBLSROoJI6oR0hgstbzLa8w84Sa3b0FzRdVg9z7Zr8Yi6QIr3Q68r2ZIv2j/o5NUBa2qN/MOMCOPDBJGDUeWpiajkuUxnOYX5/4yr0jThJ3UJoj5Y6ZVz6L4+m81gn7GWiXNOXLPo+UgGiPv55+ez34f254= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=HqC2VRE2; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="HqC2VRE2" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0Cz61p8Cz6ClY8w; Thu, 5 Sep 2024 22:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573774; x=1728165775; bh=Z5a4F BJpLeDU6zq+CE8fg8nfPMaXdkJ+OqvorL4hgDg=; b=HqC2VRE2zoJP81KfH+ECj CfP5zfwz78u/njpDbpgakFBagA+8WjOlVMcF2l0Z7F1a9/HufbYg/BGjHlusiwcO F9fvzMj0+MDALjqTsvIiTQ6ip+14i0AuOUIcnvwBsP2CYf/a5RyQ6o33NMNv36Zj Gym878luJW68qa6IvBGCgyir8gkOpA/xaYxv5Ubi6CKNF3hnGiT2IppaBGrxm790 BRV63neTgMSAlCM8Z0bu+QeVsvJzQZpBDh+GDbnpeZKPEl0oD9ptZ5f87efKcWs3 0qKy3g5yCz/f1aEswZ548SnVu/ezcbZ7RMpVhUSfptfMXkr1oMrT/ZKXSlJhSY2c A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id oA5n-pWv5PrZ; Thu, 5 Sep 2024 22:02:54 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0Cz11NWBz6ClY8x; Thu, 5 Sep 2024 22:02:53 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v4 07/10] scsi: ufs: core: Expand the ufshcd_device_init(hba, true) call Date: Thu, 5 Sep 2024 15:01:33 -0700 Message-ID: <20240905220214.738506-8-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Expand the ufshcd_device_init(hba, true) call and remove all code that depends on init_dev_params == false. This change prepares for combining the two scsi_add_host() calls. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 843566720afa..014bc74390af 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10602,7 +10602,48 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) */ ufshcd_set_ufs_dev_active(hba); - err = ufshcd_device_init(hba, /*init_dev_params=*/true); + err = ufshcd_activate_link(hba); + if (err) + goto out_disable; + + /* Verify device initialization by sending NOP OUT UPIU. */ + err = ufshcd_verify_dev_init(hba); + if (err) + goto out_disable; + + /* Initiate UFS initialization and waiting for completion. */ + err = ufshcd_complete_dev_init(hba); + if (err) + goto out_disable; + + /* + * Initialize UFS device parameters used by driver, these + * parameters are associated with UFS descriptors. + */ + err = ufshcd_device_params_init(hba); + if (err) + goto out_disable; + if (is_mcq_supported(hba)) { + ufshcd_mcq_enable(hba); + err = ufshcd_alloc_mcq(hba); + if (!err) { + ufshcd_config_mcq(hba); + } else { + /* Continue with SDB mode */ + ufshcd_mcq_disable(hba); + use_mcq_mode = false; + dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", + err); + } + err = scsi_add_host(host, hba->dev); + if (err) { + dev_err(hba->dev, "scsi_add_host failed\n"); + goto out_disable; + } + hba->scsi_host_added = true; + } + + err = ufshcd_post_device_init(hba); if (err) goto out_disable; From patchwork Thu Sep 5 22:01:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 825822 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6BDE1863F for ; Thu, 5 Sep 2024 22:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573785; cv=none; b=pJQxngs/6mr0h+dFyMGLRADcYoaAobYUNKiEDEmuOl61rwFs0h0aiNUpyJMi66w5MF5xGC//kVG2ITyxf3pvoFkfogVXjsqhQLb/sioF7l8+IpDyLhEHvrGNb3vKtf8fGpx1wmLn4zgo7ldxlm8r0jSwYGMI5w6y/sWoWOZtCSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573785; c=relaxed/simple; bh=ss/sKEDXl3PmB7Kf0sDbFGVrbRVl9/VZmQoF8Ytem7M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gBCHGhvEfHUvic94EAfKMhbNRS0H52BMVyTi5ZcsVdXRUCK68ikzG25/l11BOLedRNeyCe5KSsTRt6Dz1KFbyVqTcA0Bvlr/hnAXVodPRInqSHIChFYId5nPKMauHXDNQPZ8PWT2QSw+PtJt7fMZlne2XCrmMXbxVigHpEv7EiA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=QpR5YigQ; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="QpR5YigQ" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0CzC3Lnqz6ClY8x; Thu, 5 Sep 2024 22:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573778; x=1728165779; bh=FIIrY S+ctROYpXJeXdK6dBVc5uAUU3fdyEOTNy0DciQ=; b=QpR5YigQPGAlMIvQW9BEf Hi1ORMXlO+amIcrUYZGBn8CJ0TcyEpMdcm64lY8kGCHs10HkxXuG6Ufq5vTFWQ/J aRwEsKPAP8i1xi8vSlxqp0YZaKjdQYXY7GR2SS5c+uc69d2BqKYM9Ewkq/2CNQXw KHM1Xq4BYJEjlCl3DXljtQpKmimuhb5aT3ysjrHpKBVYLtMnwj33NafHdWKSqpTh 9cZInj1x6zw/YZMAgjolYvC8AAefuiX4HgFdJ2r52SaVNVj3NAmr0Nv/kEMz4rnV hcvU/aPaA88osuEU4f2LOGBn/Lbrj0NzI47lkiNY2bNsGn7133S0wWtbor9fCcJr A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id fk2Jbw-CY91u; Thu, 5 Sep 2024 22:02:58 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0Cz56fLFz6Cnk98; Thu, 5 Sep 2024 22:02:57 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v4 08/10] scsi: ufs: core: Move the MCQ scsi_add_host() call Date: Thu, 5 Sep 2024 15:01:34 -0700 Message-ID: <20240905220214.738506-9-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Whether or not MCQ is used, call scsi_add_host from ufshcd_add_scsi_host(). For MCQ this patch swaps the order of the scsi_add_host() and ufshcd_post_device_init() calls. This patch also prepares for moving both scsi_add_host() calls into ufshcd_add_scsi_host(). Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 014bc74390af..b46e9b526839 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10379,7 +10379,25 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba) { int err; - if (!is_mcq_supported(hba)) { + if (is_mcq_supported(hba)) { + ufshcd_mcq_enable(hba); + err = ufshcd_alloc_mcq(hba); + if (!err) { + ufshcd_config_mcq(hba); + } else { + /* Continue with SDB mode */ + ufshcd_mcq_disable(hba); + use_mcq_mode = false; + dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", + err); + } + err = scsi_add_host(hba->host, hba->dev); + if (err) { + dev_err(hba->dev, "scsi_add_host failed\n"); + return err; + } + hba->scsi_host_added = true; + } else { err = scsi_add_host(hba->host, hba->dev); if (err) { dev_err(hba->dev, "scsi_add_host failed\n"); @@ -10623,25 +10641,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) err = ufshcd_device_params_init(hba); if (err) goto out_disable; - if (is_mcq_supported(hba)) { - ufshcd_mcq_enable(hba); - err = ufshcd_alloc_mcq(hba); - if (!err) { - ufshcd_config_mcq(hba); - } else { - /* Continue with SDB mode */ - ufshcd_mcq_disable(hba); - use_mcq_mode = false; - dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", - err); - } - err = scsi_add_host(host, hba->dev); - if (err) { - dev_err(hba->dev, "scsi_add_host failed\n"); - goto out_disable; - } - hba->scsi_host_added = true; - } err = ufshcd_post_device_init(hba); if (err) From patchwork Thu Sep 5 22:01:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 826414 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EF9B198838 for ; Thu, 5 Sep 2024 22:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573788; cv=none; b=URIwxXHUv1CMgBi2nuagr1Dz5g5Bb0d3pIOB2qp8AegyPWfatQ3nC0l40bj3F1LZGcM/++XUwGFYw4gS8VdHGDyVTTDfKkk/2Fe4YkE29AkflhqOlxSLAlI4pQ1W4D4tqRnt9tgaoLp0YJVbopFPuVthJb/DmjE6lC5Vd/gtuNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573788; c=relaxed/simple; bh=vxAG7YELlPYdZmgLTddKtvaVXspoeadGd9t3Rr0aU6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CT2LEdE/+g7Iaio/gxE4daIHwgAGdYoiFLXJA8JiEfBMpbd73v5Wg2FHRZ9VP+JeveBmeccXZ78QWNNb24MM3G6owr6P4FK7PVr0vxjKIqy+r4JhD5uzEqXbh+gutFBE6YuplsMj5ztYE1C4k6venXIsH/YVcsqcLISVxLg3AwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=gpYyIQVo; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="gpYyIQVo" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0CzG7247z6Cnk98; Thu, 5 Sep 2024 22:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573783; x=1728165784; bh=d+ZU2 WmW7NTrSQcCm6ZsMaG+tRWsQFzTqNS4phBgSJ4=; b=gpYyIQVoKIU8MylgMgb8e 9/Naw6o+NvlJuCYv9zoh9klbjAz02/uISVt/rehGCBocpJJyWvKcrJSAcg10JLgU eRE1pth4dzFUD78iYYmelkBtE9OXkyUmzuvxEAIfKC1BonpYIdDsSVU2x/D9oTWb x7BAL8Z05I/R/+CKr05jOzYlcbhK7ywKc44wHi9qdtFGnetP+aob5Zx6095ZWVpV XgZJvxOJKqCTvoiK0aWL1O2mJwfSueoeTD+FtZ/t0xl81SgSQC6vbQGvpnttNags P4sPPqqsfnJ6zWVBVRYDS0yd9QRKNlqi+cyhXoK3KX7j2w2LgdvH6thR06lwlH6N w== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id nujMH__VdhU8; Thu, 5 Sep 2024 22:03:03 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0CzB4jC6z6ClY8w; Thu, 5 Sep 2024 22:03:02 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v4 09/10] scsi: ufs: core: Move code out of an if-statement Date: Thu, 5 Sep 2024 15:01:35 -0700 Message-ID: <20240905220214.738506-10-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The previous patch in this series introduced identical code in both branches of an if-statement. Move that code outside the if-statement. Signed-off-by: Bart Van Assche Reviewed-by: Bao D. Nguyen --- drivers/ufs/core/ufshcd.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index b46e9b526839..17615b56e83e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10391,21 +10391,15 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba) dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", err); } - err = scsi_add_host(hba->host, hba->dev); - if (err) { - dev_err(hba->dev, "scsi_add_host failed\n"); - return err; - } - hba->scsi_host_added = true; - } else { - err = scsi_add_host(hba->host, hba->dev); - if (err) { - dev_err(hba->dev, "scsi_add_host failed\n"); - return err; - } - hba->scsi_host_added = true; } + err = scsi_add_host(hba->host, hba->dev); + if (err) { + dev_err(hba->dev, "scsi_add_host failed\n"); + return err; + } + hba->scsi_host_added = true; + hba->tmf_tag_set = (struct blk_mq_tag_set) { .nr_hw_queues = 1, .queue_depth = hba->nutmrs, From patchwork Thu Sep 5 22:01:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 825821 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03AF71925B3 for ; Thu, 5 Sep 2024 22:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573795; cv=none; b=hTaGzr/ENQvbycrcQKkKaZbIR1d0bG5Y2HnuhjR1NusSOfVjuO2T3OY6ENp2IsFsvlN0r2gEoWtnTvYTpn0KoDpNBGa6tz38x6ehDi6h+3GvU5J5SDGDi8RPFR7/JvdLKtz9v70CLpf0joTu0pr6cI4GFVP3FEWZZ2RAJ5syHiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573795; c=relaxed/simple; bh=bXelcrPT7VxI6TbKa94HGEIMVI/JlKNEwRQC3flsi1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=edBTznuj3Vk/Hh22yJvEkaXzZfrjHm72ktPzIORI1NvsR3i65DuHPPcznlelW9K0MZA/jS2TDQO6SlzHWAt2WImgVk3l7DL9RKBG8wER9Fb5uIc0dE9/3EZkB1J5XkCg3n8SBuJ8E/G9whdVgh936MGcyl3BMgpeuQjwwBDJmsw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=hL0IjTEU; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="hL0IjTEU" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X0CzP5G6Pz6Cnk98; Thu, 5 Sep 2024 22:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725573788; x=1728165789; bh=hfxF5 /pbCNCifAV31cdhWFOh26GgCfcj81PXfUiKy7c=; b=hL0IjTEUYKypzeWzA76g0 xEHYq+AeeCZ/tayRAacyTooRulP6Zn9mmK/IcNvFdRBKVJ22mCBskiazUFgxFU49 6KpKKldnHAAAbUI7Ls7tP1LjaN+XmLSYAzFQ7Ll7orYAwMh1JJJ1GVdxM0Vhafbv vukzdLr1Pm8hyccusI8wVTle/HPtUncN9jgUHsWUaLvEcIgL/3KQDyKqg2C7n3Hb ahHdg+Z3BeI2h9nTSr0I223BLVvDuobXkcUdITpVTLVmxr7HvuNd2sOYpBT/7Xtw RkM7Y0Mtl4SZ+Fmg2FPTj4Ity69FniUHvxptPqZZmD0Sv2fjV7+OV8q/EuahawjW A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id GnV8v6ML2VjW; Thu, 5 Sep 2024 22:03:08 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X0CzH2qBdz6ClY8w; Thu, 5 Sep 2024 22:03:07 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v4 10/10] scsi: ufs: core: Remove the second argument of ufshcd_device_init() Date: Thu, 5 Sep 2024 15:01:36 -0700 Message-ID: <20240905220214.738506-11-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240905220214.738506-1-bvanassche@acm.org> References: <20240905220214.738506-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Both ufshcd_device_init() callers pass 'false' as second argument. Hence, remove that second argument. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 44 +++++---------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 17615b56e83e..779a0c7559b2 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -298,7 +298,7 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba); static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd); static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag); static void ufshcd_hba_exit(struct ufs_hba *hba); -static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params); +static int ufshcd_device_init(struct ufs_hba *hba); static int ufshcd_probe_hba(struct ufs_hba *hba); static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on); static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba); @@ -7695,7 +7695,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) /* Establish the link again and restore the device */ if (!err) { - err = ufshcd_device_init(hba, /*init_dev_params=*/false); + err = ufshcd_device_init(hba); if (!err) err = ufshcd_probe_hba(hba); } @@ -8770,9 +8770,8 @@ static int ufshcd_post_device_init(struct ufs_hba *hba) return 0; } -static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) +static int ufshcd_device_init(struct ufs_hba *hba) { - struct Scsi_Host *host = hba->host; int ret; ret = ufshcd_activate_link(hba); @@ -8780,7 +8779,7 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) return ret; /* Reconfigure MCQ upon reset */ - if (hba->mcq_enabled && !init_dev_params) { + if (hba->mcq_enabled) { ufshcd_config_mcq(hba); ufshcd_mcq_enable(hba); } @@ -8795,39 +8794,6 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) if (ret) return ret; - /* - * Initialize UFS device parameters used by driver, these - * parameters are associated with UFS descriptors. - */ - if (init_dev_params) { - ret = ufshcd_device_params_init(hba); - if (ret) - return ret; - if (is_mcq_supported(hba) && !hba->scsi_host_added) { - ufshcd_mcq_enable(hba); - ret = ufshcd_alloc_mcq(hba); - if (!ret) { - ufshcd_config_mcq(hba); - } else { - /* Continue with SDB mode */ - ufshcd_mcq_disable(hba); - use_mcq_mode = false; - dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", - ret); - } - ret = scsi_add_host(host, hba->dev); - if (ret) { - dev_err(hba->dev, "scsi_add_host failed\n"); - return ret; - } - hba->scsi_host_added = true; - } else if (is_mcq_supported(hba)) { - /* UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH is set */ - ufshcd_config_mcq(hba); - ufshcd_mcq_enable(hba); - } - } - return ufshcd_post_device_init(hba); } @@ -8861,7 +8827,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) } /* Reinit the device */ - ret = ufshcd_device_init(hba, /*init_dev_params=*/false); + ret = ufshcd_device_init(hba); if (ret) goto out; }