From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 427A9C433EF for ; Tue, 18 Jan 2022 03:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354688AbiARDHh (ORCPT ); Mon, 17 Jan 2022 22:07:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353673AbiARDCY (ORCPT ); Mon, 17 Jan 2022 22:02:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0835C08ED6D; Mon, 17 Jan 2022 18:47:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 41BEA6130B; Tue, 18 Jan 2022 02:47:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38C27C36AE3; Tue, 18 Jan 2022 02:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642474065; bh=ZC36WnheV32GTiyfyRTPvOOYO8m2u9dH7wQLkkmFlDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S9HejiR6arSKYYqoIbZV0x6Fk1kvBvLd13uvQQ/YvFvL6lQT4EvyWsljxODSmyr8Y vRDuM7SUN4tmXTSyIrZ0rB++RuRU2ZIlN26ISBESylCaSDwgN8g+MTSE4dETXIlGqz SSbE/S+YuV66qokK6eAiJZWZPyccW+sB3XeT9VfMZmpmyAu/byN7H+KOQTYVrR9Ykq uSnO0qmLbdhT2E3zGPge7PiCx2C2BXHh7bvi4sLpmSI3wqKCUKyrZibb9l827u25/G ftK9UGTG1rmdQdB1YrhNoC4qsxzq8/QhDl8uYxP2VYrSxKvDvX1iWU5IEKnC81IQtA AT71EOT1RgPrw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johannes Berg , Emmanuel Grumbach , Maximilian Ernestus , Luca Coelho , Sasha Levin , kvalo@kernel.org, davem@davemloft.net, kuba@kernel.org, mordechay.goodstein@intel.com, miriam.rachel.korenblit@intel.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 20/59] iwlwifi: mvm: synchronize with FW after multicast commands Date: Mon, 17 Jan 2022 21:46:21 -0500 Message-Id: <20220118024701.1952911-20-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118024701.1952911-1-sashal@kernel.org> References: <20220118024701.1952911-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg [ Upstream commit db66abeea3aefed481391ecc564fb7b7fb31d742 ] 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 Reported-by: Maximilian Ernestus Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20211204083238.51aea5b79ea4.I88a44798efda16e9fe480fb3e94224931d311b29@changeid Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- .../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 697a66acba9ce..3f37fb64e71c2 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -1623,6 +1623,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); @@ -1632,6 +1633,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.34.1