From 7dbbd97cdbd31e3c874a114abef3de54ba100dcf Mon Sep 17 00:00:00 2001
From: Sabeeh Khan <sabeeh-khan@ti.com>
Date: Wed, 29 Apr 2026 16:04:25 -0500
Subject: [PATCH] wowlan-debug

---
 drivers/net/wireless/ti/cc33xx/main.c | 29 +++++++++++++++++++++++----
 drivers/net/wireless/ti/cc33xx/sdio.c | 13 ++++++++++--
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ti/cc33xx/main.c b/drivers/net/wireless/ti/cc33xx/main.c
index 41d595d955cfab..806736a1b14db9 100644
--- a/drivers/net/wireless/ti/cc33xx/main.c
+++ b/drivers/net/wireless/ti/cc33xx/main.c
@@ -1982,12 +1982,19 @@ static int __maybe_unused cc33xx_op_suspend(struct ieee80211_hw *hw,
 	struct cc33xx_vif *wlvif;
 	unsigned long flags;
 	int ret;
+	bool recovery_in_progress;
 
 	cc33xx_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow);
 	WARN_ON(!wow && !cc33xx_is_wowlan_search_enabled(wl));
 
+	recovery_in_progress = test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS,
+					      &wl->flags);
+	cc33xx_debug(DEBUG_MAC80211,
+		"mac suspend entry: wow=%d keep_device_power=%d recovery=%d suspended=%d\n",
+		!!wow, wl->keep_device_power, recovery_in_progress,
+		test_bit(CC33XX_FLAG_SUSPENDED, &wl->flags));
 	/* we want to perform the recovery before suspending */
-	if (test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &wl->flags)) {
+	if (recovery_in_progress) {
 		cc33xx_warning("postponing suspend to perform recovery");
 		return -EBUSY;
 	}
@@ -2034,7 +2041,10 @@ static int __maybe_unused cc33xx_op_suspend(struct ieee80211_hw *hw,
 	spin_lock_irqsave(&wl->wl_lock, flags);
 	set_bit(CC33XX_FLAG_SUSPENDED, &wl->flags);
 	spin_unlock_irqrestore(&wl->wl_lock, flags);
-
+	cc33xx_debug(DEBUG_MAC80211,
+		"mac suspend exit: ret=%d keep_device_power=%d suspended=%d\n",
+		ret, wl->keep_device_power,
+		test_bit(CC33XX_FLAG_SUSPENDED, &wl->flags));
 	return 0;
 }
 
@@ -2049,7 +2059,12 @@ static int __maybe_unused cc33xx_op_resume(struct ieee80211_hw *hw)
 	cc33xx_debug(DEBUG_MAC80211, "mac80211 resume wow=%d",
 		     wl->keep_device_power);
 	WARN_ON(!wl->keep_device_power);
-
+	cc33xx_debug(DEBUG_MAC80211,
+		"mac resume entry: keep_device_power=%d suspended=%d pending_work=%d recovery=%d\n",
+		wl->keep_device_power,
+		test_bit(CC33XX_FLAG_SUSPENDED, &wl->flags),
+		test_bit(CC33XX_FLAG_PENDING_WORK, &wl->flags),
+		test_bit(CC33XX_FLAG_RECOVERY_IN_PROGRESS, &wl->flags));
 	/*
 	 * re-enable irq_work enqueuing, and call irq_work directly if
 	 * there is a pending work.
@@ -2092,6 +2107,9 @@ static int __maybe_unused cc33xx_op_resume(struct ieee80211_hw *hw)
 	}
 
 out:
+	cc33xx_debug(DEBUG_MAC80211,
+		"mac resume pre-clear: ret=%d keep_device_power=%d run_irq_work=%d pending_recovery=%d\n",
+		ret, wl->keep_device_power, run_irq_work, pending_recovery);
 	wl->keep_device_power = false;
 
 	/*
@@ -2101,7 +2119,10 @@ static int __maybe_unused cc33xx_op_resume(struct ieee80211_hw *hw)
 	 */
 	set_bit(CC33XX_FLAG_REINIT_TX_WDOG, &wl->flags);
 	mutex_unlock(&wl->mutex);
-
+	cc33xx_debug(DEBUG_MAC80211,
+		"mac resume exit: ret=%d keep_device_power=%d suspended=%d\n",
+		ret, wl->keep_device_power,
+		test_bit(CC33XX_FLAG_SUSPENDED, &wl->flags));
 	return ret;
 }
 
diff --git a/drivers/net/wireless/ti/cc33xx/sdio.c b/drivers/net/wireless/ti/cc33xx/sdio.c
index 9f8ac19312506f..bfef16ed41c56b 100644
--- a/drivers/net/wireless/ti/cc33xx/sdio.c
+++ b/drivers/net/wireless/ti/cc33xx/sdio.c
@@ -554,6 +554,8 @@ static int cc33xx_suspend(struct device *dev)
 	struct cc33xx_sdio_glue *glue = sdio_get_drvdata(func);
 	struct cc33xx *wl = platform_get_drvdata(glue->core);
 	mmc_pm_flag_t sdio_flags;
+	bool wowlan_configured = wl && wl->hw && wl->hw->wiphy &&
+					wl->hw->wiphy->wowlan_config;
 	int ret = 0;
 
 	if (!wl) {
@@ -561,8 +563,9 @@ static int cc33xx_suspend(struct device *dev)
 		goto out;
 	}
 
-	dev_dbg(dev, "cc33xx suspend. keep_device_power: %d\n",
-		wl->keep_device_power);
+	dev_dbg(dev,
+		"sdio suspend entry: keep_device_power=%d wowlan_configured=%d\n",
+		READ_ONCE(wl->keep_device_power), wowlan_configured);
 
 	if (wl->keep_device_power) {
 		sdio_flags = sdio_get_host_pm_caps(func);
@@ -580,8 +583,14 @@ static int cc33xx_suspend(struct device *dev)
 			dev_err(dev, "error while trying to keep power\n");
 			goto out;
 		}
+
+		dev_dbg(dev, "sdio suspend: requested MMC_PM_KEEP_POWER\n");
+	} else {
+		dev_dbg(dev,
+			"sdio suspend: not requesting MMC_PM_KEEP_POWER\n");
 	}
 out:
+	dev_dbg(dev, "sdio suspend exit: ret=%d\n", ret);
 	return ret;
 }
 
-- 
2.34.1

