Skip to contentSkip to conversation

scsi: ufs: qcom: Reprogram ESI after a host controller reset

PATCH Applied Joonhoe Kim 3 participants 4 messages Oct 22 – Nov 9

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs: qcom: Reprogram ESI after a host controller reset

ufs_qcom_config_esi() returns early once the ESI interrupts are set up. ufshcd_config_mcq() also calls it after every host controller reset, which clears the ESI base address, the vector mask and ESI enable. After the error handler has reset the controller, the completions then arrive only on the legacy interrupt while mcq_esi_enabled stays set.

Allocate the MSIs and request their interrupts only once, but program the ESI registers on every call. The MSI message is not cached for platform MSIs, so keep the one written at allocation.

Fixes 519b6274a777 ("scsi: ufs: qcom: Add MCQ ESI config vendor specific ops")

---
Tested on a Lenovo Y700 Gen 5 (TB323FU, Kaanapali; out-of-tree board support) on v7.3-rc4 with commit b52d695d0620 ("scsi: ufs: core: Keep internal commands dispatchable during error handling") applied, forcing a full reset through the debugfs saved_err file: before, REG_UFS_MEM_CFG, ESILBA and ESIUBA read 0 after the reset and all completions came on the legacy interrupt; with this patch they come on the ESI interrupts again.

 drivers/ufs/host/ufs-qcom.c | 12 +++++++++---
 drivers/ufs/host/ufs-qcom.h |  2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/ufs/host/ufs-qcom.c +9 -3
index fee9b54ba5e1..ea2a106cbe26 100644
@@ -2414,7 +2414,9 @@ static void ufs_qcom_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)
 {
 	struct device *dev = msi_desc_to_dev(desc);
 	struct ufs_hba *hba = dev_get_drvdata(dev);
+	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
 
+	host->esi_msg = *msg;
 	ufshcd_mcq_config_esi(hba, msg);
 }
 
@@ -2442,8 +2444,10 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
 	struct ufs_qcom_irq *qi;
 	int nr_irqs, ret;
 
-	if (host->esi_enabled)
-		return 0;
+	if (host->esi_enabled) {
+		ufshcd_mcq_config_esi(hba, &host->esi_msg);
+		goto enable;
+	}
 
 	/*
 	 * 1. We only handle CQs as of now.
@@ -2481,12 +2485,14 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
 		}
 	}
 
+	host->esi_enabled = true;
+
+enable:
 	if (host->hw_ver.major >= 6) {
 		ufshcd_rmwl(hba, ESI_VEC_MASK, FIELD_PREP(ESI_VEC_MASK, MAX_ESI_VEC - 1),
 			    REG_UFS_CFG3);
 	}
 	ufshcd_mcq_enable_esi(hba);
-	host->esi_enabled = true;
 	return 0;
 }
 
drivers/ufs/host/ufs-qcom.h +2 -0
index 944b2e532a09..d2647695abe3 100644
@@ -5,6 +5,7 @@
 #ifndef UFS_QCOM_H_
 #define UFS_QCOM_H_
 
+#include <linux/msi.h>
 #include <linux/reset-controller.h>
 #include <linux/reset.h>
 #include <soc/qcom/ice.h>
@@ -360,6 +361,7 @@ struct ufs_qcom_host {
 	u32 phy_gear;
 
 	bool esi_enabled;
+	struct msi_msg esi_msg;
 
 	u32 saved_tx_eq_g1_setting;
 	u32 boot_spare_cfg;

base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64

Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Joonhoe Kim

ufs_qcom_config_esi() returns early once the ESI interrupts are set up. ufshcd_config_mcq() also calls it after every host controller reset, which clears the ESI base address, the vector mask and ESI enable. After the error handler has reset the controller, the completions then arrive only on the legacy interrupt while mcq_esi_enabled stays set.

Quoted 7 lines

Allocate the MSIs and request their interrupts only once, but program the ESI registers on every call. The MSI message is not cached for platform MSIs, so keep the one written at allocation.

Fixes 519b6274a777 ("scsi: ufs: qcom: Add MCQ ESI config vendor specific ops")

---

I'm not sure it's related, but with this change, do you still need

https://lore.kernel.org/linux-arm-msm/[email protected]/

?

Konrad

#2 lore raw
Quoted 5 lines · Konrad Dybcio

I'm not sure it's related, but with this change, do you still need

https://lore.kernel.org/linux-arm-msm/[email protected]/

?

Yes, they fix different problems.

With MCQ enabled (which needs DT changes not yet upstream for Kaanapali) and without FORCE_MEM_CORE_ON on the UFS PHY AXI clock, the MCQ configuration is not retained over s2idle. The first command after resume then triggers an SMMU fault and the error handler resets the host; on my device that happened on almost every resume. With the clock patch the configuration is retained, and I have not seen a reset over s2idle since.

This patch is about any host reset, e.g. from the error handler after a UIC error: the reset clears the ESI registers, and ufs_qcom_config_esi() does not program them again, so completions fall back to the legacy interrupt. It does nothing about the s2idle faults themselves.

Thanks,
Joonhoe Kim

maintainer Applied
#3 lore raw
In reply to Joonhoe Kim
Quoted 11 lines · Joonhoe Kim

ufs_qcom_config_esi() returns early once the ESI interrupts are set up. ufshcd_config_mcq() also calls it after every host controller reset, which clears the ESI base address, the vector mask and ESI enable. After the error handler has reset the controller, the completions then arrive only on the legacy interrupt while mcq_esi_enabled stays set.

Allocate the MSIs and request their interrupts only once, but program the ESI registers on every call. The MSI message is not cached for platform MSIs, so keep the one written at allocation.

[...]

Applied to 7.4/scsi-fixes, thanks!

[1/1] scsi: ufs: qcom: Reprogram ESI after a host controller reset

      https://git.kernel.org/mkp/scsi/c/b3da73f09499
Signature · 1 line
Martin K. Petersen