[PATCH 4/4] mmc: dw_mmc: expose the watchdog state in debugfs

From: Shawn Lin

Date: Thu Aug 27 2026 - 05:16:06 EST


Debugging hangs on the request legs now means asking 'what was the
watchdog guarding and until when?' Expose the awaited events, the
valid states, and the absolute deadline of the current watch next to
the existing pending_events/completed_events nodes; all three zero out
once a leg is settled or the watch fired.

Signed-off-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>

---

drivers/mmc/host/dw_mmc.c | 6 ++++++
drivers/mmc/host/dw_mmc.h | 1 +
2 files changed, 7 insertions(+)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 6852c05..ff0b25d 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -108,6 +108,7 @@ static void dw_mci_wd_arm(struct dw_mci *host, unsigned long ms,

host->wd_events = events;
host->wd_states = states;
+ host->wd_deadline_ns = ktime_get_ns() + (u64)ms * NSEC_PER_MSEC;
hrtimer_start(&host->wd_timer, ms_to_ktime(ms), HRTIMER_MODE_REL);
}

@@ -167,6 +168,7 @@ static enum hrtimer_restart dw_mci_watchdog_fn(struct hrtimer *t)

host->wd_events = 0;
host->wd_states = 0;
+ host->wd_deadline_ns = 0;

spin_unlock_irqrestore(&host->irq_lock, irqflags);

@@ -300,6 +302,10 @@ static void dw_mci_init_debugfs(struct dw_mci *host)
&host->pending_events);
debugfs_create_xul("completed_events", 0400, root,
&host->completed_events);
+ debugfs_create_x64("wd_deadline_ns", 0400, root,
+ &host->wd_deadline_ns);
+ debugfs_create_xul("wd_events", 0400, root, &host->wd_events);
+ debugfs_create_xul("wd_states", 0400, root, &host->wd_states);
#ifdef CONFIG_FAULT_INJECTION
fault_create_debugfs_attr("fail_data_crc", root, &host->fail_data_crc);
#endif
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index 7b70392..12b88e7 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -240,6 +240,7 @@ struct dw_mci {
struct hrtimer wd_timer;
unsigned long wd_events;
unsigned long wd_states;
+ u64 wd_deadline_ns;

#ifdef CONFIG_FAULT_INJECTION
struct fault_attr fail_data_crc;
--
2.7.4