diff --git a/kernel/build-all.sh b/kernel/build-all.sh index 27e3edf7..3bc11976 100755 --- a/kernel/build-all.sh +++ b/kernel/build-all.sh @@ -45,7 +45,7 @@ echo "==> sources" fetch /src/zte-u30air "$KERNEL_REPO" "$KERNEL_REV" cd /src/zte-u30air # the tree is the pinned commit plus exactly these patches: reapply from a clean checkout whenever they change -KPATCHES="bluetooth-marlin3-link-policy of-reserved-mem-skip of-reserved-mem-add regdb-wens-certificate sipa-delegate-einprogress wcn-pcie-scan-timeout sipc-base-addr-attr sipa-delegate-pm-runtime sipc-debug-once" +KPATCHES="bluetooth-marlin3-link-policy of-reserved-mem-skip of-reserved-mem-add regdb-wens-certificate sipa-delegate-einprogress wcn-pcie-scan-timeout sipc-base-addr-attr sipa-delegate-pm-runtime sipc-debug-once sprdwcn-mbuf-pool-deinit-null" sum=$(cd /work/patches && cat $(for p in $KPATCHES; do echo $p.patch; done) | sha256sum | cut -d" " -f1) if [ "$(cat .mu300-patches 2>/dev/null)" != "$sum" ]; then git checkout -q -f "$KERNEL_REV" && git clean -q -fdx -e .mu300-patches diff --git a/kernel/patches/sprdwcn-mbuf-pool-deinit-null.patch b/kernel/patches/sprdwcn-mbuf-pool-deinit-null.patch new file mode 100644 index 00000000..93b5a04e --- /dev/null +++ b/kernel/patches/sprdwcn-mbuf-pool-deinit-null.patch @@ -0,0 +1,18 @@ +sprdwcn: mbuf_pool_deinit() on a channel without a pool does nothing + +Same fix as upstream/modules/wcn_bsp: the Wi-Fi post-init error path deinitialises the channel that failed. When +its EDMA init failed after an earlier power cycle, its pool has no memory (freed then) but keeps that cycle's size, +and the memset of NULL oopsed. + +--- a/drivers/unisoc_platform/sprdwcn/pcie/mchn.c ++++ b/drivers/unisoc_platform/sprdwcn/pcie/mchn.c +@@ -140,6 +140,9 @@ + + int mbuf_pool_deinit(struct buffer_pool *pool) + { ++ /* MU300: a channel whose EDMA init failed has no pool this time (its size is still the last one's) */ ++ if (!pool->mem) ++ return 0; + memset(pool->mem, 0x00, (sizeof(struct mbuf_t) + + pool->payload) * pool->size); + kfree(pool->mem); diff --git a/kernel/patches/wlan_combo-pcie-post-init-retry.patch b/kernel/patches/wlan_combo-pcie-post-init-retry.patch index 13f21187..2addd202 100644 --- a/kernel/patches/wlan_combo-pcie-post-init-retry.patch +++ b/kernel/patches/wlan_combo-pcie-post-init-retry.patch @@ -3,7 +3,7 @@ sprd_wlan_combo: restore the PCIe channel table on every power-on (from kanoqwq/ The vendor error path clears sc2355_hif.mchn_ops. A later WCN power-on can call post_init without rerunning pcie_init, which passes NULL to mchn_init and leaves Wi-Fi unusable until the next reboot. The table is static; restore its pointer when registering the channels. The same error path deinitialised the channel that failed and -never channel 0; it undoes 0 .. chn-1 now. +never channel 0; it undoes chn .. 0 now. --- a/sc2355/pcie.c +++ b/sc2355/pcie.c @@ -27,9 +27,9 @@ never channel 0; it undoes 0 .. chn-1 now. pr_err("%s: unregister %d ops\n", __func__, sc2355_hif.max_num); - for (; chn > 0; chn--) -+ /* MU300: undo the channels that were set up, 0 .. chn-1 (the vendor loop took chn, which failed, and -+ * never 0) */ -+ while (chn-- > 0) ++ /* MU300: undo the channels that were set up and the one that failed, chn .. 0 (the vendor loop stopped at ++ * 1; a failed channel can be registered with half its EDMA state, and deinit skips one never registered) */ ++ for (; chn >= 0; chn--) sprdwcn_bus_chn_deinit(&sc2355_hif.mchn_ops[chn]); sc2355_hif.mchn_ops = NULL; sc2355_hif.max_num = 0; diff --git a/upstream/modules/sprd_wlan_combo/sc2355/pcie.c b/upstream/modules/sprd_wlan_combo/sc2355/pcie.c index c6f11ee4..a61a668f 100644 --- a/upstream/modules/sprd_wlan_combo/sc2355/pcie.c +++ b/upstream/modules/sprd_wlan_combo/sc2355/pcie.c @@ -2049,9 +2049,9 @@ int pcie_post_init(struct sprd_hif *hif) err: pr_err("%s: unregister %d ops\n", __func__, sc2355_hif.max_num); - /* MU300: undo the channels that were set up, 0 .. chn-1 (the vendor loop took chn, which failed, and - * never 0) */ - while (chn-- > 0) + /* MU300: undo the channels that were set up and the one that failed, chn .. 0 (the vendor loop stopped at + * 1; a failed channel can be registered with half its EDMA state, and deinit skips one never registered) */ + for (; chn >= 0; chn--) sprdwcn_bus_chn_deinit(&sc2355_hif.mchn_ops[chn]); sc2355_hif.mchn_ops = NULL; sc2355_hif.max_num = 0; diff --git a/upstream/modules/wcn_bsp/pcie/mchn.c b/upstream/modules/wcn_bsp/pcie/mchn.c index 49acb3b5..e7bbcd5e 100644 --- a/upstream/modules/wcn_bsp/pcie/mchn.c +++ b/upstream/modules/wcn_bsp/pcie/mchn.c @@ -140,6 +140,9 @@ int mbuf_pool_init(struct buffer_pool *pool, int size, int payload) int mbuf_pool_deinit(struct buffer_pool *pool) { + /* MU300: a channel whose EDMA init failed has no pool this time (its size is still the last one's) */ + if (!pool->mem) + return 0; memset(pool->mem, 0x00, (sizeof(struct mbuf_t) + pool->payload) * pool->size); kfree(pool->mem);