From patchwork Sat Jun 20 07:31:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11615831 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 C004B13B1 for ; Sat, 20 Jun 2020 07:39:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FD1923A1E for ; Sat, 20 Jun 2020 07:39:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="MeGtUJXC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725935AbgFTHjX (ORCPT ); Sat, 20 Jun 2020 03:39:23 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:41712 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbgFTHjW (ORCPT ); Sat, 20 Jun 2020 03:39:22 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200620073918epoutp030a9b1636d8271f4e2435b3f76e38da90~aMINLth4N3099230992epoutp03- for ; Sat, 20 Jun 2020 07:39:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200620073918epoutp030a9b1636d8271f4e2435b3f76e38da90~aMINLth4N3099230992epoutp03- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592638758; bh=gbLzNkh7YdNcmin4lMx0Xai8fozVYmBfap1tGd47Y/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MeGtUJXCpjUWNWo5ctviNLw7QaZBxecQwUzvsK2DZuOJFY+s2nTzTLOFh+lnlRaHv QO7KN6FYXyerAesVcvNrYq6oeGV8CItcKOzLPyBHiixVTzS1LzDtb8hy74IbYF7VDB Bv349V8xv0zZKTNO/l6DO5DrgAN7VIIrMeCzmVUg= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20200620073917epcas2p2be28fea64ada4fdd42a2fa0b83a68aec~aMILtok8A0360603606epcas2p29; Sat, 20 Jun 2020 07:39:17 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.190]) by epsnrtp3.localdomain (Postfix) with ESMTP id 49pncM2pbNzMqYkZ; Sat, 20 Jun 2020 07:39:15 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id C7.43.19322.32DBDEE5; Sat, 20 Jun 2020 16:39:15 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20200620073914epcas2p2c788e787f4fff602de61e5f8e5fb79ae~aMII9546c1035810358epcas2p2e; Sat, 20 Jun 2020 07:39:14 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200620073914epsmtrp16c32ec09203f928d088f50ade6800d26~aMII9H3Y10771907719epsmtrp1A; Sat, 20 Jun 2020 07:39:14 +0000 (GMT) X-AuditID: b6c32a45-797ff70000004b7a-a3-5eedbd239ebc Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id F7.D6.08303.22DBDEE5; Sat, 20 Jun 2020 16:39:14 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200620073913epsmtip289fdf586ea389470f6e1e766752ea950~aMIIzU8OE2468524685epsmtip2f; Sat, 20 Jun 2020 07:39:13 +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 Cc: Kiwoong Kim Subject: [RFC PATCH v1 1/2] ufs: support various values per device Date: Sat, 20 Jun 2020 16:31:36 +0900 Message-Id: <1592638297-36155-2-git-send-email-kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592638297-36155-1-git-send-email-kwmad.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmma7y3rdxBmv2C1g8mLeNzWJv2wl2 i5c/r7JZHHzYyWIx7cNPZotP65exWiy6sY3J4uaWoywW3dd3sFksP/6PyYHL4/IVb4/Lfb1M HhMWHWD0+L6+g83j49NbLB59W1YxenzeJOfRfqCbKYAjKscmIzUxJbVIITUvOT8lMy/dVsk7 ON453tTMwFDX0NLCXEkhLzE31VbJxSdA1y0zB+hGJYWyxJxSoFBAYnGxkr6dTVF+aUmqQkZ+ cYmtUmpBSk6BoWGBXnFibnFpXrpecn6ulaGBgZEpUGVCTsbMP5/YCjbLVPw65dTA2CHexcjJ ISFgInGs4SBzFyMXh5DADkaJYxNvQjmfGCWuvj7LDlIlJPCZUaLnmCFMx9HrC1kginYxSpxY 848dwvnBKPFp+QUmkCo2AU2JpzenMoEkRARuMErMaT7MCpJgFlCX2DXhBFiRsICTxIaG9WA2 i4CqxL7m6UA2BwevgKvE7pMFENvkJG6e62QGsTkF3CT2bXsIdp6EwFd2iX9XLzBCFLlI7Hz7 jA3CFpZ4dXwLO4QtJfGyvw3KrpfYN7WBFaK5h1Hi6b5/UM3GErOetTOCLGYGunr9Ln0QU0JA WeLILRaIk/kkOg7/ZYcI80p0tAlBNCpL/Jo0GWqIpMTMm3egNnlI9J5rgYbJTEaJ+avmsk1g lJuFsGABI+MqRrHUguLc9NRiowJD5Ajb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M0B4uSOO/XWQvjhATSE0tSs1NTC1KLYLJMHJxSDUwX/yountjO3DjR r+vuyfI1pwsWO9hLN2zZ3uBxgOt5w5d1LbfPtLp3eSyVTdFNvDzNQDR1grbCRLNpgso5m8+I 2J3cecpzrkey1+wJG7TiVkQe3jVl3rl35uf53wmc/TRT++SDGd38b3gmd3vu8lyw9GyTYzKH a/Uhg8j/b7N2X8pcsGhSuvurVFOhKPELp6xumaYvumV+8JTdxE35kerHrW49WHXA3Vy9bd8T j+cH+U4dZTxray9k8vXcT2mWq7ufdi+2TYn/nBXqNtO0xlWy6tvkfUcbee/nHjz4lCO2ytXi tIpibVLGT0H7v//KZ2nLPZ4XWD794v6lGlw7s97Ifo4+kNVgm323yk32qshyJZbijERDLeai 4kQApHrCo8YCAAA= X-CMS-MailID: 20200620073914epcas2p2c788e787f4fff602de61e5f8e5fb79ae X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200620073914epcas2p2c788e787f4fff602de61e5f8e5fb79ae References: <1592638297-36155-1-git-send-email-kwmad.kim@samsung.com> 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 | 20 ++++++++++++++++++++ drivers/scsi/ufs/ufshcd.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 1 + 3 files changed, 59 insertions(+) diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index 2a00414..9896d98 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 */ @@ -38,6 +51,13 @@ struct ufs_dev_fix { .quirk = (_quirk), \ } +#define UFS_DEV_VAL(_vendor, _model, _key, _val) { \ + .wmanufacturerid = (_vendor),\ + .model = (_model), \ + .key = (_key), \ + .val = (_val), \ +} + /* * Some vendor's UFS device sends back to back NACs for the DL data frames * causing the host controller to raise the DFES error status. Sometimes diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 52abe82..b6bc333 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 struct ufs_dev_value ufs_dev_values[] = { + END_FIX +}; + +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,34 @@ void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups) } EXPORT_SYMBOL_GPL(ufshcd_fixup_dev_quirks); +void ufshcd_set_dev_values(struct ufs_hba *hba, struct ufs_dev_value *value) +{ + struct ufs_dev_value *f; + struct ufs_dev_info *dev_info = &hba->dev_info; + + if (!value) + return; + + for (f = 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; + } + } +} +EXPORT_SYMBOL_GPL(ufshcd_set_dev_values); + static void ufs_fixup_device_setup(struct ufs_hba *hba) { /* fix by general quirk table */ ufshcd_fixup_dev_quirks(hba, ufs_fixups); + 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 Sat Jun 20 07:31:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11615833 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 B3BA1138C for ; Sat, 20 Jun 2020 07:39:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96B1B239D2 for ; Sat, 20 Jun 2020 07:39:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="YSG0sflZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726000AbgFTHjZ (ORCPT ); Sat, 20 Jun 2020 03:39:25 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:27484 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbgFTHjW (ORCPT ); Sat, 20 Jun 2020 03:39:22 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200620073919epoutp020aa3ba819534993b2fe44f8465f83135~aMIOVhgwj1826018260epoutp02O for ; Sat, 20 Jun 2020 07:39:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200620073919epoutp020aa3ba819534993b2fe44f8465f83135~aMIOVhgwj1826018260epoutp02O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592638759; bh=FWbn8HiU64qGTBC6xNUrPg5tQqvOMoPMKnGbyqzq0vA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YSG0sflZaiiEDdxLauyy/84Sy1dKhgIt8rQNuJzVK0YOXr/XOsd+uNSvaoKL69Uzt 60siyJbim5z+hDZVItmkiiIyqPss6GXobn80Vy0rDVj/N0Lc8Nz+1TZqzBpj3mSZK0 3dE2ReeQ/V5c17MbkjEd6z56QY6hsMYg9tkHvyt4= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20200620073919epcas2p413195d198c3cf148620f8c4da7d8a162~aMINlZ9GK0538705387epcas2p4o; Sat, 20 Jun 2020 07:39:19 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.40.188]) by epsnrtp1.localdomain (Postfix) with ESMTP id 49pncP2RDfzMqYlp; Sat, 20 Jun 2020 07:39:17 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 81.A4.27013.52DBDEE5; Sat, 20 Jun 2020 16:39:17 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20200620073916epcas2p4cb1a2d9e70d3b06adc539ba15db8ef60~aMILZ_7380538705387epcas2p4m; Sat, 20 Jun 2020 07:39:16 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200620073916epsmtrp2c6a7c05c7504903e0b07637650f55823~aMILZP59T2142721427epsmtrp2s; Sat, 20 Jun 2020 07:39:16 +0000 (GMT) X-AuditID: b6c32a48-d35ff70000006985-57-5eedbd25d5cf Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 0E.32.08382.42DBDEE5; Sat, 20 Jun 2020 16:39:16 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200620073916epsmtip212a42e5225ccbc92a615f6b311c3569c~aMILLb1hI1780717807epsmtip2S; Sat, 20 Jun 2020 07:39:16 +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 Cc: Kiwoong Kim Subject: [RFC PATCH v1 2/2] ufs: change the way to complete fDeviceInit Date: Sat, 20 Jun 2020 16:31:37 +0900 Message-Id: <1592638297-36155-3-git-send-email-kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592638297-36155-1-git-send-email-kwmad.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDKsWRmVeSWpSXmKPExsWy7bCmma7q3rdxBnMX81s8mLeNzWJv2wl2 i5c/r7JZHHzYyWIx7cNPZotP65exWiy6sY3J4uaWoywW3dd3sFksP/6PyYHL4/IVb4/Lfb1M HhMWHWD0+L6+g83j49NbLB59W1YxenzeJOfRfqCbKYAjKscmIzUxJbVIITUvOT8lMy/dVsk7 ON453tTMwFDX0NLCXEkhLzE31VbJxSdA1y0zB+hGJYWyxJxSoFBAYnGxkr6dTVF+aUmqQkZ+ cYmtUmpBSk6BoWGBX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NPZotP65exWiy6sY3J4uaWoywW3dd3sFksP/6PyYHL4/IVb4/Lfb1M HhMWHWD0+L6+g83j49NbLB59W1YxenzeJOfRfqCbKYAjissmJTUnsyy1SN8ugStj9pvpTAVL RSrWrp7G1MC4XaCLkZNDQsBEYuKLa0xdjFwcQgK7GSWezv7CBpGQlDix8zkjhC0scb/lCCtE 0TdGidvHb4El2AQ0JZ7enArWLSLwiFHi98xOdpAEs4C6xK4JJ5hAbGEBd4k1HYeYQWwWAVWJ l/9nsYLYvAKuEtu6XkFtkJO4ea4TrIZTwE1i37aHYLYQUM2FH0uZJzDyLWBkWMUomVpQnJue W2xYYJiXWq5XnJhbXJqXrpecn7uJERyyWpo7GLev+qB3iJGJg/EQowQHs5II7+H3b+KEeFMS K6tSi/Lji0pzUosPMUpzsCiJ894oXBgnJJCeWJKanZpakFoEk2Xi4JRqYNo+4ftXpUsWdrMe XnhrvlBnwXb/12erUzZv3NG0PvhsVeGGsCa3q+a3u76+uFUXuvKmczajRfhUFzPTY4JSMyqL pzDyVf4ULOp9uZDDUudffI6BvHNDbKdhwcQVMpsErtdvFdDx++zO+7L+9AvBwOAzJrNWNFzT rktbfobzwI4d/Uq5opJvm875ugYJK/YwvrPYp7FbYZqdm2K4QEJNBev1GNs5h2oOrp2i7f24 KGzFamV9j99Cqh65KVtVuEtFxLcJfF7UpLMzRLXGuKzQ6ObM4pfflmiv38Zt987uzu/vYjtf bt/r1PP33b9znJET2H/8M7kt4J2in9ZyxmXrovDI4m1rPuSq+cRNDHlroMRSnJFoqMVcVJwI ABdLfGrIAgAA X-CMS-MailID: 20200620073916epcas2p4cb1a2d9e70d3b06adc539ba15db8ef60 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200620073916epcas2p4cb1a2d9e70d3b06adc539ba15db8ef60 References: <1592638297-36155-1-git-send-email-kwmad.kim@samsung.com> 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 value regarding the information. Signed-off-by: Kiwoong Kim --- drivers/scsi/ufs/ufshcd.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index b6bc333..a1d85c6 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -208,6 +208,8 @@ static struct ufs_dev_fix ufs_fixups[] = { }; static struct ufs_dev_value ufs_dev_values[] = { + UFS_DEV_VAL(UFS_VENDOR_TOSHIBA, UFS_ANY_MODEL, + DEV_VAL_FDEVICEINIT, 2000), END_FIX }; @@ -4162,9 +4164,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 = 500; + 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,19 +4180,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(1000, 2000); + } 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__); + err = -EBUSY; + } out: return err;