From patchwork Thu Jul 2 02:11:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11637741 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 0E8CC913 for ; Thu, 2 Jul 2020 02:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5AC0207E8 for ; Thu, 2 Jul 2020 02:19:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="oPPhuM5P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727846AbgGBCTr (ORCPT ); Wed, 1 Jul 2020 22:19:47 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:14949 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgGBCTq (ORCPT ); Wed, 1 Jul 2020 22:19:46 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200702021942epoutp04d89d1d93429d672f820d9445d10d16be~dzglTgX702403724037epoutp04J for ; Thu, 2 Jul 2020 02:19:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200702021942epoutp04d89d1d93429d672f820d9445d10d16be~dzglTgX702403724037epoutp04J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593656382; bh=gq8XNEz6DfOt51iMcSSB/6Jvegbfc40c/aYHfEzFe4E=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=oPPhuM5PQ621QEfdjksn7MxwFYHBUmMVMUY8bl7p9F58NdPPx6Nots8FylOi7/5Oz WTisukhMoD601RAMHDmI9wTJ3B2mMoEPVcsD/qXY9s+m8S2cFqHtsUExhlKWxcGt8F Scg8gSnrq5LoLxEwWx7geh1MuCVj7znvrdByON6U= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20200702021941epcas2p254c359ef50127b5ae3c31eb87e61531e~dzgkuvrSB1209212092epcas2p2r; Thu, 2 Jul 2020 02:19:41 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.40.186]) by epsnrtp1.localdomain (Postfix) with ESMTP id 49y1y34dfgzMqYlp; Thu, 2 Jul 2020 02:19:39 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 12.25.18874.A344DFE5; Thu, 2 Jul 2020 11:19:38 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20200702021938epcas2p249e149341d6227a2c10ab25a8695f579~dzghBzkWo1209212092epcas2p2m; Thu, 2 Jul 2020 02:19:38 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200702021938epsmtrp2763b804baf71e26c9b8471fc868ba1bb~dzghBCp8Z1404614046epsmtrp20; Thu, 2 Jul 2020 02:19:38 +0000 (GMT) X-AuditID: b6c32a46-519ff700000049ba-f9-5efd443a1661 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B1.AE.08382.9344DFE5; Thu, 2 Jul 2020 11:19:37 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200702021937epsmtip13c7625f64ca8015993088f2c9ea70208~dzggw7-Sh2260422604epsmtip1B; Thu, 2 Jul 2020 02:19:37 +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: [PATCH v1 1/2] ufs: support various values per device Date: Thu, 2 Jul 2020 11:11:48 +0900 Message-Id: <464c059503bf1262e01bb16ea9b0726bc179be8c.1593655834.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjk+LIzCtJLcpLzFFi42LZdljTVNfK5W+cwdz//BYP5m1js9jbdoLd 4uXPq2wWBx92slhM+/CT2eLT+mWsFotubGOyuLnlKItF9/UdbBbLj/9jcuDyuHzF2+NyXy+T x4RFBxg9vq/vYPP4+PQWi0ffllWMHp83yXm0H+hmCuCIyrHJSE1MSS1SSM1Lzk/JzEu3VfIO jneONzUzMNQ1tLQwV1LIS8xNtVVy8QnQdcvMAbpRSaEsMacUKBSQWFyspG9nU5RfWpKqkJFf XGKrlFqQklNgaFigV5yYW1yal66XnJ9rZWhgYGQKVJmQk3F0URNLwWnJih9H+9gbGJtFuxg5 OSQETCRmTjzO3sXIxSEksINRYuXKV0wQzidGiYULj7JCON8YJTq2bgFyOMBaVpy3gojvZZS4 efo5C4Tzg1Fi+fl+VpC5bAKaEk9vTgUbJSJwg1FiTvNhsASzgLrErgknmEBsYQE7iQPXzoPZ LAKqEn3NTWA2r0C0xJ5FIFNBDpSTuHmukxnE5hSwlDi07yojKpsLqOYnu8SWpldsEA0uEkuu nWOEsIUlXh3fwg5hS0l8frcXqqZeYt/UBlaI5h5Giaf7/kE1GEvMetbOCPInM9AL63fpQ7ys LHHkFgvE/XwSHYf/skOEeSU62oQgGpUlfk2aDDVEUmLmzTtQWz0kTnR/B9sqBLLpx06eCYzy sxDmL2BkXMUollpQnJueWmxUYIQce5sYwQlSy20H45S3H/QOMTJxM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U6qBKdGpkE3x 2b0HTYombFsc1xVECd16nLU/lfHCkoQtlcxT1t1WPljV9kL1y7ulbT68t5jW3SrpN5nj8uWi c+K0N021P8Kmbi/7XpjEX/PNYsa9+jsn/NyPMKw941gcoOlb6/csf9qJvPkv41OihWKTU5Yd 3lrRmTNJ+ddJBynXlx0VM1I/PfO/033ZtF6rYo9RwsKpDy93xBUbes+3UqxoVmcxWrfetZbh tzavwNQnq/+ukzSqPffm/nU9i8f/+RItxRdfKLp+lEcjf6XXXbtqA+NZOjIBp43Db0urMfXO urKq9v2ufN5nWR/STbZdvx1WZ7u6ZtHMyscS3JWtReuEVQuc1l3YEPxg7txDJnd5lViKMxIN tZiLihMBDE0xwN8CAAA= X-CMS-MailID: 20200702021938epcas2p249e149341d6227a2c10ab25a8695f579 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200702021938epcas2p249e149341d6227a2c10ab25a8695f579 References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Kiwoong Kim 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. Reported-by: kernel test robot Reported-by: kernel test robot --- 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..7b6f13a 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); +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); + /* 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 Thu Jul 2 02:11:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11637743 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 6DDCF913 for ; Thu, 2 Jul 2020 02:19:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E06F207F5 for ; Thu, 2 Jul 2020 02:19:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Ju6YLoyG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727921AbgGBCTs (ORCPT ); Wed, 1 Jul 2020 22:19:48 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:23316 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbgGBCTq (ORCPT ); Wed, 1 Jul 2020 22:19:46 -0400 Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200702021943epoutp03a1d1148d15a761c445760f49c0ccc42f~dzgmlg9_g0502705027epoutp03i for ; Thu, 2 Jul 2020 02:19:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200702021943epoutp03a1d1148d15a761c445760f49c0ccc42f~dzgmlg9_g0502705027epoutp03i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593656384; bh=Ey4NFKPAdZv5rk1Pqo4Qwzaczl5dhs7AIM0WQFb0Ftg=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=Ju6YLoyGrroDpUWVND9QH5oTDvMcZEz01ZPtRBmnaR6XjBgg1PENuPZLvkfra8ztD cfjPNAnQBuPau1SHlKCS02dl7KCcIvsibh9D2NGJoO6L2jQr5q6MEaTUR5bQbXoCgf ZGYXp63p0a/ZbU/zLxqVvkH1CyUNTPXcXdSM9UY8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20200702021943epcas2p2dbd47d20de2141dbf17cc5b168ecf949~dzgl7BToX2428124281epcas2p2v; Thu, 2 Jul 2020 02:19:43 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 49y1y51tXwzMqYkl; Thu, 2 Jul 2020 02:19:41 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 6E.11.19322.B344DFE5; Thu, 2 Jul 2020 11:19:39 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20200702021938epcas2p35eadff66139b6a42d438fa3ee868a29a~dzgh3V_au2388723887epcas2p3H; Thu, 2 Jul 2020 02:19:38 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200702021938epsmtrp23648e4828fc10f08348fff2074c053c4~dzgh2iyhk1404614046epsmtrp21; Thu, 2 Jul 2020 02:19:38 +0000 (GMT) X-AuditID: b6c32a45-797ff70000004b7a-44-5efd443b69bb Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 4E.80.08303.A344DFE5; Thu, 2 Jul 2020 11:19:38 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200702021938epsmtip1cdf2143388f0bab08349716fd2efff12~dzghqWWGN2097820978epsmtip1M; Thu, 2 Jul 2020 02:19:38 +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: [PATCH v1 2/2] ufs: change the way to complete fDeviceInit Date: Thu, 2 Jul 2020 11:11:49 +0900 Message-Id: <854db3aecefab74495f4661cafc8cf116e4eaa85.1593655834.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplk+LIzCtJLcpLzFFi42LZdljTTNfa5W+cQeNdM4sH87axWextO8Fu 8fLnVTaLgw87WSymffjJbPFp/TJWi0U3tjFZ3NxylMWi+/oONovlx/8xOXB5XL7i7XG5r5fJ Y8KiA4we39d3sHl8fHqLxaNvyypGj8+b5DzaD3QzBXBE5dhkpCampBYppOYl56dk5qXbKnkH xzvHm5oZGOoaWlqYKynkJeam2iq5+AToumXmAN2opFCWmFMKFApILC5W0rezKcovLUlVyMgv LrFVSi1IySkwNCzQK07MLS7NS9dLzs+1MjQwMDIFqkzIydj+8h5rQa9oxcTb+1gbGDsEuxg5 OSQETCQufvjL2sXIxSEksINR4tqag4wQzidGiZPL90E5n4GcvvnsMC33/l2CatnFKLF+000o 5wejRPO8icwgVWwCmhJPb05lAkmICNxglJjTfJgVJMEsoC6xa8IJJhBbWMBZ4u6N0yxdjBwc LAKqErNXZ4GEeQWiJd41HGCE2CYncfNcJ9h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X2DXhBBOILSzgLHH3xmmgBg4OFgFV idmrs0DCvALREu8aDkAtkJO4ea6TGcTmFLCUOLTvKlhcSMBCYs2TZ4y4xCcwCixgZFjFKJla UJybnltsWGCUl1quV5yYW1yal66XnJ+7iREc4FpaOxj3rPqgd4iRiYPxEKMEB7OSCO9pg19x QrwpiZVVqUX58UWlOanFhxilOViUxHm/zloYJySQnliSmp2aWpBaBJNl4uCUamCKzst/fmtB 56e1Z4+Eluol5RcENK0+/CehddWpHZKpLn/qpwTarzdaajr96AbXe5Ken5hXeEqJaLl7JzaV Xj8nVJzYNKvIsePPpdz8To9F7RaXN6yr8nkULDTx09cjtTwxfudC2zXZ76kuOfX3K/uEhhyZ r5bh4fKlL7a1zyt8OPWncffyB090dWYxsHYzWyxv++IX/1OA08D6Zsfamschj6d/qdy4/b+I klNzuvqevGeTtsuffmy7dbtAkjTTbe3uqz/0emwOue5x71jKJX/1ueHUv4UnDF5NXn1ywouf nfWt9QmzQycwHk3dtlL+zoEev0tPHSv4k03CYn/Z/N187FOv7dkPW2aYL81MSVRWYinOSDTU Yi4qTgQA2UJZXN8CAAA= X-CMS-MailID: 20200702021938epcas2p35eadff66139b6a42d438fa3ee868a29a X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200702021938epcas2p35eadff66139b6a42d438fa3ee868a29a 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 7b6f13a..717afed 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; }