From patchwork Mon Aug 19 22:50:18 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: 820564 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0014C1591FC for ; Mon, 19 Aug 2024 22:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107893; cv=none; b=KBWBTtz7xYaU/tH/LW743kHh4Y4Cw9dCfkPLGmLBGVvUSGE0Bk8rwvDutKFFxb1DpB7icT/S7REf9fgWAQ2siEFI5hfviTMPsLVqlA+ckYgc75qcAKK0VEXZ8VgGpYxE2Qdq2OeZURtUBuqgF5GRkEYSEboowVFYFI45VrRM8FQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107893; c=relaxed/simple; bh=nTypzgEjksi3jcwKnR0tyfT3fWHf6lw6I3DfZjucD0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o8wGDvPMDdzqLlyb/KaZsjS5VW40a+jaaz5YRd9uQOWkLXk7AI9kyE8nvhNJX7q03gMEJ6sW2K8MMeXgpO26/MPfIi8Bx+SmwJhJAePQsKnjdGEC+ZT5fdy+bXvrRBwSFMlaCSJ5l4q4V1MfE/4WRf2+KE2SLF9waht7FptrQlE= 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=RdYhIFG3; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="RdYhIFG3" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4Wnnrz2FQ9z6ClY8s; Mon, 19 Aug 2024 22:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1724107885; x=1726699886; bh=u2/WG 8iVe04Ig/1vNTkhyEqdtFiTGRq9qrsGuIQaj9c=; b=RdYhIFG3sRPFSp695H5qZ sl7k2g8pdMaAiyJ9AnMtxVT1YYJ+P3lT3LTgM9riv9TbbSjwbpuEWee0hIqUq1kP i4T47i1lIUjF3bctkn3bt9HkBPxmQksZY4cLETuAibDwXL6Iyp4103uITkvviuGg wzVKgTwTu67sQLnmjSSxq9ChzJPZ0y8kqTVM+Hm3CG0dRaDidSwSoTvzCUCf+m/R QotOom+jaPquQFMbpuL9XeRWwM/7AIo6EXVLMLiGigjJ3+ZZ4Ura5kPAi5Fx0snb q+sN3ei8qhtUZdY56nXyk1pcuv1kQfnxW79I/niV8LGkog+ld8kbTyMTgUz/ztWn Q== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 0QmHnZrd00iO; Mon, 19 Aug 2024 22:51:25 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4Wnnrr4Mjtz6Cnk9X; Mon, 19 Aug 2024 22:51:24 +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 1/9] ufs: core: Introduce ufshcd_add_scsi_host() Date: Mon, 19 Aug 2024 15:50:18 -0700 Message-ID: <20240819225102.2437307-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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 --- 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 Mon Aug 19 22:50:19 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: 820900 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3AB91591FC for ; Mon, 19 Aug 2024 22:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107896; cv=none; b=gz6PO1+Nh1D606oixmjpAo1SDp0DjTURxrMD5zBvNnDnWcZbuG64gZOY0Fq8zri+O2HwJ3nW0qSOQkzLnGwps0VOrjHe/Pcca8ppb1g9t4bq4187z1UeiAN6bNU/aneED0k7yaLFYZZlRXMNVjGNVMGYJElShv6+4tJLfrTnSaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107896; c=relaxed/simple; bh=YkhHAXhAWiKkZqXv6oyYvxDbrZcnvuqKCNANecfuSME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tZupva042yiIKf90qV7F6sutKK//R/lB4nFbaYEpulwaO1FNXTkKmEKS0Z6KFMbEmHfPEwCYH1koq8jaJ7+6TFmAt5RVJWdixeqrXLydGEgGr0ULpKgusCKK3iXdKhcC0bsobn5Htu3ZK0bE1oRq3BDi4R0yMaLfbxOO6rgzsSw= 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=uFpOCVbU; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="uFpOCVbU" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4Wnns22wjHz6Cnk9X; Mon, 19 Aug 2024 22:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1724107890; x=1726699891; bh=nZjx0 idykRFXTxU5sySZM8noGg3gIw8VanZLBw0eZio=; b=uFpOCVbUMkfvdN05j2teZ JTLqmxPWtmMFl06R4qo9/n159xo/0gs68wyN8Sj6VupSQlM7uXKdzrLEmL/DCMaL nvgqghp1V5/ydic4n2/Q6jhZ46+od0WlAX7ypFeEP/4/d7ZNce7eQWT45y2uqIbO uxvk5fKoY4ZzbFsXzFTvGZW6CcYsHpBZbvQf6ecmOAx595oDrupIBJYAXX2f7AWK pirwWFBXvD2X9H0R+AGx9UeKBy/iOkbEeNseXfWvPjAVgavyYOeGmarU8Qihm/2Z MfkU++o2kx7rhUMLkzNUOsS/wOQx7HlozwFmRh6dn71epI4Ob3ArHonLnZPP821I A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id ntBz2Idh56Aw; Mon, 19 Aug 2024 22:51:30 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4Wnnrx4NfFz6ClY8r; Mon, 19 Aug 2024 22:51:29 +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 2/9] ufs: core: Introduce ufshcd_activate_link() Date: Mon, 19 Aug 2024 15:50:19 -0700 Message-ID: <20240819225102.2437307-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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 --- 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 Mon Aug 19 22:50:20 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: 820563 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAA451591FC for ; Mon, 19 Aug 2024 22:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107902; cv=none; b=qkDOeKY2U+GcbGCiMwI8Wjq9uAlfjdCOcMEJtuTNguD5yVz8ZtVdET4KdtfI+Q1Y5tL7BWOQTJv1HXWdMQ8IeZIcC282aSrMnsFfv4tJe+ro+coa3xgq7PpMKWLxorfjGBBq/dGZ8ipq+SLBx93Boup4fFHlYRYGvTnRJRpCxiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107902; c=relaxed/simple; bh=Q07rvdW44L6LorH8aE2KjkOCg/r6W5HowZAFG5nMs1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tEsI4DZdM57Jp7rXR1NVqJzbSQ+1r3I6dDbxOy1Fm0br9irvX888wpKKLi5vUShUuFPkEEXmp7HrR87WaQwzQmzjc7uChSqi3l7EJsQ8bo5zAHME49bx7m1+6/K3NIZBVEVnhgIv3xZEOz5RlCEGVLQVX6AcDdsllB7J8YzYklU= 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=j4O+TPix; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="j4O+TPix" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4Wnns819Lyz6ClY8w; Mon, 19 Aug 2024 22:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1724107895; x=1726699896; bh=mx77B b5LfMc+BogO7LDupc79kW0Hh/qGo0zGGVHVuDk=; b=j4O+TPixM0vZgr007MloP r82AJJ+AMkFt/R4D5l9vYhZTzopIjZEM7Kyhd0my6C/hOtKeHP7gRr0xaLX9dLLr tFkc5ET7dCKoTPzEx/29MS9MtmvmkhINuaYrvy7Pz8rBDKI3Rqvl3mcBD5Or1+QL GqeYUFWudxaDIOOQN7PfeDfEHChQSCHYCQLuJUBrGQuVzt+YzRvP8uB4tW4Q7aQs D+sqWiF3RVl/TAPEe40MqiU97LJHH6eK9RFX7xdmmBJSMkOWOzDASE+1NPWRvvkI 1XC5JCbW4CAT4lCIqO1D2mKWEK+/OwP57dYIPcDdzU740kxqNBsW4ZZyvpKArpG6 A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 7gG35OGhV42D; Mon, 19 Aug 2024 22:51:35 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4Wnns23pBBz6ClY8r; Mon, 19 Aug 2024 22:51:34 +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 3/9] ufs: core: Introduce ufshcd_post_device_init() Date: Mon, 19 Aug 2024 15:50:20 -0700 Message-ID: <20240819225102.2437307-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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 --- drivers/ufs/core/ufshcd.c | 62 ++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 04d94bf5cc2d..9e64b08eaa5e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8755,6 +8755,40 @@ 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)); + + /* 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; +} + static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) { struct Scsi_Host *host = hba->host; @@ -8813,33 +8847,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 Mon Aug 19 22:50:21 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: 820899 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E168C1591FC for ; Mon, 19 Aug 2024 22:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107906; cv=none; b=Q4ILmVZQx8urtNvE5zGAp9HWoFivUm/YHLCeJuMrqSf0OXsPhARgMR3+Z/aV3NHSI3V9v7ufyXMh9c8NQEIhtdMhk/UTb6VoY9LeZ/BhSQAsxValWT6XE26vPB85tX8rGCIhRJN1bPZWerqVoQxXkIHHkmTSPnTeNF9am5Xiwis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107906; c=relaxed/simple; bh=URNmhsBxRqcgMDe8eZq301KX1pzszfHIQi5xnBoJnng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MKtWqSrBD0mx4Joo4rN984u3uqXjtYG0oxouF7i3KyX+CTtC/Ao8mNvJOHROhKZ16TrCRBGtLIucTINIkMLzpG+elLrSgDLRrh0DtNy2sW+cL+o8k2GlEO+TJEZMmvK61bO2r8uUofG1aRGdSMmbLmUdeLEFpLD/DzQL/l1s+FM= 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=pwoJaa7O; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="pwoJaa7O" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WnnsD2pK8z6Cnk9X; Mon, 19 Aug 2024 22:51: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=1724107900; x=1726699901; bh=k1Dqb 1RHZ7CNjuttDn+c+kREstvvrJTrc3hZh6i7u+k=; b=pwoJaa7OCoGwk7J8RPoCb 9AIaU5RQS/91HjjFK3KgQitpwt/5ncmwnhUbmTIKt/9/fgl6D/nrMUkT32KnA9oj E7DrDznqADTg7Ven3yW9ABqAP+WeR+038yMrMtscxJInspLB0AM9HWk9mOucMgb8 twR6ufUvAAh4i6+PdDSxm1vjw9620qj21n1Rhl1Z1XKAdMcj940cMqD30906QI4O TdvM92tKl4mCD1BXW/zz+rYg5UZh5yWa41PBWpfkczRVn46Aeh/kc1AYtneg/+Z6 rZYz1iRqWpbwS0N/z3/fOuAWC5y1uRYYykmP/OJ9bkvwii+0eRSC2egQ8x6Qh81T A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id w-Ze9NSTtWkw; Mon, 19 Aug 2024 22:51:40 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4Wnns73cbvz6ClY8s; Mon, 19 Aug 2024 22:51:39 +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 4/9] ufs: core: Call ufshcd_add_scsi_host() later Date: Mon, 19 Aug 2024 15:50:21 -0700 Message-ID: <20240819225102.2437307-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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 --- 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 9e64b08eaa5e..502d0f5a95c0 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10583,10 +10583,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); @@ -10598,7 +10594,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; } /* @@ -10633,6 +10629,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); @@ -10640,12 +10640,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 Mon Aug 19 22:50:22 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: 820562 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 458561591FC for ; Mon, 19 Aug 2024 22:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107912; cv=none; b=GQonN9SUYcdsjm8kG7l+QnQqdcDlLJbvFvqIylpZzrpIn+IcbQWjFmSFHeyDajiJF/RRJ7EtnPUasqcGhDgyYWJKGlnWa46jCsKIABmOaew9Gp4ptOj+K30vxodZZ3e40mZ9RpXLvd2OrI+X0JxyVAK3zGXbt9GuKm3ChLOlWIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107912; c=relaxed/simple; bh=S+Zf4jtaP0LCQgOMoD6AvCADQT3bjnDNxZXg6DY+OfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q5azwlMTsFMD4VBvMdW6vSDKkPxFEPMeNIpKa8JaxVkAKGZnfUYPzxvmjQCHdlYTj9c91AGLolFSD18qdrUJVvyR99B/ALo9Yiy2q3z30TN5XFjb5b7f7XfpfWWNZnpNa+fHsANR3xC82+efLDrmIdoXcCHK/oI4rVkoU4B5fxQ= 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=bXkAxzYU; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="bXkAxzYU" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WnnsL5HPmz6ClY8q; Mon, 19 Aug 2024 22:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1724107905; x=1726699906; bh=820TQ LE+LKsy+aLlUV/sxa17laJsfWAU3hQj+0uNu44=; b=bXkAxzYUS9tSNL6mE/oQE KrOaL+IlqjfPoirkaSTRib8pCuIaog8tmP33yHNoBcm3zGrO2OJEoMYV2OPnQoa3 mwAT/ekIhAnsHigLCKs5dyBh+ja6wM1UfZcpwOOJt3q4x3LJPbmQH4XmSSpEb9ZC 32Lt0iB592PQLSOU/GQK0XugWJ0jGNy6pStmg4Xjg+T2UKvSv4hskQlSN6JuvJlA ok8IPhCvQVDq050Vo40q4moRyIUMzebtpQ1rW80CgDpddhRIs0kNlw42jeXCTyrr 1CWG2J7hUA8r5iMHKqqAjIwp3AcW1IDR28YyHXWNcOyDV7LF4ioeAtTKapTtbmYW w== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id IwjPU3cuPkO0; Mon, 19 Aug 2024 22:51:45 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WnnsD39NWz6ClY8r; Mon, 19 Aug 2024 22:51:44 +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 5/9] ufs: core: Move the ufshcd_device_init() call Date: Mon, 19 Aug 2024 15:50:22 -0700 Message-ID: <20240819225102.2437307-6-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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(). Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 502d0f5a95c0..86deea546b44 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); @@ -8853,22 +8857,17 @@ 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; - if (!hba->pm_op_in_progress && (hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH)) { /* Reset the device and controller before doing reinit */ @@ -8885,7 +8884,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; } @@ -8933,7 +8932,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 Mon Aug 19 22:50:23 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: 820898 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D83301591FC for ; Mon, 19 Aug 2024 22:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107916; cv=none; b=UnkRa0u6UGS1Rd6CVZr5LzyOkNRYy9DFZtF6708NJVVezYvNXMHuflgdOb3kgBdxiPspgTWQYH5oj53iRReRDrUdiBjJAsDO1VjzKWyIrSvU4aC8xbacwEjD/fawLgpqXGg0+0BFy6aKRslLkjSeJovQAXRZ5u1swonH6n55cEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107916; c=relaxed/simple; bh=pbzzAUA5mjDwOpaQ3E68cbtHi3IBNTaGsEPVQHUSU7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cvY+xuylJqiEf8W9blGgNch7XaitP1YaeAGCsJoSWLMpvxMgSYPjdhjo8VMk37FJC21aygSGJnCcBW7qvSJnrxt97GDZr8CpzXUdMk7F2zTSyCwtNRwEq+3k3739+K8hrWn5RWnBznWvaPXPuvbM71mls8dIyU4bKcDxfQIiZhQ= 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=Kt+fqW9W; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="Kt+fqW9W" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WnnsQ0YMnz6ClY8q; Mon, 19 Aug 2024 22:51:54 +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=1724107910; x=1726699911; bh=wbJk8 lO+Vcd8A1zWrOKa9Jx+gILaiMBuKg/Of8iBn+w=; b=Kt+fqW9WtLTuZldJlRnVP IfMF3e7XhzQ9b5P1AS+7M3nmTCywz03MmDMczLGMUYT2WDo8o2lLmAo6R5cU/Bey 9XTg1w9dQhbQC09eljADPqDwRsOAbYjw65L/nKbzxd517GzcXo+r2JM/WlJCsT+C RqvgJoM5xjW2+zQ5gu+ZGMnYdqJLd8Hv7ai5PPXXzKnyd0HqVJzrmK+8qH76QWfe r3QzlwoVnv9vH90Z9hiJquTeDfqd0Oy5d7wOjx0mteGK08DzfkdeTXjdzCyvMdEy LzCiUexroUw1iAXKceidOlP6cMHxNk0jmNffrDNRf3kp+LUWFzFg9TTXNwb+8wfJ w== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id e_qbA7wk7PgD; Mon, 19 Aug 2024 22:51:50 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WnnsK2sLsz6Cnk9X; Mon, 19 Aug 2024 22:51:49 +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 6/9] ufs: core: Move the ufshcd_device_init(hba, true) call Date: Mon, 19 Aug 2024 15:50:23 -0700 Message-ID: <20240819225102.2437307-7-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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(). Signed-off-by: Bart Van Assche --- 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 86deea546b44..2754f496d10e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8931,10 +8931,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; @@ -10630,6 +10627,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 Mon Aug 19 22:50:24 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: 820561 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1A461591FC for ; Mon, 19 Aug 2024 22:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107921; cv=none; b=OI7ocqff4rsAr2uRm7HvrVAnXgwjHJnXF7Pj1vGKXhoPessB0gjogGSj6LhT9V2YIr33Ro3MmKGTNQsbGbLo4wulAqS00bRPLj0Hm4qQsp2YtIcKxtKLirRKsfImtFCBDUJpRxqlv6CIvR/rguHxI1KVP5CfclzK5W9qQjpb+CQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107921; c=relaxed/simple; bh=U7/18uJ6mNK8+gtQLT5rsKnyoNdAbrmgZczE7P3LwCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KARkZ78XgtDkw47m9uJNzo2ZUh38ZiZtRE/Q9O73eHmukhFcR4fjNWm6CVntO3j9OSUBDACQvS7BmPwiGWU3Ju70eXrefYlhxqxsuERCOAgxWWN8aM9VSEWqSD/u3Jpe+R6nXsf5nc+EcnbhNPAsh4qUfdNeoG0gm6N6R0boNYw= 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=TApmRYvX; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="TApmRYvX" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WnnsW3Jfrz6ClY8r; Mon, 19 Aug 2024 22:51: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=1724107915; x=1726699916; bh=Brw7m 6CYsyNkQ/LP2ADMUT+fY9pzvby5wp+YSq9gXJg=; b=TApmRYvX5b/USmayjBczP 14dC0QLGHs9w5omyVLph2mh3IIJik5oNPOIdQP6zJb1v2XGyqJAn6ja87v1h//28 v+MAj78JTbF7JEucD2Zof9LkS17Nvr6aXuPA+SWP0Z2tsbQVbp+Yi78Ct10cpXAo U12guzn712S8vJar595rgzp+1BYjtfSIW0DXm6ZK+2+1FXooQGvQxgI6CTVKG/yf lWnSTekTfQ6FXTrhZbqiQBFCYCtalLBReC26I+pE82nqJwDFJq7cO7WUFtSjW2k/ L9fDp+ES63oD6W8eeUq8tJ50r9GX57xfkmmtbKxuTeTRYGrUfHrDGxHOv1zgAaPi g== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id xLVHxP-kkLmv; Mon, 19 Aug 2024 22:51: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 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WnnsQ2VPvz6Cnk9X; Mon, 19 Aug 2024 22:51: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 7/9] ufs: core: Expand the ufshcd_device_init(hba, true) call Date: Mon, 19 Aug 2024 15:50:24 -0700 Message-ID: <20240819225102.2437307-8-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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 2754f496d10e..dedbef27d5c5 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10627,8 +10627,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 Mon Aug 19 22:50:25 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: 820897 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DAEA1DD3B5 for ; Mon, 19 Aug 2024 22:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107926; cv=none; b=llx/iDI5sr8sryGbUZAKhEyrWJoxiuMhxg8iLkLDyR9KPr/I3uCXenWMiMbvjpdy9tFsoQRhJTcgkJp+0LWgjCy229t1VucnKnreKhGrpde0BwrW1n1XdH27sZWitCRXxCyFCUFR9ZBOJVOMav6dCZICi4UDy5gMRNe1l+euL0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107926; c=relaxed/simple; bh=QlrZSTGvkrogyPy2k1dzpotDHSuS2TmdZtfDXjJn77Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BN7QqJvduXzBNtPNPSY8PyQJ+EFC2yBeANnLMN/qhvGCiLW3QSV2dMTy/dg0aW5s1gzVLhjRteqWUWoetVTbHp7cXiow2gGEzj8cqyOq1JMyMTVV7fF8vK/IQHuJY8bbZji9VHa6Mkf1Ru0eh2wEi0rDuV/EupC/a+knC45qWT0= 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=krysSZj8; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="krysSZj8" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4Wnnsc4NGmz6ClY8r; Mon, 19 Aug 2024 22:52:04 +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=1724107920; x=1726699921; bh=0cnm8 v/dUyGqva6tz1T3n9d8ekdZh2e/wxznsOntlXo=; b=krysSZj8rHj7EGs0EKz/N tWd6ksZZi4Tueb7hm4wSKo97OKd6PKtyGU0+AdL2In+OebPdlVtU5xvC2f4T0Guj 52ZksmyXzKKEUH/6tdrk4myQ1kt/qBEwihdnXEJ1J9WUQ5cYSjKKtc9xhnaKxs1f Jzb0ypa3PPF7NRG+GkDCB2k9kt7Kr/oWaKSMe0WEgHfCipFrV1bUw9f/FAAL9cRC 0oVjxeZZRnGYIEBl5UCTvMCfT5XuT6bMKuFHCR/2KBi/Lg3Nc2yOsMZX/Y3pgMvM X8D33ofOFJPegLBWoNnV3NiD8HK/2+2AbHCI0CEZMiByk5nv6Esye5jka6co9sHh A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id IbTIta5E44qL; Mon, 19 Aug 2024 22:52:00 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WnnsW2j69z6ClY8q; Mon, 19 Aug 2024 22:51: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 8/9] ufs: core: Move the MCQ scsi_add_host() call Date: Mon, 19 Aug 2024 15:50:25 -0700 Message-ID: <20240819225102.2437307-9-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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 dedbef27d5c5..b3fae37e4f6a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10402,15 +10402,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, @@ -10648,25 +10660,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 Mon Aug 19 22:50:26 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: 820560 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CAE41591FC for ; Mon, 19 Aug 2024 22:52:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107932; cv=none; b=YtmVzCAE3P+JkbBhXE3MmQPVDbHyx4HtEBbLdBBUG+rFhSG8qw56UcxZay/o+eiQoHNEtwy5Kc28lUKQgS6WSGfLOYmzCAc4T1QFHxFKNy4tr8c+3/DKdVCZOIBz0FPO73hXHuOkurPuCNLOuCv+b1bU6w6DftbpmQtPxkRfXyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724107932; c=relaxed/simple; bh=D/FdpSZrelHR55uGq7R5PLUuhBnzXtfJJM36ppXfMg0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMcrPNf5cW2do8d7Ph0Ekax7BJ2OqoG8m5lp/LducaGcvhQkMlOfwms9E8pzXZfr8+ta3VjKwqJuUgHPihqQOFXdgMyYseGD1NmYH7cvaLOXd6I13v+dI+YKnMYkNAb0BfVSNxBWbPSgR1PzU74y6Csa+Vo6WyP+UKsIk7RaHe8= 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=VzMsfZUd; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="VzMsfZUd" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4Wnnsl1n7Yz6ClY8q; Mon, 19 Aug 2024 22:52:11 +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=1724107925; x=1726699926; bh=ixNiK m53XQvNLlvdc5xB/k4tIyUx7HCkhLVGC/2HXfc=; b=VzMsfZUdzQTf9tDQU/XxW nIsj5A/wZbyhBiHiQHvK69wYNuvavQ7WCOZGDwLk2e7JLi+XlGIC7ePFLfBn+9GA INvf8t7BDhn/4Ie9izrDLUlsHOiBn51xxa9bny4jUvpETUqPNLs25fJNpHHJrc5N xlv+hlVx/BcyGMtbn1TqqtW4RiSD+M2VLhpvYf2yRAarpU2/eU3gFl996ixa4ReK M0iEO7/vJds9wgXxrLpxdvfp5LorD/8Y2QHnxweCyHxxTtTUagB2j074nma4pKFL 3e7+0gaNHG0CNXyoSdUyjwI3szSUxiVz4Xj0aHMPDU5yjdoOH8JrAL0ZxeqR8GWl A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id H9AI-dWmfAKr; Mon, 19 Aug 2024 22:52:05 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4Wnnsc2mDSz6Cnk9X; Mon, 19 Aug 2024 22:52:04 +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 9/9] ufs: core: Remove the second argument of ufshcd_device_init() Date: Mon, 19 Aug 2024 15:50:26 -0700 Message-ID: <20240819225102.2437307-10-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819225102.2437307-1-bvanassche@acm.org> References: <20240819225102.2437307-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 b3fae37e4f6a..9af293b39672 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); } @@ -8793,9 +8793,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); @@ -8803,7 +8802,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); } @@ -8818,39 +8817,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); } @@ -8884,7 +8850,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; }