From: Lorenzo Bianconi <lorenzo@kernel.org>
To: sean.wang@mediatek.com
Cc: nbd@nbd.name, lorenzo.bianconi@redhat.com,
Soul.Huang@mediatek.com, YN.Chen@mediatek.com,
Leon.Yen@mediatek.com, Deren.Wu@mediatek.com,
km.lin@mediatek.com, robin.chiu@mediatek.com,
ch.yeh@mediatek.com, posh.sun@mediatek.com,
Eric.Liang@mediatek.com, Stella.Chang@mediatek.com,
linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 4/6] mt76: mt7921: introduce mt7921_wpdma_reinit_cond utility routine
Date: Sun, 18 Apr 2021 18:48:23 +0200 [thread overview]
Message-ID: <YHxi1+jRHIfAuKJa@lore-desk> (raw)
In-Reply-To: <1618763767-1292-5-git-send-email-sean.wang@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 4942 bytes --]
> From: Sean Wang <sean.wang@mediatek.com>
I guess here we should use my 'From' tag
Regards,
Lorenzo
>
> Add mt7921_wpdma_reinit_cond to check dummy reg if driver needs to
> reinitialized WPDMA after driver_own operation
>
> Co-developed-by: Leon Yen <leon.yen@mediatek.com>
> Signed-off-by: Leon Yen <leon.yen@mediatek.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> .../net/wireless/mediatek/mt76/mt76_connac.h | 4 +++
> .../wireless/mediatek/mt76/mt7921/debugfs.c | 13 ++++++++++
> .../net/wireless/mediatek/mt76/mt7921/dma.c | 25 +++++++++++++++++++
> .../wireless/mediatek/mt76/mt7921/mt7921.h | 6 +++++
> 4 files changed, 48 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
> index b811f3c410a1..3b5bff80a462 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
> @@ -58,6 +58,10 @@ struct mt76_connac_pm {
> struct delayed_work ps_work;
> unsigned long last_activity;
> unsigned long idle_timeout;
> +
> + struct {
> + unsigned int lp_wake;
> + } stats;
> };
>
> struct mt76_connac_coredump {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
> index 5a54cd8d2ce4..bd2aca654767 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
> @@ -256,6 +256,17 @@ mt7921_pm_get(void *data, u64 *val)
>
> DEFINE_DEBUGFS_ATTRIBUTE(fops_pm, mt7921_pm_get, mt7921_pm_set, "%lld\n");
>
> +static int
> +mt7921_pm_stats(struct seq_file *s, void *data)
> +{
> + struct mt7921_dev *dev = dev_get_drvdata(s->private);
> + struct mt76_connac_pm *pm = &dev->pm;
> +
> + seq_printf(s, "low power wakes: %9d\n", pm->stats.lp_wake);
> +
> + return 0;
> +}
> +
> static int
> mt7921_pm_idle_timeout_set(void *data, u64 val)
> {
> @@ -322,6 +333,8 @@ int mt7921_init_debugfs(struct mt7921_dev *dev)
> debugfs_create_file("idle-timeout", 0600, dir, dev,
> &fops_pm_idle_timeout);
> debugfs_create_file("chip_reset", 0600, dir, dev, &fops_reset);
> + debugfs_create_devm_seqfile(dev->mt76.dev, "runtime_pm_stats", dir,
> + mt7921_pm_stats);
>
> return 0;
> }
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
> index 8c556ff3ae93..72f5704f8f11 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
> @@ -329,6 +329,31 @@ int mt7921_wpdma_reset(struct mt7921_dev *dev, bool force)
> return 0;
> }
>
> +int mt7921_wpdma_reinit_cond(struct mt7921_dev *dev)
> +{
> + struct mt76_connac_pm *pm = &dev->pm;
> + int err;
> +
> + /* check if the wpdma must be reinitialized */
> + if (mt7921_dma_need_reinit(dev)) {
> + /* disable interrutpts */
> + mt76_wr(dev, MT_WFDMA0_HOST_INT_ENA, 0);
> + mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0x0);
> +
> + err = mt7921_wpdma_reset(dev, false);
> + if (err) {
> + dev_err(dev->mt76.dev, "wpdma reset failed\n");
> + return err;
> + }
> +
> + /* enable interrutpts */
> + mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);
> + pm->stats.lp_wake++;
> + }
> +
> + return 0;
> +}
> +
> int mt7921_dma_init(struct mt7921_dev *dev)
> {
> /* Increase buffer size to receive large VHT/HE MPDUs */
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index 06a85d2d1c6f..bb4961d3969a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -254,6 +254,7 @@ int mt7921_eeprom_get_target_power(struct mt7921_dev *dev,
> void mt7921_eeprom_init_sku(struct mt7921_dev *dev);
> int mt7921_dma_init(struct mt7921_dev *dev);
> int mt7921_wpdma_reset(struct mt7921_dev *dev, bool force);
> +int mt7921_wpdma_reinit_cond(struct mt7921_dev *dev);
> void mt7921_dma_cleanup(struct mt7921_dev *dev);
> int mt7921_run_firmware(struct mt7921_dev *dev);
> int mt7921_mcu_init(struct mt7921_dev *dev);
> @@ -317,6 +318,11 @@ mt7921_l1_rmw(struct mt7921_dev *dev, u32 addr, u32 mask, u32 val)
> #define mt7921_l1_set(dev, addr, val) mt7921_l1_rmw(dev, addr, 0, val)
> #define mt7921_l1_clear(dev, addr, val) mt7921_l1_rmw(dev, addr, val, 0)
>
> +static inline bool mt7921_dma_need_reinit(struct mt7921_dev *dev)
> +{
> + return !mt76_get_field(dev, MT_WFDMA_DUMMY_CR, MT_WFDMA_NEED_REINIT);
> +}
> +
> void mt7921_mac_init(struct mt7921_dev *dev);
> bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask);
> void mt7921_mac_reset_counters(struct mt7921_phy *phy);
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2021-04-18 16:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-18 16:36 [PATCH 0/6] enable deep sleep mode when mt7921e suspends sean.wang
2021-04-18 16:36 ` [PATCH 1/6] mt76: mt7921: move mt7921_dma_reset in dma.c sean.wang
2021-04-18 16:47 ` Lorenzo Bianconi
2021-04-18 16:36 ` [PATCH 2/6] mt76: mt7921: introduce mt7921_wpdma_reset utility routine sean.wang
2021-04-18 16:36 ` [PATCH 3/6] mt76: mt7921: introduce mt7921_dma_{enable,disable} utilities sean.wang
2021-04-18 16:36 ` [PATCH 4/6] mt76: mt7921: introduce mt7921_wpdma_reinit_cond utility routine sean.wang
2021-04-18 16:48 ` Lorenzo Bianconi [this message]
2021-04-18 16:36 ` [PATCH 5/6] mt76: connac: introduce mt76_connac_mcu_set_deep_sleep utility sean.wang
2021-04-18 16:36 ` [PATCH 6/6] mt76: mt7921: enable deep sleep when the device suspends sean.wang
[not found] <YHxi1+jRHIfAuKJa@lore-desk--annotate>
2021-04-19 3:04 ` [PATCH 4/6] mt76: mt7921: introduce mt7921_wpdma_reinit_cond utility routine sean.wang
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=YHxi1+jRHIfAuKJa@lore-desk \
--to=lorenzo@kernel.org \
--cc=Deren.Wu@mediatek.com \
--cc=Eric.Liang@mediatek.com \
--cc=Leon.Yen@mediatek.com \
--cc=Soul.Huang@mediatek.com \
--cc=Stella.Chang@mediatek.com \
--cc=YN.Chen@mediatek.com \
--cc=ch.yeh@mediatek.com \
--cc=km.lin@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=posh.sun@mediatek.com \
--cc=robin.chiu@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).