Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6815034ybc; Thu, 28 Nov 2019 06:02:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwxi6Q8c09Xfx2qfak1aQiswwQrFWfgXb3jbfH509elt+x/LEMAi0pMbdrVZpDkY/V6oD8D X-Received: by 2002:a50:930c:: with SMTP id m12mr38582698eda.132.1574949729620; Thu, 28 Nov 2019 06:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574949729; cv=none; d=google.com; s=arc-20160816; b=Mn45T1r6fmLyLj3JIPufnUcjy00EKoZn0qHk4SjxV3ib4XHvRKmatVJDYwz403onQN Oqo4YUucJUxsIeYdRlFKx9EGOzsVqxOc2gz1zyNeJs+HHuTfliy8CO2REhZWYXZSr3CO p+29jX1/SXr5fk10p68+OWlx/U4a5r3aDJn437SQN/C/TxLM0OL/kfeadFGJSUZZjkrJ Sjp4jKRfoevGRunqsLt7C9W19lmpMu9q9+Zuqx8jg3rkRCKJir1sp4Bwe4qhd8RYem69 t5aC0kTiPrluO9/WbF+5hjrxZHaRPMHL9ijdg4VQ5PFki547Cc656ibjRBoabsZEVk4h GhKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :thread-index:content-transfer-encoding:mime-version:message-id:date :subject:in-reply-to:cc:to:from:dkim-signature:dkim-filter; bh=QRyw0lLQtVQOLJHLaBfOinFSbqQnNEXXqAEqLzOVO5g=; b=iVtrzSRee/GPcVzgfGuSoRh2amDZ4N+VFIwwYr/FUV2YVysx1OipwK+KzPTni8WWBa dRdYjytK+xV9qAlCiRl6SkAVK8ryBDrRyxGCj2vuPpnoGPaTm/IYyrue8X1fB0I5JWoe +gpsyZ4auBoLujtQXNddow6Cn3bfaGNmKNre26HIP1mgo4CLWBIGQ80yNylhs5IxaqHl L4Cnab6397h5+vwwazbVahsTVM3j8dcZfXjjoKLnQW1fco3bFUHHEAHv672Ut0F4SWXx 7pvsWnfLsxsiqcx6kT9nDrjVE4d2Offr6+HqkzUgmOCQyqhBcffTqs6hLxhKu8rqvUSH lGEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=dObXyuI7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si11657083edr.347.2019.11.28.06.01.44; Thu, 28 Nov 2019 06:02:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=dObXyuI7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbfK1N7k (ORCPT + 99 others); Thu, 28 Nov 2019 08:59:40 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:13987 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbfK1N7j (ORCPT ); Thu, 28 Nov 2019 08:59:39 -0500 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20191128135935epoutp04b5bf21af0a72951595d6e5bf248677ba~bWEtRFTUK3096730967epoutp04q for ; Thu, 28 Nov 2019 13:59:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20191128135935epoutp04b5bf21af0a72951595d6e5bf248677ba~bWEtRFTUK3096730967epoutp04q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1574949575; bh=QRyw0lLQtVQOLJHLaBfOinFSbqQnNEXXqAEqLzOVO5g=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=dObXyuI7ef1FgcMMF9S01dV3Og7XKp3VkLHYhc3sPapWcUn2zcAWa+7wNGiAFlIo2 jQTvOgsM0d4mRw7vqBSAn5uzHLXQy0upU+REczJjZ9XkrUWDVFAdXWq6EBLR8fqWW0 Dg0qALomW1ZfK7yMBx+FNONhEyRObUxWLaQWp0Ys= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20191128135933epcas5p2bf2ee973d1d0ccc435f43446487de2c9~bWEsAZErN3228632286epcas5p2M; Thu, 28 Nov 2019 13:59:33 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 15.2F.19629.5C2DFDD5; Thu, 28 Nov 2019 22:59:33 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20191128135933epcas5p1537a2987cfbd31cbe97c45e2f2268e83~bWErPjGEi0354203542epcas5p12; Thu, 28 Nov 2019 13:59:33 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20191128135933epsmtrp1f6e58e8c9e56b0ae05fd69484427caf2~bWErOz1zv2878528785epsmtrp1G; Thu, 28 Nov 2019 13:59:33 +0000 (GMT) X-AuditID: b6c32a4b-32dff70000014cad-7b-5ddfd2c5c95c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 7C.57.06569.4C2DFDD5; Thu, 28 Nov 2019 22:59:32 +0900 (KST) Received: from alimakhtar02 (unknown [107.111.84.32]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191128135930epsmtip29a07a267da03acad7434bae7bf992ea7~bWEpFnazX2555125551epsmtip2U; Thu, 28 Nov 2019 13:59:30 +0000 (GMT) From: "Alim Akhtar" To: "'sheebab'" , , , , , , , , , , , Cc: , In-Reply-To: <1574147082-22725-3-git-send-email-sheebab@cadence.com> Subject: RE: [PATCH RESEND 2/2] scsi: ufs: Update L4 attributes on manual hibern8 exit in Cadence UFS. Date: Thu, 28 Nov 2019 19:29:29 +0530 Message-ID: <0b8f01d5a5f4$0f7a8a70$2e6f9f50$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHedmnDsV+0XJYctqc2u08WFWQfYAMqNNbiAjPboCmnZAqHgA== Content-Language: en-in X-Brightmail-Tracker: H4sIAAAAAAAAA01Se0hTcRjtd+/d3XU4uc6FX0oPVxoWPkKFW5ipCF4qIgpKQtGVFxe5KZuP rMBZZj7J1D9ymNW0hyFYuubSRNPcUEvwRSaZFJr5xApfGK22q+R/53zfOb9zPvhRuGRS4EZd VKVwapU8UUaKCGOHt7dPZ/9YjP/9bj9manWIZN58ySMY/bARY1pG9jMDTRUkU/DBRDJPLH8w 5nPPT4LJNi8SjNZwl2Qqn2sx5tHLj4ixvl8QMp8WJ4lQJ7Y2bwZjs9/OCdhifRtis7taCXa5 Lpdkf0yMEKyh9RdiLcONGPurfgd7q60AOyk6JwqO5xIvpnFqv5A4kWJ64o8wucv/8mR5jVCL hvbmIwcK6EB4XNovyEciSkI3I/j06iHGk58I9L2tBE+WEBSVjJAblusvjOuLFgTLwzM4T6YR 3OutEdhUJO0Dpqoc0raQ0v0YTIxm2e047Qt9s/O4DTvQEaCf//AvkKJcaAWYqznbmKA9wWLS 2+Vi+iBUD5ZjPHaGrvJxgn9mJzTOVeB8o12wOvHYniulw+H301Ehr3GFztVCezmgu4Wg+zaA 8YYIaGhcWccuMG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8cSL+EKMAB6MSD6/ApvuxQqyJZcWVuYcYJTiYlUR4k+YChXhTEiur Uovy44tKc1KLDzFKc7AoifPK5x+LFBJITyxJzU5NLUgtgskycXBKNTAy/vmi2vHWb9I9b8F7 G2s8TqfYe6a5zRGI3n/WocHPK13HeW5reZlAl6q5U7PAcusvyYGXVAsi1z3yrzO2nP5d/q/y Gc4jZ4tmPjz0RPlL/9usZbXL3JlDV+v3rZyiELgz7FE7ww/+D7/d6hN077z2aD9rfZLjUtdF vnu3Zro5VN9etW+6rbkSS3FGoqEWc1FxIgAn7zMG3QIAAA== X-CMS-MailID: 20191128135933epcas5p1537a2987cfbd31cbe97c45e2f2268e83 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P X-CMS-RootMailID: 20191119070557epcas4p1e2ff5e9d4c69f15cb7510ab5277f0391 References: <1574147082-22725-1-git-send-email-sheebab@cadence.com> <1574147082-22725-3-git-send-email-sheebab@cadence.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: sheebab > Sent: 19 November 2019 12:35 > To: alim.akhtar@samsung.com; avri.altman@wdc.com; > pedrom.sousa@synopsys.com; jejb@linux.ibm.com; > martin.petersen@oracle.com; stanley.chu@mediatek.com; > beanhuo@micron.com; yuehaibing@huawei.com; linux-scsi@vger.kernel.org; > linux-kernel@vger.kernel.org; vigneshr@ti.com; linux-block@vger.kernel.org > Cc: rafalc@cadence.com; mparab@cadence.com; sheebab > > Subject: [PATCH RESEND 2/2] scsi: ufs: Update L4 attributes on manual hibern8 > exit in Cadence UFS. > > Backup L4 attributes duirng manual hibern8 entry and restore the L4 attributes > on manual hibern8 exit as per JESD220C. > > Signed-off-by: sheebab > --- Reviewed-by: Alim Akhtar > drivers/scsi/ufs/cdns-pltfrm.c | 97 > +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 95 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c index > adbbd60..5510567 100644 > --- a/drivers/scsi/ufs/cdns-pltfrm.c > +++ b/drivers/scsi/ufs/cdns-pltfrm.c > @@ -19,6 +19,14 @@ > > #define CDNS_UFS_REG_HCLKDIV 0xFC > #define CDNS_UFS_REG_PHY_XCFGD1 0x113C > +#define CDNS_UFS_MAX 12 > + > +struct cdns_ufs_host { > + /** > + * cdns_ufs_dme_attr_val - for storing L4 attributes > + */ > + u32 cdns_ufs_dme_attr_val[CDNS_UFS_MAX]; > +}; > > /** > * cdns_ufs_enable_intr - enable interrupts @@ -47,6 +55,77 @@ static void > cdns_ufs_disable_intr(struct ufs_hba *hba, u32 intrs) } > > /** > + * cdns_ufs_get_l4_attr - get L4 attributes on local side > + * @hba: per adapter instance > + * > + */ > +static void cdns_ufs_get_l4_attr(struct ufs_hba *hba) { > + struct cdns_ufs_host *host = ufshcd_get_variant(hba); > + > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_PEERDEVICEID), > + &host->cdns_ufs_dme_attr_val[0]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_PEERCPORTID), > + &host->cdns_ufs_dme_attr_val[1]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_TRAFFICCLASS), > + &host->cdns_ufs_dme_attr_val[2]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_PROTOCOLID), > + &host->cdns_ufs_dme_attr_val[3]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_CPORTFLAGS), > + &host->cdns_ufs_dme_attr_val[4]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_TXTOKENVALUE), > + &host->cdns_ufs_dme_attr_val[5]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_RXTOKENVALUE), > + &host->cdns_ufs_dme_attr_val[6]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_LOCALBUFFERSPACE), > + &host->cdns_ufs_dme_attr_val[7]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_PEERBUFFERSPACE), > + &host->cdns_ufs_dme_attr_val[8]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_CREDITSTOSEND), > + &host->cdns_ufs_dme_attr_val[9]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_CPORTMODE), > + &host->cdns_ufs_dme_attr_val[10]); > + ufshcd_dme_get(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), > + &host->cdns_ufs_dme_attr_val[11]); > +} > + > +/** > + * cdns_ufs_set_l4_attr - set L4 attributes on local side > + * @hba: per adapter instance > + * > + */ > +static void cdns_ufs_set_l4_attr(struct ufs_hba *hba) { > + struct cdns_ufs_host *host = ufshcd_get_variant(hba); > + > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 0); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), > + host->cdns_ufs_dme_attr_val[0]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), > + host->cdns_ufs_dme_attr_val[1]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_TRAFFICCLASS), > + host->cdns_ufs_dme_attr_val[2]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_PROTOCOLID), > + host->cdns_ufs_dme_attr_val[3]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), > + host->cdns_ufs_dme_attr_val[4]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_TXTOKENVALUE), > + host->cdns_ufs_dme_attr_val[5]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_RXTOKENVALUE), > + host->cdns_ufs_dme_attr_val[6]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_LOCALBUFFERSPACE), > + host->cdns_ufs_dme_attr_val[7]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERBUFFERSPACE), > + host->cdns_ufs_dme_attr_val[8]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_CREDITSTOSEND), > + host->cdns_ufs_dme_attr_val[9]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTMODE), > + host->cdns_ufs_dme_attr_val[10]); > + ufshcd_dme_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), > + host->cdns_ufs_dme_attr_val[11]); } > + > +/** > * Sets HCLKDIV register value based on the core_clk > * @hba: host controller instance > * > @@ -134,6 +213,7 @@ static void cdns_ufs_hibern8_notify(struct ufs_hba > *hba, enum uic_cmd_dme cmd, > * before manual hibernate entry. > */ > cdns_ufs_enable_intr(hba, UFSHCD_UIC_HIBERN8_MASK); > + cdns_ufs_get_l4_attr(hba); > } > if (status == POST_CHANGE && cmd == UIC_CMD_DME_HIBER_EXIT) { > /** > @@ -141,6 +221,7 @@ static void cdns_ufs_hibern8_notify(struct ufs_hba > *hba, enum uic_cmd_dme cmd, > * after manual hibern8 exit. > */ > cdns_ufs_disable_intr(hba, UFSHCD_UIC_HIBERN8_MASK); > + cdns_ufs_set_l4_attr(hba); > } > } > > @@ -245,15 +326,27 @@ static int cdns_ufs_pltfrm_probe(struct > platform_device *pdev) > const struct of_device_id *of_id; > struct ufs_hba_variant_ops *vops; > struct device *dev = &pdev->dev; > + struct cdns_ufs_host *host; > + struct ufs_hba *hba; > > of_id = of_match_node(cdns_ufs_of_match, dev->of_node); > vops = (struct ufs_hba_variant_ops *)of_id->data; > > /* Perform generic probe */ > err = ufshcd_pltfrm_init(pdev, vops); > - if (err) > + if (err) { > dev_err(dev, "ufshcd_pltfrm_init() failed %d\n", err); > - > + goto out; > + } > + host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); > + if (!host) { > + err = -ENOMEM; > + dev_err(dev, "%s: no memory for cdns host\n", __func__); > + goto out; > + } > + hba = platform_get_drvdata(pdev); > + ufshcd_set_variant(hba, host); > +out: > return err; > } > > -- > 2.7.4