From: Lorenzo Bianconi <lorenzo@kernel.org>
To: nbd@nbd.name
Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com,
sean.wang@mediatek.com, deren.wu@mediatek.com
Subject: Re: [PATCH] mt76: mt7921: move mt7921_init_hw in a dedicated work
Date: Sun, 13 Mar 2022 13:53:21 +0100 [thread overview]
Message-ID: <Yi3pQYQH/3pADHpd@lore-desk> (raw)
In-Reply-To: <0358e31e71481dec87f7ecb3b040db53076ffc4a.1646654230.git.lorenzo@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 4399 bytes --]
> Firmware initialization can take a while. Move mt7921_init_hw routine in
> a dedicated work in order to not slow down bootstrap process.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Hi Felix,
let's put this patch on hold for the moment and continue the upstream
discussion. Thanks.
Regards,
Lorenzo
> ---
> .../net/wireless/mediatek/mt76/mt7921/init.c | 66 +++++++++++++------
> .../wireless/mediatek/mt76/mt7921/mt7921.h | 2 +
> 2 files changed, 49 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> index fa6af85bba7b..332af886b95a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> @@ -165,7 +165,7 @@ static int __mt7921_init_hardware(struct mt7921_dev *dev)
>
> static int mt7921_init_hardware(struct mt7921_dev *dev)
> {
> - int ret, idx, i;
> + int ret, i;
>
> set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);
>
> @@ -182,6 +182,13 @@ static int mt7921_init_hardware(struct mt7921_dev *dev)
> return ret;
> }
>
> + return 0;
> +}
> +
> +static int mt7921_init_wcid(struct mt7921_dev *dev)
> +{
> + int idx;
> +
> /* Beacon and mgmt frames should occupy wcid 0 */
> idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
> if (idx)
> @@ -195,6 +202,42 @@ static int mt7921_init_hardware(struct mt7921_dev *dev)
> return 0;
> }
>
> +static void mt7921_init_work(struct work_struct *work)
> +{
> + struct mt7921_dev *dev = container_of(work, struct mt7921_dev,
> + init_work);
> + int ret;
> +
> + ret = mt7921_init_hardware(dev);
> + if (ret)
> + return;
> +
> + mt76_set_stream_caps(&dev->mphy, true);
> + mt7921_set_stream_he_caps(&dev->phy);
> +
> + ret = mt76_register_device(&dev->mt76, true, mt76_rates,
> + ARRAY_SIZE(mt76_rates));
> + if (ret) {
> + dev_err(dev->mt76.dev, "register device failed\n");
> + return;
> + }
> +
> + ret = mt7921_init_debugfs(dev);
> + if (ret) {
> + dev_err(dev->mt76.dev, "debugfs register failed\n");
> + goto error;
> + }
> +
> + ret = mt76_connac_mcu_set_deep_sleep(&dev->mt76, dev->pm.ds_enable);
> + if (ret)
> + goto error;
> +
> + dev->hw_init_done = true;
> + return;
> +error:
> + mt76_unregister_device(&dev->mt76);
> +}
> +
> int mt7921_register_device(struct mt7921_dev *dev)
> {
> struct ieee80211_hw *hw = mt76_hw(dev);
> @@ -222,6 +265,7 @@ int mt7921_register_device(struct mt7921_dev *dev)
> spin_lock_init(&dev->sta_poll_lock);
>
> INIT_WORK(&dev->reset_work, mt7921_mac_reset_work);
> + INIT_WORK(&dev->init_work, mt7921_init_work);
>
> dev->pm.idle_timeout = MT7921_PM_TIMEOUT;
> dev->pm.stats.last_wake_event = jiffies;
> @@ -234,7 +278,7 @@ int mt7921_register_device(struct mt7921_dev *dev)
> if (mt76_is_sdio(&dev->mt76))
> hw->extra_tx_headroom += MT_SDIO_TXD_SIZE + MT_SDIO_HDR_SIZE;
>
> - ret = mt7921_init_hardware(dev);
> + ret = mt7921_init_wcid(dev);
> if (ret)
> return ret;
>
> @@ -262,23 +306,7 @@ int mt7921_register_device(struct mt7921_dev *dev)
> dev->mphy.hw->wiphy->available_antennas_rx = dev->mphy.chainmask;
> dev->mphy.hw->wiphy->available_antennas_tx = dev->mphy.chainmask;
>
> - mt76_set_stream_caps(&dev->mphy, true);
> - mt7921_set_stream_he_caps(&dev->phy);
> -
> - ret = mt76_register_device(&dev->mt76, true, mt76_rates,
> - ARRAY_SIZE(mt76_rates));
> - if (ret)
> - return ret;
> -
> - ret = mt7921_init_debugfs(dev);
> - if (ret)
> - return ret;
> -
> - ret = mt76_connac_mcu_set_deep_sleep(&dev->mt76, dev->pm.ds_enable);
> - if (ret)
> - return ret;
> -
> - dev->hw_init_done = true;
> + queue_work(system_wq, &dev->init_work);
>
> return 0;
> }
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index 394a677140da..b6c8f84acb64 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -204,6 +204,8 @@ struct mt7921_dev {
> struct list_head sta_poll_list;
> spinlock_t sta_poll_lock;
>
> + struct work_struct init_work;
> +
> u8 fw_debug;
>
> struct mt76_connac_pm pm;
> --
> 2.35.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2022-03-13 12:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 11:58 [PATCH] mt76: mt7921: move mt7921_init_hw in a dedicated work Lorenzo Bianconi
2022-03-07 12:00 ` Lorenzo Bianconi
2022-03-07 13:35 ` Deren Wu
2022-03-07 14:27 ` Lorenzo Bianconi
2022-03-07 21:46 ` sean.wang
2022-03-07 21:46 ` sean.wang
2022-03-07 22:47 ` Lorenzo Bianconi
2022-03-07 22:47 ` Lorenzo Bianconi
2022-03-08 2:27 ` sean.wang
2022-03-08 2:27 ` sean.wang
2022-03-13 12:53 ` Lorenzo Bianconi [this message]
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=Yi3pQYQH/3pADHpd@lore-desk \
--to=lorenzo@kernel.org \
--cc=deren.wu@mediatek.com \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.