linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: nbd@nbd.name
Cc: linux-mediatek@lists.infradead.org, lorenzo.bianconi@redhat.com,
	ryder.lee@mediatek.com, linux-wireless@vger.kernel.org,
	sean.wang@mediatek.com
Subject: [PATCH v2 19/22] mt76: mt7615: add runtime-pm knob in mt7615 debugfs
Date: Fri,  3 Jul 2020 10:15:58 +0200	[thread overview]
Message-ID: <70ed3986f368584bb739a4c87460a5332b74804a.1593763584.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1593763584.git.lorenzo@kernel.org>

Introduce runtime-pm knob in mt7615 debugfs in order to enable/disable
runtime pm available in offload firmware

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 .../wireless/mediatek/mt76/mt7615/debugfs.c   | 24 +++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7615/mac.c   | 20 +++++++++++++++-
 .../wireless/mediatek/mt76/mt7615/mt7615.h    |  3 +++
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
index 8894a0ab407b..77889becf22e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
@@ -51,6 +51,29 @@ mt7615_scs_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(fops_scs, mt7615_scs_get,
 			 mt7615_scs_set, "%lld\n");
 
+static int
+mt7615_pm_set(void *data, u64 val)
+{
+	struct mt7615_dev *dev = data;
+
+	if (!mt7615_wait_for_mcu_init(dev))
+		return 0;
+
+	return mt7615_pm_set_enable(dev, val);
+}
+
+static int
+mt7615_pm_get(void *data, u64 *val)
+{
+	struct mt7615_dev *dev = data;
+
+	*val = dev->pm.enable;
+
+	return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_pm, mt7615_pm_get, mt7615_pm_set, "%lld\n");
+
 static int
 mt7615_dbdc_set(void *data, u64 val)
 {
@@ -351,6 +374,7 @@ int mt7615_init_debugfs(struct mt7615_dev *dev)
 	debugfs_create_file("scs", 0600, dir, dev, &fops_scs);
 	debugfs_create_file("dbdc", 0600, dir, dev, &fops_dbdc);
 	debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug);
+	debugfs_create_file("runtime-pm", 0600, dir, dev, &fops_pm);
 	debugfs_create_devm_seqfile(dev->mt76.dev, "radio", dir,
 				    mt7615_radio_read);
 	debugfs_create_u32("dfs_hw_pattern", 0400, dir, &dev->hw_pattern);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index 76751117592b..d7c2c08da3c7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -1905,7 +1905,8 @@ void mt7615_pm_power_save_sched(struct mt7615_dev *dev)
 {
 	struct mt76_phy *mphy = dev->phy.mt76;
 
-	if (!mt7615_firmware_offload(dev) || !mt76_is_mmio(mphy->dev) ||
+	if (!mt7615_firmware_offload(dev) ||
+	    !dev->pm.enable || !mt76_is_mmio(mphy->dev) ||
 	    !test_bit(MT76_STATE_RUNNING, &mphy->state))
 		return;
 
@@ -1928,6 +1929,23 @@ void mt7615_pm_power_save_work(struct work_struct *work)
 				   MT7615_PM_TIMEOUT);
 }
 
+int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable)
+{
+	if (!mt7615_firmware_offload(dev) || !mt76_is_mmio(&dev->mt76))
+		return -EOPNOTSUPP;
+
+	mt7615_mutex_acquire(dev);
+
+	if (dev->pm.enable == enable)
+		goto out;
+
+	dev->pm.enable = enable;
+out:
+	mt7615_mutex_release(dev);
+
+	return 0;
+}
+
 void mt7615_mac_work(struct work_struct *work)
 {
 	struct mt7615_phy *phy;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
index 66489f44c1a9..b80bf79e4849 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
@@ -300,6 +300,8 @@ struct mt7615_dev {
 #endif
 
 	struct {
+		bool enable;
+
 		spinlock_t txq_lock;
 		struct {
 			struct mt7615_sta *msta;
@@ -441,6 +443,7 @@ bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev);
 void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
 			  struct ieee80211_tx_rate *probe_rate,
 			  struct ieee80211_tx_rate *rates);
+int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable);
 void mt7615_pm_wake_work(struct work_struct *work);
 int mt7615_pm_wake(struct mt7615_dev *dev);
 void mt7615_pm_power_save_sched(struct mt7615_dev *dev);
-- 
2.26.2


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

  parent reply	other threads:[~2020-07-03  8:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03  8:15 [PATCH v2 00/22] add runtime-pm support to mt7663 driver Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 01/22] mt76: mt7615: avoid polling in fw_own for mt7663 Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 02/22] mt76: move mt76 worqueue in common code Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 03/22] mt76: mt7615: add mt7615_pm_wake utility routine Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 04/22] mt76: mt7615: introduce mt7615_mutex_{acquire, release} utilities Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 05/22] mt76: mt7615: wake device before accessing regmap in debugfs Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 06/22] mt76: mt7615: wake device before configuring hw keys Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 07/22] mt76: mt7615: introduce pm_power_save delayed work Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 08/22] mt76: mt7615: wake device in mt7615_update_channel before access regmap Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 09/22] mt76: mt7615: acquire driver_own before configuring device for suspend Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 10/22] mt76: mt7615: wake device before performing freq scan Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 11/22] mt76: mt7615: add missing lock in mt7615_regd_notifier Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 12/22] mt76: mt7615: run mt7615_mcu_set_wmm holding mt76 mutex Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 13/22] mt76: mt7615: run mt7615_mcu_set_roc " Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 14/22] mt76: mt7615: wake device before pulling packets from mac80211 queues Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 15/22] mt76: mt7615: wake device before pushing frames in mt7615_tx Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 16/22] mt76: mt7615: run mt7615_pm_wake in mt7615_mac_sta_{add, remove} Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 17/22] mt76: mt7615: check MT76_STATE_PM flag before accessing the device Lorenzo Bianconi
2020-07-03  8:15 ` [PATCH v2 18/22] mt76: mt7615: do not request {driver, fw}_own if already granted Lorenzo Bianconi
2020-07-03  8:15 ` Lorenzo Bianconi [this message]
2020-07-03  8:15 ` [PATCH v2 20/22] mt76: mt7615: enable beacon hw filter for runtime-pm Lorenzo Bianconi
2020-07-03  8:16 ` [PATCH v2 21/22] mt76: mt7615: add idle-timeout knob in mt7615 debugfs Lorenzo Bianconi
2020-07-03  8:16 ` [PATCH v2 22/22] 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=70ed3986f368584bb739a4c87460a5332b74804a.1593763584.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).