[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f14f19de-d272-b95b-21f3-35bfd23a29d3@lwfinger.net>
Date: Fri, 20 May 2022 12:32:57 -0500
From: Larry Finger <Larry.Finger@...inger.net>
To: Sascha Hauer <s.hauer@...gutronix.de>,
linux-wireless@...r.kernel.org
Cc: Neo Jou <neojou@...il.com>, Hans Ulli Kroll <linux@...i-kroll.de>,
Ping-Ke Shih <pkshih@...ltek.com>,
Yan-Hsuan Chuang <tony0620emma@...il.com>,
Kalle Valo <kvalo@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
kernel@...gutronix.de, Johannes Berg <johannes@...solutions.net>
Subject: Re: [PATCH 05/10] rtw88: Do not access registers while atomic
On 5/18/22 03:23, Sascha Hauer wrote:
> The driver uses ieee80211_iterate_active_interfaces_atomic()
> and ieee80211_iterate_stations_atomic() in several places and does
> register accesses in the iterators. This doesn't cope with upcoming
> USB support as registers can only be accessed non-atomically.
>
> Split these into a two stage process: First use the atomic iterator
> functions to collect all active interfaces or stations on a list, then
> iterate over the list non-atomically and call the iterator on each
> entry.
>
> Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
> Suggested-by: Pkshih <pkshih@...ltek.com>
> ---
> drivers/net/wireless/realtek/rtw88/phy.c | 6 +-
> drivers/net/wireless/realtek/rtw88/ps.c | 2 +-
> drivers/net/wireless/realtek/rtw88/util.c | 92 +++++++++++++++++++++++
> drivers/net/wireless/realtek/rtw88/util.h | 12 ++-
> 4 files changed, 105 insertions(+), 7 deletions(-)
>
...
> diff --git a/drivers/net/wireless/realtek/rtw88/util.c b/drivers/net/wireless/realtek/rtw88/util.c
> index 2c515af214e76..db55dbd5c533e 100644
> --- a/drivers/net/wireless/realtek/rtw88/util.c
> +++ b/drivers/net/wireless/realtek/rtw88/util.c
> @@ -105,3 +105,95 @@ void rtw_desc_to_mcsrate(u16 rate, u8 *mcs, u8 *nss)
> *mcs = rate - DESC_RATEMCS0;
> }
> }
> +
> +struct rtw_stas_entry {
> + struct list_head list;
> + struct ieee80211_sta *sta;
> +};
> +
> +struct rtw_iter_stas_data {
> + struct rtw_dev *rtwdev;
> + struct list_head list;
> +};
> +
> +void rtw_collect_sta_iter(void *data, struct ieee80211_sta *sta)
> +{
> + struct rtw_iter_stas_data *iter_stas = data;
> + struct rtw_stas_entry *stas_entry;
> +
> + stas_entry = kmalloc(sizeof(*stas_entry), GFP_ATOMIC);
> + if (!stas_entry)
> + return;
> +
> + stas_entry->sta = sta;
> + list_add_tail(&stas_entry->list, &iter_stas->list);
> +}
> +
> +void rtw_iterate_stas(struct rtw_dev *rtwdev,
> + void (*iterator)(void *data,
> + struct ieee80211_sta *sta),
> + void *data)
> +{
> + struct rtw_iter_stas_data iter_data;
> + struct rtw_stas_entry *sta_entry, *tmp;
> +
> + iter_data.rtwdev = rtwdev;
> + INIT_LIST_HEAD(&iter_data.list);
> +
> + ieee80211_iterate_stations_atomic(rtwdev->hw, rtw_collect_sta_iter,
> + &iter_data);
> +
> + list_for_each_entry_safe(sta_entry, tmp, &iter_data.list,
> + list) {
> + list_del_init(&sta_entry->list);
> + iterator(data, sta_entry->sta);
> + kfree(sta_entry);
> + }
> +}
> +
> +struct rtw_vifs_entry {
> + struct list_head list;
> + struct ieee80211_vif *vif;
> + u8 mac[ETH_ALEN];
> +};
> +
> +struct rtw_iter_vifs_data {
> + struct rtw_dev *rtwdev;
> + struct list_head list;
> +};
> +
> +void rtw_collect_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
> +{
> + struct rtw_iter_vifs_data *iter_stas = data;
> + struct rtw_vifs_entry *vifs_entry;
> +
> + vifs_entry = kmalloc(sizeof(*vifs_entry), GFP_ATOMIC);
> + if (!vifs_entry)
> + return;
> +
> + vifs_entry->vif = vif;
> + ether_addr_copy(vifs_entry->mac, mac);
> + list_add_tail(&vifs_entry->list, &iter_stas->list);
> +}
> +
> +void rtw_iterate_vifs(struct rtw_dev *rtwdev,
> + void (*iterator)(void *data, u8 *mac,
> + struct ieee80211_vif *vif),
> + void *data)
> +{
> + struct rtw_iter_vifs_data iter_data;
> + struct rtw_vifs_entry *vif_entry, *tmp;
> +
> + iter_data.rtwdev = rtwdev;
> + INIT_LIST_HEAD(&iter_data.list);
> +
> + ieee80211_iterate_active_interfaces_atomic(rtwdev->hw,
> + IEEE80211_IFACE_ITER_NORMAL, rtw_collect_vif_iter, &iter_data);
> +
> + list_for_each_entry_safe(vif_entry, tmp, &iter_data.list,
> + list) {
> + list_del_init(&vif_entry->list);
> + iterator(data, vif_entry->mac, vif_entry->vif);
> + kfree(vif_entry);
> + }
> +}
Sasha,
Sparse shows the following warnings:
CHECK /home/finger/iwireless-next/drivers/net/wireless/realtek/rtw88/util.c
/home/finger/wireless-next/drivers/net/wireless/realtek/rtw88/util.c:119:6:
warning: symbol 'rtw_collect_sta_iter' was not declared. Should it be static?
/home/finger/wireless-next/drivers/net/wireless/realtek/rtw88/util.c:165:6:
warning: symbol 'rtw_collect_vif_iter' was not declared. Should it be static?
Larry
Powered by blists - more mailing lists