linux/drivers/net
Zong-Zhe Yang 22b10cdb73 wifi: rtw89: introduce helpers to wait/complete on condition
MCC (multi-channel concurrency) related H2Cs (host to chip commands)
require to wait for C2H (chip to host events) responses to judge the
execution result and data. We introduce helpers to assist this process.
Besides, we would like the helpers to be generic for use in driver even
outside of MCC H2C/C2H, so we make a independent patch for them.

In the following, I describe the things first.
```
(A)	C2H is generated by FW, and then transferred upto driver. Hence,
	driver cannot get it immediately without a bit waitting/blocking.
	For this, we choose to use wait_for_completion_*() instead of
	busy polling.
(B)	From the driver management perspective, a scenario, e.g. MCC,
	may have mulitple kind of H2C functions requiring this process
	to wait for corresponding C2Hs. But, the driver management flow
	uses mutex to protect each behavior. So, one scenario triggers
	one H2C function at one time. To avoid rampant instances of
	struct completion for each H2C function, we choose to use one
	struct completion with one condition flag for one scenario.
(C)	C2Hs, which H2Cs will be waitting for, cannot be ordered with
	driver management flow, i.e. cannot enqueue work to the same
	ordered workqueue and cannot lock by the same mutex, to prevent
	H2C side from getting no C2H responses. So, those C2Hs are parsed
	in interrupt context directly as done in previous commit.
(D)	Following (C), the above underline H2Cs and C2Hs will be handled
	in different contexts without sync. So, we use atomic_cmpxchg()
	to compare and change the condition in atomic.
```

So, we introduce struct rtw89_wait_info which combines struct completion
and atomic_t. Then, the below are the descriptions for helper functions.
* rtw89_wait_for_cond() to wait for a completion based on a condition.
* rtw89_complete_cond() to complete a given condition and carry data.
Each rtw89_wait_info instance independently determines the meaning of
its waitting conditions. But, RTW89_WAIT_COND_IDLE (UINT_MAX) is reserved.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221129083130.45708-4-pkshih@realtek.com
2022-12-01 13:04:26 +02:00
..
appletalk
arcnet
bonding
caif
can Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-10 17:43:53 -08:00
dsa net: dsa: felix: use phylink_generic_validate() 2022-11-15 20:34:27 -08:00
ethernet net: ethernet: mtk_eth_soc: remove cpu_relax in mtk_pending_work 2022-11-18 12:00:17 +00:00
fddi
fjes
hamradio Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-10 17:43:53 -08:00
hippi
hyperv
ieee802154
ipa net: ipa: avoid a null pointer dereference 2022-11-18 11:46:18 +00:00
ipvlan
mctp mctp i2c: don't count unused / invalid keys for flow release 2022-11-11 20:13:27 -08:00
mdio
netdevsim devlink: Allow to set up parent in devl_rate_leaf_create() 2022-11-17 21:41:27 -08:00
pcs net: pcs: xpcs: use mdiodev accessors 2022-11-09 19:28:49 -08:00
phy net: phy: mscc: macsec: do not copy encryption keys 2022-11-18 09:17:42 +00:00
plip
ppp
pse-pd
slip
team
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-17 18:30:39 -08:00
vmxnet3
vxlan rtnetlink: pass netlink message header and portid to rtnl_configure_link() 2022-10-31 18:10:21 -07:00
wan net: lapbether: fix issue of invalid opcode in lapbeth_open() 2022-11-08 12:47:36 +01:00
wireguard
wireless wifi: rtw89: introduce helpers to wait/complete on condition 2022-12-01 13:04:26 +02:00
wwan Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-10 17:43:53 -08:00
xen-netback
amt.c
bareudp.c
dummy.c ethtool: doc: clarify what drivers can implement in their get_drvinfo() 2022-11-17 19:26:02 -08:00
eql.c
geneve.c rtnetlink: pass netlink message header and portid to rtnl_configure_link() 2022-10-31 18:10:21 -07:00
gtp.c
ifb.c
Kconfig
LICENSE.SRC
loopback.c
macsec.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-10 17:43:53 -08:00
macvlan.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-17 18:30:39 -08:00
macvtap.c
Makefile
mdio.c
mhi_net.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-17 18:30:39 -08:00
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c
thunderbolt.c net: thunderbolt: Fix error handling in tbnet_init() 2022-11-16 09:19:37 +00:00
tun.c net: tun: rebuild error handling in tun_get_user 2022-11-14 09:52:07 +00:00
veth.c bpf: veth driver panics when xdp prog attached before veth_open 2022-11-09 21:02:24 -08:00
virtio_net.c
vrf.c
vsockmon.c
xen-netfront.c