[][MAC80211][WiFi7][misc][Prevent deadlock in a multiple AP+STA mode]

[Description]
Fix the deadlock in multiple AP+STA mode.

When setting up interfaces in a multiple AP+STA mode, there might be
a deadlock between hostapd and wpa_supplicant.

Netifd sets up each radio in order of radio number. For single radio
setup, hostapd is first asked for setting up AP interface, then it
leverages ucode to ask wpa_supplicant for setting up STA interface.
An interface setup order in a multiple AP+STA mode might be:
phy0-ap0 -> phy0-sta0 -> phy1-ap0 -> phy1-sta0 -> phy2-ap0 -> phy2-sta0

However, since netifd only controls the order to set radio up and the
setup time of each AP interface varies, the atual setup order might change.
For example, phy2-ap0 might start its setup BEFORE phy1-sta0 finishes the
setup.

Moreover, hostapd blocks when it levereges ucode to send message to
wpa_supplicant, and vice versa.

A deadlock happens in the following scenario:
1. [wpa_supplicant] phy1-sta0 enters SCANNING state and leverages ucode
   to stop phy1-ap0. wpa_cupplicant blocks unitl hostapd finishes
   stopping phy1-ap0.
2. [hostapd] After hostapd finishes setting up phy2-ap0, it leverages
   ucode to ask wpa_supplicant for setting up phy2-sta0. hostapd blocks
   until wpa_supplicant finishes setting up phy2-sta0.

To avoid the deadlock, the interval between setting up each radio
becomes longer so that each radio is set up without affecting
each other.

[Release-log]
N/A

Change-Id: Ieaaba99bd6505abd500c1f2ebe5137a61b9655fa
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8102680
diff --git a/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch b/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch
index 72e03a4..69e9ff3 100644
--- a/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch
+++ b/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch
@@ -1,5 +1,5 @@
 diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
-index c9e2a37f..af1932ff 100644
+index c9e2a37..af1932f 100644
 --- a/package/kernel/mac80211/Makefile
 +++ b/package/kernel/mac80211/Makefile
 @@ -20,6 +20,7 @@ PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz
@@ -31,7 +31,7 @@
  		$(PKG_BUILD_DIR)/include/linux/ssb \
  		$(PKG_BUILD_DIR)/include/linux/bcma \
 diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
-index 86060930..d68c5044 100644
+index 8606093..e1091df 100644
 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
 +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
 @@ -25,10 +25,12 @@ drv_mac80211_init_device_config() {
@@ -456,9 +456,9 @@
 +
 +	# each phy sleeps different times to prevent for ubus race condition.
 +	if [ "$phy" = "phy1" ]; then
-+		sleep 1;
++		sleep 3;
 +	elif [ "$phy" = "phy2" ]; then
-+		sleep 2;
++		sleep 6;
 +	fi
 +
  	local hostapd_res="$(ubus call hostapd config_set "{ \"phy\": \"$phy\", \"config\":\"${hostapd_conf_file}\", \"prev_config\": \"${hostapd_conf_file}.prev\"}")"
@@ -531,7 +531,7 @@
  
  	json_set_namespace wdev_uc prev
 diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
-index e24a2a63..da3ee8cc 100644
+index e24a2a6..da3ee8c 100644
 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
 +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
 @@ -60,6 +60,9 @@ BEGIN {
@@ -686,7 +686,7 @@
  	done
  }
 diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
-index 271c1f7b..4482c179 100644
+index 271c1f7..4482c17 100644
 --- a/package/network/services/hostapd/files/hostapd.sh
 +++ b/package/network/services/hostapd/files/hostapd.sh
 @@ -60,7 +60,14 @@ hostapd_append_wpa_key_mgmt() {