Skip to contentSkip to conversation

scsi: ufs-qcom: Enable Dumping of Hibern8, MCQ, and Testbus Registers

PATCH Superseded Manish Pandey 4 participants 12 messages Oct 25, 2024 – Feb 27, 2025

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover scsi: ufs-qcom: Enable Dumping of Hibern8, MCQ, and Testbus Registers

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

Manish Pandey (3):
scsi: ufs-qcom: Add support for dumping HW and SW hibern8 count
scsi: ufs-qcom: Add support for dumping MCQ registers
scsi: ufs-qcom: Add support for testbus registers

 drivers/ufs/host/ufs-qcom.c | 141 ++++++++++++++++++++++++++++++++++++
 drivers/ufs/host/ufs-qcom.h |  11 +++
 2 files changed, 152 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 scsi: ufs-qcom: Add support for dumping HW and SW hibern8 count

This patch adds functionality to dump both hardware and software hibern8 enter counts. This enhancement will aid in monitoring and debugging hibern8 state transitions by providing detailed count information.

---
 drivers/ufs/host/ufs-qcom.c | 9 +++++++++
 drivers/ufs/host/ufs-qcom.h | 9 +++++++++
 2 files changed, 18 insertions(+)
drivers/ufs/host/ufs-qcom.c +9 -0
index a5a0646bb80a..4752311b1f76 100644
@@ -1487,6 +1487,15 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
 
 	host = ufshcd_get_variant(hba);
 
+	dev_err(hba->dev, "HW_H8_ENTER_CNT=%d\n", ufshcd_readl(hba, REG_UFS_HW_H8_ENTER_CNT));
+	dev_err(hba->dev, "HW_H8_EXIT_CNT=%d\n", ufshcd_readl(hba, REG_UFS_HW_H8_EXIT_CNT));
+
+	dev_err(hba->dev, "SW_H8_ENTER_CNT=%d\n", ufshcd_readl(hba, REG_UFS_SW_H8_ENTER_CNT));
+	dev_err(hba->dev, "SW_H8_EXIT_CNT=%d\n", ufshcd_readl(hba, REG_UFS_SW_H8_EXIT_CNT));
+
+	dev_err(hba->dev, "SW_AFTER_HW_H8_ENTER_CNT=%d\n",
+			ufshcd_readl(hba, REG_UFS_SW_AFTER_HW_H8_ENTER_CNT));
+
 	ufshcd_dump_regs(hba, REG_UFS_SYS1CLK_1US, 16 * 4,
 			 "HCI Vendor Specific Registers ");
 
drivers/ufs/host/ufs-qcom.h +9 -0
index b9de170983c9..84e42fa123d2 100644
@@ -72,6 +72,15 @@ enum {
 	UFS_UFS_DBG_RD_EDTL_RAM			= 0x1900,
 };
 
+/* Vendor-specific Hibern8 count registers for the QCOM UFS host controller. */
+enum {
+	REG_UFS_HW_H8_ENTER_CNT			= 0x2700,
+	REG_UFS_SW_H8_ENTER_CNT			= 0x2704,
+	REG_UFS_SW_AFTER_HW_H8_ENTER_CNT	= 0x2708,
+	REG_UFS_HW_H8_EXIT_CNT			= 0x270C,
+	REG_UFS_SW_H8_EXIT_CNT			= 0x2710,
+};
+
 enum {
 	UFS_MEM_CQIS_VS		= 0x8,
 };
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 scsi: ufs-qcom: Add support for dumping MCQ registers

In reply to Manish Pandey

This patch adds functionality to dump Multi-Queue (MCQ) registers. This will help in diagnosing issues related to MCQ operations by providing detailed register dumps.

---
 drivers/ufs/host/ufs-qcom.c | 59 +++++++++++++++++++++++++++++++++++++
 drivers/ufs/host/ufs-qcom.h |  2 ++
 2 files changed, 61 insertions(+)
drivers/ufs/host/ufs-qcom.c +59 -0
index 4752311b1f76..a43e818a7e14 100644
@@ -1480,6 +1480,52 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
 	return 0;
 }
 
