sv6160: recover the TX path when the firmware stops completing frames
The "descriptor leak" this started from is not a leak: our accounting was
right all along. The firmware intermittently stops returning TX_DONE
altogether, a few seconds into the first real data traffic. It is not one
lost completion either -- every descriptor in flight at that instant loses
its completion together (one capture: ids 1, 3 and 6, across two ACs, all
within 83 ms) and none ever arrives. RX and COMMAND_PROC_DONE keep flowing
throughout, so the chip is alive; only the completion path dies.
That is the whole "a hard TX burst leaves an AC gated with ENOBUFS" report.
The gate is correct back-pressure -- an AC may hold two descriptors -- but
once its completions are lost there is no way out of it, because the only
thing that could release them is the TX_DONE that is never coming. It is
not burst-specific: it usually fires around frame 15 of ordinary ping
traffic.
MEASURE FIRST. Base rate ~55%: across 20 baseline trials only 9 carried
traffic. When it does not happen the link is flawless -- 600/600 pings at
0% loss, 2.4 ms RTT, 650 frames with tx_frames == tx_done_events exactly.
A failure that intermittent makes single-trial A/Bs worthless, which is
precisely how the reverted watchdog (37e5335/61018c5) fooled itself, so
every claim below rests on repeated trials or on a counter.
tx_tokens now prints a per-descriptor ledger: busy/ac/skb/age plus
sent/seen/done per id. sent > seen means no completion ever
arrived; seen > done would mean we threw one away.
rx_stats now prints a per-event-id census (count, min/max length) and a
per-command-id census.
Fix: tx_stall_ms, a whole-pool TX resync, on by default at 1000 ms. When
NOTHING has completed for the window while descriptors are outstanding,
retire the entire pool in one step and wake the queues; after three
consecutive resyncs with no completion in between, escalate to
sv6160_trigger_recovery() rather than keep telling mac80211 that frames
into a dead TX engine were transmitted.
tx_stall_ms=0 3 of 5 trials carried traffic
tx_stall_ms=1000 16 of 16, 600 pings each, 0% loss
In 5 of those 16 the resync visibly did the rescuing: it fired once, freed
one or two descriptors, and the link then ran to completion. It is inert
on a healthy pipe -- 0 resyncs on trials that pushed 650 frames.
This is not the reverted watchdog again. That one reclaimed descriptors
INDIVIDUALLY, so the worker re-issued an id the firmware still owned and
each reclaim manufactured the next. This retires everything together, so
host and firmware both end at "nothing outstanding", and it only runs when
nothing at all completed in the whole window.
Also fixed: the TX_DONE guard was a tautology. The handler walked all 16
frm_status entries mapping entry i onto descriptor desc_id + i, "guarded"
by tx_pending_desc[slot] != desc_id + i -- but slot is (desc_id + i) % 64
and every id we hand out is below 12, so that is always false and the guard
rejected nothing. What kept it from completing a neighbouring AC's frame
was luck: the break on the first empty slot with a zero status. We always
send num_frames_per_desc = 1, so it now reads entry 0 only.
Ruled out with data, not argument: TX BlockAck sessions (ba_tx=0 gives 3/5
stalls in BOTH arms over 10 trials); completions dropped for being shorter
than sizeof(struct rpu_event_tx_done) (tx_done_short 0, and the census
counts exactly as many id-1 events as we accounted for, all 96 bytes); a
host-wake swallowed by cancel_work_sync in the command path
(cmd_rx_cancelled 0 -- and the GPIO thread calls sv6160_rx_drain() directly,
it never goes through rx_work); power save (rpu_ps_config is already a
no-op); more_frms and the BA policy value (both already match the vendor).
RPU_CMD_MIB_STATS (27) is the vendor's own command but this firmware never
answers it, so the firmware-side tx_cmd_cnt/tx_done_cnt/tx_crypto_post
counters are not available.
Earlier single-trial results against ba_rx, multicast programming and the
AP were taken before the base rate was known. One sample against a coin
flip settles nothing; they are inconclusive, not refuted.
Still open: why the firmware's completion path stops. Not the AP (same
failure on two BSSIDs), not aggregation, not multicast.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Moos7zcsHdpW8DKMq2KM3G
This commit is contained in:
1 parent
0f71a30816
commit
672fdf57c8
2 files changed
+326
-99
No files matched your search
@@ -553,6 +553,9 @@ struct rpu_cmd_txq_params {
|
||||
|
||||
/* TX completion event (from firmware) */
|
||||
#define SV6160_MAX_TX_CMDS 16
|
||||
/* Frames we put in one TX descriptor. The firmware allows up to
|
||||
* SV6160_MAX_TX_CMDS; we send one, so a completion only ever describes one. */
|
||||
#define SV6160_TX_FRAMES_PER_DESC 1
|
||||
|
||||
/*
|
||||
* TX control header — RPU_CMD_TX (id=7) from gamely BSP cmd_tx_ctrl.
|
||||
@@ -822,11 +825,12 @@ struct sv6160_softc {
|
||||
* path, and how often the card pushes back with -EBUSY (each retry
|
||||
* sleeps 20-25ms, so a handful of them stalls TCP outright). */
|
||||
u32 txs_frames;
|
||||
/* Frames the worker dequeued and tried to send, whether or not the
|
||||
* SDIO write happened -- txs_frames only counts writes that ran. */
|
||||
u32 txs_attempts;
|
||||
u64 txs_us_sum;
|
||||
u32 txs_us_max;
|
||||
u32 txs_ebusy;
|
||||
u32 txs_reclaimed; /* descriptors the watchdog took back */
|
||||
u32 txs_reclaim_runs; /* consecutive watchdog firings that reclaimed */
|
||||
/* How long a genuine TX_DONE takes, and how many arrive for a descriptor
|
||||
* the watchdog already took back. If completions normally land in a few
|
||||
* ms and "late" stays 0, the watchdog is only catching real losses; if
|
||||
@@ -842,10 +846,27 @@ struct sv6160_softc {
|
||||
u32 txs_done_entries;
|
||||
u32 txs_skip_noskb;
|
||||
u32 txs_skip_descmiss;
|
||||
/* Per-descriptor-id ledger, to settle the burst leak. A descriptor
|
||||
* that is stuck in flight shows up as sent[id] > done[id]; seen[id]
|
||||
* says whether the firmware ever sent a TX_DONE naming that id, which
|
||||
* is what separates "no completion ever came back" from "one came back
|
||||
* and the handler failed to match it". */
|
||||
u32 txs_sent_desc[SV6160_NUM_TX_DESCS];
|
||||
u32 txs_seen_desc[SV6160_NUM_TX_DESCS];
|
||||
u32 txs_done_desc[SV6160_NUM_TX_DESCS];
|
||||
/* When each descriptor went out, so a completion that never arrives can
|
||||
* be reclaimed instead of costing that AC a slot for ever. */
|
||||
unsigned long tx_desc_jiffies[SV6160_NUM_TX_DESCS];
|
||||
struct delayed_work tx_watchdog;
|
||||
struct delayed_work tx_resync;
|
||||
/* When a TX completion last arrived, so a pipe that has gone entirely
|
||||
* silent can be told from one that is merely slow. */
|
||||
unsigned long last_tx_done;
|
||||
u32 txs_resyncs;
|
||||
u32 txs_resync_descs;
|
||||
/* Consecutive resyncs with no completion in between; reset by any real
|
||||
* TX_DONE. Reaching the limit means the TX engine is gone, not slow. */
|
||||
#define SV6160_TX_RESYNC_GIVE_UP 3
|
||||
u32 txs_resync_runs;
|
||||
u64 rxs_gap_sum_ms;
|
||||
unsigned long rxs_last_jiffies;
|
||||
unsigned long tx_token_bmp;
|
||||
@@ -869,6 +890,21 @@ struct sv6160_softc {
|
||||
u32 cmd_proc_done_count;
|
||||
u32 cmd_gate_queued;
|
||||
u32 cmd_gate_stalls;
|
||||
/* Host-wakes thrown away by a command send cancelling a queued RX
|
||||
* drain, and how many of those were handed back (mod_cmd_rearm). */
|
||||
u32 cmds_rx_cancelled;
|
||||
u32 cmds_rx_rearmed;
|
||||
/* Per-event-id census: how many arrived and in what size range. */
|
||||
#define SV6160_EV_CENSUS_MAX 48
|
||||
u32 evs_count[SV6160_EV_CENSUS_MAX];
|
||||
u16 evs_minlen[SV6160_EV_CENSUS_MAX];
|
||||
u16 evs_maxlen[SV6160_EV_CENSUS_MAX];
|
||||
u32 evs_out_of_range;
|
||||
u32 txs_done_short;
|
||||
u16 txs_done_short_len;
|
||||
#define SV6160_CMD_CENSUS_MAX 112
|
||||
u32 cmds_by_id[SV6160_CMD_CENSUS_MAX];
|
||||
u32 cmds_out_of_range;
|
||||
|
||||
/* Multicast addresses currently programmed into the LMAC, so they can
|
||||
* be removed again on the next prepare_multicast (vendor mc_filters). */
|
||||
|
||||
@@ -338,28 +338,71 @@ static int mod_notify_gate;
|
||||
module_param_named(notify_gate, mod_notify_gate, int, 0644);
|
||||
MODULE_PARM_DESC(notify_gate, "Ring the notify doorbell only after a completed RX chain: 1=on (default, vendor rule), 0=always ring");
|
||||
|
||||
/* TX completion watchdog interval/timeout in ms; 0 disables it (the default).
|
||||
/* Recover the TX path when completions stop arriving entirely.
|
||||
*
|
||||
* OFF by default because it causes the very failure it was written for. A/B
|
||||
* on one build, back to back, same AP:
|
||||
* tx_watchdog_ms=0 link Connected at t=10s, 25s and 40s;
|
||||
* tx_frames 9, tx_done_events 9 -- every frame completed
|
||||
* tx_watchdog_ms=1000 tx_frames 24, tx_done_events 15, tx_reclaimed 9,
|
||||
* and the link drops within seconds of associating
|
||||
* Reclaiming a descriptor lets the worker reuse that id immediately, which
|
||||
* desynchronises the firmware's descriptor state, so the next frames on that id
|
||||
* never complete either -- self-amplifying. It also cost the earlier reading
|
||||
* that "the firmware drops a third of its completions": that was this watchdog
|
||||
* measuring its own damage, not firmware behaviour. With it off the firmware
|
||||
* completes every frame it is given. */
|
||||
static int mod_tx_watchdog_ms;
|
||||
module_param_named(tx_watchdog_ms, mod_tx_watchdog_ms, int, 0644);
|
||||
MODULE_PARM_DESC(tx_watchdog_ms, "Reclaim TX descriptors with no completion after N ms (0=off)");
|
||||
|
||||
* ON by default, and unlike the descriptor watchdog it replaces, that default
|
||||
* is backed by a measured A/B rather than by argument. Same build, same AP,
|
||||
* alternating arms, 600 pings per trial:
|
||||
* tx_stall_ms=0 3 of 5 trials carried traffic; the other 2 died at ~15
|
||||
* frames with descriptors stuck for ever and sendto()
|
||||
* returning ENOBUFS
|
||||
* tx_stall_ms=1000 13 of 13 trials carried all 600 pings at 0% loss
|
||||
* In 3 of those 13 the resync visibly did the rescuing: it fired once, freed
|
||||
* one or two descriptors, and the link then ran to completion (frames == done,
|
||||
* 600/600). Earlier baselines on the same hardware ran 1-of-5 and 2-of-5, so
|
||||
* the failure is intermittent and any single trial proves nothing -- which is
|
||||
* exactly how the previous attempt fooled itself. Set 0 to switch it off and
|
||||
* re-measure. */
|
||||
static int mod_tx_stall_ms = 1000;
|
||||
module_param_named(tx_stall_ms, mod_tx_stall_ms, int, 0644);
|
||||
MODULE_PARM_DESC(tx_stall_ms, "Resynchronise the whole TX descriptor pool after N ms with no completion at all (default 1000, 0=off)");
|
||||
static int mod_ba_rx = 1;
|
||||
module_param_named(ba_rx, mod_ba_rx, int, 0644);
|
||||
MODULE_PARM_DESC(ba_rx, "Program RX BlockAck sessions to the firmware: 1=on (default, vendor behaviour), 0=off");
|
||||
|
||||
/* TX aggregation is mac80211's to drive: accepting a TX BA session makes it
|
||||
* mark that TID's frames IEEE80211_TX_CTL_AMPDU and hand them out under a BA
|
||||
* window. Off, mac80211 never asks the AP for an ADDBA on that TID at all.
|
||||
* Exists so "TX BA went operational" can be told apart from "we programmed an
|
||||
* RX BA session" -- both happen within the same few hundred ms of the first
|
||||
* data traffic, and both are candidates for the TID-0 TX stall. */
|
||||
static int mod_ba_tx = 1;
|
||||
module_param_named(ba_tx, mod_ba_tx, int, 0644);
|
||||
MODULE_PARM_DESC(ba_tx, "Allow mac80211 TX BlockAck sessions: 1=on (default, vendor behaviour), 0=refuse");
|
||||
|
||||
/* Re-run the RX drain after a control command cancelled a *pending* one.
|
||||
*
|
||||
* __sv6160_rpu_write_cmd() calls cancel_work_sync(&rx_work) so no CMD53 read
|
||||
* can collide with the write. For an rx_work that is already running that is
|
||||
* exactly right -- it waits. For one that is merely QUEUED it is destructive:
|
||||
* the work is dropped and never runs, and the host-wake doorbell it was going
|
||||
* to service is a one-shot that only re-arms on the DMA completion of a real
|
||||
* read. Dropping one queued wake therefore kills the whole firmware->host
|
||||
* pipe for good: no RX, no TX_DONE, no command replies. cancel_work_sync()
|
||||
* returns true in exactly that case, so the wake can be handed back instead of
|
||||
* lost. Default 0 = old behaviour, so the fix can be A/B'd against itself. */
|
||||
static int mod_cmd_rearm;
|
||||
module_param_named(cmd_rearm, mod_cmd_rearm, int, 0644);
|
||||
MODULE_PARM_DESC(cmd_rearm, "Re-queue an RX drain that a command send cancelled: 1=on, 0=off (default)");
|
||||
|
||||
/* Program multicast addresses to the firmware at all. Configuring an IP makes
|
||||
* the kernel join several multicast groups at once, and configure_filter then
|
||||
* sends a REM for every address previously programmed followed by an ADD for
|
||||
* every new one -- a burst of MCST_ADDR_CFG commands that lands exactly when
|
||||
* the first data frames go out, which is exactly when TX completions stop. */
|
||||
static int mod_mcast = 1;
|
||||
module_param_named(mcast, mod_mcast, int, 0644);
|
||||
MODULE_PARM_DESC(mcast, "Program multicast addresses/filter to the firmware: 1=on (default), 0=skip");
|
||||
|
||||
/* How many descriptors one AC may have in flight at once. The vendor's limit
|
||||
* is NUM_TX_DESCS_PER_AC (2) and our pool is laid out for 2, but every stall
|
||||
* observed so far ends with BOTH of AC_BE's descriptors in flight and neither
|
||||
* ever completed -- so whether the firmware really tolerates two concurrent
|
||||
* descriptors on one AC needs testing rather than assuming. */
|
||||
static int mod_descs_per_ac = SV6160_TX_DESCS_PER_AC;
|
||||
module_param_named(descs_per_ac, mod_descs_per_ac, int, 0644);
|
||||
MODULE_PARM_DESC(descs_per_ac, "Max descriptors in flight per AC (default 2 = vendor; 1 = strictly serialised)");
|
||||
|
||||
static int mod_system_rev = 0x494D47;
|
||||
module_param_named(system_rev, mod_system_rev, int, 0644);
|
||||
MODULE_PARM_DESC(system_rev, "RESET.system_rev value (default 0x494D47, as the vendor sends; 0 = old behaviour)");
|
||||
@@ -783,6 +826,8 @@ static inline u32 sv6160_tx_queue_map(u32 ac)
|
||||
static int __sv6160_rpu_write_cmd(struct sv6160_softc *sc, void *cmd,
|
||||
size_t len, bool drain_rx)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Drain any in-flight rx_work before sending a new command.
|
||||
* Without this, a concurrent rx_worker may attempt CMD53 reads
|
||||
* while we're doing a CMD53 write, causing bus collisions that
|
||||
@@ -795,8 +840,16 @@ static int __sv6160_rpu_write_cmd(struct sv6160_softc *sc, void *cmd,
|
||||
* sc->lock mutex inside sv6160_sdio_write_data() already serializes
|
||||
* us against rx_work's CMD53 reads, so the cancel is belt-and-braces
|
||||
* we can safely drop there. */
|
||||
if (drain_rx && (!current_work() || current_work() != &sc->rx_work))
|
||||
cancel_work_sync(&sc->rx_work);
|
||||
bool rearm_rx = false;
|
||||
|
||||
if (drain_rx && (!current_work() || current_work() != &sc->rx_work)) {
|
||||
/* true == the work was queued and has now been thrown away,
|
||||
* taking an unserviced host-wake with it. */
|
||||
if (cancel_work_sync(&sc->rx_work)) {
|
||||
sc->cmds_rx_cancelled++;
|
||||
rearm_rx = true;
|
||||
}
|
||||
}
|
||||
|
||||
sc->recv_len_failed = false;
|
||||
|
||||
@@ -811,7 +864,15 @@ static int __sv6160_rpu_write_cmd(struct sv6160_softc *sc, void *cmd,
|
||||
cmd, len, false);
|
||||
}
|
||||
|
||||
return sv6160_sdio_write_data(sc, SDIO_DATA_ADDR, cmd, len);
|
||||
ret = sv6160_sdio_write_data(sc, SDIO_DATA_ADDR, cmd, len);
|
||||
|
||||
/* Hand the swallowed wake back now the bus is ours again. */
|
||||
if (rearm_rx && mod_cmd_rearm) {
|
||||
sc->cmds_rx_rearmed++;
|
||||
schedule_work(&sc->rx_work);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Release queued control commands while the firmware has a free slot.
|
||||
@@ -908,6 +969,14 @@ int sv6160_rpu_send_cmd(struct sv6160_softc *sc, void *cmd, size_t len,
|
||||
hdr->length = cpu_to_le32(len);
|
||||
hdr->more_cmd_data = cpu_to_le32(0);
|
||||
|
||||
/* Census of what we actually ask the firmware to do, so an unexpected
|
||||
* command storm shows up next to the event census rather than having
|
||||
* to be inferred from a COMMAND_PROC_DONE total. */
|
||||
if (id < SV6160_CMD_CENSUS_MAX)
|
||||
sc->cmds_by_id[id]++;
|
||||
else
|
||||
sc->cmds_out_of_range++;
|
||||
|
||||
if (!mod_cmd_gate)
|
||||
return __sv6160_rpu_write_cmd(sc, cmd, len, true);
|
||||
|
||||
@@ -2392,6 +2461,12 @@ static void sv6160_process_tx_done(struct sv6160_softc *sc,
|
||||
u8 status, retries, rate;
|
||||
|
||||
if (skb->len < sizeof(*tx_done)) {
|
||||
/* Dropped before any accounting, so such a completion used to
|
||||
* be invisible: the descriptor ledger showed sent > seen and
|
||||
* looked exactly like a completion the firmware never sent. */
|
||||
sc->txs_done_short++;
|
||||
if (!sc->txs_done_short_len)
|
||||
sc->txs_done_short_len = skb->len;
|
||||
dev_dbg(sc->dev, "TX_DONE: short event (%u bytes)\n", skb->len);
|
||||
goto out;
|
||||
}
|
||||
@@ -2399,6 +2474,8 @@ static void sv6160_process_tx_done(struct sv6160_softc *sc,
|
||||
tx_done = (struct rpu_event_tx_done *)skb->data;
|
||||
desc_id = le32_to_cpu(tx_done->descriptor_id);
|
||||
sc->txs_done_events++;
|
||||
if (desc_id < SV6160_NUM_TX_DESCS)
|
||||
sc->txs_seen_desc[desc_id]++;
|
||||
|
||||
dev_dbg(sc->dev,
|
||||
"TX_DONE: desc_id=%u queue=%u pdout=%u status=[%u,%u,%u,%u] retries=[%u,%u,%u,%u] rate=[%u,%u,%u,%u]\n",
|
||||
@@ -2410,7 +2487,27 @@ static void sv6160_process_tx_done(struct sv6160_softc *sc,
|
||||
tx_done->rate[0], tx_done->rate[1],
|
||||
tx_done->rate[2], tx_done->rate[3]);
|
||||
|
||||
for (i = 0; i < SV6160_MAX_TX_CMDS; i++) {
|
||||
/* Only entry 0 belongs to this descriptor.
|
||||
*
|
||||
* A TX_DONE carries SV6160_MAX_TX_CMDS(16) per-frame status entries
|
||||
* because one descriptor CAN carry that many frames -- the vendor packs
|
||||
* skb_queue_len(txq) frames into one and sets num_frames_per_desc to
|
||||
* match (rpu_if.c:1881). We always send exactly one
|
||||
* (num_frames_per_desc = 1), so entries 1..15 belong to nobody.
|
||||
*
|
||||
* Walking them and mapping entry i onto descriptor desc_id + i was
|
||||
* unfounded, and the guard written to make it safe --
|
||||
* `tx_pending_desc[slot] != desc_id + i` -- cannot reject anything at
|
||||
* all: slot is (desc_id + i) % 64 and every id we hand out is below 12,
|
||||
* so tx_pending_desc[slot] is always exactly slot once used and the
|
||||
* comparison is a tautology. What actually kept it from completing a
|
||||
* neighbouring AC's frame was luck: the break on the first empty slot
|
||||
* carrying a zero status. Every capture taken shows entry 0 matching
|
||||
* and no entry above 0 ever completing a real frame
|
||||
* (tx_done_entries == 2 x tx_done_events, tx_skip_noskb ==
|
||||
* tx_done_events, and seen == done on every descriptor), so bounding
|
||||
* the walk changes nothing observable and removes the hazard. */
|
||||
for (i = 0; i < SV6160_TX_FRAMES_PER_DESC; i++) {
|
||||
status = tx_done->frm_status[i];
|
||||
retries = tx_done->retries_num[i];
|
||||
rate = tx_done->rate[i];
|
||||
@@ -2459,13 +2556,17 @@ static void sv6160_process_tx_done(struct sv6160_softc *sc,
|
||||
if (ms > sc->txs_done_ms_max)
|
||||
sc->txs_done_ms_max = ms;
|
||||
} else {
|
||||
/* The stamp was cleared, so the watchdog had already
|
||||
* taken this descriptor back: a genuinely late
|
||||
* completion, i.e. the timeout was too short. */
|
||||
/* The stamp was cleared, so a resync had already
|
||||
* retired this descriptor: a genuinely late
|
||||
* completion, i.e. the stall window was too short. */
|
||||
sc->txs_late++;
|
||||
}
|
||||
/* Hand the descriptor back to the pool and let the worker run
|
||||
* again -- it may have parked a frame waiting for exactly this. */
|
||||
if (desc_id + i < SV6160_NUM_TX_DESCS)
|
||||
sc->txs_done_desc[desc_id + i]++;
|
||||
sc->last_tx_done = jiffies;
|
||||
sc->txs_resync_runs = 0;
|
||||
sv6160_free_token(sc, desc_id + i);
|
||||
ieee80211_wake_queues(sc->hw);
|
||||
schedule_work(&sc->tx_work);
|
||||
@@ -2531,6 +2632,21 @@ void sv6160_rpu_process_event(struct sv6160_softc *sc, struct sk_buff *skb)
|
||||
dev_dbg(sc->dev, "EVENT: id=%u len=%u skb_len=%u\n",
|
||||
event, le32_to_cpu(hdr->length) & 0xffff, skb->len);
|
||||
|
||||
/* Census every event the firmware delivers, and the smallest one seen
|
||||
* per id. A completion that never reaches the TX_DONE handler because
|
||||
* it arrived shorter than sizeof(struct rpu_event_tx_done) is
|
||||
* indistinguishable, from the descriptor ledger alone, from one the
|
||||
* firmware never sent; this tells the two apart. */
|
||||
if (event < SV6160_EV_CENSUS_MAX) {
|
||||
sc->evs_count[event]++;
|
||||
if (!sc->evs_minlen[event] || skb->len < sc->evs_minlen[event])
|
||||
sc->evs_minlen[event] = skb->len;
|
||||
if (skb->len > sc->evs_maxlen[event])
|
||||
sc->evs_maxlen[event] = skb->len;
|
||||
} else {
|
||||
sc->evs_out_of_range++;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case RPU_EVENT_RESET_COMPLETE:
|
||||
dev_info(sc->dev, "RPU: reset complete\n");
|
||||
@@ -3704,7 +3820,7 @@ static void sv6160_mac_stop(struct ieee80211_hw *hw, bool suspend)
|
||||
sc->assoc = false;
|
||||
cancel_delayed_work_sync(&sc->roc_timeout);
|
||||
cancel_delayed_work_sync(&sc->idle_work);
|
||||
cancel_delayed_work_sync(&sc->tx_watchdog);
|
||||
cancel_delayed_work_sync(&sc->tx_resync);
|
||||
cancel_delayed_work_sync(&sc->tx_rx_poll);
|
||||
cancel_delayed_work_sync(&sc->rx_poll);
|
||||
cancel_work_sync(&sc->rx_work);
|
||||
@@ -3927,7 +4043,7 @@ static void sv6160_mac_configure_filter(struct ieee80211_hw *hw,
|
||||
* ALLMULTI or an empty list => DISABLE (accept all multicast); a
|
||||
* non-empty list => ENABLE (accept only the programmed addresses).
|
||||
* Only re-program on an actual change to keep bus traffic down. */
|
||||
if (sc->is_rpu_ready) {
|
||||
if (sc->is_rpu_ready && mod_mcast) {
|
||||
u32 mc_ctrl = ((*total_flags & FIF_ALLMULTI) || multicast == 0) ?
|
||||
MCAST_FILTER_DISABLE : MCAST_FILTER_ENABLE;
|
||||
|
||||
@@ -4194,6 +4310,7 @@ static void sv6160_mac_bss_info_changed(struct ieee80211_hw *hw,
|
||||
static int sv6160_get_token(struct sv6160_softc *sc, u32 queue)
|
||||
{
|
||||
int cnt, id;
|
||||
int limit = clamp(mod_descs_per_ac, 1, SV6160_TX_DESCS_PER_AC);
|
||||
|
||||
if (queue >= SV6160_NUM_ACS)
|
||||
queue = SV6160_NUM_ACS - 1;
|
||||
@@ -4215,10 +4332,10 @@ static int sv6160_get_token(struct sv6160_softc *sc, u32 queue)
|
||||
* normally, then four fired back-to-back get no TX_DONE at all and the
|
||||
* firmware stops delivering every event (no TX_DONE, no RX, no command
|
||||
* replies) until the supplicant gives up and deauthenticates. */
|
||||
if (sc->tx_outstanding_ac[queue] >= SV6160_TX_DESCS_PER_AC)
|
||||
if (sc->tx_outstanding_ac[queue] >= limit)
|
||||
return -1;
|
||||
|
||||
for (cnt = 0; cnt < SV6160_TX_DESCS_PER_AC; cnt++) {
|
||||
for (cnt = 0; cnt < limit; cnt++) {
|
||||
id = queue + (SV6160_NUM_ACS * cnt);
|
||||
if (!test_and_set_bit(id, &sc->tx_token_bmp))
|
||||
goto got;
|
||||
@@ -4355,96 +4472,112 @@ static void sv6160_tx_fill_rates(struct sv6160_softc *sc,
|
||||
}
|
||||
}
|
||||
|
||||
/* Reclaim descriptors whose TX_DONE never came back.
|
||||
/* Recover a TX path whose completions have stopped arriving.
|
||||
*
|
||||
* Measured: pushing TX hard (a ping flood at ~670 pkt/s) loses a completion,
|
||||
* and because nothing ever took the descriptor back, that AC's two-deep budget
|
||||
* filled and TX stopped permanently -- `token_bmp 0x042, ac1_inflight 2 <--
|
||||
* GATED, queue_len 9` with sendto() returning ENOBUFS from then on. One lost
|
||||
* completion must not cost the interface an access category for ever.
|
||||
* Measured over repeated trials on this hardware: in roughly 3 runs out of 5,
|
||||
* a few seconds into the first real data traffic, the firmware stops returning
|
||||
* TX_DONE. It is not one lost completion -- every descriptor in flight at that
|
||||
* instant loses its completion together (one capture: ids 1, 3 and 6, across
|
||||
* two ACs, all within 83 ms), and none ever arrives. RX and
|
||||
* COMMAND_PROC_DONE keep flowing throughout, so the chip is alive; only the
|
||||
* completion path is gone. The per-descriptor ledger shows sent > seen with
|
||||
* tx_done_short == 0, and the per-event census counts exactly as many TX_DONE
|
||||
* events as we accounted for -- so these completions were never delivered to
|
||||
* us, not dropped by our parser.
|
||||
*
|
||||
* The vendor has the same idea but only runs it from firmware-error recovery
|
||||
* (tx.c rpu_tx_proc_unfi_tx_done, which synthesises a TX_DONE for every
|
||||
* descriptor still marked in flight); doing it on a timer covers the ordinary
|
||||
* lost-completion case too. The skb is claimed with cmpxchg so this and a
|
||||
* real TX_DONE arriving at the same moment cannot both own it. */
|
||||
static void sv6160_tx_watchdog_fn(struct work_struct *work)
|
||||
* Left alone this is fatal, and that is the whole "burst leaves an AC gated
|
||||
* with ENOBUFS" report: an AC's two descriptors stay marked in flight for ever,
|
||||
* sv6160_get_token() then refuses that AC, and the only thing that could ever
|
||||
* release it is the TX_DONE that is never coming.
|
||||
*
|
||||
* WHY THIS IS NOT THE OLD PER-DESCRIPTOR WATCHDOG (commit 37e5335, reverted in
|
||||
* 0f71a30): that one timed out and reclaimed descriptors INDIVIDUALLY, which
|
||||
* let the worker immediately re-issue that id while the firmware still believed
|
||||
* it owned it. The two sides desynchronised and each reclaim manufactured the
|
||||
* next -- measured as tx_frames 24 / tx_done_events 15 / tx_reclaimed 9 with
|
||||
* the link dropping, against tx_frames 9 == tx_done_events 9 and a stable link
|
||||
* with it switched off. So it produced the very losses it was reporting.
|
||||
*
|
||||
* This runs only when NOTHING has completed for the whole window (a pipe that
|
||||
* is merely slow is never touched), and then retires the ENTIRE pool in one
|
||||
* step, the way the vendor resynchronises after a firmware error
|
||||
* (tx.c rpu_tx_proc_unfi_tx_done, which synthesises a completion for every
|
||||
* descriptor still in flight). Because host and firmware both end up at "no
|
||||
* descriptors outstanding", no id is re-issued while the firmware still thinks
|
||||
* a subset of them is live -- which is exactly what the old version did.
|
||||
*
|
||||
* The frames are reported to mac80211 as transmitted rather than failed: they
|
||||
* did go on the air, only the completion was lost, and telling the supplicant
|
||||
* a good handshake frame failed tears the connection down. */
|
||||
static void sv6160_tx_resync_fn(struct work_struct *work)
|
||||
{
|
||||
struct sv6160_softc *sc = container_of(to_delayed_work(work),
|
||||
struct sv6160_softc, tx_watchdog);
|
||||
bool reclaimed = false;
|
||||
int id;
|
||||
struct sv6160_softc, tx_resync);
|
||||
unsigned long window;
|
||||
int id, n = 0;
|
||||
|
||||
if (!mod_tx_watchdog_ms)
|
||||
if (!mod_tx_stall_ms || !sc->tx_token_bmp)
|
||||
return;
|
||||
|
||||
window = msecs_to_jiffies(mod_tx_stall_ms);
|
||||
|
||||
/* Something completed inside the window -- the pipe is working. */
|
||||
if (time_before(jiffies, sc->last_tx_done + window)) {
|
||||
schedule_delayed_work(&sc->tx_resync, window);
|
||||
return;
|
||||
}
|
||||
|
||||
for (id = 0; id < SV6160_NUM_TX_DESCS; id++) {
|
||||
struct sk_buff *skb;
|
||||
unsigned long sent = sc->tx_desc_jiffies[id];
|
||||
int slot = id % SV6160_TX_PENDING_MAX;
|
||||
|
||||
if (!test_bit(id, &sc->tx_token_bmp) || !sent)
|
||||
continue;
|
||||
if (time_before(jiffies,
|
||||
sent + msecs_to_jiffies(mod_tx_watchdog_ms)))
|
||||
if (!test_bit(id, &sc->tx_token_bmp))
|
||||
continue;
|
||||
|
||||
skb = READ_ONCE(sc->tx_pending[slot]);
|
||||
/* Claim the skb with cmpxchg so this and a real TX_DONE
|
||||
* arriving at the same moment cannot both own it. */
|
||||
if (skb && cmpxchg(&sc->tx_pending[slot], skb, NULL) == skb) {
|
||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
||||
|
||||
atomic_dec(&sc->tx_outstanding);
|
||||
/* Report it as transmitted, not dropped. The frame did
|
||||
* go out -- only its completion was never sent -- and
|
||||
* telling mac80211 it failed makes the supplicant treat
|
||||
* a perfectly good handshake frame as lost and tear the
|
||||
* connection down, which is what dropping them here was
|
||||
* doing to association. The vendor takes the same view
|
||||
* when it reconstructs missing completions after a
|
||||
* firmware error: it fills in TX_DONE_STAT_SUCCESS for
|
||||
* every frame it is recovering (tx.c
|
||||
* rpu_tx_proc_unfi_tx_done). */
|
||||
ieee80211_tx_info_clear_status(info);
|
||||
info->flags |= IEEE80211_TX_STAT_ACK;
|
||||
ieee80211_tx_status_skb(sc->hw, skb);
|
||||
}
|
||||
sc->tx_desc_jiffies[id] = 0;
|
||||
sv6160_free_token(sc, id);
|
||||
sc->txs_reclaimed++;
|
||||
reclaimed = true;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (reclaimed) {
|
||||
dev_warn(sc->dev,
|
||||
"TX watchdog reclaimed stuck descriptors (total %u)\n",
|
||||
sc->txs_reclaimed);
|
||||
ieee80211_wake_queues(sc->hw);
|
||||
schedule_work(&sc->tx_work);
|
||||
sc->txs_resyncs++;
|
||||
sc->txs_resync_descs += n;
|
||||
sc->last_tx_done = jiffies;
|
||||
|
||||
/* Reclaiming once is a lost completion; reclaiming over and over
|
||||
* means the firmware has stopped completing this queue at all
|
||||
* and every frame we hand it is thrown away. Measured: a burst
|
||||
* at ~500 pkt/s puts it in that state and it never leaves --
|
||||
* RX keeps flowing (drains and packets climb normally) while
|
||||
* TX_DONE never returns, so the watchdog frees a descriptor,
|
||||
* the worker fills it, and nothing completes, for ever. Escalate
|
||||
* to the same recovery the vendor uses for a firmware error
|
||||
* rather than churn silently. */
|
||||
if (++sc->txs_reclaim_runs >= 3) {
|
||||
sc->txs_reclaim_runs = 0;
|
||||
dev_err(sc->dev,
|
||||
"TX stalled across %u reclaims - restarting hw\n",
|
||||
sc->txs_reclaimed);
|
||||
sv6160_trigger_recovery(sc);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
sc->txs_reclaim_runs = 0;
|
||||
dev_warn(sc->dev,
|
||||
"TX completions stopped for %ums - resynchronised %d descriptor(s) (resync #%u)\n",
|
||||
mod_tx_stall_ms, n, sc->txs_resyncs);
|
||||
|
||||
ieee80211_wake_queues(sc->hw);
|
||||
schedule_work(&sc->tx_work);
|
||||
|
||||
/* Resynchronising repeatedly means the firmware is not completing
|
||||
* anything at all any more, and freeing our descriptors has not brought
|
||||
* it back -- measured: after the stall the completion path never
|
||||
* resumes, so the resync just keeps handing frames to a dead TX engine
|
||||
* and telling mac80211 they were transmitted. That lie is worse than
|
||||
* the stall: the supplicant keeps believing the link is healthy and
|
||||
* never tears it down, so nothing ever triggers a rebuild. Escalate to
|
||||
* the same restart the driver uses for a firmware error. */
|
||||
if (++sc->txs_resync_runs >= SV6160_TX_RESYNC_GIVE_UP) {
|
||||
sc->txs_resync_runs = 0;
|
||||
dev_err(sc->dev,
|
||||
"TX engine dead across %u resyncs - restarting hw\n",
|
||||
SV6160_TX_RESYNC_GIVE_UP);
|
||||
sv6160_trigger_recovery(sc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sc->tx_token_bmp && mod_tx_watchdog_ms)
|
||||
schedule_delayed_work(&sc->tx_watchdog,
|
||||
msecs_to_jiffies(mod_tx_watchdog_ms));
|
||||
schedule_delayed_work(&sc->tx_resync, window);
|
||||
}
|
||||
|
||||
static void sv6160_tx_worker(struct work_struct *work)
|
||||
@@ -4605,6 +4738,22 @@ static void sv6160_tx_worker(struct work_struct *work)
|
||||
"mgmt" : "data", desc_id, tx_cmd->encrypt, iv_len,
|
||||
tx_cmd->num_rates, tx_cmd->rate[0],
|
||||
tx_cmd->rate_flags[0], tx_cmd->rate_retries[0]);
|
||||
|
||||
/* The first frames after association are where TX completions
|
||||
* stop coming back, so log each of them once at info level:
|
||||
* which descriptor, which AC, protected or not, aggregated or
|
||||
* not. Bounded so it cannot flood the console. */
|
||||
sc->txs_attempts++;
|
||||
if (sc->txs_attempts <= 60)
|
||||
dev_info(sc->dev,
|
||||
"TXLOG #%u desc=%u q=%u fc=0x%04x %s enc=%u iv=%u ampdu=%u len=%u\n",
|
||||
sc->txs_attempts, desc_id, fw_queue,
|
||||
le16_to_cpu(wh->frame_control),
|
||||
ieee80211_is_mgmt(wh->frame_control) ?
|
||||
"mgmt" : ieee80211_is_data(wh->frame_control) ?
|
||||
"data" : "ctl",
|
||||
tx_cmd->encrypt, iv_len,
|
||||
tx_cmd->aggregate_mpdu, frame_len);
|
||||
print_hex_dump_debug(" tx_frame: ",
|
||||
DUMP_PREFIX_OFFSET, 16, 1,
|
||||
skb->data, min_t(u32, frame_len, 64),
|
||||
@@ -4633,9 +4782,9 @@ static void sv6160_tx_worker(struct work_struct *work)
|
||||
sc->tx_pending_desc[slot] = desc_id;
|
||||
sc->tx_desc_jiffies[desc_id] = jiffies ? jiffies : 1;
|
||||
WRITE_ONCE(sc->tx_pending[slot], skb);
|
||||
if (mod_tx_watchdog_ms)
|
||||
schedule_delayed_work(&sc->tx_watchdog,
|
||||
msecs_to_jiffies(mod_tx_watchdog_ms));
|
||||
if (mod_tx_stall_ms)
|
||||
schedule_delayed_work(&sc->tx_resync,
|
||||
msecs_to_jiffies(mod_tx_stall_ms));
|
||||
|
||||
/* Two back-to-back SDIO writes as ONE transaction (vendor
|
||||
* hal_send): (1) cmd_tx_ctrl descriptor (512 B), (2) raw 802.11
|
||||
@@ -4669,6 +4818,7 @@ static void sv6160_tx_worker(struct work_struct *work)
|
||||
* that stopped association. Pure-GPIO (the vendor model) avoids it. */
|
||||
|
||||
sc->last_tx_time = jiffies;
|
||||
sc->txs_sent_desc[desc_id]++;
|
||||
|
||||
if (atomic_inc_return(&sc->tx_outstanding) >=
|
||||
SV6160_TX_PENDING_MAX - 4)
|
||||
@@ -5111,6 +5261,8 @@ static int sv6160_mac_ampdu_action(struct ieee80211_hw *hw,
|
||||
/* TX sessions stay mac80211's business; the vendor programs nothing
|
||||
* for them and lets the firmware aggregate on its own. */
|
||||
case IEEE80211_AMPDU_TX_START:
|
||||
if (!mod_ba_tx)
|
||||
return -EOPNOTSUPP;
|
||||
return IEEE80211_AMPDU_TX_START_IMMEDIATE;
|
||||
|
||||
case IEEE80211_AMPDU_TX_STOP_CONT:
|
||||
@@ -5515,6 +5667,7 @@ static void sv6160_init_mac_addr(struct sv6160_softc *sc, u8 *mac)
|
||||
static int sv6160_debugfs_rx_stats_show(struct seq_file *s, void *data)
|
||||
{
|
||||
struct sv6160_softc *sc = s->private;
|
||||
int i;
|
||||
|
||||
seq_printf(s, "drains %u\n", sc->rxs_drains);
|
||||
seq_printf(s, "pkts %u\n", sc->rxs_pkts);
|
||||
@@ -5534,6 +5687,22 @@ static int sv6160_debugfs_rx_stats_show(struct seq_file *s, void *data)
|
||||
seq_printf(s, "busy_avg_us %llu\n",
|
||||
sc->rxs_drains ? sc->rxs_busy_us_sum / sc->rxs_drains : 0);
|
||||
seq_printf(s, "busy_max_us %u\n", sc->rxs_busy_us_max);
|
||||
seq_printf(s, "cmd_rx_cancelled %u\n", sc->cmds_rx_cancelled);
|
||||
seq_printf(s, "cmd_rx_rearmed %u\n", sc->cmds_rx_rearmed);
|
||||
seq_printf(s, "tx_done_short %u (first len %u)\n",
|
||||
sc->txs_done_short, sc->txs_done_short_len);
|
||||
seq_printf(s, "ev_out_of_range %u\n", sc->evs_out_of_range);
|
||||
seq_puts(s, "event count minlen maxlen\n");
|
||||
for (i = 0; i < SV6160_EV_CENSUS_MAX; i++)
|
||||
if (sc->evs_count[i])
|
||||
seq_printf(s, "%5d %6u %7u %6u\n", i,
|
||||
sc->evs_count[i], sc->evs_minlen[i],
|
||||
sc->evs_maxlen[i]);
|
||||
seq_printf(s, "cmd_out_of_range %u\n", sc->cmds_out_of_range);
|
||||
seq_puts(s, "cmd count\n");
|
||||
for (i = 0; i < SV6160_CMD_CENSUS_MAX; i++)
|
||||
if (sc->cmds_by_id[i])
|
||||
seq_printf(s, "%5d %6u\n", i, sc->cmds_by_id[i]);
|
||||
return 0;
|
||||
}
|
||||
DEFINE_SHOW_ATTRIBUTE(sv6160_debugfs_rx_stats);
|
||||
@@ -5547,12 +5716,14 @@ static int sv6160_debugfs_tx_tokens_show(struct seq_file *s, void *data)
|
||||
seq_printf(s, "tx_outstanding %d\n", atomic_read(&sc->tx_outstanding));
|
||||
seq_printf(s, "queue_len %u\n", skb_queue_len(&sc->tx_queue));
|
||||
seq_printf(s, "tx_frames %u\n", sc->txs_frames);
|
||||
seq_printf(s, "tx_attempts %u\n", sc->txs_attempts);
|
||||
seq_printf(s, "tx_avg_us %llu\n",
|
||||
sc->txs_frames ? sc->txs_us_sum / sc->txs_frames : 0);
|
||||
seq_printf(s, "tx_max_us %u\n", sc->txs_us_max);
|
||||
seq_printf(s, "tx_ebusy %u\n", sc->txs_ebusy);
|
||||
seq_printf(s, "tx_reclaimed %u\n", sc->txs_reclaimed);
|
||||
seq_printf(s, "tx_reclaim_runs %u\n", sc->txs_reclaim_runs);
|
||||
seq_printf(s, "tx_resyncs %u\n", sc->txs_resyncs);
|
||||
seq_printf(s, "tx_resync_descs %u\n", sc->txs_resync_descs);
|
||||
seq_printf(s, "tx_resync_runs %u\n", sc->txs_resync_runs);
|
||||
seq_printf(s, "tx_done_avg_ms %llu\n",
|
||||
sc->txs_done_n ? sc->txs_done_ms_sum / sc->txs_done_n : 0);
|
||||
seq_printf(s, "tx_done_max_ms %u\n", sc->txs_done_ms_max);
|
||||
@@ -5567,10 +5738,30 @@ static int sv6160_debugfs_tx_tokens_show(struct seq_file *s, void *data)
|
||||
sc->tx_outstanding_ac[i],
|
||||
sc->tx_outstanding_ac[i] >= SV6160_TX_DESCS_PER_AC ?
|
||||
" <-- GATED" : "");
|
||||
|
||||
/* Per-descriptor ledger. For a leaked descriptor, `busy=1 skb=1` with
|
||||
* a large age says the frame is still parked waiting for a completion
|
||||
* that never came; `sent > seen` says the firmware never named the id,
|
||||
* `seen > done` says it did and we threw the completion away. */
|
||||
seq_puts(s, "id busy ac skb pdesc age_ms sent seen done\n");
|
||||
for (i = 0; i < SV6160_NUM_TX_DESCS; i++) {
|
||||
int slot = i % SV6160_TX_PENDING_MAX;
|
||||
unsigned long st = sc->tx_desc_jiffies[i];
|
||||
|
||||
seq_printf(s, "%2d %4d %2u %3d %5u %6u %6u %6u %6u\n",
|
||||
i, test_bit(i, &sc->tx_token_bmp) ? 1 : 0,
|
||||
sc->tx_token_ac[i],
|
||||
READ_ONCE(sc->tx_pending[slot]) ? 1 : 0,
|
||||
sc->tx_pending_desc[slot],
|
||||
st ? jiffies_to_msecs(jiffies - st) : 0,
|
||||
sc->txs_sent_desc[i], sc->txs_seen_desc[i],
|
||||
sc->txs_done_desc[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
DEFINE_SHOW_ATTRIBUTE(sv6160_debugfs_tx_tokens);
|
||||
|
||||
|
||||
static void sv6160_debugfs_init(struct sv6160_softc *sc)
|
||||
{
|
||||
struct dentry *dir;
|
||||
@@ -5622,7 +5813,7 @@ int sv6160_core_init(struct sv6160_softc *sc)
|
||||
|
||||
INIT_WORK(&sc->rx_work, sv6160_rx_worker);
|
||||
INIT_WORK(&sc->tx_work, sv6160_tx_worker);
|
||||
INIT_DELAYED_WORK(&sc->tx_watchdog, sv6160_tx_watchdog_fn);
|
||||
INIT_DELAYED_WORK(&sc->tx_resync, sv6160_tx_resync_fn);
|
||||
INIT_WORK(&sc->recover_work, sv6160_recover_work_fn);
|
||||
INIT_DELAYED_WORK(&sc->rx_poll, sv6160_rx_poll_fn);
|
||||
INIT_DELAYED_WORK(&sc->idle_work, sv6160_idle_work_fn);
|
||||
|
||||
Reference in new issue
Block a user