Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d16d406 authored by Stanley Chu's avatar Stanley Chu
Browse files

UPSTREAM: scsi: ufs: fix Auto-Hibern8 error detection

Auto-Hibern8 may be disabled by some vendors or sysfs in runtime even if
Auto-Hibern8 capability is supported by host. If Auto-Hibern8 capability is
supported by host but not actually enabled, Auto-Hibern8 error shall not
happen.

To fix this, provide a way to detect if Auto-Hibern8 is actually enabled
first, and bypass Auto-Hibern8 disabling case in
ufshcd_is_auto_hibern8_error().

Bug: 151050916
(cherry picked from commit 5a244e0ea67b293abb1d26c825db2ddde5f2862f)
Fixes: 82174440 ("scsi: ufs: Add error-handling of Auto-Hibernate")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200129105251.12466-4-stanley.chu@mediatek.com


Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Reviewed-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
Reviewed-by: default avatarCan Guo <cang@codeaurora.org>
Signed-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Change-Id: I04557ed9ad16a22cdf68e455e78dd0b4a7417d60
parent 9c4239e5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5677,7 +5677,8 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba)
static bool ufshcd_is_auto_hibern8_error(struct ufs_hba *hba,
					 u32 intr_mask)
{
	if (!ufshcd_is_auto_hibern8_supported(hba))
	if (!ufshcd_is_auto_hibern8_supported(hba) ||
	    !ufshcd_is_auto_hibern8_enabled(hba))
		return false;

	if (!(intr_mask & UFSHCD_UIC_HIBERN8_MASK))
+6 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/regulator/consumer.h>
#include <linux/bitfield.h>
#include "unipro.h"

#include <asm/irq.h>
@@ -836,6 +837,11 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
	return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT);
}

static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
{
	return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;
}

#define ufshcd_writel(hba, val, reg)	\
	writel((val), (hba)->mmio_base + (reg))
#define ufshcd_readl(hba, reg)	\