public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Masi Osmani <mas-i@hotmail.de>
To: Christian Lamparter <chunkeey@googlemail.com>
Cc: linux-wireless@vger.kernel.org, Masi Osmani <mas-i@hotmail.de>
Subject: [PATCH 14/16] carl9170: main: guard op_config and bss_info_changed against non-STARTED state
Date: Tue, 17 Mar 2026 12:06:32 +0100	[thread overview]
Message-ID: <AM7PPF5613FA0B6FDA6759CDCBE2421A8039441A@AM7PPF5613FA0B6.EURP251.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20260317110634.70347-1-mas-i@hotmail.de>

During driver deregistration (USB unbind or restart), mac80211 calls
carl9170_op_config() and carl9170_op_bss_info_changed() which write
hardware registers such as AR9170_MAC_REG_SLOT_TIME (0x1c36f0) via
carl9170_set_slot_time().  At this point the firmware is already dead:
carl9170_restart() has transitioned the state machine from STARTED to
IDLE, and IS_ACCEPTING_CMD() returns true for IDLE (state >= IDLE),
so the USB command is attempted but times out with -EIO:

  ieee80211 phy31: writing reg 0x1c36f0 (val 0x2400) failed (-5)
  ieee80211 phy31: writing reg 0x1c36f0 (val 0x5000) failed (-5)

When wavemon or NetworkManager trigger rapid USB unbind/rebind
recovery cycles, each deregistration produces these -EIO errors.
Over 30+ cycles this exhausts mac80211 resources and causes a
kernel panic.

Add early returns if !IS_STARTED(ar) to both carl9170_op_config()
and carl9170_op_bss_info_changed() to prevent all hardware register
writes when the device is not fully operational.

Signed-off-by: Masi Osmani <mas-i@hotmail.de>
---
 drivers/net/wireless/ath/carl9170/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index dcedcb1..a1b2c3d 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -926,6 +926,13 @@ static int carl9170_op_config(struct ieee80211_hw *hw, int radio_idx, u32 change
 	struct ar9170 *ar = hw->priv;
 	int err = 0;

+	/*
+	 * All register writes below require running firmware.
+	 * Bail out early during teardown or restart (state != STARTED).
+	 */
+	if (!IS_STARTED(ar))
+		return 0;
+
 	mutex_lock(&ar->mutex);
 	if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) {
 		/* TODO */
@@ -1077,6 +1084,13 @@ static void carl9170_op_bss_info_changed(struct ieee80211_hw *hw,
 	struct carl9170_vif_info *vif_priv;
 	struct ieee80211_vif *main_vif;

+	/*
+	 * All register writes below require running firmware.
+	 * Bail out early during teardown or restart (state != STARTED).
+	 */
+	if (!IS_STARTED(ar))
+		return;
+
 	mutex_lock(&ar->mutex);
 	vif_priv = (void *) vif->drv_priv;
 	main_vif = carl9170_get_main_vif(ar);
--
2.51.0

       reply	other threads:[~2026-03-17 11:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260317110634.70347-1-mas-i@hotmail.de>
2026-03-17 11:06 ` Masi Osmani [this message]
2026-03-21 22:28   ` [PATCH 14/16] carl9170: main: guard op_config and bss_info_changed against non-STARTED state Christian Lamparter
2026-03-17 11:06 ` [PATCH 15/16] carl9170: phy: warm BB reset and same-channel no-op Masi Osmani
2026-03-17 11:06 ` [PATCH 16/16] carl9170: cmd: downgrade transient register I/O errors to wiphy_dbg Masi Osmani
2026-03-21 22:41   ` Christian Lamparter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM7PPF5613FA0B6FDA6759CDCBE2421A8039441A@AM7PPF5613FA0B6.EURP251.PROD.OUTLOOK.COM \
    --to=mas-i@hotmail.de \
    --cc=chunkeey@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox