nss-drv: add boot wait

Ensures NSS cores are fully booted to hopefully workaround issues with
wifi stats (rx/tx rates) and inactive time.

Patch-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Sean Khan <datapronix@protonmail.com>
This commit is contained in:
Sean Khan 2024-08-09 01:35:22 -04:00
parent c5340b8d58
commit 0cf4f442e2
2 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,60 @@
--- a/nss_core.c
+++ b/nss_core.c
@@ -87,6 +87,8 @@ MODULE_PARM_DESC(pn_qlimits, "Queue limi
static atomic_t jumbo_mru;
static atomic_t paged_mode;
+static int nss_bootstate = 0;
+
/*
* nss_core_update_max_ipv4_conn()
* Update the maximum number of configured IPv4 connections
@@ -2187,6 +2189,19 @@ static inline void nss_core_handle_tx_un
nss_hal_disable_interrupt(nss_ctx, nss_ctx->int_ctx[0].shift_factor, NSS_N2H_INTR_TX_UNBLOCKED);
}
+void nss_bootwait(void)
+{
+ int dead = 10 * 10;
+#if (NSS_MAX_CORES > 1)
+ while (nss_bootstate < 2 && dead-- > 0)
+#else
+ while (!nss_bootstate && dead-- > 0)
+#endif
+ {
+ msleep(100);
+ }
+}
+
/*
* nss_core_handle_cause_nonqueue()
* Handle non-queue interrupt causes (e.g. empty buffer SOS, Tx unblocked)
@@ -2255,6 +2270,9 @@ static void nss_core_handle_cause_nonque
#endif
#endif
}
+ if (unlikely(nss_ctx->state == NSS_CORE_STATE_INITIALIZED)) {
+ nss_bootstate++;
+ }
/*
* TODO: find better mechanism to handle empty buffers
--- a/nss_hal/nss_hal.c
+++ b/nss_hal/nss_hal.c
@@ -827,6 +827,7 @@ int nss_hal_probe(struct platform_device
}
nss_info("%px: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id);
+ nss_bootwait();
goto out;
err_register_irq:
--- a/nss_core.h
+++ b/nss_core.h
@@ -1035,4 +1035,6 @@ extern void nss_ppe_free(void);
extern nss_tx_status_t nss_n2h_cfg_empty_pool_size(struct nss_ctx_instance *nss_ctx, uint32_t pool_sz);
extern nss_tx_status_t nss_n2h_paged_buf_pool_init(struct nss_ctx_instance *nss_ctx);
+void nss_bootwait(void);
+
#endif /* __NSS_CORE_H */

View File

@ -0,0 +1,60 @@
--- a/nss_core.c
+++ b/nss_core.c
@@ -93,6 +93,8 @@ static int qos_mem_size = 0;
module_param(qos_mem_size, int, S_IRUGO);
MODULE_PARM_DESC(qos_mem_size, "QoS memory size");
+static int nss_bootstate = 0;
+
/*
* Atomic variables to control jumbo_mru & paged_mode
*/
@@ -2249,6 +2251,19 @@ static inline void nss_core_handle_tx_un
nss_hal_disable_interrupt(nss_ctx, nss_ctx->int_ctx[0].shift_factor, NSS_N2H_INTR_TX_UNBLOCKED);
}
+void nss_bootwait(void)
+{
+ int dead = 10 * 10;
+#if (NSS_MAX_CORES > 1)
+ while (nss_bootstate < 2 && dead-- > 0)
+#else
+ while (!nss_bootstate && dead-- > 0)
+#endif
+ {
+ msleep(100);
+ }
+}
+
/*
* nss_core_handle_cause_nonqueue()
* Handle non-queue interrupt causes (e.g. empty buffer SOS, Tx unblocked)
@@ -2317,6 +2332,9 @@ static void nss_core_handle_cause_nonque
#endif
#endif
}
+ if (unlikely(nss_ctx->state == NSS_CORE_STATE_INITIALIZED)) {
+ nss_bootstate++;
+ }
#if defined(NSS_DRV_EDMA_LITE_ENABLE)
/*
--- a/nss_hal/nss_hal.c
+++ b/nss_hal/nss_hal.c
@@ -855,6 +855,7 @@ int nss_hal_probe(struct platform_device
}
nss_info("%px: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id);
+ nss_bootwait();
goto out;
err_register_irq:
--- a/nss_core.h
+++ b/nss_core.h
@@ -1067,4 +1067,6 @@ extern nss_tx_status_t nss_n2h_cfg_empty
extern nss_tx_status_t nss_n2h_paged_buf_pool_init(struct nss_ctx_instance *nss_ctx);
extern nss_tx_status_t nss_n2h_cfg_qos_mem_size(struct nss_ctx_instance *nss_ctx, uint32_t pool_sz);
+void nss_bootwait(void);
+
#endif /* __NSS_CORE_H */