From patchwork Sat Oct 22 07:22:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1092209wrr; Sat, 22 Oct 2022 00:53:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4W5Uvnkcv7E38CcZQKLP3bdSgtL9NCBQgJouvt6/nnQy8jU7Jt4bemyPoyVuv/GEDxyWJU X-Received: by 2002:a17:902:cac3:b0:186:6ce4:f94a with SMTP id y3-20020a170902cac300b001866ce4f94amr10592426pld.145.1666425201073; Sat, 22 Oct 2022 00:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425201; cv=none; d=google.com; s=arc-20160816; b=d+cOOdeFm5vGtspRZIL1GZM8n61p441WSv+wCsr8peIjV7I9A4PbAEJBn9wdVobNJO PVCFwrA8vomnnf8ZAylwXMHQLmO1WB42i6NC944nrH/l8169G6BPQqPB2bVJSv0NXajZ vN9VCA/+Qmb7nX5UJhThV1RPDyi0W8ds0Wrnam9sifM2jEalnbKEtNLv/nGsPqjSyVb4 VVTzxiuw84BRZ0FuTJBoRlGB8Vh1ocjBC0VQdyTaDctMRl1G6W/LimhqIV7t5yE3zaUJ 5wY33AYnS4ltVKf6RFkDSD5UKPXrYv6Fp4wC1IbxNBvtElwdvVTmas7jkp+nhrDdmqxE 7YEg== 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=3nHgGXwDyXhxrIoWp/w4G3QpnHPU7gCyagY0RPYLytE=; b=feKaQqKvKPFsQHVuE5p8d4Pql+HY5bih+N9OJOxnfwaUm/gPWVcD09scHAfazYgiPT hi0IOCEFTqOwA3rBSl/OE7rp0Qd2NHti3b+9LBmMAhxLo5HB1M0TtgPnXFBCPNPg4RaD mUGb3h6lfWHS96JxK396w/UsBaFfcykqxRDSBzxjSG3GMf65GqizV2BTdiBQbi0K0ZOf 4HUnP5PoOlNGsdYb72DNIuo/Y8vPg1aJPxgHfZayqEFEgivCeDzcbqFUT8AK6WTJIEXU /BflKR7JbYL4jjEzBEn9oQLo2C+6HLjGSEftONGNuOk/zNK46UuJNo1jdWMvVvaiW2QH 6Pnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GXRXHfxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a656ab1000000b004347b49d045si29076764pgu.631.2022.10.22.00.53.08; Sat, 22 Oct 2022 00:53:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GXRXHfxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231857AbiJVHwv (ORCPT + 99 others); Sat, 22 Oct 2022 03:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231948AbiJVHtl (ORCPT ); Sat, 22 Oct 2022 03:49:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF579A3B88; Sat, 22 Oct 2022 00:46:06 -0700 (PDT) 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 32EDDB82E20; Sat, 22 Oct 2022 07:45:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F1AAC433D6; Sat, 22 Oct 2022 07:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424705; bh=x6YESoJfx3sab24CZpUUqkR9w/aWB/eTAk+eNCGXbKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GXRXHfxkN5OSTvVV7h4d5pTdOGhRhO5b7HuUYHmoyAEeqwaSWxyqHgqo9HZJPjm10 oGaEZqlk+P6Ptwx/MEBOlte8Sh8r0LYwXAUVQqg/rp6fyi4MfwXB+VNTyyxi1s0zm9 b7QMMOPVZAn/ASkpAbhYFkt/3J6i40DWWu/qLu5o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, AngeloGioacchino Del Regno , Sean Wang , Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.19 246/717] wifi: mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap Date: Sat, 22 Oct 2022 09:22:05 +0200 Message-Id: <20221022072458.428220926@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747373471324207191?= X-GMAIL-MSGID: =?utf-8?q?1747373471324207191?= From: Sean Wang [ Upstream commit 52b44015f031f629f1ce1d73415a2017593c7ade ] Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race with the context holding dev->muxtex and the driver might access the device in low power state. Fixes: 9d958b60ebc2 ("mt76: mt7921: fix command timeout in AP stop period") Tested-by: AngeloGioacchino Del Regno Signed-off-by: Sean Wang Acked-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- .../net/wireless/mediatek/mt76/mt7921/main.c | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index d3f310877248..22c9793e4a40 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -1499,17 +1499,23 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct mt7921_dev *dev = mt7921_hw_dev(hw); int err; + mt7921_mutex_acquire(dev); + err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, true); if (err) - return err; + goto out; err = mt7921_mcu_set_bss_pm(dev, vif, true); if (err) - return err; + goto out; + + err = mt7921_mcu_sta_update(dev, NULL, vif, true, + MT76_STA_INFO_STATE_NONE); +out: + mt7921_mutex_release(dev); - return mt7921_mcu_sta_update(dev, NULL, vif, true, - MT76_STA_INFO_STATE_NONE); + return err; } static void @@ -1520,11 +1526,16 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct mt7921_dev *dev = mt7921_hw_dev(hw); int err; + mt7921_mutex_acquire(dev); + err = mt7921_mcu_set_bss_pm(dev, vif, false); if (err) - return; + goto out; mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, false); + +out: + mt7921_mutex_release(dev); } const struct ieee80211_ops mt7921_ops = {