Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1582498ybl; Sun, 19 Jan 2020 06:29:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzrgtyrUXA5eiNFzLvwa0ZpTaKMT/H40M4gAQlsfgrt6f/Al6OPMupGS8erGJs+ZJ7wgFLd X-Received: by 2002:a9d:674f:: with SMTP id w15mr13028992otm.243.1579444167468; Sun, 19 Jan 2020 06:29:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579444167; cv=none; d=google.com; s=arc-20160816; b=lV1/m9HJrOVgrroXKG6GzAm1palQc+/pozGM16TsoiRj+ULMp9nrHvQ4TI/PNA3jHn 1yogHexHSwEw2maFU4hLxN/09p9SO9gDykWt9w9cp0oVoyGa6ITB8CK77gTDtQaqYpNc dTHQGUB8BAUNsL6EIR2El8LYzgnDKoZggiDuWV0Vs4c47pHgyMIKkF9a9XHJ0kWhDe0e k5PuWdcvdVHWGNwWdgGQ2xsARNdLvjF/tHOxk0DIhvlZiyLVp0pUbdmfT1k6T3ejA/jV 3xA7K6Xj2oKFvc39fEsHw+iLIQMu3gRimiOmMFHFGf+uP8XrEbd9pyCZl3dy3Lu4bRXq UK8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hXWYeX6AjtCDD1kv6pJLbNztbwW499IxeNUMgb5p23o=; b=fIpFNLCEpdAInD35k8Ol2W0Z5RkB33nk4UrS1cDydDInHfHTn7vSZGLvrFppGiSC9I QYB90zD5NhgBfdHJ12SZYSS4drAej4+YvMt5hsH+zViM8AbmgHZoSG6ifKj+gchMzfEO /2k5Rs4kyGJ8jbFkdqLMOB5QhQorNqqCLhK005mZTUWElRF737RetOH1MED8ddBsmj/n 3vRzHCvkox/lCCaC088aFvpO8c36U4aEIjeGsdaFriXmpVwaxNYd3RbhC5rLBWpngPoA 9ga8MFcUuxm4Ns34exhQe6AgCgCQ6FvNrhejf0BWC70W3+eckHwxCGOdVV2zdM2INzDv Ln4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rYQjOwK7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si16911525otn.108.2020.01.19.06.29.15; Sun, 19 Jan 2020 06:29:27 -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=@gmail.com header.s=20161025 header.b=rYQjOwK7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbgASO2Y (ORCPT + 99 others); Sun, 19 Jan 2020 09:28:24 -0500 Received: from mail-vs1-f67.google.com ([209.85.217.67]:33647 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbgASO2Y (ORCPT ); Sun, 19 Jan 2020 09:28:24 -0500 Received: by mail-vs1-f67.google.com with SMTP id n27so17517896vsa.0; Sun, 19 Jan 2020 06:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hXWYeX6AjtCDD1kv6pJLbNztbwW499IxeNUMgb5p23o=; b=rYQjOwK7eKiea9ZzsLJpVr/fXJw6Odp4y9oVfXjpZ5Ypqm1TDdcsTmyDgkF57qzaM3 53Fh+Opzf06Zj7t1IOM3DK3rTYv90QhGYbmx6pPAwUP040ziVECm/V3YfHOFFy4DOd/4 qE7Tbmq1b17DI1RiJ4bHccmrRBUIeGj9SxyczYA2s7+lAGcKi+CoS0iqHiwBbr6otv/w YAm7LuJDbwNjDxqdx/zCp3cfc4QdE1vwREHwUhvdoS+56RYx07QOtlwEKrdKRYdQvgSi 8p1OGceTrELl9lJSaLNZzzPImLJu6d9xW2BoEAjSyh6yU1TivUsROh9Lz/Ck48TAEOox CNEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hXWYeX6AjtCDD1kv6pJLbNztbwW499IxeNUMgb5p23o=; b=LxFKA01iMmwRBqTP+gx19Y/bOanDfJ0VBHRpFabFbeNok1eWELGpDw1lLeOCuNSfNT UXa74HAPcp+q/egP06kTksg3Mg7y2Giu5pQfGh+UOPgwE1UjeVbdp2pbQuhtpH8fuKaW OKXcSja5tB8tEIfPJ2rXdNbyVnuOcgCdm6jKcFn8UUWz9MLILeuSULktLg8hrhcPGIE3 ZJk+OufdfHSSJadsEYsRT0TXgyzPCrd2LdZPY7WCnCvqNVe5FmA47USlMF7OhxIz1Lnb rNB2FsLosPbvA7OcMWry/TAXBeM+/1HoDfev85qy+8c8gDmWmwfEFP+DH2cgKu2NkQpl /7eQ== X-Gm-Message-State: APjAAAVt0dZ8pbwgwaxl7XsvYovoxvYPwtfwYtz3CMVWCvQFaq+KpAWf 3B0eI4jADI9WQKsFaC4vp8SI/2RKlxy1k/LpxyM= X-Received: by 2002:a05:6102:3102:: with SMTP id e2mr10235569vsh.179.1579444103046; Sun, 19 Jan 2020 06:28:23 -0800 (PST) MIME-Version: 1.0 References: <20200117035108.19699-1-stanley.chu@mediatek.com> <20200117035108.19699-4-stanley.chu@mediatek.com> In-Reply-To: <20200117035108.19699-4-stanley.chu@mediatek.com> From: Alim Akhtar Date: Sun, 19 Jan 2020 19:57:47 +0530 Message-ID: Subject: Re: [PATCH v1 3/3] scsi: ufs-mediatek: enable low-power mode for hibern8 state To: Stanley Chu Cc: linux-scsi@vger.kernel.org, "Martin K. Petersen" , Avri Altman , Alim Akhtar , "James E.J. Bottomley" , "Bean Huo (beanhuo)" , asutoshd@codeaurora.org, Can Guo , Matthias Brugger , Bart Van Assche , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, open list , Kuohong Wang , peter.wang@mediatek.com, chun-hung.wu@mediatek.com, andy.teng@mediatek.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 17, 2020 at 9:44 AM Stanley Chu wrote: > > In MediaTek Chipsets, UniPro link and ufshci can enter proprietary > low-power mode while link is in hibern8 state. > > Signed-off-by: Stanley Chu > --- Reviewed-by: Alim Akhtar > drivers/scsi/ufs/ufs-mediatek.c | 53 +++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > > diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c > index d5194d0c4ef5..f32f3f34f6d0 100644 > --- a/drivers/scsi/ufs/ufs-mediatek.c > +++ b/drivers/scsi/ufs/ufs-mediatek.c > @@ -382,11 +382,60 @@ static void ufs_mtk_device_reset(struct ufs_hba *hba) > dev_info(hba->dev, "device reset done\n"); > } > > +static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) > +{ > + int err; > + > + err = ufshcd_hba_enable(hba); > + if (err) > + return err; > + > + err = ufshcd_dme_set(hba, > + UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), > + 0); > + if (err) > + return err; > + > + err = ufshcd_uic_hibern8_exit(hba); > + if (!err) > + ufshcd_set_link_active(hba); > + else > + return err; > + > + err = ufshcd_make_hba_operational(hba); > + if (err) > + return err; > + > + return 0; > +} > + > +static int ufs_mtk_link_set_lpm(struct ufs_hba *hba) > +{ > + int err; > + > + err = ufshcd_dme_set(hba, > + UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), > + 1); > + if (err) { > + /* Resume UniPro state for following error recovery */ > + ufshcd_dme_set(hba, > + UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), > + 0); > + return err; > + } > + > + return 0; > +} > + > static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) > { > + int err; > struct ufs_mtk_host *host = ufshcd_get_variant(hba); > > if (ufshcd_is_link_hibern8(hba)) { > + err = ufs_mtk_link_set_lpm(hba); > + if (err) > + return -EAGAIN; > phy_power_off(host->mphy); > ufs_mtk_setup_ref_clk(hba, false); > } > @@ -397,10 +446,14 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) > static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) > { > struct ufs_mtk_host *host = ufshcd_get_variant(hba); > + int err; > > if (ufshcd_is_link_hibern8(hba)) { > ufs_mtk_setup_ref_clk(hba, true); > phy_power_on(host->mphy); > + err = ufs_mtk_link_set_hpm(hba); > + if (err) > + return err; > } > > return 0; > -- > 2.18.0 -- Regards, Alim