Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3873265pxu; Tue, 20 Oct 2020 02:46:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPAAAKi2Vy0aBfpPB8RWOjjjGjtN4amVdZvQYaCNJ5ljzga+H2Lw0BSAS+7u1czoAhbP6a X-Received: by 2002:a17:906:5249:: with SMTP id y9mr2388304ejm.440.1603187193515; Tue, 20 Oct 2020 02:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603187193; cv=none; d=google.com; s=arc-20160816; b=R+AHcIrZEAsu/Y+EWLLsxmKMVhWIljL/+KeZXjFGTYyIe1oMdVqHY/sq+zHjBmQ+3f iBjcTTIG4kMXBfSBT7i0nK2OsFPQrSa/5179HkW2LcBq5Lvd1uwFl7mE7/tl63xD/FER 4fGC0Pk2bYz3mPv8u7z9feqamSg0f1D+vPlQGe3nDg+EkZQSZQjyJ13x1a+rAF846kRF X8U5dHQCdYiUO9epTyI51PtyzqPQ37fk77zjLp1TacwHy3c5nCEgwGjv/hwGr7Z7iwfW 4rmOCsn4nSCHaIrXdrXS7/LTK+itfHGt3VHPu4RUOAFr6zDGKzx/LchE6QzVbDMmV4kx ywmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:dkim-filter; bh=lz40hHps79hqNfcnD+cI3oHpIVLgeD6CDqiBeBo/A8M=; b=sWTpHF4k2n2AEU7D/VYFd+zmw6fjxonckjHcLsbqhBhiI7R9fnCW/fk7sliliSPy1T JkH+Kf38zYcaMsWy7L9t/8W/RjaF8eu4bEvKlAOr7Hp9bJvIcmO2ZrgN6jh9VajwZHR4 9hQPaay757qAPlJbsEgNF9zhovIz8tiJPyNc1H7FbyKucxhdr9fJnjWwEN4uH9sUnmBK /V/giTmZCGHRJTWQJvxGOK5ept9/FT/66R8JX/CWI3+34E5pnVhV9bsx9ws0FTAOYTyI wEY92t6LPktlcNSKJNVXLvIMBAW896HHPxKxCfqZfl7znWBNtE0vHlWoBtA23nE1Ej98 iy4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=stwK0Ovi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si768044edx.563.2020.10.20.02.46.11; Tue, 20 Oct 2020 02:46:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=stwK0Ovi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404789AbgJTHF2 (ORCPT + 99 others); Tue, 20 Oct 2020 03:05:28 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:52172 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404784AbgJTHF1 (ORCPT ); Tue, 20 Oct 2020 03:05:27 -0400 Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20201020070525epoutp02863b803cc3a2c302fe0d13adf04f2f95~-oXcjluKr2790627906epoutp02d for ; Tue, 20 Oct 2020 07:05:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20201020070525epoutp02863b803cc3a2c302fe0d13adf04f2f95~-oXcjluKr2790627906epoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1603177525; bh=lz40hHps79hqNfcnD+cI3oHpIVLgeD6CDqiBeBo/A8M=; h=From:To:Cc:Subject:Date:References:From; b=stwK0OviaweTFSwolWPfyyffNR3bnL648FfkGNSaVmudvE6NNA+7zYQNO+Qlk6Hi0 0rnLAdMhoLqd0CGUClyPyAxwH2IY8zc+8dqIcIaq2ern5GKRAgwdsAZ27YITOMT6ka m0WrLdgRJd8wPeU2eVbqZlmlVSG+UjnCDpYnkiWk= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20201020070525epcas2p49eb6cc2621c08aa65df0b14235df06b4~-oXcOPvH21677716777epcas2p4r; Tue, 20 Oct 2020 07:05:25 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.182]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4CFl4y4DSdzMqYkr; Tue, 20 Oct 2020 07:05:22 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 5F.9A.09588.13C8E8F5; Tue, 20 Oct 2020 16:05:22 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20201020070519epcas2p27906d7db7c74e45f2acf8243ec2eae1d~-oXXbkF4G0868808688epcas2p2C; Tue, 20 Oct 2020 07:05:19 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201020070519epsmtrp11d1d02b0f52fdcfb924fba2933fc18a2~-oXXape6_1391713917epsmtrp1g; Tue, 20 Oct 2020 07:05:19 +0000 (GMT) X-AuditID: b6c32a45-36bff70000002574-c7-5f8e8c311e37 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 57.32.08745.F2C8E8F5; Tue, 20 Oct 2020 16:05:19 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201020070519epsmtip161a3e009d658aad5260cf63c88ae6d7f~-oXXNZSlV2165121651epsmtip1n; Tue, 20 Oct 2020 07:05:19 +0000 (GMT) From: Chanho Park 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 Subject: [PATCH] scsi: ufs: make sure scan sequence for multiple hosts Date: Tue, 20 Oct 2020 16:05:16 +0900 Message-Id: <20201020070516.129273-1-chanho61.park@samsung.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHKsWRmVeSWpSXmKPExsWy7bCmqa5RT1+8wbsrTBYP5m1js3j58yqb xeX92haLbmxjsri8aw6bRff1HWwWy4//Y3Jg95iw6ACjx8ent1g8+rasYvT4vEnOo/1AN1MA a1SOTUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7QFUoK ZYk5pUChgMTiYiV9O5ui/NKSVIWM/OISW6XUgpScAkPDAr3ixNzi0rx0veT8XCtDAwMjU6DK hJyMD2++sBdcFqyY+PUOYwPjXr4uRk4OCQETiaNPFrF3MXJxCAnsYJTY8vMmK4TziVHi2eqX rCBVQgKfGSX2X2OG6Xjx7iFUxy5GiY2n2xghnI+MEgs+trCBVLEJ6Epsef4KKMHBISJgJHFt lSdIDbPAdEaJgys/gtUIC7hJ7Nx/DmwDi4CqxNHHC8HqeQXsJV42eEEsk5d42rscbDGvgKDE yZlPWEBsZqB489bZzCAzJQTOsUvce93JBtHgInH7Qj/UpcISr45vYYewpSRe9rdB2fUSKx41 QTX3MEq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CRaRWjZGpBcW56brFhgVFearlecWJucWleul5yfu4mRnCI amntYNyz6oPeIUYmDsZDjBIczEoivBNY++KFeFMSK6tSi/Lji0pzUosPMUpzsCiJ836dtTBO SCA9sSQ1OzW1ILUIJsvEwSnVwNSo1MhqULM3SeishajfqX0Nr6/cq/bjDirhP9z8aOvh+QzH r10sbzhaErheM+0Yv42L1S+f1z38xpujjT5MVuKXFb2SzX5D3izzSOwjpYR9tsnvKxsFrb9w O08OvaZe/H9e/cfX6v8dVNlU0hkm+hwobxQW3fRTag2z/4RQvQI+nXsx3W5LphWyqDxXbzzZ udl07ocN1ddZbmhKXL5elC34UPXMh/MuEVpF00q9Xoe9DTK5p9q1imcWd7+Njvr3yTN1t1zZ vaDr1Jcraru7+T2T+bne8lf5HFrYuHH9wx3b5utuW1cdMInZji/CTCph5pEtW1q4Z2+ecOXu rSz3p+37JORuWwWvvvqz/U3/ESWW4oxEQy3mouJEAACj59XAAgAA X-CMS-MailID: 20201020070519epcas2p27906d7db7c74e45f2acf8243ec2eae1d X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20201020070519epcas2p27906d7db7c74e45f2acf8243ec2eae1d References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 #include #include +#include #include #include #include @@ -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