From patchwork Mon Jun 29 10:15:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11631383 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 1BFCA739 for ; Mon, 29 Jun 2020 18:43:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F38EF20663 for ; Mon, 29 Jun 2020 18:43:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="G0wScVvd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726824AbgF2Snq (ORCPT ); Mon, 29 Jun 2020 14:43:46 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:63877 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbgF2Snj (ORCPT ); Mon, 29 Jun 2020 14:43:39 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200629102354epoutp03132295923ecaf9322b18b44722c0a29a~c-LfmH79U0684206842epoutp03e for ; Mon, 29 Jun 2020 10:23:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200629102354epoutp03132295923ecaf9322b18b44722c0a29a~c-LfmH79U0684206842epoutp03e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593426234; bh=gq8XNEz6DfOt51iMcSSB/6Jvegbfc40c/aYHfEzFe4E=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=G0wScVvdJ9ZMsIysEo1QewrnxsPi+rS7exn3iRRUiImfoJAQqp1BpeMTn9CqhnTuw Kafr1vdTDZRti0d1rRYFMgn9F5EJiNzZWQHCCuEY7crI3J3uV01sOD7LGf+zsvtCdu jHdO0zGp9ZDemDk8pToV1mdhIZkj3OZsc8kBCRMA= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20200629102354epcas2p32620640889b12a08d23ef5ca933d9549~c-LfLV0yh2931829318epcas2p3_; Mon, 29 Jun 2020 10:23:54 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.40.189]) by epsnrtp3.localdomain (Postfix) with ESMTP id 49wNr82JNszMqYkc; Mon, 29 Jun 2020 10:23:52 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 4F.E2.18874.631C9FE5; Mon, 29 Jun 2020 19:23:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20200629102350epcas2p4f4ef326c55c897479643ebcd3e132f50~c-LbGLIPS3182431824epcas2p4Q; Mon, 29 Jun 2020 10:23:50 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200629102350epsmtrp23711665e3648542f1633b7acfdb356d3~c-LbFi2Ez0132801328epsmtrp2P; Mon, 29 Jun 2020 10:23:50 +0000 (GMT) X-AuditID: b6c32a46-519ff700000049ba-6a-5ef9c136db28 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E5.A1.08382.531C9FE5; Mon, 29 Jun 2020 19:23:50 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200629102349epsmtip25210435e2d4de3ebdd3c2a12134c8cdd~c-La8M02U0942409424epsmtip2e; Mon, 29 Jun 2020 10:23:49 +0000 (GMT) From: Kiwoong Kim To: linux-scsi@vger.kernel.org Cc: Kiwoong Kim Subject: [RFC PATCH v2 1/2] ufs: support various values per device Date: Mon, 29 Jun 2020 19:15:55 +0900 Message-Id: <21f8e3dd4d68f9ef4009e0a05cfac1ee01dd7213.1593412974.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEKsWRmVeSWpSXmKPExsWy7bCmqa7ZwZ9xBkdnyFnc3HKUxaL7+g42 ByaPvi2rGD0+b5ILYIrKsclITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21 VXLxCdB1y8wBGq+kUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJKTA0LNArTswtLs1L 10vOz7UyNDAwMgWqTMjJOLqoiaXgtGTFj6N97A2MzaJdjJwcEgImEgtWvmPrYuTiEBLYwShx 4udCdgjnE6NES99jqMw3Rom7c/czw7S8av3LCJHYyyix6PEcKOcHo8T3NZOYQKrYBDQlnt6c CmaLCMhJbF7+lQXEZhZQl9g14QRYXFjASeLTwY/sIDaLgKrE+ScXWEFsXoFoiWdr1rNAbJOT uHmuE2wzp4ClxIvb19HYXEA1/ewSU97+hGpwkbh46icrhC0s8er4FnYIW0ri87u9bBB2vcS+ qQ2sEM09jBJP9/1jhEgYS8x61g5kcwBdqimxfpc+iCkhoCxx5BbU/XwSHYf/skOEeSU62oQg GpUlfk2aDDVEUmLmzTtQWz0kOi5/ZoWED9Cm9t6JjBMY5WchLFjAyLiKUSy1oDg3PbXYqMAI Ofo2MYITk5bbDsYpbz/oHWJk4mA8xCjBwawkwvvZ+lucEG9KYmVValF+fFFpTmrxIUZTYEBO ZJYSTc4Hpsa8knhDUyMzMwNLUwtTMyMLJXHeesULcUIC6YklqdmpqQWpRTB9TBycUg1MLZfX feZ/OtmwcUnI9jNRUQsyG96/XmgZ/OPGXdH1uRuPcMb7Lu/lD2p4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yUO6qEXbnszO6MElm4+EZaScYnv36tV8mPfiTjmNyUGTJlTfWU0PfZi6qO6Ai kJf189k6uSt8ofqJklyv93OrsTfeVZI6oGysxFKckWioxVxUnAgAf78415cCAAA= X-CMS-MailID: 20200629102350epcas2p4f4ef326c55c897479643ebcd3e132f50 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200629102350epcas2p4f4ef326c55c897479643ebcd3e132f50 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. --- 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 Mon Jun 29 10:15:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11631387 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 5258B912 for ; Mon, 29 Jun 2020 18:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FC432065D for ; Mon, 29 Jun 2020 18:44:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="FAaHqeAs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbgF2SoA (ORCPT ); Mon, 29 Jun 2020 14:44:00 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:58160 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727964AbgF2Sn4 (ORCPT ); Mon, 29 Jun 2020 14:43:56 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200629102359epoutp041280b406d8f74d0765f0a0edb4dd859b~c-Lj3ODX_0782707827epoutp04s for ; Mon, 29 Jun 2020 10:23:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200629102359epoutp041280b406d8f74d0765f0a0edb4dd859b~c-Lj3ODX_0782707827epoutp04s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593426239; bh=iO9dqCnrbL9OrGTJU2+4BM2Rv7CtQaF84mdvj1REYWo=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=FAaHqeAszbe79QcaqMAFbtdYTXeO9WdJYswDCXd/sIzGskXmCeNDR2IeHbS902H8l iq0rBBZf4uigs8Yh4LPfwqqoPRabSJcQba6ETVfPJoqJ13zqXH29aEpZ4/H55MnofO cRn4KdUb0/2VgAyteNu9qYrfqf067DApDbNNmbF4= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20200629102359epcas2p3185d7239c01e8c53b8d4df3f4a249cb1~c-LjjJHfV0169901699epcas2p3t; Mon, 29 Jun 2020 10:23:59 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.40.187]) by epsnrtp3.localdomain (Postfix) with ESMTP id 49wNrF1RgTzMqYkZ; Mon, 29 Jun 2020 10:23:57 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id E7.A5.27013.C31C9FE5; Mon, 29 Jun 2020 19:23:56 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20200629102355epcas2p13f8714a906291e5444adfb2f5ac2c469~c-Lf79AKN3124231242epcas2p14; Mon, 29 Jun 2020 10:23:55 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200629102355epsmtrp179014ab9b6f13b67609c2ef141f2f8dd~c-Lf7XVo-2797727977epsmtrp1w; Mon, 29 Jun 2020 10:23:55 +0000 (GMT) X-AuditID: b6c32a48-d1fff70000006985-38-5ef9c13c477b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id E3.84.08303.B31C9FE5; Mon, 29 Jun 2020 19:23:55 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200629102355epsmtip221b90ab6809fcedef555eff318798d89~c-LfvwEEf0968509685epsmtip25; Mon, 29 Jun 2020 10:23:55 +0000 (GMT) From: Kiwoong Kim To: linux-scsi@vger.kernel.org Cc: Kiwoong Kim Subject: [RFC PATCH v2 2/2] ufs: change the way to complete fDeviceInit Date: Mon, 29 Jun 2020 19:15:56 +0900 Message-Id: <1ca1a52df36ad3393c0487537832cf7f0a7e1260.1593412974.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIKsWRmVeSWpSXmKPExsWy7bCmha7NwZ9xBm8Xq1vc3HKUxaL7+g42 ByaPvi2rGD0+b5ILYIrKsclITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21 VXLxCdB1y8wBGq+kUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8usVVKLUjJKTA0LNArTswtLs1L 10vOz7UyNDAwMgWqTMjJ+P5lBnvBRNGK29sqGxh7BLsYOTkkBEwktvbcZuli5OIQEtjBKHH8 9Ud2COcTo8SfY5+hMp8ZJe7dPswI0/JhfTsrRGIXo8Tsxk4mCOcHo0Tr97esIFVsApoST29O ZQKxRQTkJDYv/8oCYjMLqEvsmnACLC4s4C7x6dITsHoWAVWJL//es4HYvALREvMX/YHaJidx 81wnM4jNKWAp8eL2dTQ2F1BNN7vE06YrrBANLhL35l1jhrCFJV4d38IOYUtJvOxvg7LrJfZN bWCFaO5hlHi67x/UNmOJWc/agWwOoEs1Jdbv0gcxJQSUJY7cgrqfT6Lj8F92iDCvREebEESj ssSvSZOhhkhKzLx5B2qTh8Sh11OggQW0acmnY0wTGOVnISxYwMi4ilEstaA4Nz212KjABDn2 NjGC05KWxw7G2W8/6B1iZOJgPMQowcGsJML72fpbnBBvSmJlVWpRfnxRaU5q8SFGU2BATmSW Ek3OBybGvJJ4Q1MjMzMDS1MLUzMjCyVx3ndWF+KEBNITS1KzU1MLUotg+pg4OKUamGIz3s3o Zr0pN+38r/eJe7XX50anWSsLO5nc3THrpd7zd1M8KhtF+C+ltgS/+Dtp353XZhab7pzleVxp tkih2WTBBF3ORrVv03ICfmvMS502oX3lRc9/F/2aKpMVGq+c5kx7c9N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R3lv1y8rtvduVFGW6GxW4mlOCPRUIu5qDgRAGgOIX6WAgAA X-CMS-MailID: 20200629102355epcas2p13f8714a906291e5444adfb2f5ac2c469 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200629102355epcas2p13f8714a906291e5444adfb2f5ac2c469 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..27afdf0 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 = 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,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(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__); - + "%s fDeviceInit was not cleared by the device\n", + __func__); + err = -EBUSY; + } out: return err; }