linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sheebab <sheebab@cadence.com>
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 <sheebab@cadence.com>
Subject: [PATCH RESEND 1/2] scsi: ufs: Enable hibern8 interrupt only during manual hibern8 in Cadence UFS.
Date: Tue, 19 Nov 2019 08:04:41 +0100	[thread overview]
Message-ID: <1574147082-22725-2-git-send-email-sheebab@cadence.com> (raw)
In-Reply-To: <1574147082-22725-1-git-send-email-sheebab@cadence.com>

Auto hibern8 causes false interrupt assertion.
To overcome this, disable hibern8 interrupt during initialization
and Enable/Disable hibern8 interrupt during manual hibern8 Entry/Exit.

Signed-off-by: sheebab <sheebab@cadence.com>
---
 drivers/scsi/ufs/cdns-pltfrm.c | 75 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 72 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c
index b2af04c..adbbd60 100644
--- a/drivers/scsi/ufs/cdns-pltfrm.c
+++ b/drivers/scsi/ufs/cdns-pltfrm.c
@@ -21,6 +21,32 @@
 #define CDNS_UFS_REG_PHY_XCFGD1	0x113C
 
 /**
+ * cdns_ufs_enable_intr - enable interrupts
+ * @hba: per adapter instance
+ * @intrs: interrupt bits
+ */
+static void cdns_ufs_enable_intr(struct ufs_hba *hba, u32 intrs)
+{
+	u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+
+	set = set | intrs;
+	ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
+}
+
+/**
+ * cdns_ufs_disable_intr - disable interrupts
+ * @hba: per adapter instance
+ * @intrs: interrupt bits
+ */
+static void cdns_ufs_disable_intr(struct ufs_hba *hba, u32 intrs)
+{
+	u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+
+	set = set & ~intrs;
+	ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
+}
+
+/**
  * Sets HCLKDIV register value based on the core_clk
  * @hba: host controller instance
  *
@@ -71,10 +97,51 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba)
 static int cdns_ufs_hce_enable_notify(struct ufs_hba *hba,
 				      enum ufs_notify_change_status status)
 {
-	if (status != PRE_CHANGE)
-		return 0;
+	int err = 0;
+
+	switch (status) {
+	case PRE_CHANGE:
+		err = cdns_ufs_set_hclkdiv(hba);
+		break;
+	case POST_CHANGE:
+		/**
+		 * Hibern8 interrupts(UHESE, UHXSE) disabled
+		 * during initialization.
+		 */
+		cdns_ufs_disable_intr(hba, UFSHCD_UIC_HIBERN8_MASK);
+		break;
+	default:
+		dev_err(hba->dev, "%s: invalid status %d\n", __func__, status);
+		err = -EINVAL;
+		break;
+	}
+	return err;
+}
 
-	return cdns_ufs_set_hclkdiv(hba);
+/**
+ * Called around hibern8 enter/exit.
+ * @hba: host controller instance
+ * @cmd: UIC Command
+ * @status: notify stage (pre, post change)
+ *
+ */
+static void cdns_ufs_hibern8_notify(struct ufs_hba *hba, enum uic_cmd_dme cmd,
+				    enum ufs_notify_change_status status)
+{
+	if (status == PRE_CHANGE && cmd == UIC_CMD_DME_HIBER_ENTER) {
+		/**
+		 * Hibern8 interrupts(UHESE, UHXSE) enabled
+		 * before manual hibernate entry.
+		 */
+		cdns_ufs_enable_intr(hba, UFSHCD_UIC_HIBERN8_MASK);
+	}
+	if (status == POST_CHANGE && cmd == UIC_CMD_DME_HIBER_EXIT) {
+		/**
+		 * Hibern8 interrupts(UHESE, UHXSE) disabled
+		 * after manual hibern8 exit.
+		 */
+		cdns_ufs_disable_intr(hba, UFSHCD_UIC_HIBERN8_MASK);
+	}
 }
 
 /**
@@ -140,6 +207,7 @@ static const struct ufs_hba_variant_ops cdns_ufs_pltfm_hba_vops = {
 	.name = "cdns-ufs-pltfm",
 	.hce_enable_notify = cdns_ufs_hce_enable_notify,
 	.link_startup_notify = cdns_ufs_link_startup_notify,
+	.hibern8_notify = cdns_ufs_hibern8_notify,
 };
 
 static const struct ufs_hba_variant_ops cdns_ufs_m31_16nm_pltfm_hba_vops = {
@@ -148,6 +216,7 @@ static const struct ufs_hba_variant_ops cdns_ufs_m31_16nm_pltfm_hba_vops = {
 	.hce_enable_notify = cdns_ufs_hce_enable_notify,
 	.link_startup_notify = cdns_ufs_link_startup_notify,
 	.phy_initialization = cdns_ufs_m31_16nm_phy_initialization,
+	.hibern8_notify = cdns_ufs_hibern8_notify,
 };
 
 static const struct of_device_id cdns_ufs_of_match[] = {
-- 
2.7.4


  reply	other threads:[~2019-11-19  7:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19  7:04 [PATCH RESEND 0/2] scsi: ufs: hibern8 fixes sheebab
2019-11-19  7:04 ` sheebab [this message]
2019-11-19  7:04 ` [PATCH RESEND 2/2] scsi: ufs: Update L4 attributes on manual hibern8 exit in Cadence UFS sheebab
2019-11-20 16:20   ` Alim Akhtar
2019-11-21 10:56     ` Vignesh Raghavendra
2019-11-27  3:42       ` Alim Akhtar
2019-11-27  4:15         ` Vignesh Raghavendra
2019-11-27 15:18         ` Avri Altman
2019-11-28 13:59   ` Alim Akhtar
2019-11-22 11:44 ` [PATCH RESEND 0/2] scsi: ufs: hibern8 fixes Vignesh Raghavendra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1574147082-22725-2-git-send-email-sheebab@cadence.com \
    --to=sheebab@cadence.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mparab@cadence.com \
    --cc=pedrom.sousa@synopsys.com \
    --cc=rafalc@cadence.com \
    --cc=stanley.chu@mediatek.com \
    --cc=vigneshr@ti.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).