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;