Skip to content

Commit 25b5ee1

Browse files
quic-mapamartinkpetersen
authored andcommitted
scsi: ufs: ufs-qcom: Add support to dump testbus registers
Add support to dump testbus registers to enhance debugging capabilities for the Qualcomm UFS Host Controller. Signed-off-by: Manish Pandey <quic_mapa@quicinc.com> Link: https://lore.kernel.org/r/20250411121345.16859-4-quic_mapa@quicinc.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 82edd86 commit 25b5ee1

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

drivers/ufs/host/ufs-qcom.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <linux/acpi.h>
77
#include <linux/clk.h>
8+
#include <linux/cleanup.h>
89
#include <linux/delay.h>
910
#include <linux/devfreq.h>
1011
#include <linux/gpio/consumer.h>
@@ -98,6 +99,24 @@ static const struct __ufs_qcom_bw_table {
9899
[MODE_MAX][0][0] = { 7643136, 819200 },
99100
};
100101

102+
static const struct {
103+
int nminor;
104+
char *prefix;
105+
} testbus_info[TSTBUS_MAX] = {
106+
[TSTBUS_UAWM] = {32, "TSTBUS_UAWM"},
107+
[TSTBUS_UARM] = {32, "TSTBUS_UARM"},
108+
[TSTBUS_TXUC] = {32, "TSTBUS_TXUC"},
109+
[TSTBUS_RXUC] = {32, "TSTBUS_RXUC"},
110+
[TSTBUS_DFC] = {32, "TSTBUS_DFC"},
111+
[TSTBUS_TRLUT] = {32, "TSTBUS_TRLUT"},
112+
[TSTBUS_TMRLUT] = {32, "TSTBUS_TMRLUT"},
113+
[TSTBUS_OCSC] = {32, "TSTBUS_OCSC"},
114+
[TSTBUS_UTP_HCI] = {32, "TSTBUS_UTP_HCI"},
115+
[TSTBUS_COMBINED] = {32, "TSTBUS_COMBINED"},
116+
[TSTBUS_WRAPPER] = {32, "TSTBUS_WRAPPER"},
117+
[TSTBUS_UNIPRO] = {256, "TSTBUS_UNIPRO"},
118+
};
119+
101120
static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
102121
static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq);
103122

@@ -1566,6 +1585,32 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
15661585
return 0;
15671586
}
15681587

1588+
static void ufs_qcom_dump_testbus(struct ufs_hba *hba)
1589+
{
1590+
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
1591+
int i, j, nminor = 0, testbus_len = 0;
1592+
u32 *testbus __free(kfree) = NULL;
1593+
char *prefix;
1594+
1595+
testbus = kmalloc_array(256, sizeof(u32), GFP_KERNEL);
1596+
if (!testbus)
1597+
return;
1598+
1599+
for (j = 0; j < TSTBUS_MAX; j++) {
1600+
nminor = testbus_info[j].nminor;
1601+
prefix = testbus_info[j].prefix;
1602+
host->testbus.select_major = j;
1603+
testbus_len = nminor * sizeof(u32);
1604+
for (i = 0; i < nminor; i++) {
1605+
host->testbus.select_minor = i;
1606+
ufs_qcom_testbus_config(host);
1607+
testbus[i] = ufshcd_readl(hba, UFS_TEST_BUS);
1608+
}
1609+
print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
1610+
16, 4, testbus, testbus_len, false);
1611+
}
1612+
}
1613+
15691614
static int ufs_qcom_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
15701615
const char *prefix, enum ufshcd_res id)
15711616
{
@@ -1688,6 +1733,11 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
16881733
/* Dump MCQ Host Vendor Specific Registers */
16891734
if (hba->mcq_enabled)
16901735
ufs_qcom_dump_mcq_hci_regs(hba);
1736+
1737+
/* voluntarily yield the CPU as we are dumping too much data */
1738+
ufshcd_dump_regs(hba, UFS_TEST_BUS, 4, "UFS_TEST_BUS ");
1739+
cond_resched();
1740+
ufs_qcom_dump_testbus(hba);
16911741
}
16921742
}
16931743

0 commit comments

Comments
 (0)