mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-05 08:02:40 +00:00
fix: backport upstream Wi-Fi and installer stability fixes
Select reviewed fixes from upstream maina5da67f: WCN power serialization and PCIe cleanup (1f6e825,1196cf2), firmware log policy (f0323bf), AP DNS ordering (f4f5e76), pristine legacy driver rebuilds (b0e9595), bounded eMMC probes and RNDIS address handoff (bde23d0,486856c). Preserve TF deployment, USB recovery, IPv6 software checksums and latency tuning; do not import the power/VPN redesign. Validation: 176 dash/bash Python tests; 417 PowerShell checks; Wi-Fi/WCN modules built for 6.18.54 and 7.2.8 with matching vermagic and build manifests; legacy patch applicability verified. No device deployment or ZIP rebuild.
This commit is contained in:
23 files changed
+578
-50
No files matched your search
@@ -1,5 +1,16 @@
|
||||
# 更新日志
|
||||
|
||||
## 2026-10-10 · 上游稳定性修复(尚未打包)
|
||||
|
||||
- 合入 Wi-Fi 上下电并发保护,修复启动或重新打开热点时可能卡死的问题;补齐初始化失败后的资源清理。
|
||||
- 关闭无线固件默认调试日志,恢复时不再擅自开启;保留手动调试入口。
|
||||
- 修正热点 DNS 数据包处理顺序,保留现有 IPv6 软件校验和与低延迟优化。
|
||||
- 修复切换 RNDIS 后旧地址清理顺序,保留原有 USB 二次重枚举方案。
|
||||
- 安装、卸载及密码重置工具不再探测 eMMC 容量以外的位置,降低不同容量机型卡死的风险。
|
||||
- 修复旧内核重复构建可能漏打驱动补丁的问题,补丁失配立即报错。
|
||||
|
||||
本次仅合入适用修复,不引入上游整套省电、VPN、休眠或部署改造;现有 r4 安装包和实机未改动。
|
||||
|
||||
## 2026-10-08 · TF 安装包 r4
|
||||
|
||||
本次提供 Linux **6.18.54** 和 **7.2.8** 两套 Magisk TF 安装包。
|
||||
|
||||
@@ -12,6 +12,8 @@ The mainline builds use the same `upstream/modules/` vendor module source. `upst
|
||||
| `sipc-base-addr-attr` | Present in `upstream/modules/sprd_modem/sipc/` and `mailbox/`; the unusable attributes are absent. |
|
||||
| `sprdbt-tty-one-port` | Present in `upstream/modules/sprdbt_tty/tty-pcie/tty.c`. |
|
||||
| `wcn-pcie-scan-timeout` | Present in `upstream/modules/wcn_bsp/pcie/pcie.c`. |
|
||||
| `sprdwcn-mbuf-pool-deinit-null` | Added 2026-10-10 to the 5.4 kernel patch list and shared mainline `wcn_bsp/pcie/mchn.c`; a failed PCIe channel init can be unwound without zeroing a NULL pool. |
|
||||
| `wlan_combo-wcn-power-serialise` | Added 2026-10-10 for 5.4 and both mainline builds: serialize power transitions, release/acquire the RX context, reject contextless RX and power off before freeing the containing structure. |
|
||||
| `wlan_combo-5ghz-ap-ds-params`, `allow-bridging-ap`, `ap-stations-channel`, `default-board-config`, `pcie-post-init-retry`, `tx-complock-irqsave` | Present in `upstream/modules/sprd_wlan_combo/`. |
|
||||
| `wlan_combo-rx-software-checksum` | Present in the shared source after the 7.2.8 Wi-Fi repair. The running 7.2.8 module was verified to return `CHECKSUM_NONE` without calling `rx_ipv6_csum`. The local `upstream/out` (6.18) and `upstream/out-7.2` WLAN modules were subsequently rebuilt from this source; old TF ZIPs and kernel bundles remain unchanged and must not be reused. |
|
||||
| `audio-mem-fixed-region`, `audio-mem-shm-shift`, `mcdt-enable-clock`, `sprd-card-dummy-on-defer` | Only used by the separate optional 5.4 audio build. No corresponding audio modules are in the current 6.18 / 7.2 module set. |
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# Selective upstream stability integration
|
||||
|
||||
Reviewed `dikeckaan/mu300-linux` main at `a5da67f` against local `0d93695`.
|
||||
Their merge base is `1a69a41`; 352 upstream-side commits are not ancestors of
|
||||
this branch. This is a **selective backport**, not a full main merge.
|
||||
|
||||
## Applied
|
||||
|
||||
| Upstream source | Integration |
|
||||
| --- | --- |
|
||||
| `1f6e825` | WCN power-transition mutex, safe probe/remove ordering, failed power-on cleanup, RX NULL guard and context publication. Shared 6.18/7.2 sources plus the 5.4 patch. |
|
||||
| `1196cf2` | Unwind every PCIe channel including the failed channel and channel zero; allow deinit when a pool was never allocated. Both kernel families. |
|
||||
| `f0323bf` | Default firmware ARM logging off; resume preserves the chosen state. Shared mainline WCN sources. |
|
||||
| `f4f5e76` | Our AP ARP/DNS data-queue fix was already present. Move its DNS bypass before the command-path checksum manipulation, as reviewed upstream. |
|
||||
| `b0e9595` | Recreate legacy Wi-Fi/Bluetooth build trees when patch hashes change. Also reject an outdated hash in standalone `build-wlan.sh` instead of silently accepting it. |
|
||||
| `bde23d0`, `486856c` | Adapt eMMC probe bounds to this branch's existing shell/PowerShell installers, uninstallers and reset-password tool (there is no upstream `storage.sh` here). Clamp empty regions to zero. Move RNDIS bridging before address cleanup and handle differing preinit prefixes. |
|
||||
|
||||
These changes retain the fork's independent LuCI plugin, TF installer, active
|
||||
slot handling, USB host settings, NCM startup re-enumeration and fast modem
|
||||
startup. No kernel version/configuration change is included.
|
||||
|
||||
## Deliberately not imported
|
||||
|
||||
- `b951035` / `6e616ab`: our tested `CHECKSUM_NONE` path already prevents the
|
||||
IPv6 RX drops. Keep stack verification for all packets rather than change
|
||||
checksum policy as part of a stability backport.
|
||||
- `3435100` and the larger suspend/power-profile series: default WoWLAN and
|
||||
automatic idle/radio policy need a separate end-to-end suspend evaluation.
|
||||
Firmware log suppression above does not enable system sleep.
|
||||
- `760d561`: our startup/module-loading paths already carry the fork fixes;
|
||||
do not add another hotspot restart or extend waits.
|
||||
- Upstream's LAN-hotplug rebind loop: keep our existing procd-managed USB
|
||||
endpoint recovery; do not introduce a second re-enumeration owner.
|
||||
- Upstream SMS pooling/deletion: our local storage, direct receive and
|
||||
archive-before-delete implementation also integrates forwarding/history
|
||||
barriers. Replacing it would discard fork-specific behavior.
|
||||
- VPN toolkit, power pages, release workflow, updater/boot rollback and APK
|
||||
upgrades: these are separate feature/build changes, not dependencies of
|
||||
the selected fixes. Existing TF packages remain unchanged.
|
||||
- Existing BA latency tuning, IPv6 behavior and dashboard presentation are
|
||||
preserved; withdrawn wireless rate/signal experiments are not restored.
|
||||
|
||||
## Verification
|
||||
|
||||
- Rebuilt `wcn_bsp` and `sprd_wlan_combo` for **6.18.54** and **7.2.8** in
|
||||
`upstream/out-kvm-6.18` / `upstream/out-kvm-7.2`. Both builds succeeded;
|
||||
module vermagic and the existing configuration/hash checks passed.
|
||||
- Applied the complete 5.4 WLAN patch set to a disposable pristine vendor
|
||||
source copy; dry-ran the WCN pool patch against the existing kernel source.
|
||||
This is patch applicability, **not** a new full 5.4 kernel build.
|
||||
- Added offline regressions for lock/lifetime safeguards, PCIe unwind,
|
||||
firmware logging, DNS ordering, eMMC boundaries and RNDIS address handoff.
|
||||
- Full local Python suite: **176 passed** with `MU300_TEST_SHELLS=dash,bash`;
|
||||
PowerShell 7 installer checks: **417 passed**. BusyBox's standalone applets
|
||||
bypass this host's command mocks, so it was excluded from the full suite.
|
||||
- No device was contacted, flashed, rebooted or runtime-tested. These are
|
||||
repository/build checks; runtime boot-cycle acceptance remains outstanding.
|
||||
- No rootfs/ZIP rebuild or remote push. Old r4 packages do not contain these
|
||||
changes; rebuilt module directories do.
|
||||
@@ -422,6 +422,7 @@ if ($parts.Count -ne 2) { Die (T 'could not read the partition table from the de
|
||||
[int64]$lastEnd = $parts[0]; [int64]$disk = $parts[1]
|
||||
[int64]$start = [math]::Floor($lastEnd / 4096 + 1) * 4096
|
||||
[int64]$end = [math]::Floor(($disk - 34) / 4096 - 1) * 4096
|
||||
if ($end -le $start) { $end = $start }
|
||||
[int64]$OFF = $start * 512
|
||||
[int64]$SIZE = ($end - $start) * 512
|
||||
function Gib([int64]$b) { '{0:N1} GiB' -f ($b / 1GB) }
|
||||
@@ -440,7 +441,9 @@ if ($SIZE -lt 700MB) {
|
||||
}
|
||||
|
||||
$existing = 'no'
|
||||
function RegionOnDisk([int64]$bytes) { $bytes -ge 0 -and ($bytes + 2048) -le ($disk * 512) }
|
||||
foreach ($cand in @($OFF, 27762098176)) {
|
||||
if (-not (RegionOnDisk $cand)) { continue }
|
||||
$m = (SuDo "dd if=/dev/block/mmcblk0 bs=1 skip=$($cand + 1080) count=2 2>/dev/null | od -An -tx1") -replace '\s', ''
|
||||
$l = (SuDo "dd if=/dev/block/mmcblk0 bs=1 skip=$($cand + 1144) count=16 2>/dev/null") -replace '\0', ''
|
||||
if ($m -eq '53ef' -and $l.Trim() -eq 'mu300root') {
|
||||
|
||||
@@ -242,6 +242,8 @@ set -- $(su_do 'e=0; for p in /sys/block/mmcblk0/mmcblk0p*; do x=$(( $(cat $p/st
|
||||
last_end=$1; disk=$2
|
||||
start=$(( (last_end / 4096 + 1) * 4096 ))
|
||||
end=$(( ((disk - 34) / 4096 - 1) * 4096 ))
|
||||
# Upstream bde23d0: a full partition table leaves no region, not a negative one.
|
||||
[ $end -gt $start ] || end=$start
|
||||
OFF=$((start * 512)); SIZE=$(( (end - start) * 512 ))
|
||||
gib() { awk -v b="$1" 'BEGIN { printf "%.1f GiB", b / 1073741824 }'; }
|
||||
# What each choice needs: the installed systems measure ~320 MiB (OpenWrt) and ~580 MiB (Ubuntu), and an update
|
||||
@@ -259,6 +261,8 @@ fi
|
||||
# an existing installation defines the region (it may have been created with a slightly different size)
|
||||
existing=no
|
||||
for cand in $OFF 27762098176; do
|
||||
# Never probe a superblock beyond the eMMC: the vendor block driver can hang.
|
||||
[ "$cand" -ge 0 ] && [ $((cand + 2048)) -le $((disk * 512)) ] || continue
|
||||
m=$(su_do "dd if=/dev/block/mmcblk0 bs=1 skip=$((cand + 1080)) count=2 2>/dev/null | od -An -tx1" | tr -d ' ')
|
||||
l=$(su_do "dd if=/dev/block/mmcblk0 bs=1 skip=$((cand + 1144)) count=16 2>/dev/null" | tr -d '\000')
|
||||
if [ "$m" = 53ef ] && [ "$l" = mu300root ]; then
|
||||
|
||||
+13
-5
@@ -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"
|
||||
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 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
|
||||
@@ -55,10 +55,18 @@ fi
|
||||
echo -gb50db5b6224c > .scmversion
|
||||
M=kernel_modules/kernel5.4
|
||||
fetch /src/realme "$MODULES_REPO" "$MODULES_REV" $M/wcn/wlan/wlan_combo $M/wcn/bluetooth/driver $M/gpu/natt/mali
|
||||
[ -d /src/ext-wlan_combo ] || cp -r /src/realme/$M/wcn/wlan/wlan_combo /src/ext-wlan_combo
|
||||
[ -d /src/ext-sprdbt ] || cp -r /src/realme/$M/wcn/bluetooth/driver /src/ext-sprdbt
|
||||
# like build-wlan.sh does for Wi-Fi: the MU300 fixes of the Bluetooth driver, skipped when already applied
|
||||
(cd /src/ext-sprdbt && for p in /work/patches/sprdbt-*.patch; do patch -p1 --forward -s < "$p" || true; done)
|
||||
# Upstream b0e9595: changed patch sets must start from pristine vendor sources.
|
||||
# Never silently keep an old or partly patched driver in a reused build volume.
|
||||
patched_copy() { # DEST SOURCE PATCH-GLOB; destinations are fixed build scratch directories
|
||||
local sum; sum=$(cat /work/patches/$3 | sha256sum | cut -d" " -f1)
|
||||
[ "$(cat "$1/.mu300-patches" 2>/dev/null)" = "$sum" ] && return 0
|
||||
case "$1" in /src/ext-wlan_combo|/src/ext-sprdbt) ;; *) exit 1 ;; esac
|
||||
rm -rf "$1" && cp -r "$2" "$1"
|
||||
(cd "$1" && for p in /work/patches/$3; do patch -p1 -s -f < "$p"; done)
|
||||
echo "$sum" > "$1/.mu300-patches"
|
||||
}
|
||||
patched_copy /src/ext-wlan_combo /src/realme/$M/wcn/wlan/wlan_combo "wlan_combo-*.patch"
|
||||
patched_copy /src/ext-sprdbt /src/realme/$M/wcn/bluetooth/driver "sprdbt-*.patch"
|
||||
[ -d /src/ext-mali ] || cp -r /src/realme/$M/gpu/natt/mali /src/ext-mali
|
||||
|
||||
echo "==> kernel"
|
||||
|
||||
+11
-1
@@ -3,7 +3,17 @@
|
||||
# Source: realme C51/C53 AndroidT kernel_modules/kernel5.4/wcn/wlan/wlan_combo (GPL), patched for the MU300.
|
||||
set -e
|
||||
WSRC=${WSRC:-/src/ext-wlan_combo}
|
||||
cd "$WSRC" && for p in /work/patches/wlan_combo-*.patch; do patch -p1 --forward < "$p" || true; done
|
||||
cd "$WSRC"
|
||||
sum=$(cat /work/patches/wlan_combo-*.patch | sha256sum | cut -d" " -f1)
|
||||
if [ -f .mu300-patches ]; then
|
||||
[ "$(cat .mu300-patches)" = "$sum" ] || {
|
||||
echo "Wi-Fi patches changed: rerun kernel/build-all.sh with pristine sources" >&2
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
for p in /work/patches/wlan_combo-*.patch; do patch -p1 -s -f < "$p"; done
|
||||
echo "$sum" > .mu300-patches
|
||||
fi
|
||||
cd /src/zte-u30air
|
||||
make O=/src/out-linux ARCH=arm64 LLVM=1 LLVM_IAS=1 CC=clang LD=ld.lld -j"$(nproc)" M="$WSRC" modules
|
||||
llvm-strip --strip-debug -o /src/out-linux/sprd_wlan_combo.ko "$WSRC/sprd_wlan_combo.ko"
|
||||
@@ -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);
|
||||
@@ -1,18 +1,18 @@
|
||||
sprd_wlan_combo: restore the PCIe channel table on every power-on
|
||||
sprd_wlan_combo: restore the PCIe channel table on every power-on (from kanoqwq/mu300-linux), and unwind the channels that were set up
|
||||
|
||||
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 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 chn .. 0 now.
|
||||
|
||||
--- a/sc2355/pcie.c
|
||||
+++ b/sc2355/pcie.c
|
||||
@@ -2034,6 +2034,14 @@ int pcie_post_init(struct sprd_hif *hif)
|
||||
@@ -1995,6 +1995,14 @@
|
||||
int ret = -EINVAL, chn = 0;
|
||||
|
||||
sc2355_hif.hif = (void *)hif;
|
||||
+ /*
|
||||
+ * A failed/aborted earlier power cycle clears this pointer in the
|
||||
+ * MU300 (from kanoqwq/mu300-linux): a failed/aborted earlier power cycle clears this pointer in the
|
||||
+ * error path below. The vendor driver only restores it in pcie_init(),
|
||||
+ * but a later WCN power-on may call post_init directly. Passing
|
||||
+ * &NULL[0] to mchn_init then makes Wi-Fi permanently fail until reboot.
|
||||
@@ -22,3 +22,15 @@ static; restore its pointer when registering the channels.
|
||||
sc2355_hif.max_num =
|
||||
sizeof(sc2355_pcie_hif_ops) / sizeof(struct mchn_ops_t);
|
||||
|
||||
@@ -2016,7 +2024,9 @@
|
||||
err:
|
||||
pr_err("%s: unregister %d ops\n", __func__, sc2355_hif.max_num);
|
||||
|
||||
- for (; chn > 0; chn--)
|
||||
+ /* 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;
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
sprd_wlan_combo: one WCN power transition at a time; an RX interrupt without a context is dropped, not a panic
|
||||
|
||||
power_cnt is atomic, the transitions behind it are not. The probe powers the chip off after it registered wlan0,
|
||||
outside RTNL, so userspace (hostapd, netifd) can open the interface meanwhile: the open's power-on ran
|
||||
start_marlin + post_init while the probe's power-off was still in post_deinit, which then cleared the channels and
|
||||
sc2355_hif.hif that post_init had just set; the next RX interrupt read hif->rx_mgmt from NULL in hard IRQ
|
||||
(pcie_rx_handle+0x34, "paging request at 00000000000030b8", seen under 6.18 in FINDINGS 31n; the 5.4 driver has
|
||||
the same code). sprd_iface_set_power holds a mutex across the transition; pcie_rx_handle drops a list that
|
||||
arrives with no context and logs it once; the context pointer is published with release/acquire.
|
||||
On the way: probe's error paths and remove powered off after sprd_core_free had freed hif (now before), and a
|
||||
power-on that failed in post_init or the version sync left the chip started, and after a failed sync the
|
||||
channels registered, with the count at 0 (now undone as a power-off does).
|
||||
|
||||
--- a/common/hif.h
|
||||
+++ b/common/hif.h
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef __HIF_H__
|
||||
#define __HIF_H__
|
||||
|
||||
+#include <linux/mutex.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <misc/marlin_platform.h>
|
||||
|
||||
@@ -117,6 +118,8 @@
|
||||
|
||||
int exit;
|
||||
atomic_t power_cnt;
|
||||
+ /* MU300: one WCN power transition at a time (sprd_iface_set_power) */
|
||||
+ struct mutex power_lock;
|
||||
int flag;
|
||||
int lastflag;
|
||||
u8 cp_asserted;
|
||||
@@ -289,6 +292,9 @@
|
||||
}
|
||||
|
||||
if (sprd_hif_post_init(hif)) {
|
||||
+ /* MU300: post_init unwound its channels; the chip was started, stop it as a power-off would */
|
||||
+ if (stop_marlin(MARLIN_WIFI))
|
||||
+ pr_err("stop_marlin failed!!\n");
|
||||
atomic_sub(1, &hif->power_cnt);
|
||||
return -ENODEV;
|
||||
}
|
||||
@@ -301,6 +307,15 @@
|
||||
}
|
||||
|
||||
if (sprd_sync_version(hif)) {
|
||||
+ /*
|
||||
+ * MU300: undo the power-on as sprd_hif_power_off() does. The vendor left the channels registered
|
||||
+ * and the chip started with the count at 0: the next power-on registered them again over live ones,
|
||||
+ * and a probe that failed here freed hif under channels that could still interrupt.
|
||||
+ */
|
||||
+ sprd_clean_work(hif->priv);
|
||||
+ sprd_hif_post_deinit(hif);
|
||||
+ if (stop_marlin(MARLIN_WIFI))
|
||||
+ pr_err("stop_marlin failed!!\n");
|
||||
atomic_sub(1, &hif->power_cnt);
|
||||
return -EIO;
|
||||
}
|
||||
--- a/common/iface.c
|
||||
+++ b/common/iface.c
|
||||
@@ -270,6 +270,15 @@
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
+ /*
|
||||
+ * MU300: power_cnt is atomic, the transitions behind it are not. Probe powers the chip off after it
|
||||
+ * registered wlan0, outside RTNL, so userspace (hostapd, netifd) can open the interface meanwhile: the
|
||||
+ * open's power-on (1st count) ran start_marlin + post_init while the probe's power-off (last count) was
|
||||
+ * still in post_deinit. post_deinit then cleared the channels and sc2355_hif.hif that post_init had just
|
||||
+ * set, stop_marlin powered the chip down, and the next RX interrupt read hif->rx_mgmt from NULL
|
||||
+ * (pcie_rx_handle+0x34, "paging request at 00000000000030b8", FINDINGS 31n). One transition at a time.
|
||||
+ */
|
||||
+ mutex_lock(&hif->power_lock);
|
||||
if (val) {
|
||||
sprd_wlan_power_status_sync(1, 1);
|
||||
ret = sprd_hif_power_on(hif);
|
||||
@@ -280,12 +289,14 @@
|
||||
else if (ret == -EIO)
|
||||
pr_err("SYNC cmd error!\n");
|
||||
|
||||
- return ret;
|
||||
+ goto out;
|
||||
}
|
||||
if (atomic_read(&hif->power_cnt) == 1)
|
||||
sprd_get_fw_info(hif->priv);
|
||||
} else
|
||||
sprd_hif_power_off(hif);
|
||||
+out:
|
||||
+ mutex_unlock(&hif->power_lock);
|
||||
return ret;
|
||||
}
|
||||
#ifdef DRV_RESET_SELF
|
||||
@@ -1768,6 +1779,7 @@
|
||||
iface_set_priv(priv);
|
||||
platform_set_drvdata(pdev, priv);
|
||||
hif = &priv->hif;
|
||||
+ mutex_init(&hif->power_lock);
|
||||
hif->priv = priv;
|
||||
hif->pdev = pdev;
|
||||
hif->ops = hif_ops;
|
||||
@@ -1790,9 +1802,10 @@
|
||||
ret = iface_core_init(&pdev->dev, priv);
|
||||
if (ret) {
|
||||
pr_err("%s core init failed: %d\n", __func__, ret);
|
||||
+ /* MU300: power off while hif still exists (sprd_core_free frees priv, and hif with it) */
|
||||
+ sprd_iface_set_power(hif, false);
|
||||
sprd_hif_deinit(hif);
|
||||
sprd_core_free(priv);
|
||||
- sprd_iface_set_power(hif, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1800,9 +1813,9 @@
|
||||
if (ret) {
|
||||
pr_err("%s notify init failed: %d\n", __func__, ret);
|
||||
iface_core_deinit(priv);
|
||||
+ sprd_iface_set_power(hif, false);
|
||||
sprd_hif_deinit(hif);
|
||||
sprd_core_free(priv);
|
||||
- sprd_iface_set_power(hif, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1829,11 +1842,12 @@
|
||||
|
||||
iface_notify_deinit(priv);
|
||||
iface_core_deinit(priv);
|
||||
+ /* MU300: power off while hif still exists (sprd_core_free frees priv, and hif and its lock with it) */
|
||||
+ pr_info("Power off WCN (%d time)\n", atomic_read(&hif->power_cnt));
|
||||
+ sprd_iface_set_power(hif, false);
|
||||
sprd_hif_deinit(hif);
|
||||
sprd_core_free(priv);
|
||||
iface_set_priv(NULL);
|
||||
- pr_info("Power off WCN (%d time)\n", atomic_read(&hif->power_cnt));
|
||||
- sprd_iface_set_power(hif, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
--- a/sc2355/pcie.c
|
||||
+++ b/sc2355/pcie.c
|
||||
@@ -372,7 +372,7 @@
|
||||
struct mbuf_t *tail, int num)
|
||||
{
|
||||
struct sprd_hif *hif = sc2355_pcie_get_hif();
|
||||
- struct rx_mgmt *rx_mgmt = (struct rx_mgmt *)hif->rx_mgmt;
|
||||
+ struct rx_mgmt *rx_mgmt;
|
||||
struct sprd_msg *msg = NULL;
|
||||
int buf_num = 0, len = 0, ret = 0;
|
||||
struct mbuf_t *pos = head;
|
||||
@@ -380,6 +380,20 @@
|
||||
pr_debug("%s: channel:%d head:%p tail:%p num:%d\n",
|
||||
__func__, chn, head, tail, num);
|
||||
|
||||
+ /*
|
||||
+ * MU300: an RX interrupt outside the channels' lifetime (post_init publishes hif before it registers
|
||||
+ * them, post_deinit clears it after it unregistered them, sprd_iface_set_power serialises the two).
|
||||
+ * Without hif there is no device to unmap the buffers from and no queue to hand them to, and the
|
||||
+ * channel's mbuf pool is already freed (no sprdwcn_bus_list_free): the data buffers of this one list
|
||||
+ * leak, and it is said once. A NULL here was a panic in hard IRQ (FINDINGS 31n).
|
||||
+ */
|
||||
+ rx_mgmt = hif ? (struct rx_mgmt *)READ_ONCE(hif->rx_mgmt) : NULL;
|
||||
+ if (unlikely(!rx_mgmt)) {
|
||||
+ pr_err_once("%s: RX on channel %d with no Wi-Fi context, %d buffer(s) dropped\n",
|
||||
+ __func__, chn, num);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
for (buf_num = num; buf_num > 0; buf_num--, pos = pos->next) {
|
||||
if (unlikely(!pos)) {
|
||||
pr_err("%s: NULL mbuf\n", __func__);
|
||||
@@ -646,7 +660,7 @@
|
||||
|
||||
struct sprd_hif *sc2355_pcie_get_hif(void)
|
||||
{
|
||||
- return (struct sprd_hif *)sc2355_hif.hif;
|
||||
+ return (struct sprd_hif *)smp_load_acquire(&sc2355_hif.hif);
|
||||
}
|
||||
|
||||
#define INTF_IS_PCIE \
|
||||
@@ -1994,7 +2008,8 @@
|
||||
{
|
||||
int ret = -EINVAL, chn = 0;
|
||||
|
||||
- sc2355_hif.hif = (void *)hif;
|
||||
+ /* MU300: published before any channel can interrupt (the RX/TX callbacks read it in hard IRQ) */
|
||||
+ smp_store_release(&sc2355_hif.hif, (void *)hif);
|
||||
/*
|
||||
* MU300 (from kanoqwq/mu300-linux): a failed/aborted earlier power cycle clears this pointer in the
|
||||
* error path below. The vendor driver only restores it in pcie_init(),
|
||||
@@ -2040,7 +2055,8 @@
|
||||
|
||||
for (chn = 0; chn < sc2355_hif.max_num; chn++)
|
||||
sprdwcn_bus_chn_deinit(&sc2355_hif.mchn_ops[chn]);
|
||||
- sc2355_hif.hif = NULL;
|
||||
+ /* MU300: cleared only after every channel is unregistered (the callbacks check for NULL) */
|
||||
+ WRITE_ONCE(sc2355_hif.hif, NULL);
|
||||
sc2355_hif.max_num = 0;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
#!/bin/sh
|
||||
# Stop the temporary preinit DHCP server only when the real LAN is up.
|
||||
[ "$ACTION" = ifup ] && [ "$INTERFACE" = lan ] || exit 0
|
||||
# RNDIS must be a bridge port before removing its inherited preinit address.
|
||||
# Installed bridge configurations can predate the user's switch to RNDIS.
|
||||
if [ -e /sys/class/net/rndis0 ]; then
|
||||
ip link set rndis0 master br-lan 2>/dev/null
|
||||
ip link set rndis0 up 2>/dev/null
|
||||
fi
|
||||
pid=$(cat /run/mu300-early-udhcpd.pid 2>/dev/null)
|
||||
[ -n "$pid" ] && kill "$pid" 2>/dev/null
|
||||
rm -f /run/mu300-early-udhcpd.pid
|
||||
@@ -17,19 +23,14 @@ bridge_ip=$(ip -4 -o addr show dev br-lan 2>/dev/null | awk 'NR == 1 { print $4
|
||||
if [ -n "$bridge_ip" ]; then
|
||||
for nic in usb0 rndis0; do
|
||||
ip -o link show dev "$nic" 2>/dev/null | grep -q 'master br-lan' || continue
|
||||
ip -4 -o addr show dev "$nic" 2>/dev/null | grep -Fq "inet $bridge_ip " || continue
|
||||
ip addr del "$bridge_ip" dev "$nic" 2>/dev/null || true
|
||||
# Match the address even when preinit and netifd used different prefixes.
|
||||
nic_ip=$(ip -4 -o addr show dev "$nic" 2>/dev/null |
|
||||
awk -v a="${bridge_ip%/*}" '{ split($4, p, "/"); if (p[1] == a) { print $4; exit } }')
|
||||
[ -n "$nic_ip" ] || continue
|
||||
ip addr del "$nic_ip" dev "$nic" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
|
||||
# On an already-installed rootfs, firstboot's bridge UCI section predates a
|
||||
# later switch to RNDIS. Reattach its gadget netdev after every LAN ifup, not
|
||||
# only the first boot; this also covers a network reload from Device Management.
|
||||
if [ -e /sys/class/net/rndis0 ]; then
|
||||
ip link set rndis0 master br-lan 2>/dev/null
|
||||
ip link set rndis0 up 2>/dev/null
|
||||
fi
|
||||
|
||||
# The final NCM endpoint health check/rebind is a procd one-shot in mu300-post.
|
||||
# A detached child launched by hotplug can be reaped with the hotplug process;
|
||||
# keep this hook limited to the deterministic DHCP handoff above.
|
||||
@@ -13,7 +13,7 @@ function Check($name, $got, $want) {
|
||||
|
||||
# the functions under test, straight from install.ps1
|
||||
$ast = [System.Management.Automation.Language.Parser]::ParseFile((Join-Path $Top "install.ps1"), [ref]$null, [ref]$null)
|
||||
$want = 'LoadLanguage', 'T', 'NormalizeAnswer', 'Gib'
|
||||
$want = 'LoadLanguage', 'T', 'NormalizeAnswer', 'Gib', 'RegionOnDisk'
|
||||
$defs = $ast.FindAll({ param($n) $n -is [System.Management.Automation.Language.FunctionDefinitionAst] -and $want -contains $n.Name }, $true)
|
||||
foreach ($d in $defs) { . ([scriptblock]::Create($d.Extent.Text)) }
|
||||
foreach ($w in 'LoadLanguage', 'T', 'NormalizeAnswer') {
|
||||
@@ -56,5 +56,18 @@ if (Get-Command Gib -ErrorAction SilentlyContinue) {
|
||||
Check 'Gib' ((Gib 34828075008) -replace ',', '.') '32.4 GiB'
|
||||
}
|
||||
|
||||
# Only evaluate the extracted guard/loop, never execute an installer or adb.
|
||||
$disk = [int64]33554432
|
||||
foreach ($case in @(@(-1, $false), @(0, $true), @(17179867136, $true), @(17179867137, $false), @(27762098176, $false))) {
|
||||
Check "RegionOnDisk $($case[0])" (RegionOnDisk $case[0]) $case[1]
|
||||
}
|
||||
$uninstallText = [IO.File]::ReadAllText((Join-Path $Top 'uninstall.ps1'))
|
||||
$guard = ($uninstallText -split "`n" | Where-Object { $_ -match 'if \(\$cand -lt 0 -or' })
|
||||
Check 'uninstall bounds guard exists' ([bool]$guard) $true
|
||||
if ($guard) {
|
||||
$loop = 'foreach ($cand in @(-1, 0, 17179867136, 17179867137, 27762098176)) { ' + $guard + '; $cand }'
|
||||
Check 'uninstall bounded probes' ((& ([scriptblock]::Create($loop))) -join ',') '0,17179867136'
|
||||
}
|
||||
|
||||
Write-Host "$script:passed passed, $script:failed failed"
|
||||
exit $script:failed
|
||||
@@ -0,0 +1,122 @@
|
||||
"""Selected upstream fixes: offline checks only, never a real device or disk."""
|
||||
import unittest
|
||||
|
||||
from helpers import TOP, ShellTest
|
||||
|
||||
|
||||
class WifiSource(unittest.TestCase):
|
||||
def test_power_transition_lock_and_lifetime(self):
|
||||
wlan = TOP / 'upstream/modules/sprd_wlan_combo'
|
||||
hif = (wlan / 'common/hif.h').read_text()
|
||||
iface = (wlan / 'common/iface.c').read_text()
|
||||
pcie = (wlan / 'sc2355/pcie.c').read_text()
|
||||
patch = (TOP / 'kernel/patches/wlan_combo-wcn-power-serialise.patch').read_text()
|
||||
self.assertIn('struct mutex power_lock;', hif)
|
||||
for call in ('mutex_init', 'mutex_lock', 'mutex_unlock'):
|
||||
self.assertIn(call + '(&hif->power_lock);', iface)
|
||||
self.assertIn(call + '(&hif->power_lock);', patch)
|
||||
body = iface.split('int sprd_iface_set_power(', 1)[1].split('\n}\n', 1)[0]
|
||||
self.assertNotIn('return ', body.split('mutex_unlock', 1)[0])
|
||||
remove = iface.split('int sprd_iface_remove(', 1)[1]
|
||||
self.assertLess(remove.index('sprd_iface_set_power(hif, false)'), remove.index('sprd_core_free(priv)'))
|
||||
for name in ('core init failed', 'notify init failed'):
|
||||
error = iface.split(name, 1)[1].split('return ret;', 1)[0]
|
||||
self.assertLess(error.index('sprd_iface_set_power(hif, false)'), error.index('sprd_core_free(priv)'))
|
||||
rx = pcie.split('static int pcie_rx_handle(', 1)[1].split('\n}\n', 1)[0]
|
||||
self.assertLess(rx.index('if (unlikely(!rx_mgmt))'), rx.index('rx_mgmt->rx_list'))
|
||||
self.assertIn('smp_load_acquire(&sc2355_hif.hif)', pcie)
|
||||
self.assertIn('smp_store_release(&sc2355_hif.hif, (void *)hif)', pcie)
|
||||
off = pcie.split('void pcie_post_deinit(', 1)[1].split('\n}\n', 1)[0]
|
||||
self.assertLess(off.index('sprdwcn_bus_chn_deinit'), off.index('WRITE_ONCE(sc2355_hif.hif, NULL)'))
|
||||
failure = hif.split('if (sprd_sync_version(hif))', 1)[1].split('return -EIO;', 1)[0]
|
||||
for call in ('sprd_clean_work', 'sprd_hif_post_deinit', 'stop_marlin'):
|
||||
self.assertIn(call, failure)
|
||||
|
||||
def test_cleanup_dns_and_firmware_logging(self):
|
||||
root = TOP / 'upstream/modules'
|
||||
pcie = (root / 'sprd_wlan_combo/sc2355/pcie.c').read_text()
|
||||
self.assertIn('for (; chn >= 0; chn--)', pcie)
|
||||
pool = (root / 'wcn_bsp/pcie/mchn.c').read_text().split('int mbuf_pool_deinit(', 1)[1]
|
||||
self.assertLess(pool.index('if (!pool->mem)'), pool.index('memset(pool->mem'))
|
||||
tx = (root / 'sprd_wlan_combo/sc2355/tx.c').read_text().split('if (is_data2cmd)', 1)[1]
|
||||
self.assertLess(tx.index('(is_ipv4_dns || is_ipv6_dns)'), tx.index('skb->ip_summed = CHECKSUM_NONE'))
|
||||
resume = (root / 'wcn_bsp/pcie/pcie.c').read_text().split('static int sprd_ep_resume(', 1)[1]
|
||||
self.assertNotIn('wcn_set_armlog(true)', resume.split('\n}\n', 1)[0])
|
||||
init = (root / 'wcn_bsp/platform/sysfs.c').read_text().split('int init_wcn_sysfs(', 1)[1]
|
||||
self.assertIn('sysfs_info.armlog_status = 0;', init)
|
||||
rx = (root / 'sprd_wlan_combo/sc2355/rx.c').read_text()
|
||||
# Keep the deployed fork's conservative IPv6 fix; do not revive firmware checksum drops.
|
||||
fill = rx.split('int sc2355_fill_skb_csum(', 1)[1].split('\n}\n', 1)[0]
|
||||
self.assertIn('CHECKSUM_NONE', fill)
|
||||
self.assertNotIn('return -1', fill)
|
||||
|
||||
def test_legacy_build_does_not_hide_patch_failure(self):
|
||||
build = (TOP / 'kernel/build-all.sh').read_text()
|
||||
wlan = (TOP / 'kernel/build-wlan.sh').read_text()
|
||||
self.assertIn('sprdwcn-mbuf-pool-deinit-null', build)
|
||||
self.assertIn('patched_copy /src/ext-wlan_combo', build)
|
||||
self.assertIn('Wi-Fi patches changed:', wlan)
|
||||
for line in (build + wlan).splitlines():
|
||||
if 'patch -p1' in line:
|
||||
self.assertNotIn('|| true', line)
|
||||
|
||||
|
||||
class DiskBounds(ShellTest):
|
||||
def test_each_shell_probe_rejects_out_of_disk_offsets(self):
|
||||
for path in ('install.sh', 'uninstall.sh', 'tools/reset-password.sh'):
|
||||
source = (TOP / path).read_text()
|
||||
loop = source.split('for cand in ', 1)[1]
|
||||
guard = next(line for line in loop.splitlines() if 'cand + 2048' in line)
|
||||
self.assertLess(loop.index(guard), loop.index('m=$(su_do'))
|
||||
for shell in self.each_shell():
|
||||
# Includes a legacy 25.8-GiB offset on a 16-GiB eMMC and the exact boundary.
|
||||
r = self.sh(shell, 'disk=33554432\nfor cand in -1 0 17179867136 17179867137 27762098176; do\n'
|
||||
+ guard + '\nprintf "%s\\n" "$cand"\ndone')
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertEqual(r.stdout.splitlines(), ['0', '17179867136'])
|
||||
|
||||
def test_full_partition_table_yields_zero_region(self):
|
||||
source = (TOP / 'install.sh').read_text()
|
||||
calc = source.split('last_end=$1; disk=$2', 1)[1].split('\ngib()', 1)[0]
|
||||
for shell in self.each_shell():
|
||||
for disk in (33554432, 67108864):
|
||||
r = self.sh(shell, f'last_end={disk - 34}; disk={disk}\n' + calc + '\nprintf "%s" "$SIZE"')
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertEqual(r.stdout, '0')
|
||||
|
||||
|
||||
class UsbHandoff(ShellTest):
|
||||
def test_rndis_bridged_before_address_cleanup_without_extra_rebind(self):
|
||||
source = (TOP / 'openwrt/overlay/etc/hotplug.d/iface/10-mu300-usb').read_text()
|
||||
self.assertNotIn('/UDC', source) # the established procd re-enumeration stays in mu300-post
|
||||
net = self.tmp / 'net'
|
||||
(net / 'rndis0').mkdir(parents=True)
|
||||
source = source.replace('/sys/class/net', str(net)).replace('/run/mu300-early-udhcpd.pid', str(self.tmp / 'absent-pid'))
|
||||
self.stub('ip', '''
|
||||
printf '%s\n' "$*" >> "$STUBLOG/ip-calls"
|
||||
case "$*" in
|
||||
'link set rndis0 master br-lan') touch "$STUBLOG/bridged" ;;
|
||||
'-4 -o addr show dev br-lan') echo '2: br-lan inet 192.168.77.1/24 scope global br-lan' ;;
|
||||
'-o link show dev rndis0') [ -f "$STUBLOG/bridged" ] && echo '3: rndis0 master br-lan' ;;
|
||||
'-o link show dev usb0') echo '4: usb0' ;;
|
||||
'-4 -o addr show dev rndis0') echo "3: rndis0 inet $PORT_ADDR scope global rndis0" ;;
|
||||
esac
|
||||
exit 0
|
||||
''')
|
||||
for shell in self.each_shell():
|
||||
for address in ('192.168.77.1/24', '192.168.77.1/16', '192.168.88.1/24'):
|
||||
for name in ('bridged', 'ip-calls'):
|
||||
(self.tmp / name).unlink(missing_ok=True)
|
||||
r = self.sh(shell, source, ACTION='ifup', INTERFACE='lan', PORT_ADDR=address)
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
calls = (self.tmp / 'ip-calls').read_text()
|
||||
self.assertLess(calls.index('link set rndis0 master br-lan'), calls.index('-4 -o addr show dev br-lan'))
|
||||
if address.startswith('192.168.77.1/'):
|
||||
self.assertIn(f'addr del {address} dev rndis0', calls)
|
||||
else:
|
||||
self.assertNotIn('addr del ', calls)
|
||||
self.assertNotIn('addr del 192.168.77.1/24 dev usb0', calls)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -24,10 +24,12 @@ require_android
|
||||
|
||||
say "Looking for the Linux filesystem"
|
||||
# the same search install.sh does; all byte arithmetic happens here, not in Android's 32-bit shell
|
||||
set -- $(su_do 'e=0; for p in /sys/block/mmcblk0/mmcblk0p*; do x=$(( $(cat $p/start) + $(cat $p/size) )); [ $x -gt $e ] && e=$x; done; echo $e')
|
||||
[ -n "${1:-}" ] || die "could not read the partition table from the device"
|
||||
set -- $(su_do 'e=0; for p in /sys/block/mmcblk0/mmcblk0p*; do x=$(( $(cat $p/start) + $(cat $p/size) )); [ $x -gt $e ] && e=$x; done; echo $e $(cat /sys/block/mmcblk0/size)')
|
||||
[ $# -eq 2 ] || die "could not read the partition table from the device"
|
||||
disk=$2
|
||||
OFF=
|
||||
for cand in $(( ($1 / 4096 + 1) * 4096 * 512 )) 27762098176; do
|
||||
[ "$cand" -ge 0 ] && [ $((cand + 2048)) -le $((disk * 512)) ] || continue
|
||||
m=$(su_do "dd if=/dev/block/mmcblk0 bs=1 skip=$((cand + 1080)) count=2 2>/dev/null | od -An -tx1" | tr -d ' ')
|
||||
l=$(su_do "dd if=/dev/block/mmcblk0 bs=1 skip=$((cand + 1144)) count=16 2>/dev/null" | tr -d '\000')
|
||||
if [ "$m" = 53ef ] && [ "$l" = mu300root ]; then
|
||||
|
||||
@@ -148,6 +148,8 @@ if ($parts.Count -ne 2) { Die 'could not read the partition table from the devic
|
||||
[int64]$OFF = 0; [int64]$SIZE = 0
|
||||
[int64]$start = [math]::Floor($lastEnd / 4096 + 1) * 4096 * 512
|
||||
foreach ($cand in @($start, 27762098176)) {
|
||||
# Upstream 486856c: do not read a legacy/dynamic superblock past the eMMC.
|
||||
if ($cand -lt 0 -or ($cand + 2048) -gt ($disk * 512)) { continue }
|
||||
$m = (SuDo "dd if=/dev/block/mmcblk0 bs=1 skip=$($cand + 1080) count=2 2>/dev/null | od -An -tx1") -replace '\s', ''
|
||||
$l = (SuDo "dd if=/dev/block/mmcblk0 bs=1 skip=$($cand + 1144) count=16 2>/dev/null") -replace '\0', ''
|
||||
if ($m -eq '53ef' -and $l.Trim() -eq 'mu300root') {
|
||||
|
||||
@@ -37,6 +37,7 @@ last_end=$1; disk=$2
|
||||
OFF=; SIZE=
|
||||
start=$(( (last_end / 4096 + 1) * 4096 * 512 ))
|
||||
for cand in $start 27762098176; do
|
||||
[ "$cand" -ge 0 ] && [ $((cand + 2048)) -le $((disk * 512)) ] || continue
|
||||
m=$(su_do "dd if=/dev/block/mmcblk0 bs=1 skip=$((cand + 1080)) count=2 2>/dev/null | od -An -tx1" | tr -d ' ')
|
||||
l=$(su_do "dd if=/dev/block/mmcblk0 bs=1 skip=$((cand + 1144)) count=16 2>/dev/null" | tr -d '\000')
|
||||
if [ "$m" = 53ef ] && [ "$l" = mu300root ]; then
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef __HIF_H__
|
||||
#define __HIF_H__
|
||||
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <misc/marlin_platform.h>
|
||||
|
||||
@@ -117,6 +118,8 @@ struct sprd_hif {
|
||||
|
||||
int exit;
|
||||
atomic_t power_cnt;
|
||||
/* MU300: one WCN power transition at a time (sprd_iface_set_power) */
|
||||
struct mutex power_lock;
|
||||
int flag;
|
||||
int lastflag;
|
||||
u8 cp_asserted;
|
||||
@@ -289,6 +292,9 @@ static inline int sprd_hif_power_on(struct sprd_hif *hif)
|
||||
}
|
||||
|
||||
if (sprd_hif_post_init(hif)) {
|
||||
/* MU300: post_init unwound its channels; the chip was started, stop it as a power-off would */
|
||||
if (stop_marlin(MARLIN_WIFI))
|
||||
pr_err("stop_marlin failed!!\n");
|
||||
atomic_sub(1, &hif->power_cnt);
|
||||
return -ENODEV;
|
||||
}
|
||||
@@ -301,6 +307,15 @@ static inline int sprd_hif_power_on(struct sprd_hif *hif)
|
||||
}
|
||||
|
||||
if (sprd_sync_version(hif)) {
|
||||
/*
|
||||
* MU300: undo the power-on as sprd_hif_power_off() does. The vendor left the channels registered
|
||||
* and the chip started with the count at 0: the next power-on registered them again over live ones,
|
||||
* and a probe that failed here freed hif under channels that could still interrupt.
|
||||
*/
|
||||
sprd_clean_work(hif->priv);
|
||||
sprd_hif_post_deinit(hif);
|
||||
if (stop_marlin(MARLIN_WIFI))
|
||||
pr_err("stop_marlin failed!!\n");
|
||||
atomic_sub(1, &hif->power_cnt);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@@ -266,6 +266,15 @@ int sprd_iface_set_power(struct sprd_hif *hif, int val)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* MU300: power_cnt is atomic, the transitions behind it are not. Probe powers the chip off after it
|
||||
* registered wlan0, outside RTNL, so userspace (hostapd, netifd) can open the interface meanwhile: the
|
||||
* open's power-on (1st count) ran start_marlin + post_init while the probe's power-off (last count) was
|
||||
* still in post_deinit. post_deinit then cleared the channels and sc2355_hif.hif that post_init had just
|
||||
* set, stop_marlin powered the chip down, and the next RX interrupt read hif->rx_mgmt from NULL
|
||||
* (pcie_rx_handle+0x34, "paging request at 00000000000030b8", FINDINGS 31n). One transition at a time.
|
||||
*/
|
||||
mutex_lock(&hif->power_lock);
|
||||
if (val) {
|
||||
sprd_wlan_power_status_sync(1, 1);
|
||||
ret = sprd_hif_power_on(hif);
|
||||
@@ -276,12 +285,14 @@ int sprd_iface_set_power(struct sprd_hif *hif, int val)
|
||||
else if (ret == -EIO)
|
||||
pr_err("SYNC cmd error!\n");
|
||||
|
||||
return ret;
|
||||
goto out;
|
||||
}
|
||||
if (atomic_read(&hif->power_cnt) == 1)
|
||||
sprd_get_fw_info(hif->priv);
|
||||
} else
|
||||
sprd_hif_power_off(hif);
|
||||
out:
|
||||
mutex_unlock(&hif->power_lock);
|
||||
return ret;
|
||||
}
|
||||
#ifdef DRV_RESET_SELF
|
||||
@@ -1770,6 +1781,7 @@ int sprd_iface_probe(struct platform_device *pdev,
|
||||
iface_set_priv(priv);
|
||||
platform_set_drvdata(pdev, priv);
|
||||
hif = &priv->hif;
|
||||
mutex_init(&hif->power_lock);
|
||||
hif->priv = priv;
|
||||
hif->pdev = pdev;
|
||||
hif->ops = hif_ops;
|
||||
@@ -1792,9 +1804,10 @@ int sprd_iface_probe(struct platform_device *pdev,
|
||||
ret = iface_core_init(&pdev->dev, priv);
|
||||
if (ret) {
|
||||
pr_err("%s core init failed: %d\n", __func__, ret);
|
||||
/* MU300: power off while hif still exists (sprd_core_free frees priv, and hif with it) */
|
||||
sprd_iface_set_power(hif, false);
|
||||
sprd_hif_deinit(hif);
|
||||
sprd_core_free(priv);
|
||||
sprd_iface_set_power(hif, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1802,9 +1815,9 @@ int sprd_iface_probe(struct platform_device *pdev,
|
||||
if (ret) {
|
||||
pr_err("%s notify init failed: %d\n", __func__, ret);
|
||||
iface_core_deinit(priv);
|
||||
sprd_iface_set_power(hif, false);
|
||||
sprd_hif_deinit(hif);
|
||||
sprd_core_free(priv);
|
||||
sprd_iface_set_power(hif, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1831,11 +1844,12 @@ int sprd_iface_remove(struct platform_device *pdev)
|
||||
|
||||
iface_notify_deinit(priv);
|
||||
iface_core_deinit(priv);
|
||||
/* MU300: power off while hif still exists (sprd_core_free frees priv, and hif and its lock with it) */
|
||||
pr_info("Power off WCN (%d time)\n", atomic_read(&hif->power_cnt));
|
||||
sprd_iface_set_power(hif, false);
|
||||
sprd_hif_deinit(hif);
|
||||
sprd_core_free(priv);
|
||||
iface_set_priv(NULL);
|
||||
pr_info("Power off WCN (%d time)\n", atomic_read(&hif->power_cnt));
|
||||
sprd_iface_set_power(hif, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ static int pcie_rx_handle(int chn, struct mbuf_t *head,
|
||||
struct mbuf_t *tail, int num)
|
||||
{
|
||||
struct sprd_hif *hif = sc2355_pcie_get_hif();
|
||||
struct rx_mgmt *rx_mgmt = (struct rx_mgmt *)hif->rx_mgmt;
|
||||
struct rx_mgmt *rx_mgmt;
|
||||
struct sprd_msg *msg = NULL;
|
||||
int buf_num = 0, len = 0, ret = 0;
|
||||
struct mbuf_t *pos = head;
|
||||
@@ -394,6 +394,20 @@ static int pcie_rx_handle(int chn, struct mbuf_t *head,
|
||||
pr_debug("%s: channel:%d head:%p tail:%p num:%d\n",
|
||||
__func__, chn, head, tail, num);
|
||||
|
||||
/*
|
||||
* MU300: an RX interrupt outside the channels' lifetime (post_init publishes hif before it registers
|
||||
* them, post_deinit clears it after it unregistered them, sprd_iface_set_power serialises the two).
|
||||
* Without hif there is no device to unmap the buffers from and no queue to hand them to, and the
|
||||
* channel's mbuf pool is already freed (no sprdwcn_bus_list_free): the data buffers of this one list
|
||||
* leak, and it is said once. A NULL here was a panic in hard IRQ (FINDINGS 31n).
|
||||
*/
|
||||
rx_mgmt = hif ? (struct rx_mgmt *)READ_ONCE(hif->rx_mgmt) : NULL;
|
||||
if (unlikely(!rx_mgmt)) {
|
||||
pr_err_once("%s: RX on channel %d with no Wi-Fi context, %d buffer(s) dropped\n",
|
||||
__func__, chn, num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (buf_num = num; buf_num > 0; buf_num--, pos = pos->next) {
|
||||
if (unlikely(!pos)) {
|
||||
pr_err("%s: NULL mbuf\n", __func__);
|
||||
@@ -660,7 +674,7 @@ out:
|
||||
|
||||
struct sprd_hif *sc2355_pcie_get_hif(void)
|
||||
{
|
||||
return (struct sprd_hif *)sc2355_hif.hif;
|
||||
return (struct sprd_hif *)smp_load_acquire(&sc2355_hif.hif);
|
||||
}
|
||||
|
||||
#define INTF_IS_PCIE \
|
||||
@@ -2019,9 +2033,10 @@ int pcie_post_init(struct sprd_hif *hif)
|
||||
{
|
||||
int ret = -EINVAL, chn = 0;
|
||||
|
||||
sc2355_hif.hif = (void *)hif;
|
||||
/* MU300: published before any channel can interrupt (the RX/TX callbacks read it in hard IRQ) */
|
||||
smp_store_release(&sc2355_hif.hif, (void *)hif);
|
||||
/*
|
||||
* A failed/aborted earlier power cycle clears this pointer in the
|
||||
* MU300 (from kanoqwq/mu300-linux): a failed/aborted earlier power cycle clears this pointer in the
|
||||
* error path below. The vendor driver only restores it in pcie_init(),
|
||||
* but a later WCN power-on may call post_init directly. Passing
|
||||
* &NULL[0] to mchn_init then makes Wi-Fi permanently fail until reboot.
|
||||
@@ -2049,7 +2064,9 @@ int pcie_post_init(struct sprd_hif *hif)
|
||||
err:
|
||||
pr_err("%s: unregister %d ops\n", __func__, sc2355_hif.max_num);
|
||||
|
||||
for (; chn > 0; chn--)
|
||||
/* 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;
|
||||
@@ -2063,7 +2080,8 @@ void pcie_post_deinit(struct sprd_hif *hif)
|
||||
|
||||
for (chn = 0; chn < sc2355_hif.max_num; chn++)
|
||||
sprdwcn_bus_chn_deinit(&sc2355_hif.mchn_ops[chn]);
|
||||
sc2355_hif.hif = NULL;
|
||||
/* MU300: cleared only after every channel is unregistered (the callbacks check for NULL) */
|
||||
WRITE_ONCE(sc2355_hif.hif, NULL);
|
||||
sc2355_hif.max_num = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -1060,6 +1060,17 @@ static int tx_filter_ip_pkt(struct sk_buff *skb, struct net_device *ndev)
|
||||
|
||||
/*as CP request, send data with CMD */
|
||||
if (is_data2cmd) {
|
||||
/* AP DNS is ordinary client traffic. The board NVM can leave
|
||||
* special_data_flag outside its 0..2 enum (observed: 32); using
|
||||
* CMD_TX_DATA for every DNS reply can wedge the firmware command
|
||||
* queue and assert CP2. Keep DHCP and VoWiFi on their paths.
|
||||
*/
|
||||
if ((vif->mode == SPRD_MODE_AP ||
|
||||
vif->mode == SPRD_MODE_P2P_GO) &&
|
||||
(is_ipv4_dns || is_ipv6_dns) &&
|
||||
!is_ipv4_dhcp && !is_ipv6_dhcp && !is_vowifi2cmd)
|
||||
return 1;
|
||||
|
||||
if (is_ipv4_dhcp || is_ipv6_dhcp)
|
||||
pr_info("dhcp,check:%x,skb->ip_summed:%d\n",
|
||||
udphdr->check, skb->ip_summed);
|
||||
@@ -1083,17 +1094,6 @@ static int tx_filter_ip_pkt(struct sk_buff *skb, struct net_device *ndev)
|
||||
skb->ip_summed = CHECKSUM_NONE;
|
||||
}
|
||||
|
||||
/* AP DNS is ordinary client traffic. The board NVM can leave
|
||||
* special_data_flag outside its 0..2 enum (observed: 32); using
|
||||
* CMD_TX_DATA for every DNS reply can wedge the firmware command
|
||||
* queue and assert CP2. Keep DHCP and VoWiFi on their paths.
|
||||
*/
|
||||
if ((vif->mode == SPRD_MODE_AP ||
|
||||
vif->mode == SPRD_MODE_P2P_GO) &&
|
||||
(is_ipv4_dns || is_ipv6_dns) &&
|
||||
!is_ipv4_dhcp && !is_ipv6_dhcp && !is_vowifi2cmd)
|
||||
return 1;
|
||||
|
||||
spin_lock_bh(&adap_info.adap_lock);
|
||||
pr_info("%s special_data_flag: %d\n",
|
||||
__func__, adap_info.special_data_flag);
|
||||
|
||||
@@ -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);
|
||||
@@ -363,4 +366,3 @@ int mchn_deinit(struct mchn_ops_t *ops)
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(mchn_deinit);
|
||||
|
||||
@@ -1268,7 +1268,11 @@ static int sprd_ep_resume(struct device *dev)
|
||||
|
||||
wcn_bus_change_state(priv, WCN_BUS_UP);
|
||||
atomic_set(&priv->is_suspending, 0);
|
||||
wcn_set_armlog(true);
|
||||
/*
|
||||
* MU300: the vendor turned the firmware's ARM log on here after every resume. The firmware keeps the setting
|
||||
* through D3hot, and with the log on it pulls PCIe WAKE# within 0-2 s of every L2 entry to push log packets:
|
||||
* a system sleep with Wi-Fi up ended at once (FINDINGS 37). It is off by default (sysfs.c); leave it as it was.
|
||||
*/
|
||||
mdbg_device_lock_notify();
|
||||
for (chn = 0; chn < 16; chn++) {
|
||||
ops = mchn_ops(chn);
|
||||
|
||||
@@ -1064,6 +1064,14 @@ int init_wcn_sysfs(void)
|
||||
atomic_set(&sysfs_info.is_reset, 0x0);
|
||||
sysfs_info.armlog_status = 1;
|
||||
#endif
|
||||
/*
|
||||
* MU300: the firmware's ARM log off, as in Android's user builds (it is turned on at every chip power-on
|
||||
* from this value, and wifi-start's "at+armlog=0" did not outlive the next power-on). With it on, the
|
||||
* firmware pulls PCIe WAKE# within 0-2 s of every L2 entry to push log packets, and a system sleep with
|
||||
* PCIe wakeup enabled ended at once (FINDINGS 37). echo 1 > /sys/devices/virtual/misc/wcn/devices/armlog_status
|
||||
* turns it on for debugging.
|
||||
*/
|
||||
sysfs_info.armlog_status = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user