Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3618875pxb; Mon, 24 Jan 2022 13:39:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyo8yYid3o9RJwJPAcTbuG+9OAegiqb2HdlhrlW5y5WsC+GiAme7kPrRC7kownU1wl7Jw/o X-Received: by 2002:a17:902:a50f:b0:149:bc1a:2c98 with SMTP id s15-20020a170902a50f00b00149bc1a2c98mr15961700plq.35.1643060344316; Mon, 24 Jan 2022 13:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060344; cv=none; d=google.com; s=arc-20160816; b=O8awiDbhykFq0PQxomoaikFk33EDzOmF6/TByEwvZHUxgPNvZdnKDrMfFJo75CvA6Y A0nMAXGRiSdqH/KJsOEGXMPDwuyYdRuKjUke7N2QSQwstrxrKdZ7+4xfT20bZ3mkW5qM RfCbmsXmR3xApq6FHdG45LMESxKadlL3/3vd3p272YD0As5WlLUrgrLtulx7yL0dV149 XYL8uwGHh9E7n90ZMeIUF36iCHuvGCDmHqPWERZsdFDphZhyQ8ylrC8a4Zg2zjCgafpq yZ/+7Vau4p7qXuLreNDXoHON64gmvONJ5vpypwHC62Jp8bsEH2f5J8JtTpebkntPIucm HpDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J6FUhpPaqQPkDdIHr80G6CoPc82VLTVxnRuOBy2lO9A=; b=NVZ4xzgs2TowTi7RLibGlNoaHKAr5rpax759i8Ye8BhWdyaa8MYI2HXTjzjYzTF/vv K32w9/un/y0pw4TlVBV3XjPbmuXlwUxk4lNk0z4wDCEBFDDNhd7Wk+Q0MYzIW7WveC9g CPXa6MDSXgVUpFC38FfDhsL+0JisfSxGoHIa2TXGTFjSNoihYHD9oeUl2vyyKT2JykYe ml3Xhogm40LWNSdAqduhSI+Zoe1UMpcfp49lI0p+sKTT4L3bYx/iQKUexvSD/nUW4Yxo zea6Qbq9IRC0CeeiVOoA2Dp+ak/ifUyCCBB9kgOeApbkC+5VJWTfdOzCtRl36vhcPGrU US1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vq0TaAaN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z6si12912767pfz.340.2022.01.24.13.38.51; Mon, 24 Jan 2022 13:39:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vq0TaAaN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1450382AbiAXVUY (ORCPT + 99 others); Mon, 24 Jan 2022 16:20:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441805AbiAXUvl (ORCPT ); Mon, 24 Jan 2022 15:51:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB46DC054330; Mon, 24 Jan 2022 11:58:33 -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 ams.source.kernel.org (Postfix) with ESMTPS id 89869B810AF; Mon, 24 Jan 2022 19:58:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2B58C340E5; Mon, 24 Jan 2022 19:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643054311; bh=hhcJmuN2kWlMk96NPFUrqTDWUoSgBnttal2l50VDvZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vq0TaAaNCBawkhTbvvp8KsOyLd+Y4m1fZcklpGGBp8/2xJr6V1nXscs5YIXmbcugn rnfdNuoswE4d3J1r63BvZQjcqFcwAE7ak88qJFPXBD70jl7J70G/36Bf5ssy2n/vEK 8IgYmZh+yfGW7xyjn1HpuhxYHx69tm4NDc1vWZGc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Emmanuel Grumbach , Maximilian Ernestus , Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH 5.10 347/563] iwlwifi: mvm: synchronize with FW after multicast commands Date: Mon, 24 Jan 2022 19:41:52 +0100 Message-Id: <20220124184036.411665606@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 81cc85a97eb20..922a7ea0cd24e 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -1739,6 +1739,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); @@ -1748,6 +1749,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