Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3073305ybc; Thu, 21 Nov 2019 02:57:53 -0800 (PST) X-Google-Smtp-Source: APXvYqypQxaFKp71fo373BS5VmUeRyY/tuDk9hy2LvFVKgKF/QfuHTsMmZRwQ2F6dZmgb87xxSGi X-Received: by 2002:a17:906:278a:: with SMTP id j10mr13132123ejc.125.1574333873036; Thu, 21 Nov 2019 02:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574333873; cv=none; d=google.com; s=arc-20160816; b=y+ClHpbR8Y9BPsYulyZRXPpFJgNo5PKARF9PzRr45/OyXX5KAH7owHP6TlhRx7urPo w8LCTj1Z13X1Iv413vkPtJYsd/TbIeSL2JyLsARLlrKCzfcuiHQP6yx8CRjrLoJkP+Fq pp5/9aJtEBPe2Tdy1QHWTldZMXK7jqtqeBKmX8rtdJR2NZ8U65jqEPF8ufZZz0noi92d mE6ebSmTZUeYJcjoFIKyFUV5bCudWbFlaG49kKV2GipiWhtc6LM3D3ygVc5vXxUL9YUx kHvizdtSEnHqDrXw5ihUZt/r21ozXpfHkmFOQM7xqu4e4+h5+UBXZAPW/Pc8i8YX3R4x +jvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=BN2cOGR0bwSm+uHqvrKwYNrZacJcbpFiZui1RldBkdA=; b=wYGJmVN/eqy0x56AjqFDubUp2/plbHsvBdCcWC4mh5gH42xLxdWpYym3Xp0Hvs4gs0 QxaNy2X+9NQ6U9hS/dGvYohWS9Ouxwr2+aKZNNK6Zkf0y4V0AxxdMEgfh3xlEU6YSNHm enD2iVhnmcKJW67Mts4gXxftYEjHBtsVB6o7SAaW3muu6cqMDPy3EngGrzPpeKfFt/yW QcFxSPXCBIjPpgODZpjuDyRoDF8fGTjMSrHAjVpDW9qfivtK3P5753/sMt0OxL5e0FIn nhoY7zTLvKbBDVcQp2ohv6Cu1+kKcqQ8RYrmX3ueEG/9UkZWUbPBzBZ5bBaoVIyHNWZZ jSqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=iW2Sym4S; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si2016250eda.291.2019.11.21.02.57.27; Thu, 21 Nov 2019 02:57:53 -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=@ti.com header.s=ti-com-17Q1 header.b=iW2Sym4S; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbfKUK4P (ORCPT + 99 others); Thu, 21 Nov 2019 05:56:15 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:50126 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfKUK4O (ORCPT ); Thu, 21 Nov 2019 05:56:14 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xALAthcK026316; Thu, 21 Nov 2019 04:55:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1574333743; bh=BN2cOGR0bwSm+uHqvrKwYNrZacJcbpFiZui1RldBkdA=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=iW2Sym4SpEH0edQkHk1ql6Ls1TYm9nYirNeZR5AF6CsvcPnpQxFz5nUVM1brbVxXy J3vMh1iw7E6VN5QEFkx4+nlsqy22d70pqsGJ46WXFHUls2966LHBOvjTdMj9uXOhNK 0Jpy0tpEogNoDVgVm97ivMFkPB9OsVpM/h3qPGiU= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xALAthZx068246 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Nov 2019 04:55:43 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 21 Nov 2019 04:55:43 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 21 Nov 2019 04:55:43 -0600 Received: from [172.24.145.136] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id xALAtcCc041419; Thu, 21 Nov 2019 04:55:39 -0600 Subject: Re: [PATCH RESEND 2/2] scsi: ufs: Update L4 attributes on manual hibern8 exit in Cadence UFS. To: Alim Akhtar , sheebab CC: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , "Bean Huo (beanhuo)" , , , open list , , , References: <1574147082-22725-1-git-send-email-sheebab@cadence.com> <1574147082-22725-3-git-send-email-sheebab@cadence.com> From: Vignesh Raghavendra Message-ID: Date: Thu, 21 Nov 2019 16:26:10 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/11/19 9:50 PM, Alim Akhtar wrote: > Hi Sheebab > > On Tue, Nov 19, 2019 at 12:38 PM sheebab wrote: >> >> Backup L4 attributes duirng manual hibern8 entry >> and restore the L4 attributes on manual hibern8 exit as per JESD220C. >> > Can you point me to the relevant section on the spec? > Per JESD 220C 9.4 UniPro/UFS Control Interface (Control Plane): "NOTE After exit from Hibernate all UniPro Transport Layer attributes (including L4 T_PeerDeviceID, L4 T_PeerCPortID, L4 T_ConnectionState, etc.) will be reset to their reset values. All required attributes must be restored properly on both ends before communication can resume." But its not clear whether SW needs to restore these attributes or hardware Regards Vignesh >> Signed-off-by: sheebab >> --- >> 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 >> > > -- Regards Vignesh