From patchwork Wed Aug 4 07:36:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 492070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BA93C432BE for ; Wed, 4 Aug 2021 07:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 018C860F25 for ; Wed, 4 Aug 2021 07:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235903AbhHDHhR (ORCPT ); Wed, 4 Aug 2021 03:37:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:40242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235807AbhHDHhO (ORCPT ); Wed, 4 Aug 2021 03:37:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 52F1C60F25; Wed, 4 Aug 2021 07:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628062622; bh=F5qB4vBPdVM5lYyWLWRw0Hb+0oPRAx2k5+vWuoPabu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuEjdTpOTpY8W8h4htZeELq8xW1E1pg1TGi3KhuqqLYRSJtEAZDkGZkQ+KYsxsQNJ 7uApLnu1Qqbmh2LBLjvDld4G6WstTcLM3fqQlgN+p4TE1SnSjdmfdNE6zVR9eVWnMl E/H88pxtkQYh5zpRnVPEYMcFmDkSNeN5KhkY9WtKwFfns6aa6fCTSTB7F7njx5btzt T1Q/9RzWqZVmf0RmRJ1rKQAYJnGhCV0BO8m7OAx6P6veyMJu/Y3MW5qxLMNXC4JIdp RdAv10BXvKuF9Ls2+nj6z9NWCQKjiyIpS6pKBgsnttUjBRRy/aPaP5gkNO3CusBYJX 3GFABaiojOoKg== From: Lorenzo Bianconi To: nbd@nbd.name, johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, ryder.lee@mediatek.com, chui-hao.chiu@mediatek.com Subject: [PATCH mac80211-next 3/7] mt76: mt7915: introduce __mt7915_get_tsf routine Date: Wed, 4 Aug 2021 09:36:34 +0200 Message-Id: <42c4d8f3f5d5c5bb489163c54ff42049c2bda938.1628062233.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Introduce an unlocked verion of mt7915_get_tsf routine. This is a preliminary patch to add TWT support to mt7915. Tested-by: Peter Chiu Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7915/main.c | 20 ++++++++++++++----- .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 48b5e2051bad..fa4fd04affd8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -789,10 +789,8 @@ mt7915_get_stats(struct ieee80211_hw *hw, return 0; } -static u64 -mt7915_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif) { - struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw); bool band = phy != &dev->phy; @@ -802,7 +800,7 @@ mt7915_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) } tsf; u16 n; - mutex_lock(&dev->mt76.mutex); + lockdep_assert_held(&dev->mt76.mutex); n = mvif->omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : mvif->omac_idx; /* TSF software read */ @@ -811,9 +809,21 @@ mt7915_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(band)); tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(band)); + return tsf.t64; +} + +static u64 +mt7915_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; + struct mt7915_dev *dev = mt7915_hw_dev(hw); + u64 ret; + + mutex_lock(&dev->mt76.mutex); + ret = __mt7915_get_tsf(hw, mvif); mutex_unlock(&dev->mt76.mutex); - return tsf.t64; + return ret; } static void diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index a6b5b300d415..068ef0f881b8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -271,7 +271,7 @@ extern const struct ieee80211_ops mt7915_ops; extern const struct mt76_testmode_ops mt7915_testmode_ops; u32 mt7915_reg_map(struct mt7915_dev *dev, u32 addr); - +u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif); int mt7915_register_device(struct mt7915_dev *dev); void mt7915_unregister_device(struct mt7915_dev *dev); int mt7915_eeprom_init(struct mt7915_dev *dev);