From patchwork Thu Aug 22 21:36:02 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: 13774247 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 3B28EA933 for ; Thu, 22 Aug 2024 21:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362621; cv=none; b=C2EWgcjLt8yXy+qUnCP/m4MfimLuzKxuRH65VV/U/fn07UmI+TV/V0yu6Q3sb+2smnB0R9XeNFJUMrC8QBqqvrD9Me8CBgIAazqisf3VBX3mCfP6DseSuEs3Erflmom/9GOYj85yW6mBiL+83bDRhUHhrEaHbuuqQKgBKCL8nvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362621; c=relaxed/simple; bh=nTypzgEjksi3jcwKnR0tyfT3fWHf6lw6I3DfZjucD0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r29CAy9g0ARrLq+KKE8ZEtp66HHr2jxqlbGMAk4sbl0MX5WJKwDmMcUMdRYHfpSj76vSuVqIghCygpHyjxt3xZwDDqpAT1tIEOTlsMm4hD9nG0Up2DX7bs4a3xo/QCwsyNjoB5edEupoyfiz1CfML+X1uutj7QYcG9mNknNItU4= 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=c3Xmhzmu; arc=none smtp.client-ip=199.89.1.12 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="c3Xmhzmu" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc3b4s9czlgT1K; Thu, 22 Aug 2024 21:36:59 +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=1724362615; x=1726954616; bh=u2/WG 8iVe04Ig/1vNTkhyEqdtFiTGRq9qrsGuIQaj9c=; b=c3XmhzmuTPAAGgbU0L540 GnQgBRmn6kx6UIzXUPs/uQDODP7SYuJXZmUH0Gw02A/JooDp+RUTZcZ6cddGb0Yz rWVrqRiVLjVfBCLfnx7jJVFK+bxyJxp8Ft9FR2hLG/Mx1PdQJoCWmsiclJ7QCVgy qxwigzBGx1tIa3P5Oo5/mMNFEhtalBEiKEXWsCYAOW1HrW9Od41fuDQcEO+jh1PL OR3R2SUAd9bLbMLMOIcygokDGlPK42MXm1u2jPcPG6Q9MWz/LMecHJ0D0opIK1aw YdSVlZa8kd3zL1Y21gH3z/2dIBvDHwleEkZHZFlG8U06yELyGszSF4K/6qg8+iFr g== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id azMw9IYG9gxl; Thu, 22 Aug 2024 21:36:55 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc3V2sXczlgVnK; Thu, 22 Aug 2024 21:36:54 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v2 1/9] ufs: core: Introduce ufshcd_add_scsi_host() Date: Thu, 22 Aug 2024 14:36:02 -0700 Message-ID: <20240822213645.1125016-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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(). No functionality has been changed. Signed-off-by: Bart Van Assche Reviewed-by: Avri Altman --- 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 0dd26059f5d7..d29e469c3873 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10381,6 +10381,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 @@ -10514,35 +10564,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); @@ -10600,9 +10624,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 Aug 22 21:36:03 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: 13774248 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 7C2BE1D172E for ; Thu, 22 Aug 2024 21:37:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362625; cv=none; b=RCgD1T3k4msG9ZOG0icIiosqu6KnVNsnh9p25W+tTZ8L/BEClFFFl/fKhfOPvhBS3TXM7lboi4S/IdiJqR5tsi/Sq6t2fosTojK60rweeuBsUSgbXZ1oRNbwpOHqHZ++ZDEPWccgm68XRXds/5BzWWy5TKyRRZUAEvjv5TpcKuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362625; c=relaxed/simple; bh=YkhHAXhAWiKkZqXv6oyYvxDbrZcnvuqKCNANecfuSME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l3951JomI7+9YOAjfd7D4nE7CbHM7d4SXAYYahsbeTbcNHoq2mhgM2DJqY7VdqxIh3tsgWv+Ir1EoxdHSOmzMtXEXsyjRLh584+sLn/Y242Mh85kZ7J7P3zNfb8PVk9VnAhcHbEzOYldoHb9rfqq10HCyD2oRgxYUaejqoW32zA= 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=u17Vi148; arc=none smtp.client-ip=199.89.1.12 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="u17Vi148" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc3g1jb3zlgVnK; Thu, 22 Aug 2024 21:37: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=1724362619; x=1726954620; bh=nZjx0 idykRFXTxU5sySZM8noGg3gIw8VanZLBw0eZio=; b=u17Vi148vxkdVe2U/U4n3 K/3aOqiupiSczhsX3XNs0FKYumWv4ybv31RB4sOMpYcO51Lp7tX2X0L2RX7nMZez ebjXSqZPEUvuRFLFJr1yCjVPB4aM1zZI66lW27yA1I4wZQ+BwNRXfyoKXR8vcDzS 1pXdqYqSOetZVZg7IS5ZN3FaG5XWKeA7LrT8iH427zK+2gE40QzRgCRdftHcTaDu 17R7b+UA/UtuYCoZXi94DWe7HES6mopGwss0B8kSOrcZY5VP3H4GqMaag54CoBT2 7pGgxtoxDeqXGS0wBFdsziC3N/4k4wd2a/kmR6MKskZXloaP2F16vqbZLAc6TS93 w== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id vXgWQLRjqARk; Thu, 22 Aug 2024 21:36:59 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc3b1Fx9zlgVnf; Thu, 22 Aug 2024 21:36:59 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Bean Huo , Andrew Halaney Subject: [PATCH v2 2/9] ufs: core: Introduce ufshcd_activate_link() Date: Thu, 22 Aug 2024 14:36:03 -0700 Message-ID: <20240822213645.1125016-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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. Signed-off-by: Bart Van Assche Reviewed-by: Avri Altman Reviewed-by: Manivannan Sadhasivam --- 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 d29e469c3873..04d94bf5cc2d 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8733,10 +8733,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; @@ -8753,6 +8752,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 Aug 22 21:36:04 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: 13774249 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 5C053A933 for ; Thu, 22 Aug 2024 21:37:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362630; cv=none; b=Ib1hzOYDulY0IYzgtvg/q3UsEXdPXszka+1infaUG6Cv0FrSM7GHopuDXELXVKJZQiZGT4zDFThuAqgUKqB7kiM9PUpGkKqkGNswvbNMNFZIZ9mgVjHT0sE9WZ6jkK4UjUsgnvrpo9FIGXydx/UN62i1aqJOiMi+k3Lrsd6eKmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362630; c=relaxed/simple; bh=fwyu1hknNvAuljuuHR+27iLEm8RQ+sfqU90d539ygts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f0AWgvJRVxXSbJ1iNziTTtedO32ZEgza0cV1AWdEk6ulSFGNluWd/W6GcVgM82hP4SMrKHPKWfhjYrRyaoMPfc8DmWi++GNAFEHKSXs+V63hZH6CtStdqGkJF8KBPa8fdNxHww1OmrCodq8FOYFEbgZJw8ExOxy2yiAUovwwGng= 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=Mt0OLA6c; arc=none smtp.client-ip=199.89.1.12 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="Mt0OLA6c" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc3m5hrrzlgVnK; Thu, 22 Aug 2024 21:37:08 +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=1724362624; x=1726954625; bh=KIbXD ef4LacrzposKu0PpYIjaZGGnm5G8d8NEvkCOw0=; b=Mt0OLA6cOgcxkgcLE+r1R YK951D0t7KpWoI+9v0GYe4LYhR/ZWZyOqMPDq2lU7qMRtPgQxzbE3ex/ruo3/RZr BXr30svXrOr73e/G4UyjLUkCThqaruD9hB2NIV//uIIuFGEOcmEBUq9Vxa5OL8Ha 2PlLhXPnYH0qZ9PJT6wbuRjtYgOC42A5aWM10sjAs7x/bxBPB8jX/Br3RTU9TR8b f7vtCS1UnEI2pUuE91ns5qImj6idmE1cP0AbjrZgQepYm4Y1Hl555Skt2jPrZQRR qtVjg1C7Ena1NDn3qiWujGcT0xj90V/GThwLB4RAHYeWlSz6+/TB7wBcKBBpC2NY Q== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id GDccsa3LI0AX; Thu, 22 Aug 2024 21:37:04 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc3h0MFBzlgVnf; Thu, 22 Aug 2024 21:37:03 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v2 3/9] ufs: core: Introduce ufshcd_post_device_init() Date: Thu, 22 Aug 2024 14:36:04 -0700 Message-ID: <20240822213645.1125016-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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. Signed-off-by: Bart Van Assche Reviewed-by: Avri Altman Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 64 ++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 04d94bf5cc2d..dcc417d7e19c 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8755,6 +8755,42 @@ 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; + + /* Gear up to HS gear. */ + + /* + * 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; +} + static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) { struct Scsi_Host *host = hba->host; @@ -8813,33 +8849,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 Aug 22 21:36:05 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: 13774250 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 69E881D1F42 for ; Thu, 22 Aug 2024 21:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362634; cv=none; b=P3CeZf3LF0zBD0wW62LYkWtCAygMbeqvdulvbN1ruoG8Q6fyXOK549HH0JORGLJKoZf7X1l2VuyMAiG9Ox4e4mQogKO3onI1FlWKDolG7ELUKJl7GBfRu89pI2nk4KG08iJhu93VBsv7A919DifAkqjZpKmb/sc+i6oROXgFL94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362634; c=relaxed/simple; bh=ewPHbCmQVpyq3A5Tqg0HlePebFfhASchmdO5YVo5tIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qSdWflyqD+ygcFz9KDenbqbIAhz0nB3MJwYvviX/UErvSLWvCAtPM0aE87yR0cT8e8yLdE5VnVkMwAeUUuijm3cVrRLBlJg0zlsHDpVit934Hn+DM3fl1LlnrwlyDgA9EOk529aRHD3vhZAMU6Wp1AdfsKvNifkREv9H00LO/GM= 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=DhCrAHnX; arc=none smtp.client-ip=199.89.1.12 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="DhCrAHnX" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc3s0ZGyzlgVnK; Thu, 22 Aug 2024 21:37: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=1724362629; x=1726954630; bh=3qyuM SlRKZgkvJNw3433u0bgkcJrHXj/PWMXslBDeFs=; b=DhCrAHnXgkY2v03gNxBQA 44APQ1ap+Dnki+tLM7BVLu7fTqLN4hnuFexZ8EQOmQaYbCNH+I/itTxeCqNcGBmL XbTOQGAAbE7jqIjPMvxtg4sXVfSt2bVwAYFh3W818m6N61PZe4UJpGtWULHVcBad //k8tdy5lFE4uZ8MBT6F6biDT3hAtP5D4HQnTfeaaLrsz3HD1B+IzRfT1kLbQ6N9 FNUcKH0jirEjlJGdVn8z1pcb7JnpNrLyev9VUNJ73c3+xqdfpecpet5gqXukupt3 Ysb9APcW6h7xOs9tPMQUZK8Dfjt6FCw+Egb4BZWCpypuMYdlbWfHxA9j38TXfVPE w== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id vIBnKHR24WfU; Thu, 22 Aug 2024 21:37:09 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc3m63mMzlgVnf; Thu, 22 Aug 2024 21:37:08 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Bean Huo , Andrew Halaney Subject: [PATCH v2 4/9] ufs: core: Call ufshcd_add_scsi_host() later Date: Thu, 22 Aug 2024 14:36:05 -0700 Message-ID: <20240822213645.1125016-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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. Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- 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 dcc417d7e19c..b513ef46d848 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10585,10 +10585,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); @@ -10600,7 +10596,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; } /* @@ -10635,6 +10631,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); @@ -10642,12 +10642,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 Aug 22 21:36:06 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: 13774251 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 193961D173C for ; Thu, 22 Aug 2024 21:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362640; cv=none; b=b9UxeyXtPYEHaV2R57yDj1s+RKjSIoRuCmlUauXzOiBONlXJ9E35RZXUcTGwZOKTjymlbowj43+6g+HA4E1a9ACO8FAeZAHrlXX2B8gJBEndyzihUp6DOBrTowI3hqOHOHRra4aAgElSKz5kr7qsoDUTLjv1POWicfT5U7OxtEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362640; c=relaxed/simple; bh=MIsl1MVN0Nw2cJ6pbgLiAsJmRdVAsdfLUbBRgicc51c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iqY50KC+cpL1Sx1X+O9VuJwVTN2/fXPB21r3dMn+KoMvt4Uq93Nkk3YBuBvX08mN93UlFie3Ni6ZIOTuPVBGyvPItoSVkrLWTGsjYcoLiOwzOBe4sqePTG34gio690+R3MA7KWeA8NPpR/CzV2ERQxMJYGBhE5xbroqMu4tb6J4= 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=ZzFMJxd4; arc=none smtp.client-ip=199.89.1.12 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="ZzFMJxd4" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc3y41glzlgVnK; Thu, 22 Aug 2024 21:37:18 +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=1724362634; x=1726954635; bh=87V24 8CQ2zOUcmVMauXV6EqkwPUWBy4EbMTXxqEQftU=; b=ZzFMJxd4jg7e2IdwE9NMw dNDqXUVbkCklVqeoUbUr7Bc5Ssl4OL7IFHn0cZHmJq2nkWQ3nBC8FvjOJ/gbRuYB uzRQfKzyQlWT7CD6rFpoQiUTho0E30EyQ0u27CEv3GPT4nrnzaTrxJosSs3CFkPX uJngR7tStB57Z3SL3b0ItQctkvQEuGPDgdvP0tLJg/gGrriKg9x29FQh8qlulUsq zEWVM/Qa7pSSc9xZir7ZWPsCN5jEaNwYAXU92gekFyA4QpsO+aYbolWjLjlOhu8e kRE3jJqHw6wMzDrTR7Vf0VW2cdSUxfeS2lVu5azAYKpR+BfAjplkCIFb3/WtvHlV A== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id DfwPVi5e-sKC; Thu, 22 Aug 2024 21:37:14 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc3s4pVczlgVnf; Thu, 22 Aug 2024 21:37:13 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Bean Huo , Andrew Halaney Subject: [PATCH v2 5/9] ufs: core: Move the ufshcd_device_init() call Date: Thu, 22 Aug 2024 14:36:06 -0700 Message-ID: <20240822213645.1125016-6-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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. 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 b513ef46d848..5c8751672bc7 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); @@ -7717,8 +7718,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); @@ -8855,21 +8859,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)) { @@ -8887,7 +8886,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; } @@ -8935,7 +8934,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 Aug 22 21:36:07 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: 13774252 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 48C62A933 for ; Thu, 22 Aug 2024 21:37:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362644; cv=none; b=JVyQIG2xvBWGbJh4zs63KtitaIQIfIYzw09rS0SWebCD4MPMqObKZVzoy4kMW7WSGBFk8JirEuu8MjeTQmXJ6PD3sFG3VamV07mdTft91iywowGl7/qD0D3uvbqS747aZ9cXga3eQYthC3VDxJqcBj2Oa1Kn5bELz+JAsDnHg7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362644; c=relaxed/simple; bh=j4pdLL9Yw9DBsT5fmbg29U+agDA9fFtG4Lgqwkpbg3Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V4o6wd+/mSSjtRcgZGMWYqi81Sto1TIRHCtnFPjqQR6pLw1I8JTJOsYNUyHKOWobZnqv/D2TjParUXTcbZ33AZYshCCTuk+hLSh+1sHqyPMqpw5AT/n1NQ69E+fnpt9cfRpFZMtDf42pY++Wt47Vk7iJ8QjUdCs0ppfblgxNkUc= 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=pfO0MU3M; arc=none smtp.client-ip=199.89.1.12 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="pfO0MU3M" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc426ML6zlgVnK; Thu, 22 Aug 2024 21:37:22 +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=1724362639; x=1726954640; bh=0YazD 5+p7Rwln0to7DqY+9rbQQ4jYV+1W1F/00+9VIw=; b=pfO0MU3MJwMeLFX0qn1X4 UpN8T9Ozd0BJllVusg9VpfF70UzJZeKfpcCeH0114FuT2rTh9oNeRLig9cPIfSCG wGgTseudbCrpEu4rU+naBzZYHyy66y8ZOfOkhvh+O/LwFgIbKfBifE6vXYgxe2G/ xXohPNwJIek61CbR77iqycIMhDqUSoTnOZqNnpPBajHdB0usJtjTEHzEAqJUtx9q mLLDQEXegWxjoA5O2PwkMt/eCxsJT7rFTwtClKut7CdXI5M59ylH9ofJVyrcV3ww gxEoSlVxia8iFRodsr3f1DEx+rYeRnKj+z/7dsCKYx2g4NAdxL3OJQJG6v0NKsEK A== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id Wo0umtqhwJdQ; Thu, 22 Aug 2024 21:37:19 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc3y4xmZzlgVnf; Thu, 22 Aug 2024 21:37:18 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v2 6/9] ufs: core: Move the ufshcd_device_init(hba, true) call Date: Thu, 22 Aug 2024 14:36:07 -0700 Message-ID: <20240822213645.1125016-7-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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 because hba->host_sem serializes core code with sysfs callback code and because the ufshcd_device_init() is moved before the scsi_add_host() call. Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 5c8751672bc7..0fdf19889191 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8933,10 +8933,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; @@ -10632,6 +10629,11 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) */ ufshcd_set_ufs_dev_active(hba); + /* Initialize hba, detect and initialize UFS device */ + 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 Aug 22 21:36:08 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: 13774253 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 DF30C1D174A for ; Thu, 22 Aug 2024 21:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362649; cv=none; b=u0MUxLA2anrSzs5+pXUR/DbYZ74Z0EHhsakO+RWt4Dtc6pbJpgFvwFG+hi7tQkt+t9ChgOse79biQQERXhkm8GwqoD0xgaX1SlECgYZXvyjY38hLKzvKWKJRw45gw/3w5+OCUIVshPJCgVNFOGRQ+O5edj5mE9FvgbEr1XrNTto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362649; c=relaxed/simple; bh=Pcyj7fQVV3nz554GsRrq2SpPP7hIzKuQiJGrX02bGZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p/rnVpULdG5vNlrg6t5Erl0wL+38Bqb7a8WM3wZRPEt+Pty8y85WI2p6QhIy/XrVA4PAQq1pXwCHRI6HACDPY7dMI2imcsSS1Pn4oB7nTs0RhBUp/6u+IjxT6yzDRsNIliCOHB5WG5dSKdSXwZFXecbVCnUD8aJY/k3pctpdyJg= 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=4rkFw6AM; arc=none smtp.client-ip=199.89.1.12 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="4rkFw6AM" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc474H5LzlgVnK; Thu, 22 Aug 2024 21:37:27 +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=1724362644; x=1726954645; bh=PN1Fo F6ET/Fi7afoMrP8ADAM3PYfwa1Ba1hrkrrzBP8=; b=4rkFw6AM8CMo2NS5qv3/g UXBXrrrbiwp/ZkcbjGCsDJum6r5LbkjUAz1jK3czKrxRDJdPyBEAu8r96LGEU6VM 38uFyksgD0PqJnGuD2MFNhxBYTfiTDnHMdAMMMHWe5epONLQuGYI5Eq3ncbFkIf1 Tg7X7Xuf+6JIXi9/X8OGZY7P8PHuv6FXLTF82XWlD25/ZM8hemdQaOgpzAeH3SOk HaxYaEw2/w7OblWDA0FYnd2u+m1UKLdn3C+6jL+ZyRmTzlHTtDoZaEwH4EU6+NBL ZTLudgki2yvYMpKh5bCeCS+VMk6rLq2H2o63GtfuOu1QROTjizQdeR8a9kXBwkOr g== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 9diblfe2ZE9u; Thu, 22 Aug 2024 21:37:24 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc434cZvzlgVnf; Thu, 22 Aug 2024 21:37:23 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v2 7/9] ufs: core: Expand the ufshcd_device_init(hba, true) call Date: Thu, 22 Aug 2024 14:36:08 -0700 Message-ID: <20240822213645.1125016-8-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 44 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 0fdf19889191..6a3873991d2a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10629,8 +10629,48 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) */ ufshcd_set_ufs_dev_active(hba); - /* Initialize hba, detect and initialize UFS device */ - 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 Aug 22 21:36:09 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: 13774254 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 1313E1D172E for ; Thu, 22 Aug 2024 21:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362654; cv=none; b=TDZQAGs3hEsaUWVfPJKGVhT/kYH6tPdQBPDAFxn5xyGT8sX7Ura2TXrCDNHAPp7odxAvdYCP97R3e7MNV38Raj+XAbNCdHWIBiQq8cf0VdfMhcj7tqTGbgFeLP7qPOrT2UvwQxNl9o8PiS85ZMQ9BAyHhH10AUPXL7kPo4T26EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362654; c=relaxed/simple; bh=O7f4AK9uAe/0m0yfKC5aNABGNOhD8/tfbXxrNMbwY+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IeT5da22PxFzpWr18YUv1gXb4rze697Pl6yAENTT7/69FPNu9d3kmkLPSGZjyOODcoe7b3InSzYFG+uvPZDUOIj63BPpvm05f63GP9oD6EtrRDr689/PLF+y4RI0Z9troShjr65jTn2EjprGrqZ87u/skPkjZGnN6JbrK7iWnbA= 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=aTC+oZY/; arc=none smtp.client-ip=199.89.1.12 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="aTC+oZY/" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc4D4VGjzlgVnK; Thu, 22 Aug 2024 21:37:32 +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=1724362649; x=1726954650; bh=uY7Wg LCZQp6b0dMRnpJQ9/izYWM4XFzPTNtTEgTM/Wo=; b=aTC+oZY/UgUstzxYP69Kj 2AyVV64/Oq9Z0oIkvh4v2oqq05Cy+96n1w8fAInyJYZNKAlcPDAE44HOewMOudDw uHo0VUDzXxxJAFwHKLx6BKndhdMFVLgvivbNVbqnTYwRvJ42NRJaSzKoeMgzJC8u 5LVDsb7qhon9zlfBOUn6a6jkXP9fskFRQwu4X547U7nGDCrdIAUHZPnyjoN/oJCr Vt1dyNHTQnxaYQPw+XXItEP72l7VujaEcc7egDuQLVPIOSKgGPkoUVxGTPFIgs9x tfzGGjgZgFzlNJB3vGA0K7Ke5TAgV4RREsJQJhyzQQU9nQom5RTKINU/KfhKQJ5t Q== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id FeAoW00fP_hj; Thu, 22 Aug 2024 21:37:29 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc483PFkzlgVnf; Thu, 22 Aug 2024 21:37:28 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v2 8/9] ufs: core: Move the MCQ scsi_add_host() call Date: Thu, 22 Aug 2024 14:36:09 -0700 Message-ID: <20240822213645.1125016-9-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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 | 43 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 6a3873991d2a..b9aaa3c55d17 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10404,15 +10404,27 @@ 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; + 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); } - 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, @@ -10650,25 +10662,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 Aug 22 21:36:10 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: 13774255 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 7EAE118EB1 for ; Thu, 22 Aug 2024 21:37:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362659; cv=none; b=afUtAXiGiRgKC9CJdBmFtLOHPHEvxxdwI5qEcHAkJF8eiTwBhE5+5nhN+y2ST2ThW44xfm0UiYTK0qI9EQKb4HxC4Rqfpjxla3lrL67S9U1pMKRevsFJWt1e9p+TxTtIDbCii1+CKmkzbXWKQgCnvbaYTqe6FYtoj8s1lvkFlLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724362659; c=relaxed/simple; bh=yAywN31zpxDe0MEAaUogKh5yD9SvBoWb/kxxEYFKsIk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W9YujLXYJyDOD/j82iP9jvuGV0CcazBKD6wnIGo1X+WAAt3YBz2UnzbRfTfP9iAsKpS4Lm+G90anMDNUh40uV5dYiyUXiIZRdYwFDOxV1+3tUvIgXSa/MQOUHNATEMpYdSvkhXOq7mT9ax+hllWHbEeNriN+8kAFtSzWKDbgJYM= 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=3YFo2Pu4; arc=none smtp.client-ip=199.89.1.12 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="3YFo2Pu4" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Wqc4L1yWqzlgVnK; Thu, 22 Aug 2024 21:37:38 +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=1724362654; x=1726954655; bh=L8Wq/ KwOm2eZhxCd3abi3FuGwa0QfjD2YCD2mau1weg=; b=3YFo2Pu4bvRJfCjq+a4qJ C27XBxryhHnHfjz7btpL/z+OvrvIiSqbcXjw+ZbQplywOUMC+zEhpy/BQ0OdE/0r t8PaRf5yuCdsftXTlfdCSe71dYadCVkzbJODX6MJPddIX/VwxI5TfAzkWvOiCARb c3YcYV8Oqq60Mhf3OIwHAO9JNouGsG4BGAZrwH0n0tG4YVJt0nLRkC7DfS4kl7vr kOqKtkkmLLlEJnh/yEj7oD6zjChvX7GfKMr504fsBrmwP9+209/L3aF+iugFAmBD 1BphQG3LBHNnoL+PccscB85dZaUZbYFK9tbM09v+Cq++tdaLHA1Duh1F3zf1RQEg g== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id o3IfjC6FSCkQ; Thu, 22 Aug 2024 21:37:34 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4Wqc4F26SvzlgVnf; Thu, 22 Aug 2024 21:37:33 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v2 9/9] ufs: core: Remove the second argument of ufshcd_device_init() Date: Thu, 22 Aug 2024 14:36:10 -0700 Message-ID: <20240822213645.1125016-10-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240822213645.1125016-1-bvanassche@acm.org> References: <20240822213645.1125016-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 b9aaa3c55d17..9091e5939fac 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); @@ -7719,7 +7719,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); } @@ -8795,9 +8795,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); @@ -8805,7 +8804,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); } @@ -8820,39 +8819,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); } @@ -8886,7 +8852,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; }