linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: Sascha Hauer <s.hauer@pengutronix.de>, linux-wireless@vger.kernel.org
Cc: Neo Jou <neojou@gmail.com>, Hans Ulli Kroll <linux@ulli-kroll.de>,
	Ping-Ke Shih <pkshih@realtek.com>,
	Yan-Hsuan Chuang <tony0620emma@gmail.com>,
	Kalle Valo <kvalo@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	kernel@pengutronix.de, Johannes Berg <johannes@sipsolutions.net>
Subject: Re: [PATCH 05/10] rtw88: Do not access registers while atomic
Date: Fri, 20 May 2022 12:32:57 -0500	[thread overview]
Message-ID: <f14f19de-d272-b95b-21f3-35bfd23a29d3@lwfinger.net> (raw)
In-Reply-To: <20220518082318.3898514-6-s.hauer@pengutronix.de>

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@pengutronix.de>
> Suggested-by: Pkshih <pkshih@realtek.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

  parent reply	other threads:[~2022-05-20 17:33 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18  8:23 [PATCH 00/10] RTW88: Add support for USB variants Sascha Hauer
2022-05-18  8:23 ` [PATCH 01/10] rtw88: Call rtw_fw_beacon_filter_config() with rtwdev->mutex held Sascha Hauer
2022-05-18  8:23 ` [PATCH 02/10] rtw88: Drop rf_lock Sascha Hauer
2022-05-20  3:49   ` Pkshih
2022-05-20  6:54     ` s.hauer
2022-05-18  8:23 ` [PATCH 03/10] rtw88: Drop h2c.lock Sascha Hauer
2022-05-18  8:23 ` [PATCH 04/10] rtw88: Drop coex mutex Sascha Hauer
2022-05-18  8:23 ` [PATCH 05/10] rtw88: Do not access registers while atomic Sascha Hauer
2022-05-20  6:06   ` Pkshih
2022-05-20  7:07     ` s.hauer
2022-05-20 17:32   ` Larry Finger [this message]
2022-05-18  8:23 ` [PATCH 06/10] rtw88: Add common USB chip support Sascha Hauer
2022-05-18  8:32   ` Sascha Hauer
2022-05-18  8:34     ` Johannes Berg
2022-05-19 13:58       ` Sascha Hauer
2022-05-20  7:39   ` Pkshih
2022-05-20  8:51     ` s.hauer
2022-05-20  9:23       ` Pkshih
2022-05-20 18:33   ` Larry Finger
2022-05-23  4:07   ` Hans Ulli Kroll
2022-05-18  8:23 ` [PATCH 07/10] rtw88: Add rtw8723du chipset support Sascha Hauer
2022-05-18 16:55   ` kernel test robot
2022-05-20  7:47   ` Pkshih
2022-05-20  8:16     ` s.hauer
2022-05-30  6:34   ` Icenowy Zheng
2022-05-18  8:23 ` [PATCH 08/10] rtw88: Add rtw8821cu " Sascha Hauer
2022-05-20  7:56   ` Pkshih
2022-05-18  8:23 ` [PATCH 09/10] rtw88: Add rtw8822bu " Sascha Hauer
2022-05-20  7:58   ` Pkshih
2022-05-23 11:56   ` Rin Cat (鈴猫)
2022-05-23 12:34     ` Sascha Hauer
2022-05-18  8:23 ` [PATCH 10/10] rtw88: Add rtw8822cu " Sascha Hauer
2022-05-20  8:03   ` Pkshih
2022-05-20  8:56     ` s.hauer
2022-05-23  4:07 ` [PATCH 00/10] RTW88: Add support for USB variants Hans Ulli Kroll
2022-05-23  6:53   ` Sascha Hauer
2022-05-23 11:39     ` Ping-Ke Shih
2022-05-24  6:54       ` s.hauer
2022-05-23 10:13   ` Sascha Hauer
2022-05-30  9:25 ` Kalle Valo
2022-05-30  9:52   ` Sascha Hauer
2022-05-30 10:07     ` Kalle Valo
2022-05-30 10:16       ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f14f19de-d272-b95b-21f3-35bfd23a29d3@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=johannes@sipsolutions.net \
    --cc=kernel@pengutronix.de \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@ulli-kroll.de \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=neojou@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=s.hauer@pengutronix.de \
    --cc=tony0620emma@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).