+static void ufs_qcom_dump_mcq_hci_regs(struct ufs_hba *hba)
+{
+	/* RES_MCQ_1 */
+	ufshcd_dump_regs(hba, 0x0, 256 * 4, "MCQ HCI 1da0000-1da03f0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_2 */
+	ufshcd_dump_regs(hba, 0x400, 256 * 4, "MCQ HCI 1da0400-1da07f0 ");
+	usleep_range(1000, 1100);
+
+	/*RES_MCQ_VS */
+	ufshcd_dump_regs(hba, 0x0, 5 * 4, "MCQ VS 1da4000-1da4010 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_1 */
+	ufshcd_dump_regs(hba, 0x0, 256 * 4, "MCQ SQD 1da5000-1da53f0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_2 */
+	ufshcd_dump_regs(hba, 0x400, 256 * 4, "MCQ SQD 1da5400-1da57f0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_3 */
+	ufshcd_dump_regs(hba, 0x800, 256 * 4, "MCQ SQD 1da5800-1da5bf0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_4 */
+	ufshcd_dump_regs(hba, 0xc00, 256 * 4, "MCQ SQD 1da5c00-1da5ff0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_5 */
+	ufshcd_dump_regs(hba, 0x1000, 256 * 4, "MCQ SQD 1da6000-1da63f0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_6 */
+	ufshcd_dump_regs(hba, 0x1400, 256 * 4, "MCQ SQD 1da6400-1da67f0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_7 */
+	ufshcd_dump_regs(hba, 0x1800, 256 * 4, "MCQ SQD 1da6800-1da6bf0 ");
+	usleep_range(1000, 1100);
+
+	/* RES_MCQ_SQD_8 */
+	ufshcd_dump_regs(hba, 0x1c00, 256 * 4, "MCQ SQD 1da6c00-1da6ff0 ");
+}
+
 static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
 {
 	u32 reg;
@@ -1538,6 +1584,19 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
 
 	reg = ufs_qcom_get_debug_reg_offset(host, UFS_DBG_RD_REG_TMRLUT);
 	ufshcd_dump_regs(hba, reg, 9 * 4, "UFS_DBG_RD_REG_TMRLUT ");
+
+	if (hba->mcq_enabled) {
+		reg = ufs_qcom_get_debug_reg_offset(host, UFS_RD_REG_MCQ);
+		ufshcd_dump_regs(hba, reg, 64 * 4, "HCI MCQ Debug Registers ");
+	}
+
+	if (in_task()) {
+		/* Dump MCQ Host Vendor Specific Registers */
+		if (hba->mcq_enabled) {
+			ufs_qcom_dump_mcq_hci_regs(hba);
+			usleep_range(1000, 1100);
+		}
+	}
 }
 
 /**
drivers/ufs/host/ufs-qcom.h +2 -0
index 84e42fa123d2..980af902bab5 100644
@@ -50,6 +50,8 @@ enum {
 	 */
 	UFS_AH8_CFG				= 0xFC,
 
+	UFS_RD_REG_MCQ                          = 0xD00,
+
 	REG_UFS_CFG3				= 0x271C,
 
 	REG_UFS_DEBUG_SPARE_CFG			= 0x284C,
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/3 scsi: ufs-qcom: Add support for testbus registers

In reply to Manish Pandey

This patch introduces support for dumping testbus registers, enhancing the debugging capabilities for UFS-QCOM drivers.

---
 drivers/ufs/host/ufs-qcom.c | 73 +++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
drivers/ufs/host/ufs-qcom.c +73 -0
index a43e818a7e14..7370b4a3bb83 100644
@@ -1480,6 +1480,75 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
 	return 0;
 }
 
+static void ufs_qcom_dump_testbus(struct ufs_hba *hba)
+{
+	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
+	u32 *testbus = NULL;
+	int i, j, nminor = 0, testbus_len = 0;
+	char *prefix;
+
+	testbus = kmalloc(256 * sizeof(u32), GFP_KERNEL);
+	if (!testbus)
+		return;
+
+	for (j = 0; j < TSTBUS_MAX; j++) {
+		nminor = 32;
+
+		switch (j) {
+		case TSTBUS_UAWM:
+			prefix = "TSTBUS_UAWM ";
+			break;
+		case TSTBUS_UARM:
+			prefix = "TSTBUS_UARM ";
+			break;
+		case TSTBUS_TXUC:
+			prefix = "TSTBUS_TXUC ";
+			break;
+		case TSTBUS_RXUC:
+			prefix = "TSTBUS_RXUC ";
+			break;
+		case TSTBUS_DFC:
+			prefix = "TSTBUS_DFC ";
+			break;
+		case TSTBUS_TRLUT:
+			prefix = "TSTBUS_TRLUT ";
+			break;
+		case TSTBUS_TMRLUT:
+			prefix = "TSTBUS_TMRLUT ";
+			break;
+		case TSTBUS_OCSC:
+			prefix = "TSTBUS_OCSC ";
+			break;
+		case TSTBUS_UTP_HCI:
+			prefix = "TSTBUS_UTP_HCI ";
+			break;
+		case TSTBUS_COMBINED:
+			prefix = "TSTBUS_COMBINED ";
+			break;
+		case TSTBUS_WRAPPER:
+			prefix = "TSTBUS_WRAPPER ";
+			break;
+		case TSTBUS_UNIPRO:
+			nminor = 256;
+			prefix = "TSTBUS_UNIPRO ";
+			break;
+		default:
+			break;
+		}
+
+		host->testbus.select_major = j;
+		testbus_len = nminor * sizeof(u32);
+		for (i = 0; i < nminor; i++) {
+			host->testbus.select_minor = i;
+			ufs_qcom_testbus_config(host);
+			testbus[i] = ufshcd_readl(hba, UFS_TEST_BUS);
+		}
+		print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
+			       16, 4, testbus, testbus_len, false);
+	}
+	kfree(testbus);
+}
+
 static void ufs_qcom_dump_mcq_hci_regs(struct ufs_hba *hba)
 {
 	/* RES_MCQ_1 */
@@ -1596,6 +1665,10 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
 			ufs_qcom_dump_mcq_hci_regs(hba);
 			usleep_range(1000, 1100);
 		}
+		ufshcd_dump_regs(hba, UFS_TEST_BUS, 4, "UFS_TEST_BUS ");
+		usleep_range(1000, 1100);
+		ufs_qcom_dump_testbus(hba);
+		usleep_range(1000, 1100);
 	}
 }
 
Signature · 1 line
2.17.1
#4 lore raw
In reply to Manish Pandey
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

- Mani

Quoted 13 lines

Manish Pandey (3):
scsi: ufs-qcom: Add support for dumping HW and SW hibern8 count
scsi: ufs-qcom: Add support for dumping MCQ registers
scsi: ufs-qcom: Add support for testbus registers

 drivers/ufs/host/ufs-qcom.c | 141 ++++++++++++++++++++++++++++++++++++
 drivers/ufs/host/ufs-qcom.h |  11 +++
 2 files changed, 152 insertions(+)
Signature · 1 line
2.17.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#5 lore raw
Quoted 10 lines · Manivannan Sadhasivam
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

I wouldn't mind if the code for dumping UFSHC registers would be removed.

Thanks,

Bart.

#6 lore raw
Quoted 7 lines · Bart Van Assche
Quoted 6 lines · Manivannan Sadhasivam
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

Quoted 7 lines
Quoted 4 lines

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

I wouldn't mind if the code for dumping UFSHC registers would be removed.

Instead of removing, I'm planning to move the dump to dev_coredump framework. But should we move all the error prints also? Like all ufshcd_print_*() functions?

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#7 lore raw
Quoted 13 lines · Manivannan Sadhasivam
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Manivannan Sadhasivam
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

Quoted 5 lines
Quoted 1 line

I wouldn't mind if the code for dumping UFSHC registers would be removed.

Instead of removing, I'm planning to move the dump to dev_coredump framework. But should we move all the error prints also? Like all ufshcd_print_*() functions?

Hmm ... we may be better off to check which of these functions can be removed rather than moving all of them to another framework.

Thanks,

Bart.

#8 lore raw
Quoted 14 lines · Bart Van Assche
Quoted 13 lines · Manivannan Sadhasivam
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Manivannan Sadhasivam
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

I wouldn't mind if the code for dumping UFSHC registers would be removed.

Instead of removing, I'm planning to move the dump to dev_coredump framework. But should we move all the error prints also? Like all ufshcd_print_*() functions?

Hmm ... we may be better off to check which of these functions can be removed rather than moving all of them to another framework.

They are mostly for debugging the errors. I don't see why we should completely get rid of them. Moving to devcoredump allows debugging the errors in a standardized way and also prevents spamming the kernel ring buffer.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#9 lore raw
In reply to Bart Van Assche
Quoted 14 lines · Bart Van Assche
Quoted 13 lines · Manivannan Sadhasivam
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Manivannan Sadhasivam
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

I wouldn't mind if the code for dumping UFSHC registers would be removed.

Instead of removing, I'm planning to move the dump to dev_coredump framework. But should we move all the error prints also? Like all ufshcd_print_*() functions?

Hmm ... we may be better off to check which of these functions can be removed rather than moving all of them to another framework.

devcoredump turned out to be not a good fit for storage drivers. And I can't figure out another way. And Qcom is telling me that these debug prints are necessary for them to debug the issues going forward.

Your thoughts?

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#10 lore raw
Quoted 21 lines · Manivannan Sadhasivam
Quoted 20 lines · Bart Van Assche
Quoted 18 lines · Manivannan Sadhasivam
Quoted 7 lines · Bart Van Assche
Quoted 6 lines · Manivannan Sadhasivam
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

Quoted 6 lines
Quoted 4 lines

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

I wouldn't mind if the code for dumping UFSHC registers would be removed.

Instead of removing, I'm planning to move the dump to dev_coredump framework. But should we move all the error prints also? Like all ufshcd_print_*() functions?

Quoted 8 lines
Quoted 2 lines

Hmm ... we may be better off to check which of these functions can be removed rather than moving all of them to another framework.

devcoredump turned out to be not a good fit for storage drivers. And I can't figure out another way. And Qcom is telling me that these debug prints are necessary for them to debug the issues going forward.

Your thoughts?

Does this mean that printk() is the best alternative we have available?

Thanks,

Bart.

#11 lore raw
Quoted 25 lines · Bart Van Assche
Quoted 24 lines · Manivannan Sadhasivam
Quoted 22 lines · Bart Van Assche
Quoted 13 lines · Manivannan Sadhasivam
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Manivannan Sadhasivam
Quoted 4 lines · Manish Pandey

Submitting a series of patches aimed at enhancing the debugging and monitoring capabilities of the UFS-QCOM driver. These patches introduce new functionalities that will significantly aid in diagnosing and resolving issues related to hardware and software operations.

TBH, the current state of dumping UFSHC registers itself is just annoying as it pollutes the kernel ring buffer. I don't think any peripheral driver in the kernel does this. Please dump only relevant registers, not everything that you feel like dumping.

Quoted 5 lines
Quoted 1 line

I wouldn't mind if the code for dumping UFSHC registers would be removed.

Instead of removing, I'm planning to move the dump to dev_coredump framework. But should we move all the error prints also? Like all ufshcd_print_*() functions?

Hmm ... we may be better off to check which of these functions can be removed rather than moving all of them to another framework.

Quoted 8 lines
Quoted 5 lines

devcoredump turned out to be not a good fit for storage drivers. And I can't figure out another way. And Qcom is telling me that these debug prints are necessary for them to debug the issues going forward.

Your thoughts?

Does this mean that printk() is the best alternative we have available?

For storage, yes unfortunately.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்