From patchwork Fri Jul 3 05:30:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11640889 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBA8113B6 for ; Fri, 3 Jul 2020 05:38:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF82D207CD for ; Fri, 3 Jul 2020 05:38:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Wr9rjHtR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725960AbgGCFiF (ORCPT ); Fri, 3 Jul 2020 01:38:05 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:24745 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725891AbgGCFiD (ORCPT ); Fri, 3 Jul 2020 01:38:03 -0400 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200703053759epoutp012b0a92171d19c80d033dec6e89013166~eJ2-xAGIe2423724237epoutp01x for ; Fri, 3 Jul 2020 05:37:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200703053759epoutp012b0a92171d19c80d033dec6e89013166~eJ2-xAGIe2423724237epoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593754679; bh=8z7z+/v9tHoImnK9+4J8GzYCdc8KTKE5pdOGFWD21pg=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=Wr9rjHtRGM6p/jfiTDT5oS1RWiFw6n8poqQeOMym7YOkNJ1mTCsucPPvrEx/sP8LL QayTpiihGG5uRVp+Q7iyCoAyHxXlnkypSnWLeQ9ySh0lmRsj66NzbaNdUH1+KuwQIF juQTCad8ffoCXDiWXoOzO2zxOqZc5bb1iqysXeFg= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20200703053759epcas2p134bf534684721f3477a9c5e6cd14cf58~eJ2-KaYDA2348023480epcas2p1G; Fri, 3 Jul 2020 05:37:59 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.40.189]) by epsnrtp3.localdomain (Postfix) with ESMTP id 49ykJN3SxczMqYkV; Fri, 3 Jul 2020 05:37:56 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 45.9C.27441.434CEFE5; Fri, 3 Jul 2020 14:37:56 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20200703053756epcas2p1f32da04da87c8f56a6052caada95fb9a~eJ28M2mC40052000520epcas2p17; Fri, 3 Jul 2020 05:37:56 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200703053756epsmtrp2c60dae03b104fd41e415462e214de39b~eJ28L6nyD0408904089epsmtrp26; Fri, 3 Jul 2020 05:37:56 +0000 (GMT) X-AuditID: b6c32a47-fc5ff70000006b31-65-5efec4345975 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 56.6E.08303.334CEFE5; Fri, 3 Jul 2020 14:37:55 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200703053755epsmtip1f3af98a3e22062ec75d82d1100c3aef1~eJ28Aq6r02755227552epsmtip1H; Fri, 3 Jul 2020 05:37:55 +0000 (GMT) From: Kiwoong Kim To: linux-scsi@vger.kernel.org, alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com, beanhuo@micron.com, asutoshd@codeaurora.org, cang@codeaurora.org, bvanassche@acm.org, grant.jung@samsung.com, sc.suh@samsung.com, hy50.seo@samsung.com, sh425.lee@samsung.com Cc: Kiwoong Kim Subject: [RFC PATCH v3 1/2] ufs: support various values per device Date: Fri, 3 Jul 2020 14:30:01 +0900 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmqa7JkX9xBiv/Slo8mLeNzWJv2wl2 i5c/r7JZHHzYyWIx7cNPZotP65exWvz6u57dYvXiBywWi25sY7K4ueUoi0X39R1sFsuP/2Oy 6Lp7g9Fi6b+3LA58HpeveHtc7utl8piw6ACjx/f1HWweH5/eYvHo27KK0ePzJjmP9gPdTAEc UTk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUB3KymU JeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKDA0L9IoTc4tL89L1kvNzrQwNDIxMgSoT cjL+vVnNWHBGsmLn6Y8sDYy/RboYOTkkBEwkru7YzNrFyMUhJLCDUeJTy2smkISQwCdGiWnt gRCJz4wS+05fZYXrWPCYHSKxi1Fiz+rLTBDOD0aJdbcOsIBUsQloSjy9ORUsISKwmUni1YL7 zCAJZgF1iV0TToDtEBZwkljYcQJsLIuAqsT0Kd1gNbwC0RKT7rxiglgnJ3HzXCdYnFPAUuLj yadsqGwuoJqpHBLzTvQBORxAjovEm1XmEL3CEq+Ob2GHsKUkPr/bywZh10vsm9rACtHbwyjx dN8/RoiEscSsZ+2MIHOYgT5Yv0sfYqSyxJFbLBDn80l0HP7LDhHmlehoE4JoVJb4NWky1BBJ iZk370Bt9ZDo23EXGrxAmy79/cw6gVF+F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QIxMH4yFGCQ5mJRHeBNV/cUK8KYmVValF+fFFpTmpxYcYpTlYlMR5v85aGCckkJ5Y kpqdmlqQWgSTZeLglGpguvhxnrWktR3zzMdMkt+4Jq1fwXc8ob5G40v65aeSond2F+ZenTxt 7/Nv10T4LKXDj7x3uDh9avvrDo/qvfpTT7JpBhy5tfGjukCh0NxXu6dMn+7qrW6744k8y08x 5ZvbLJ2PL+zN3mqesuUz29b1/U8WzBH5VPhsQ18fd9T80rptMqfsy8sDZnqcfX3O8fF8r1v8 0flLZ7434NglG3pyDpeT+IlZjOs+tjMwOn6XFPnrZKn5kuX7ReeMdwffPFRc+82pSaA/fDmj dKn9lZoH97v/cV04VXlho8U0pqSK+i1TuOI/O+e88py1+1cPf+vf3CqWCGueMBPnyMYiN4GE 2Fvv0srsZM6svjRlneGdO0osxRmJhlrMRcWJACqVhTj0AgAA X-CMS-MailID: 20200703053756epcas2p1f32da04da87c8f56a6052caada95fb9a X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200703053756epcas2p1f32da04da87c8f56a6052caada95fb9a References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Respective UFS devices have their own characteristics and many of them could be a form of numbers, such as timeout and a number of retires. This introduces the way to set those things per specific device vendor or specific device. I wrote this like the style of ufs_fixups stuffs. Signed-off-by: Kiwoong Kim --- drivers/scsi/ufs/ufs_quirks.h | 13 +++++++++++++ drivers/scsi/ufs/ufshcd.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 1 + 3 files changed, 53 insertions(+) diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index 2a00414..f074093 100644 --- a/drivers/scsi/ufs/ufs_quirks.h +++ b/drivers/scsi/ufs/ufs_quirks.h @@ -29,6 +29,19 @@ struct ufs_dev_fix { unsigned int quirk; }; +enum dev_val_type { + DEV_VAL_FDEVICEINIT = 0x0, + DEV_VAL_NUM, +}; + +struct ufs_dev_value { + u16 wmanufacturerid; + u8 *model; + u32 key; + u32 val; + bool enable; +}; + #define END_FIX { } /* add specific device quirk */ diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 52abe82..b26f182 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -207,6 +207,21 @@ static struct ufs_dev_fix ufs_fixups[] = { END_FIX }; +static const struct ufs_dev_value ufs_dev_values[] = { + {0, 0, 0, 0, false}, +}; + +static inline bool +ufs_get_dev_specific_value(struct ufs_hba *hba, + enum dev_val_type type, u32 *val) +{ + if (!ufs_dev_values[type].enable) + return false; + + *val = hba->dev_value[type]; + return true; +} + 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); @@ -6923,11 +6938,35 @@ void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups) } EXPORT_SYMBOL_GPL(ufshcd_fixup_dev_quirks); +static void ufshcd_set_dev_values(struct ufs_hba *hba, + const struct ufs_dev_value *value) +{ + struct ufs_dev_value *f; + struct ufs_dev_info *dev_info = &hba->dev_info; + + if (!value) + return; + + for (f = (struct ufs_dev_value *)value; f->val; f++) { + if ((f->wmanufacturerid == dev_info->wmanufacturerid || + f->wmanufacturerid == UFS_ANY_VENDOR) && + ((dev_info->model && + STR_PRFX_EQUAL(f->model, dev_info->model)) || + !strcmp(f->model, UFS_ANY_MODEL))) { + f->enable = true; + hba->dev_value[f->key] = f->val; + } + } +} + static void ufs_fixup_device_setup(struct ufs_hba *hba) { /* fix by general quirk table */ ufshcd_fixup_dev_quirks(hba, ufs_fixups); + /* set device specific values */ + ufshcd_set_dev_values(hba, ufs_dev_values); + /* allow vendors to fix quirks */ ufshcd_vops_fixup_dev_quirks(hba); } diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index c774012..f221ca7 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -670,6 +670,7 @@ struct ufs_hba { /* Device deviations from standard UFS device spec. */ unsigned int dev_quirks; + u32 dev_value[DEV_VAL_NUM]; struct blk_mq_tag_set tmf_tag_set; struct request_queue *tmf_queue; From patchwork Fri Jul 3 05:30:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11640893 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81BBD912 for ; Fri, 3 Jul 2020 05:38:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 600D020771 for ; Fri, 3 Jul 2020 05:38:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="VgWiBPCd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725984AbgGCFiH (ORCPT ); Fri, 3 Jul 2020 01:38:07 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:17394 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgGCFiG (ORCPT ); Fri, 3 Jul 2020 01:38:06 -0400 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200703053804epoutp023e7f6ced27dc0a93469efc863acea426~eJ3Dr9BFw1766317663epoutp02- for ; Fri, 3 Jul 2020 05:38:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200703053804epoutp023e7f6ced27dc0a93469efc863acea426~eJ3Dr9BFw1766317663epoutp02- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593754684; bh=2pjz71oUTjidQIgpnWnMela1RqN5S8mbju02vjVVznI=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=VgWiBPCdxBKAH/BHZvHAgpwk74NpTQks3qsUJquJhYMXJotmNPWMIRvE2ZMkbVqpV ufwoVdcoKH77GRmurmcAVG5DJVhiGuWhXPhZWR8QtGpeF9e2hObOGKXLVBAHXDUMCq km+XcIccXvvROAJZhMspCZlv5zY2gVvW3KIrWvHM= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20200703053803epcas2p33805daf2f1cfb9773945c481fbbea685~eJ3DHtQFd3267032670epcas2p3Y; Fri, 3 Jul 2020 05:38:03 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.185]) by epsnrtp4.localdomain (Postfix) with ESMTP id 49ykJQ16tRzMqYkd; Fri, 3 Jul 2020 05:37:58 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 1B.F8.19322.634CEFE5; Fri, 3 Jul 2020 14:37:58 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20200703053757epcas2p3416b0a10e4419015da549a9c4bfbf37f~eJ29rCgn-3267032670epcas2p3Q; Fri, 3 Jul 2020 05:37:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200703053757epsmtrp221e08ef42aad8475f16b90d2b3d4bf37~eJ29qSUgJ0409004090epsmtrp2z; Fri, 3 Jul 2020 05:37:57 +0000 (GMT) X-AuditID: b6c32a45-797ff70000004b7a-57-5efec436fb12 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CA.8A.08382.534CEFE5; Fri, 3 Jul 2020 14:37:57 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200703053757epsmtip14788e9dc84361771254d9275ced991fc~eJ29dqNEM2555325553epsmtip1l; Fri, 3 Jul 2020 05:37:57 +0000 (GMT) From: Kiwoong Kim To: linux-scsi@vger.kernel.org, alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com, beanhuo@micron.com, asutoshd@codeaurora.org, cang@codeaurora.org, bvanassche@acm.org, grant.jung@samsung.com, sc.suh@samsung.com, hy50.seo@samsung.com, sh425.lee@samsung.com Cc: Kiwoong Kim Subject: [RFC PATCH v3 2/2] ufs: change the way to complete fDeviceInit Date: Fri, 3 Jul 2020 14:30:02 +0900 Message-Id: <08bc1641fdce941175596fe106fd5c02161683bf.1593753896.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmua7ZkX9xBjd+slo8mLeNzWJv2wl2 i5c/r7JZHHzYyWIx7cNPZotP65exWvz6u57dYvXiBywWi25sY7K4ueUoi0X39R1sFsuP/2Oy 6Lp7g9Fi6b+3LA58HpeveHtc7utl8piw6ACjx/f1HWweH5/eYvHo27KK0ePzJjmP9gPdTAEc UTk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUB3KymU JeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKDA0L9IoTc4tL89L1kvNzrQwNDIxMgSoT cjL67l1jLugVrbiydC5LA2OHYBcjJ4eEgInE+WsLGLsYuTiEBHYwSpzcMIMFJCEk8IlRYsM3 RYjEN0a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weH5/eYvHo27KK0ePzJjmP9gPdTAEc UVw2Kak5mWWpRfp2CVwZffeuMRf0ilZcWTqXpYGxQ7CLkZNDQsBEYsm7A+xdjFwcQgK7GSUu HprAApGQlDix8zkjhC0scb/lCCtE0TdGiWc9TWwgCTYBTYmnN6cygSREBA4zSfzf+pwdJMEs oC6xa8IJJhBbWMBdYt2VmWA2i4CqxLftX8FqeAWiJc78vM8MsUFO4ua5TjCbU8BS4uPJp2AL hAQsJA68mcCKS3wCo8ACRoZVjJKpBcW56bnFhgWGeanlesWJucWleel6yfm5mxjBsaCluYNx +6oPeocYmTgYDzFKcDArifAmqP6LE+JNSaysSi3Kjy8qzUktPsQozcGiJM57o3BhnJBAemJJ anZqakFqEUyWiYNTqoHpTFLEm3LrxpeHix6s62UM2BWzfXHbSVbr6LO63K3m2yIDLl7JZuA4 3W1TezhPuufmZsF8ZvEtLRILbIQfNp1TnbjzX135osNBW5lTmbbwd31fGxNxsi/5f/LCabKd m7uuH3L8LDA7J/nVnrO3w7P3fEnZWq8Zu/l351UdyTXfG0KOasRfZu5hENnYXh+y92VgdeWf iGMPulYyvbZ8d/mUwGmNP3lrp9z/v4/hRmPINIG7/maqK7Su/Y37H6a30Or0jwv9mxY0NJgr i06JmnBBw3LSBWNfpb075M3OH11bbxI9b4tni+XihfwZD4rXZWcdSAyV61qWxt01Y6KChYzT qdaEKZ0Xz3tu3nDh+rVLSizFGYmGWsxFxYkAedoHxPQCAAA= X-CMS-MailID: 20200703053757epcas2p3416b0a10e4419015da549a9c4bfbf37f X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200703053757epcas2p3416b0a10e4419015da549a9c4bfbf37f References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Currently, UFS driver checks if fDeviceInit is cleared at several times, not period. This patch is to wait its completion with the period, not retrying. Many device vendors usually provides the specification on it with just period, not a combination of a number of retrying and period. So it could be proper to regard to the information coming from device vendors. I first added one device specific value regarding the information. Signed-off-by: Kiwoong Kim --- drivers/scsi/ufs/ufshcd.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index b26f182..6c08ed2 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -208,6 +208,7 @@ static struct ufs_dev_fix ufs_fixups[] = { }; static const struct ufs_dev_value ufs_dev_values[] = { + {UFS_VENDOR_TOSHIBA, UFS_ANY_MODEL, DEV_VAL_FDEVICEINIT, 2000, false}, {0, 0, 0, 0, false}, }; @@ -4162,9 +4163,12 @@ EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode); */ static int ufshcd_complete_dev_init(struct ufs_hba *hba) { - int i; + u32 dev_init_compl_in_ms = 1000; + unsigned long timeout; int err; bool flag_res = true; + bool is_dev_val; + u32 val; err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG, QUERY_FLAG_IDN_FDEVICEINIT, 0, NULL); @@ -4175,20 +4179,28 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) goto out; } - /* poll for max. 1000 iterations for fDeviceInit flag to clear */ - for (i = 0; i < 1000 && !err && flag_res; i++) - err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG, - QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res); + /* Poll fDeviceInit flag to be cleared */ + is_dev_val = ufs_get_dev_specific_value(hba, DEV_VAL_FDEVICEINIT, &val); + dev_init_compl_in_ms = (is_dev_val) ? val : 500; + timeout = jiffies + msecs_to_jiffies(dev_init_compl_in_ms); + do { + err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, + QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res); + if (!flag_res) + break; + usleep_range(5, 10); + } while (time_before(jiffies, timeout)); - if (err) + if (err) { dev_err(hba->dev, - "%s reading fDeviceInit flag failed with error %d\n", - __func__, err); - else if (flag_res) + "%s reading fDeviceInit flag failed with error %d\n", + __func__, err); + } else if (flag_res) { dev_err(hba->dev, - "%s fDeviceInit was not cleared by the device\n", - __func__); - + "%s fDeviceInit was not cleared by the device\n", + __func__); + err = -EBUSY; + } out: return err; }