linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chanho Park <chanho61.park@samsung.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: alim.akhtar@samsung.com, avri.altman@wdc.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chanho Park <chanho61.park@samsung.com>
Subject: [PATCH] scsi: ufs: make sure scan sequence for multiple hosts
Date: Tue, 20 Oct 2020 16:05:16 +0900	[thread overview]
Message-ID: <20201020070516.129273-1-chanho61.park@samsung.com> (raw)
In-Reply-To: CGME20201020070519epcas2p27906d7db7c74e45f2acf8243ec2eae1d@epcas2p2.samsung.com

By doing scan as asynchronous way, scsi device scannning can be out of
order execution. It is no problem if there is a ufs host but the scsi
device name of each host can be changed according to the scan sequences.

Ideal Case) host0 scan first
host0 will be started from /dev/sda
 -> /dev/sdb (BootLUN0 of host0)
 -> /dev/sdc (BootLUN1 of host1)
host1 will be started from /dev/sdd

This might be an ideal case and we can easily find the host device by
this mappinng.

However, Abnormal Case) host1 scan first,
host1 will be started from /dev/sda and host0 will be followed later.

To make sure the scan sequences according to the host, we can use a
bitmap which hosts are scanned and wait until previous hosts are
finished to scan.

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b8f573a02713..1ced5996e988 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -13,6 +13,7 @@
 #include <linux/devfreq.h>
 #include <linux/nls.h>
 #include <linux/of.h>
+#include <linux/bitmap.h>
 #include <linux/bitfield.h>
 #include <linux/blk-pm.h>
 #include <linux/blkdev.h>
@@ -214,6 +215,10 @@ static struct ufs_dev_fix ufs_fixups[] = {
 	END_FIX
 };
 
+/* Ordered scan host */
+static unsigned long scanned_hosts = 0;
+static wait_queue_head_t scan_wq = __WAIT_QUEUE_HEAD_INITIALIZER(scan_wq);
+
 static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba);
 static void ufshcd_async_scan(void *data, async_cookie_t cookie);
 static int ufshcd_reset_and_restore(struct ufs_hba *hba);
@@ -7709,8 +7714,13 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
 	if (ret)
 		goto out;
 
-	/* Probe and add UFS logical units  */
+	/* Probe and add UFS logical units. Sequential scan by host_no */
+	wait_event(scan_wq,
+		   find_first_zero_bit(&scanned_hosts, hba->host->max_id) ==
+		   hba->host->host_no);
 	ret = ufshcd_add_lus(hba);
+	set_bit(hba->host->host_no, &scanned_hosts);
+	wake_up(&scan_wq);
 out:
 	/*
 	 * If we failed to initialize the device or the device is not
-- 
2.28.0


       reply	other threads:[~2020-10-20  7:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20201020070519epcas2p27906d7db7c74e45f2acf8243ec2eae1d@epcas2p2.samsung.com>
2020-10-20  7:05 ` Chanho Park [this message]
2020-10-21  3:15   ` [PATCH] scsi: ufs: make sure scan sequence for multiple hosts Bart Van Assche
2020-10-21  4:23     ` chanho61.park
2020-10-22  0:29       ` Bart Van Assche
2020-10-22  4:59         ` Chanho Park
2020-10-22  6:52           ` Avri Altman
2020-10-26 11:20             ` Chanho Park
2020-10-23 15:27           ` Bart Van Assche
     [not found] <CGME20201020084429epcas2p3685bcb89c3ab1cacefb183384dcb2b6e@epcas2p3.samsung.com>
2020-10-20  8:44 ` Chanho Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201020070516.129273-1-chanho61.park@samsung.com \
    --to=chanho61.park@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).