All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: luca@coelho.fi, linux-wireless@vger.kernel.org
Subject: [PATCH 02/12] iwlwifi: mvm: synchronize with FW after multicast commands
Date: Sat,  4 Dec 2021 08:35:45 +0200	[thread overview]
Message-ID: <iwlwifi.20211204083238.51aea5b79ea4.I88a44798efda16e9fe480fb3e94224931d311b29@changeid> (raw)
In-Reply-To: <20211204063555.769822-1-luca@coelho.fi>

From: Johannes Berg <johannes.berg@intel.com>

If userspace installs a lot of multicast groups very quickly, then
we may run out of command queue space as we send the updates in an
asynchronous fashion (due to locking concerns), and the CPU can
create them faster than the firmware can process them. This is true
even when mac80211 has a work struct that gets scheduled.

Fix this by synchronizing with the firmware after sending all those
commands - outside of the iteration we can send a synchronous echo
command that just has the effect of the CPU waiting for the prior
asynchronous commands to finish. This also will cause fewer of the
commands to be sent to the firmware overall, because the work will
only run once when rescheduled multiple times while it's running.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=213649
Suggested-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Reported-by: Maximilian Ernestus <maximilian@ernestus.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c   | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 20422e640059..9d84be991469 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1710,6 +1710,7 @@ static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm)
 	struct iwl_mvm_mc_iter_data iter_data = {
 		.mvm = mvm,
 	};
+	int ret;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -1719,6 +1720,22 @@ static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm)
 	ieee80211_iterate_active_interfaces_atomic(
 		mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
 		iwl_mvm_mc_iface_iterator, &iter_data);
+
+	/*
+	 * Send a (synchronous) ech command so that we wait for the
+	 * multiple asynchronous MCAST_FILTER_CMD commands sent by
+	 * the interface iterator. Otherwise, we might get here over
+	 * and over again (by userspace just sending a lot of these)
+	 * and the CPU can send them faster than the firmware can
+	 * process them.
+	 * Note that the CPU is still faster - but with this we'll
+	 * actually send fewer commands overall because the CPU will
+	 * not schedule the work in mac80211 as frequently if it's
+	 * still running when rescheduled (possibly multiple times).
+	 */
+	ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
+	if (ret)
+		IWL_ERR(mvm, "Failed to synchronize multicast groups update\n");
 }
 
 static u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw,
-- 
2.33.1


  parent reply	other threads:[~2021-12-04  6:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-04  6:35 [PATCH 00/12] iwlwifi: updates intended for v5.16 2021-12-04 part 1 Luca Coelho
2021-12-04  6:35 ` [PATCH 01/12] iwlwifi: mvm: fix delBA vs. NSSN queue sync race Luca Coelho
2021-12-04  6:35 ` Luca Coelho [this message]
2021-12-04  6:35 ` [PATCH 03/12] iwlwifi: properly support 4-bit MAC step Luca Coelho
2021-12-07 13:44   ` Kalle Valo
2021-12-07 13:49     ` Luca Coelho
2021-12-07 13:58       ` Kalle Valo
2021-12-07 14:05   ` [PATCH v2 03/12] iwlwifi: support 4-bits in MAC step value Luca Coelho
2021-12-04  6:35 ` [PATCH 04/12] iwlwifi: add support for Bz-Z HW Luca Coelho
2021-12-04  6:35 ` [PATCH 05/12] iwlwifi: mvm: d3: move GTK rekeys condition Luca Coelho
2021-12-04  6:35 ` [PATCH 06/12] iwlwifi: pcie: support Bz suspend/resume trigger Luca Coelho
2021-12-04  6:35 ` [PATCH 07/12] iwlwifi: mvm: parse firmware alive message version 6 Luca Coelho
2021-12-04  6:35 ` [PATCH 08/12] iwlwifi: mvm: d3: support v12 wowlan status Luca Coelho
2021-12-04  6:35 ` [PATCH 09/12] iwlwifi: mvm: support RLC configuration command Luca Coelho
2021-12-04  6:35 ` [PATCH 10/12] iwlwifi: fw: api: add link to PHY context command struct v1 Luca Coelho
2021-12-04  6:35 ` [PATCH 11/12] iwlwifi: mvm: add support for PHY context command v4 Luca Coelho
2021-12-04  6:35 ` [PATCH 12/12] iwlwifi: remove unused iwlax210_2ax_cfg_so_hr_a0 structure Luca Coelho
2021-12-07 13:49 ` [PATCH 00/12] iwlwifi: updates intended for v5.16 2021-12-04 part 1 Kalle Valo

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=iwlwifi.20211204083238.51aea5b79ea4.I88a44798efda16e9fe480fb3e94224931d311b29@changeid \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.