From patchwork Wed Aug 28 17:43:53 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: 13781639 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 449DB1A4F35 for ; Wed, 28 Aug 2024 17:45:08 +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=1724867109; cv=none; b=EoO38aSnnOj54vKFcK4xjIqX/iGeIrEWfUrquWWHPSBM9d5SsK1vAmTHCOI3VfpYNL0hWqiY+jp53hE755Zr8XMaXNh1WO8YEO7NeJ9BSbxvxbs39ElRYfWYoQdP8n7P8d6aLSR6aVWDetO4LBJjyDGYDWIw/gHNI2dFuX3qELc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867109; c=relaxed/simple; bh=G1mh7doqNt0soSa5KXOLkj+Bb9aof6kYYeM0UYqp8AU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gp6RMrpnZbsFrhWrMkDXx2JB0BW/ap+ZThFKQVuCS9Aki7szXoPqw909+cFcaDL2+KNDT+EfBCRAdpERrlsruH92c+Zuqv/xQJ5QcVgFQhqWJrQ3S4MdFWHfgA4tsQ9MW1Stmr13qS44CTjkxO0OoxNVjtoK0WSNAodrbjJ3+aA= 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=1p6QOKN3; 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="1p6QOKN3" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdH4NXBzlgVnN; Wed, 28 Aug 2024 17:45:07 +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=1724867102; x=1727459103; bh=k66Gm c4RQgqClSPReQpW1JNIervQeYIltr84qndgRhs=; b=1p6QOKN3fjV9cL1DEyhtL sXxoUTMWPeBzQLjT9LOpcWn1kiSRzRtk62lKLZyitl85eE6/avxkR2PNcacBUW9R nBCfoqfv249FppwYc/JnVwp4jOOTMWP7u1rWUo9pSB6MjzOFxpdhgJM9+wU4fbUH l54VeqR/iMDNLB8ScioPkt2Rd/V6kllVDK3l/lYVp6sklc031JornLLXrm3BF6Z7 Heh0kgOjdnee0Yn2kezAQu6nAK70nwSi1UTeG921z2BQVjJxKmKIiV9U0agm84ab KqxAIfe4M54gdqQELqn7mckpuEVne98o5ugXYLUfVFtZTfk1nwPyJ1IssYIqKU2R 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 VrkPXHfLEba6; Wed, 28 Aug 2024 17:45:02 +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 4WvBd96NWjzlgVXv; Wed, 28 Aug 2024 17:45:01 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Avri Altman , "James E.J. Bottomley" , Manivannan Sadhasivam , Peter Wang , Bean Huo , Andrew Halaney Subject: [PATCH v3 1/9] ufs: core: Introduce ufshcd_add_scsi_host() Date: Wed, 28 Aug 2024 10:43:53 -0700 Message-ID: <20240828174435.2469498-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 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 e13b9ac145f6..70e9341a3043 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10375,6 +10375,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 @@ -10506,35 +10556,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); @@ -10592,9 +10616,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 Wed Aug 28 17:43:54 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: 13781640 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 D34D51A4F35 for ; Wed, 28 Aug 2024 17:45:10 +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=1724867112; cv=none; b=DcSmIm3WTArI46AyMw1WUfSc5FxfpmqwIa0nZeogSIet016k8jyA66VWTXYbSqH2BwbaaSTlSIa90OUDWV96VAjt5C/4WgVhXlfYxUcSAcG1QnxznB7Tw8RsOzY5uXNf24cnqfW81XMpSemWol2n3JnBLFfQivVnNNU6bPnVgi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867112; c=relaxed/simple; bh=xZJOu6jbrtxGIi43e24drfszxB4/XyV33YO7+9uSTQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=etYUlo3wZp+ZjrlLx8v4L8aQQA3Ft8gD6NiYpmG/tLZN7jNlj+Y7k2cCCl4qt3R2eJ9vGzaNmqJZ1IhbM2/Ul5G0VyN9Q75BL+USFvngyV2I0an0Q+MdO3MhgDNRRsNPP61LO8gh2B0z/1AgV152+FBwdrlTiXkeItPI0ujsgkY= 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=TRkePe9V; 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="TRkePe9V" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdL4HNYzlgVXv; Wed, 28 Aug 2024 17:45:10 +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=1724867107; x=1727459108; bh=LnzIy yhOnZY+p66B6nwgFw3YMD8ecCvnxJOHOB47lOA=; b=TRkePe9VRtFbebE4tiTl8 CEx4SzcQulCV0Hl42G6DbaCV5IHafgy0ZlSD4d00gb4LqhZsmEjeEFjR8rAN+sIs aUeZEYGsJAO6HMRZgf5wIusY5a3ln9XoTpmjF21CgC5gafThn64tW8PFb6CP5b/d KDTD2/asBAUdSv3mYGWEyFwL5EI3IzCyIjDVEiJNz9YbBJj2DQYZdfOBzBp6qxaL AX6O5d893s6p/+GPKQUcoxVhh/wpA+9oEOkmyFsbHZcVLgpmpsk3qo5BB9Ol07u+ Z48MnM2fHo0m2iN4sCYNzuSDbxSSmJi9OCrZN4DDphvF3IyoWmMojp0p66oii4xA 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 TBumYg9S8Kxn; Wed, 28 Aug 2024 17:45:07 +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 4WvBdG4S1CzlgTGW; Wed, 28 Aug 2024 17:45:06 +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 , Bean Huo , Andrew Halaney Subject: [PATCH v3 2/9] ufs: core: Introduce ufshcd_activate_link() Date: Wed, 28 Aug 2024 10:43:54 -0700 Message-ID: <20240828174435.2469498-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 Signed-off-by: Bart Van Assche Reviewed-by: Bean Huo --- 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 70e9341a3043..6dbc01b47ff6 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8727,10 +8727,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; @@ -8747,6 +8746,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 Wed Aug 28 17:43:55 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: 13781641 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 88F1B1A706A for ; Wed, 28 Aug 2024 17:45:16 +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=1724867118; cv=none; b=UU8gFys4fPugBxogI/o4uUvJigGlIsmZYFG4Q8yKo5EKHey1/sfqs8/+ovxOvqScXGnREt2HxtC70lQWNFvHMG0DzIL4pF+dV1snJhuptTrvcZyxsxyCLSdpE/UmvyB9++/3i7w2XmoJ2BErnVfsdUbqEaFpnBNks74GeUx1uiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867118; c=relaxed/simple; bh=/KE/k6Cb5aqLg5P914tYx4I/lFhdr9sTzFwP3gzEpko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U1/Vk8ZrQjy3Py8gyFmYzXDi2hDzKXkNfdChYgIYL/te60zo4+HzAwNQ30z6jg0lJZ8UJe02eceT6kBCUCpvrZCWRP6lON4EVm+u7QqZb47xpjbHKWt1im8EEapTVX+PMR+bMVBw4KhTJj12BbJzRE0oaKW77KytJ2IcdxLKJiU= 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=ZNkrHsSD; 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="ZNkrHsSD" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdS040wzlgVnN; Wed, 28 Aug 2024 17:45:16 +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=1724867112; x=1727459113; bh=G+h1K XEQtdvCm9wSoYEiSGFSlKUcWGTrENP64ws5SPM=; b=ZNkrHsSDhJlRfDBpKLVGo QwnfLpvGdNzkMA+qz+rOYgnlzM9QkHjU/iel8bmvpoB8p113rYooghRXQ6a42z7Q TcR8ioU3cTIkScHCY6fjgWWPDayP5qVKJ1tVotfWQXNcYV6+WV3lRcMoKV4YrsiZ /hwPc20inPErpB5WqSj+VbiFBpwqt/DlHVPZ8OGGj5sSRWbOHOvHnzws6mIN2PTW DzNlLKv8BxSJuIlA1n2w6N6NmlyVrRhJErYe650tGP/n6aHUuM7jNV0V59ul9khB JQoV+uR+7QS8qkNXvtI7v7gUNr7gf/Ywi8tJ1WF1OXx4g8bo7AB+y9XMSmMJ2eGZ 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 0sSoMX44JHvD; Wed, 28 Aug 2024 17:45:12 +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 4WvBdM1mryzlgTGW; Wed, 28 Aug 2024 17:45:11 +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 v3 3/9] ufs: core: Introduce ufshcd_post_device_init() Date: Wed, 28 Aug 2024 10:43:55 -0700 Message-ID: <20240828174435.2469498-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 6dbc01b47ff6..1b69b370991d 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8749,6 +8749,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; @@ -8807,33 +8842,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 Wed Aug 28 17:43:56 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: 13781642 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 95D351A254F for ; Wed, 28 Aug 2024 17:45:20 +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=1724867122; cv=none; b=Zz8jt7xtn0XlufDKduEw+Ry9C0gktZO2WWWln9I0go0knXer3QNf5iGonVPLed2uBXYZAkLaK2grqudOtg5QyHvijR8f7HDEgYD8qS+vM4dynSdUqx4nAhRAAHfH2kjwIbtJxIrMvtRO6iGC7tbCrWlgyleIf1yglbFS8dLjRzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867122; c=relaxed/simple; bh=xISFm7Swyov+VWmn5kO5OkMXBY69JoEFK3eIlzHNd1A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b5q2L8pC34mSPdigTdinzQNUlMoWDxvaXY5ccVI+RKBRxsTHpKPFVAip3jMewmIx4g2Cbr4Uki8gk8j7Y9LAJvZqo/SENhrQjLW3iZqGqFNWSlXzvCgHGi0TQT9PzU0gjJ8STyyu5R6FI7LVTROJ5MZCpDccfBv21mnZfLTpxsg= 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=kP6UTLX8; 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="kP6UTLX8" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdX0rRwzlgTGW; Wed, 28 Aug 2024 17:45:20 +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=1724867116; x=1727459117; bh=sCS5j gvUBL2CiNcfPh57wQWHu2vQJ5PVvJPno3ObagY=; b=kP6UTLX8fyRFHvGag57Q6 4acj/wSqXqWBUHTAOGksq9qCAzfOlsY19krsbnRNd2UFmkPOxMKwuZfsnPEFwhHV 5y6tvQ3Z6fM2jpsSO6cu6K/G0tOLqyb8obMeS/cJhPS8yJEHBH4HZskU0Yd81fZ2 cUw0MfNPRtPzduIpHqgT4A2qpjb99JK9pkFQKKgHGzJFlZVafDAVbfJRGYBdgh+X hGj9YusnDY19rZ7K2TZMXw0lvc/rU29NH/QEn/P1kOGCzpE0yTGw0eYcHMFMPYq4 3a0b2iUsmdYJGibXPbhhPPHsRcIx97HsFOkS++g8GXElNxJkNHeT91YWGSzAjPgh 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 uWoqCEr6kCaS; Wed, 28 Aug 2024 17:45:16 +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 4WvBdR6dzjzlgVXv; Wed, 28 Aug 2024 17:45:15 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Manivannan Sadhasivam , "James E.J. Bottomley" , Peter Wang , Avri Altman , Bean Huo , Andrew Halaney Subject: [PATCH v3 4/9] ufs: core: Call ufshcd_add_scsi_host() later Date: Wed, 28 Aug 2024 10:43:56 -0700 Message-ID: <20240828174435.2469498-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 Signed-off-by: Bart Van Assche Reviewed-by: Bean Huo --- 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 1b69b370991d..20e00ec5fda8 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10576,10 +10576,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); @@ -10591,7 +10587,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; } /* @@ -10626,6 +10622,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); @@ -10633,12 +10633,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 Wed Aug 28 17:43:57 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: 13781643 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 5B47C149C53 for ; Wed, 28 Aug 2024 17:45:26 +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=1724867127; cv=none; b=ovhSVqSxbYSQcKNU0KXw8QCOx1aUPxbrtzKXVpwM83wg0tjKVmWBHkVlXm23aDUVHC/EfO3RLLGma9o6UdsCGphP8B9clngBQhGdA1BxKYw0uBr+4a+Y/gVSMuhOgFbeLUVbocm+Jh/ssUOo1upvFPwc3sTZHuQmJJXrnITVgUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867127; c=relaxed/simple; bh=9/H3ngvvJ3LzJi039HZgCnl3JtdffiqVh5V7yM5qoSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eYiI3Xa8MN07ZfF5pPv4dGHE+ICF0gdCaODuM216hDtXuT5a1CkZ+gcoKjcAyFkn/YxwkUGcGLS4BE+3UbwLd59+c/cAqQznrae+yT+t21oihb4S5XDNyATAgdFMvkxtkI/XYgbWagpiZjdd1kzLVSsGfgLd+x/RrRPGoD6E5uk= 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=X+343Z/E; 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="X+343Z/E" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdd64xwzlgVnN; Wed, 28 Aug 2024 17:45:25 +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=1724867121; x=1727459122; bh=b8vZt 5oazZLWBAQIjbwsd+uatf5Y9nhoo9DTaXSBXM0=; b=X+343Z/E1V8IDedXCiFgO qCh68nHuIHnudpCdLrLesH49o/QWq5mBO43SvrAV2VJF1voD19WXJEu6p9wOaN6/ 2ReKIJpZrTBqTAZB8HMPKfG8P121NaiRBdt2sHNHVVIioBdVKMhI3Y/XJ0MoHf+J ll4bDyPWbK39yfsbbhwwE5ismjLSA2ehd5BXhXdVIWtUVumT2LjWozDQrQ3VHTZM yMz+CKBW7gCyei71/X4zSSb9CFjphplZc11YttlWgB1ey0Tdd0cZtKXN7LKyrmhe nq5wbH2MPuBFU6xY/DgG7ZSMYwCvKzlhEE90+Xy/XIYhxwYk1A2KkwKU9C19BgID 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 Db6gjGPQkLb6; Wed, 28 Aug 2024 17:45:21 +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 4WvBdX4GDDzlgVXv; Wed, 28 Aug 2024 17:45:20 +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 , Bean Huo , Andrew Halaney Subject: [PATCH v3 5/9] ufs: core: Move the ufshcd_device_init() call Date: Wed, 28 Aug 2024 10:43:57 -0700 Message-ID: <20240828174435.2469498-6-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 20e00ec5fda8..f62fff878980 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); @@ -7711,8 +7712,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); @@ -8848,21 +8852,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)) { @@ -8880,7 +8879,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; } @@ -8928,7 +8927,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 Wed Aug 28 17:43:58 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: 13781644 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 5ED241A705E for ; Wed, 28 Aug 2024 17:45:29 +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=1724867130; cv=none; b=fR3ZGN5MSN222QBLxydWgeYQDjFJrT+u0EcOz6SGqlooQ104ma7ThXCgI6hv0zxObTMsWm8jGy/37gSh9OLk0S6lZoDXT4KPGb9r78NXUzzVkF+x6rfCHHDzTUUgl3VEdZfonHQSvt3gxQ2XCVkbx2K3/bu2KF8mjfJIe7Fjw/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867130; c=relaxed/simple; bh=nw/VJQ4J+CPqhC9yI0gXfJNtmSDcBkS2aDfZNGwFCHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hjoQCnXxm08UiydEsPcWtEcF8qH3n/gE9RCsI1C9M16YU88HH64n3wSaFc+Gm8aY5weiKaDh2bFb/ZlKyCLk6bA+cqm2i3TLrdG6dH47UYF54LLyWAMwmLINeYwRZAV6MFQlyDz0laEO8/Q45953V/wGuijtpiA2lMUAY6uJLw0= 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=K738+pJ2; 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="K738+pJ2" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdj13R1zlgVXv; Wed, 28 Aug 2024 17:45:29 +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=1724867125; x=1727459126; bh=LtzUz yKuqCYZOZSTuLuW77fiJFRF1qtsZx5UDKWRzNU=; b=K738+pJ2BHOAh9gOgviS2 fNiMv1rmZTJ+SQjsgdupKRmRQ/uiUCnOiH54cwnfigXbH8XPIjBesRSnoXnrcmLk Xyfu8C8eGUz3ZkrUJfBXv1NxfqhZpklECrzk1dGrGbevjKARRWoC1p/xco8ZItKn k7fjKS3B8jarMpwjvYuqmLWWCG2aUSXZjbOLpbUt0n7r96u31sRcEGYFIcAIBcsF 9/3NfzPguW1SuOo5jzawROiAZRQMIzhddFaWHhVLOjYrNfYfsWafWQqZlwmteGRB z3JPjp4slBht59+2k2pdpZ7LPjwNT6DU5Y3kwRRsfr2gZ53PHw7yOUjanLJKr79W 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 xy7fhlQwJscH; Wed, 28 Aug 2024 17:45: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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4WvBdd1LnmzlgTGW; Wed, 28 Aug 2024 17:45:25 +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 , Bean Huo , Andrew Halaney Subject: [PATCH v3 6/9] ufs: core: Move the ufshcd_device_init(hba, true) call Date: Wed, 28 Aug 2024 10:43:58 -0700 Message-ID: <20240828174435.2469498-7-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 f62fff878980..33e5dfd794a4 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8926,10 +8926,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; @@ -10623,6 +10620,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 Wed Aug 28 17:43:59 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: 13781645 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 3110013C8E8 for ; Wed, 28 Aug 2024 17:45:34 +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=1724867135; cv=none; b=fOkrIqNI6SQgsvSq+mh37wJyYgHKe3HL5P97+fES3Z6B2HPB19OvL5k5TwiHwvaCsJ+a23H0tOS9Na9fvwBdrs3k+GwSsjEY4NtvhNooePnGirLVjvyrIMMFM8Qv+LJLneA30GTtHRsYTXIl2mbgZbDIkYwmcQp4Gsy4a6Arc1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867135; c=relaxed/simple; bh=1bZiUcS/X8173YYKLyL0jH3AJGvic3rdPBj3iGDCpNU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XfuVYA7HuxLxeRb7HMUdmTy2fSXmCTl4GBvh1Q3UMvvCYlVzkcvKLXPXG7uXQkc70uKuIY/xiIbrAA+b7cQFTDBxBZCXT6q3BwSAanQbnPXr2GMCR6cdT7kXNBq+O1IR0wYYW81DAjjR4HQL6IQMdiv1o1DTqL19ettlHT1fQSc= 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=VU5oa+MP; 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="VU5oa+MP" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdn6tmfzlgVXv; Wed, 28 Aug 2024 17:45:33 +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=1724867130; x=1727459131; bh=4cvGE mf3RrSXDGecNOPayhZQIy/Q3jCqp1ik6Ctdt6w=; b=VU5oa+MPLqvpHMsmUmIVJ pFBmBYaiwq9nSG6v+DcDIeZo6DxePabeV2szh8oHhGKWBkmiU51PzVGdL8qwTPC8 kHzMpLjb+nvl7f2bLlxiuLDGEwFaNOXdzmc7nExc+IcM3OP6YxV6ifYE3m7hlzJK Q2Iud8DoYsyx4GN4BoH3yUqP/7132ksIeLA3EP697ZtkXHur/pK5HegEWTS8Bw/z 2VvVQ90gX2qIAHvmlrzEn5X6WsnQJvhT5FFESAu8ZjxXr9lvVTP/hx+CC5cPzFV2 89HsCrgmbv6lSrx8ymFFH9Ub01f6fHwh34c9xZ9/qtrF6QZeUN1TJtX8lB9WZfs7 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 XM1yjve478Ib; Wed, 28 Aug 2024 17:45: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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4WvBdj607JzlgTGW; Wed, 28 Aug 2024 17:45:29 +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 , Bean Huo , Andrew Halaney Subject: [PATCH v3 7/9] ufs: core: Expand the ufshcd_device_init(hba, true) call Date: Wed, 28 Aug 2024 10:43:59 -0700 Message-ID: <20240828174435.2469498-8-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 33e5dfd794a4..eb2cc1521b66 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10620,7 +10620,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 Wed Aug 28 17:44:00 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: 13781646 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 46D711A4F26 for ; Wed, 28 Aug 2024 17:45:39 +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=1724867140; cv=none; b=NpbDZSiKc9qC+IWjLzxNMYvP/Deg02N8WBHYf1c6dqbSf34e3bKsJheuV1dNDa3exSggPFO/IHQsWz9BbLiPsmWGc98HU/543haPAr8zhSjIFyByQjKa4b1EJABW7UQ4tKYiAhjNWjPHFxUoqRKQHAUkckMRlTDfCV0m7ChM7cE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867140; c=relaxed/simple; bh=JwgLAbh0CXa9VFbSK45ttSt7pIf891i6+N8hP+S0yO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ATMqTKWJ2rdmeT6srUTKq0g8mWNqSjVoItRso0Q0sf2SXU4KJk6L0werfdUV/q/4Rv+KGwj0wwOijVbLUnGwdcVT+0l+eAXqyYbaOpx0EEH53XtNlrGiV7UtLwr6RELLD8Bs9LczIpBMSTvwt/s8DtWN5IhTjkl/qt743fSFEfs= 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=WAOC5qew; 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="WAOC5qew" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBdt72FMzlgVXv; Wed, 28 Aug 2024 17:45: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=1724867135; x=1727459136; bh=SGOj2 C6y7d9EyGb8Y8nbwDSTaDDhSYhLuvUtCkXYJ14=; b=WAOC5qeweYqcQfs1uhCgK 7QT+hKJ9rjPQcLfP/xL2yDbu6hmSVSXaAGCVNORy7wxcBbwRGhzUH5sgY+TGACUG devx+wN2/Vcv8qtBzFGRLnpKcqfIQuW850ZSn7/Lg9uJTiLq4V8WLI40EcbHSrmw 7Y30MCUtA44VQ4NeZ2hqcP+dwkCYle5wZXweydoTKV/dfOzIRppTxLgWMWGvZ5Wt HP6a4/VTK9KpbZN+6bJWvavdSSK7/15Dv6p7Kgd7BXYUJxL2Ngv1fujejoil9JFI FfbSLRQ5BbEH6QnCV0/kjKoJyAYa3FrQXTDu9RHvHHSsnfr7venZVVSNIfzH3ISl 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 UfO5sVJBTuUY; Wed, 28 Aug 2024 17:45: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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4WvBdp3QQjzlgTGW; Wed, 28 Aug 2024 17:45:34 +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 , Bean Huo , Andrew Halaney Subject: [PATCH v3 8/9] ufs: core: Move the MCQ scsi_add_host() call Date: Wed, 28 Aug 2024 10:44:00 -0700 Message-ID: <20240828174435.2469498-9-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 eb2cc1521b66..16638974b34f 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10397,15 +10397,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, @@ -10641,25 +10653,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 Wed Aug 28 17:44:01 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: 13781647 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 E616E1A76DD for ; Wed, 28 Aug 2024 17:45:44 +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=1724867146; cv=none; b=Smt591oueDSybB0sjtYr0pnnY2+nEDESO6EFzSmhFvXnTqIimKkNLrxKaymLxOgWpiSwZLZHg3cokCQFUSIIu0AWfNVlcHorSTydaSsgEHRq2wO2d+jJqZoGzmz89ELsp+MXGFmu9KT3xkS4N+2jjmHUOR33mkO8qRJtg03sODo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724867146; c=relaxed/simple; bh=JDYyNmU8c0iOubICsxNNsOtAjdn2TfR4H5+dm7pVXWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d+NSQj2uAu9X8sDPnFredycU9pRyJg417ar3uByYTYAds3lb88oxFmthff+Ou52nKqBVM2p2LSWZ+ZpLKlmxIh4QfwVzujsJ58idjkwTP/xIarZZq4e1yAkJt6pxYELf0KWtwN8bCk4c2nCTW7+Y6pbqb92pzonHVe6bANvWvSw= 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=ghFK8dm+; 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="ghFK8dm+" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4WvBf03Mn7zlgVXv; Wed, 28 Aug 2024 17:45: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=1724867139; x=1727459140; bh=sFlTR OTiLIwTILzMA1TwDe91+GeAPCtNN+QFgSjLIeo=; b=ghFK8dm+eJpVPlIzeYoxg WdJf0vptTEl4PiFFmlelC52vKQ/DaEL4IXsr1jyP/7ryKEyUm5/KzTXppe249rkm Zz7G2ZXlhUZWI/kF/ZMPlSr3zFYjKLPDjg3LgD82YdILHzWz+qVaLhss4qgjvchJ LFqdy2OS8PySn8U5fgk8/+s++LQ8BlBDJ93rnPCDn84IYd4IB5ul9vDpq3trF0Rb mYYH7+fr+cK07vsjAIXKEsOU5fvPP0LXQqyRC+p05FGHJI+aPpZq+CAgKAe4ddlm CEgf6tjziu5cNnXw2/qyD8BUfCQkJw7uzDajHXbBAImvQnmrQQtQgY6gIKysCrIU 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 XSMHT5QHopl3; Wed, 28 Aug 2024 17:45:39 +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 4WvBdv1HCRzlgTGW; Wed, 28 Aug 2024 17:45:39 +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 , Bean Huo , Andrew Halaney Subject: [PATCH v3 9/9] ufs: core: Remove the second argument of ufshcd_device_init() Date: Wed, 28 Aug 2024 10:44:01 -0700 Message-ID: <20240828174435.2469498-10-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240828174435.2469498-1-bvanassche@acm.org> References: <20240828174435.2469498-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 16638974b34f..5239caf3fc65 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); @@ -7713,7 +7713,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); } @@ -8788,9 +8788,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); @@ -8798,7 +8797,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); } @@ -8813,39 +8812,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); } @@ -8879,7 +8845,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; }