From: Lorenzo Bianconi <lorenzo@kernel.org>
To: nbd@nbd.name
Cc: linux-mediatek@lists.infradead.org, lorenzo.bianconi@redhat.com,
sean.wang@mediatek.com, linux-wireless@vger.kernel.org,
ryder.lee@mediatek.com
Subject: [PATCH 08/17] mt76: mt7615: wake device in mt7615_update_channel before access regmap
Date: Fri, 26 Jun 2020 23:25:08 +0200 [thread overview]
Message-ID: <d4124fd37d4aa36a29eb191f25f060c61f836d1d.1593204577.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1593204577.git.lorenzo@kernel.org>
Introduce mt7615_update_survey utility routine in order to compute
survey stats without waking up the device since it runs holding mt76 lock.
Run mt7615_pm_wake directly in mt7615_update_channel since it can run
with mt76.mutex held if called by mac80211
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/mac80211.c | 4 +--
drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
.../net/wireless/mediatek/mt76/mt7615/mac.c | 30 +++++++++++++++++--
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index a15862920f19..fecdd91cdf5f 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -558,8 +558,7 @@ mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
return &msband->chan[idx];
}
-static void
-mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
+void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
{
struct mt76_channel_state *state = phy->chan_state;
@@ -567,6 +566,7 @@ mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
phy->survey_time));
phy->survey_time = time;
}
+EXPORT_SYMBOL_GPL(mt76_update_survey_active_time);
void mt76_update_survey(struct mt76_dev *dev)
{
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 265ee55d22f1..c6e44283bd5f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -893,6 +893,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw,
bool mt76_has_tx_pending(struct mt76_phy *phy);
void mt76_set_channel(struct mt76_phy *phy);
void mt76_update_survey(struct mt76_dev *dev);
+void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
int mt76_get_survey(struct ieee80211_hw *hw, int idx,
struct survey_info *survey);
void mt76_set_stream_caps(struct mt76_phy *phy, bool vht);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index 7804928f54d8..acefcc2e571a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -1747,9 +1747,9 @@ mt7615_phy_update_channel(struct mt76_phy *mphy, int idx)
state->noise = -(phy->noise >> 4);
}
-void mt7615_update_channel(struct mt76_dev *mdev)
+static void __mt7615_update_channel(struct mt7615_dev *dev)
{
- struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
+ struct mt76_dev *mdev = &dev->mt76;
mt7615_phy_update_channel(&mdev->phy, 0);
if (mdev->phy2)
@@ -1758,8 +1758,32 @@ void mt7615_update_channel(struct mt76_dev *mdev)
/* reset obss airtime */
mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
}
+
+void mt7615_update_channel(struct mt76_dev *mdev)
+{
+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
+
+ if (mt7615_pm_wake(dev))
+ return;
+
+ __mt7615_update_channel(dev);
+ mt7615_pm_power_save_sched(dev);
+}
EXPORT_SYMBOL_GPL(mt7615_update_channel);
+static void mt7615_update_survey(struct mt7615_dev *dev)
+{
+ struct mt76_dev *mdev = &dev->mt76;
+ ktime_t cur_time;
+
+ __mt7615_update_channel(dev);
+ cur_time = ktime_get_boottime();
+
+ mt76_update_survey_active_time(&mdev->phy, cur_time);
+ if (mdev->phy2)
+ mt76_update_survey_active_time(mdev->phy2, cur_time);
+}
+
static void
mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
{
@@ -1888,7 +1912,7 @@ void mt7615_mac_work(struct work_struct *work)
mt7615_mutex_acquire(phy->dev, &mdev->mutex);
- mt76_update_survey(mdev);
+ mt7615_update_survey(phy->dev);
if (++phy->mac_work_count == 5) {
phy->mac_work_count = 0;
--
2.26.2
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2020-06-26 21:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 21:25 [PATCH 00/17] add runtime-pm support to mt7663 driver Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 01/17] mt76: mt7615: avoid polling in fw_own for mt7663 Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 02/17] mt76: move mt76 worqueue in common code Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 03/17] mt76: mt7615: add mt7615_pm_wake utility routine Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 04/17] mt76: mt7615: introduce mt7615_mutex_{acquire, release} utilities Lorenzo Bianconi
2020-07-01 19:26 ` [PATCH 04/17] mt76: mt7615: introduce mt7615_mutex_{acquire,release} utilities Felix Fietkau
2020-06-26 21:25 ` [PATCH 05/17] mt76: mt7615: wake device before accessing regmap in debugfs Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 06/17] mt76: mt7615: wake device before configuring hw keys Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 07/17] mt76: mt7615: introduce pm_power_save delayed work Lorenzo Bianconi
2020-06-26 21:25 ` Lorenzo Bianconi [this message]
2020-06-26 21:25 ` [PATCH 09/17] mt76: mt7615: acquire driver_own before configuring device for suspend Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 10/17] mt76: mt7615: wake device before pulling packets from mac80211 queues Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 11/17] mt76: mt7615: wake device before pushing frames in mt7615_tx Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 12/17] mt76: mt7615: check MT76_STATE_PM flag before accessing the device Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 13/17] mt76: mt7615: do not request {driver, fw}_own if already granted Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 14/17] mt76: mt7615: add runtime-pm knob in mt7615 debugfs Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 15/17] mt76: mt7615: enable beacon hw filter for runtime-pm Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 16/17] mt76: mt7615: add idle-timeout knob in mt7615 debugfs Lorenzo Bianconi
2020-06-26 21:25 ` [PATCH 17/17] mt76: mt7615: improve mt7615_driver_own reliability Lorenzo Bianconi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d4124fd37d4aa36a29eb191f25f060c61f836d1d.1593204577.git.lorenzo@kernel.org \
--to=lorenzo@kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).