Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1749015rwd; Fri, 9 Jun 2023 01:18:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cmiybFe81IzrskE/cpPXbV/I2ABRbuW4p9xB6T/3/VPP8JiN/4N1FJqMqmJenESSmy3/5 X-Received: by 2002:a05:6358:bd19:b0:127:fb1b:6b16 with SMTP id dh25-20020a056358bd1900b00127fb1b6b16mr752440rwb.15.1686298737982; Fri, 09 Jun 2023 01:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686298737; cv=none; d=google.com; s=arc-20160816; b=kNS0zXjO5TE9hnxQrfpYrPSWdDP9YUzlUVspRtO2OmHu79NHKluB8GqXsJ6hOqks8y WUh1tA21TcbcAjaKnZVfUYzilnHvJ0PIA6CTKO8voYKWmMtSgYOhgXvJ8a21zSjPPonE /LglbVdhJrLYTgSWPFeuasWLECjbUi1TMi4XTiU8QC2Hx7/NzSCB66b9VNn3bfL0vRV+ iaCwmt7nsWXxUdHAGd2FMcSQdvdwAlTkWZntU1KJ+SiIG5C0/1u2fD8jiUdZZEXRU4Fi hmyU+rxi6dx8F68VeEiBpzyT62+OwxYwRPu1uCR1bYR+nWhuDSAYFvDui3ENzDQNLHt0 IrFw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+MwX/Q8sZV7G47ONbn5TAc8rfLh0rQ68zzdYdzJVq34=; b=nKYuu6NTESgBzzbL9XPc3ZHFHzgH/QdPgeuNo4pyWUJ0ivNP8cc4eZTFe6OL5h47oj XgzwAB7EFoZe1KcoDQ0K/w+VPnUwWe8fwzJN5I01UxYWeQBjcQTocM4EOcrZU5bAaIiy VybKfd90LsCeWThUH7au0rxThNisF3s5jlL4cWiAdclLf+QmyIrageX/6j3cfygEkDHd ccQPS6jkfqeEs33UGZ6lefQ0+lwaLF0sbqc1nOm0x4N/6TiH+/FqHGfxdvffhJHrQnBG C0Q42UtAOdHAuINAbCSEkWpKJdf2G+bDt2ZWi6Zhq9tjMuH7fljETwT4WtntyXvePMpB +c+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ZhyJ/pIx"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a639257000000b0054481da6ee7si2414798pgn.582.2023.06.09.01.18.29; Fri, 09 Jun 2023 01:18:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@kernel.org header.s=k20201202 header.b="ZhyJ/pIx"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239318AbjFIIQZ (ORCPT + 61 others); Fri, 9 Jun 2023 04:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240097AbjFIIQW (ORCPT ); Fri, 9 Jun 2023 04:16:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 607FE30DA for ; Fri, 9 Jun 2023 01:16:14 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E940765477 for ; Fri, 9 Jun 2023 08:16:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07B02C433EF; Fri, 9 Jun 2023 08:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686298573; bh=OPmrK71qMy64vPoT6d4Tw4lBQQAA/BuLCxPBEPnPOzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZhyJ/pIxkFU+kW7zXJupBJ6VZ1sBfd0EHB8oQMrZ+ZKdYpIGjdL4olUScZTz1d2+a r3KGvvW2NHV2e+0hyQW+evgX6mEd81QA4xRQovYy5xy0zf5xT4YwMKqw+JRk8B0Ky8 nHMwMU0umBXU86WBTqM5xhLZYOj4lW2bZgI4xWB1neXOOW51gZjCFItugoGJCANKym gCFhQLMiU3D1IpaHveoj3D3kzZImvxXjJzVkX4qlieCW9WJtrVNHwJeQUUIyrL8rca RCAfJyRHI2Soof0d/uZ1/fcyR+hrYEj7hpenZb08Sehx1hw7ar9Ff552irWXjpDQSQ WlybygKBIg0PQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH v2 05/15] wifi: mt76: mt7921: rely on shared sta_poll_list and sta_poll_lock Date: Fri, 9 Jun 2023 10:15:34 +0200 Message-Id: <9a3a8b5b5631ca876ae3798d65b73b62d9d113e2.1686298162.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-wireless@vger.kernel.org Rely on sta_poll_list and sta_poll_lock fields in mt76_dev structure and get rid of private copies. Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/init.c | 2 -- .../net/wireless/mediatek/mt76/mt7921/mac.c | 32 ++++++++++--------- .../net/wireless/mediatek/mt76/mt7921/main.c | 8 ++--- .../wireless/mediatek/mt76/mt7921/mt7921.h | 3 -- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index e929f6eb65ce..cdb4478f04d0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -392,8 +392,6 @@ int mt7921_register_device(struct mt7921_dev *dev) #endif skb_queue_head_init(&dev->phy.scan_event_list); skb_queue_head_init(&dev->coredump.msg_list); - INIT_LIST_HEAD(&dev->sta_poll_list); - spin_lock_init(&dev->sta_poll_lock); INIT_WORK(&dev->reset_work, mt7921_mac_reset_work); INIT_WORK(&dev->init_work, mt7921_init_work); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index bde73859b5da..d81d78ac5c91 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -68,9 +68,9 @@ static void mt7921_mac_sta_poll(struct mt7921_dev *dev) s8 rssi[4]; int i; - spin_lock_bh(&dev->sta_poll_lock); - list_splice_init(&dev->sta_poll_list, &sta_poll_list); - spin_unlock_bh(&dev->sta_poll_lock); + spin_lock_bh(&dev->mt76.sta_poll_lock); + list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); + spin_unlock_bh(&dev->mt76.sta_poll_lock); while (true) { bool clear = false; @@ -78,15 +78,15 @@ static void mt7921_mac_sta_poll(struct mt7921_dev *dev) u16 idx; u8 bw; - spin_lock_bh(&dev->sta_poll_lock); + spin_lock_bh(&dev->mt76.sta_poll_lock); if (list_empty(&sta_poll_list)) { - spin_unlock_bh(&dev->sta_poll_lock); + spin_unlock_bh(&dev->mt76.sta_poll_lock); break; } msta = list_first_entry(&sta_poll_list, struct mt7921_sta, poll_list); list_del_init(&msta->poll_list); - spin_unlock_bh(&dev->sta_poll_lock); + spin_unlock_bh(&dev->mt76.sta_poll_lock); idx = msta->wcid.idx; addr = mt7921_mac_wtbl_lmac_addr(idx, MT_WTBL_AC0_CTT_OFFSET); @@ -280,10 +280,11 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) if (status->wcid) { msta = container_of(status->wcid, struct mt7921_sta, wcid); - spin_lock_bh(&dev->sta_poll_lock); + spin_lock_bh(&dev->mt76.sta_poll_lock); if (list_empty(&msta->poll_list)) - list_add_tail(&msta->poll_list, &dev->sta_poll_list); - spin_unlock_bh(&dev->sta_poll_lock); + list_add_tail(&msta->poll_list, + &dev->mt76.sta_poll_list); + spin_unlock_bh(&dev->mt76.sta_poll_lock); } mt7921_get_status_freq_info(dev, mphy, status, chfreq); @@ -566,10 +567,10 @@ void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data) if (!wcid->sta) goto out; - spin_lock_bh(&dev->sta_poll_lock); + spin_lock_bh(&dev->mt76.sta_poll_lock); if (list_empty(&msta->poll_list)) - list_add_tail(&msta->poll_list, &dev->sta_poll_list); - spin_unlock_bh(&dev->sta_poll_lock); + list_add_tail(&msta->poll_list, &dev->mt76.sta_poll_list); + spin_unlock_bh(&dev->mt76.sta_poll_lock); out: rcu_read_unlock(); @@ -647,10 +648,11 @@ static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len) continue; msta = container_of(wcid, struct mt7921_sta, wcid); - spin_lock_bh(&dev->sta_poll_lock); + spin_lock_bh(&mdev->sta_poll_lock); if (list_empty(&msta->poll_list)) - list_add_tail(&msta->poll_list, &dev->sta_poll_list); - spin_unlock_bh(&dev->sta_poll_lock); + list_add_tail(&msta->poll_list, + &mdev->sta_poll_list); + spin_unlock_bh(&mdev->sta_poll_lock); continue; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 0c9a472bc81a..ffbe48f33d49 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -357,10 +357,10 @@ static void mt7921_remove_interface(struct ieee80211_hw *hw, phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx); mt7921_mutex_release(dev); - spin_lock_bh(&dev->sta_poll_lock); + spin_lock_bh(&dev->mt76.sta_poll_lock); if (!list_empty(&msta->poll_list)) list_del_init(&msta->poll_list); - spin_unlock_bh(&dev->sta_poll_lock); + spin_unlock_bh(&dev->mt76.sta_poll_lock); mt76_packet_id_flush(&dev->mt76, &msta->wcid); } @@ -843,10 +843,10 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, mvif->ctx); } - spin_lock_bh(&dev->sta_poll_lock); + spin_lock_bh(&dev->mt76.sta_poll_lock); if (!list_empty(&msta->poll_list)) list_del_init(&msta->poll_list); - spin_unlock_bh(&dev->sta_poll_lock); + spin_unlock_bh(&dev->mt76.sta_poll_lock); mt76_connac_power_save_sched(&dev->mphy, &dev->pm); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 9640cc033300..ef1fe4d9ab99 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -303,9 +303,6 @@ struct mt7921_dev { bool hw_init_done:1; bool fw_assert:1; - struct list_head sta_poll_list; - spinlock_t sta_poll_lock; - struct work_struct init_work; u8 fw_debug; -- 2.40.1