[PATCH] mt76: mt7921e: fix reset failure in mt7921_pci_probe
Sean Wang
sean.wang at kernel.org
Thu Jan 6 16:53:34 PST 2022
@nbd please drop the patch, I will post a new one to fix the aspm issue
On Thu, Jan 6, 2022 at 1:32 PM <sean.wang at mediatek.com> wrote:
>
> From: Deren Wu <deren.wu at mediatek.com>
>
> Ensure that the device returns to the driver's own state to switch ASPM
> into the active state before we start resetting the device to fix
> the following kernel panic.
>
> [ 17.164952] dump_stack_lvl+0x48/0x5e
> [ 17.164955] bad_page.cold+0x63/0x94
> [ 17.164957] free_pcppages_bulk+0x1f2/0x360
> [ 17.164961] free_unref_page+0xb4/0x120
> [ 17.164963] mt76_dma_rx_cleanup+0x94/0x110 [mt76]
> [ 17.164969] mt7921_wpdma_reset+0xbc/0x1c0 [mt7921e]
> [ 17.164972] mt7921_register_device+0x32b/0x5d0 [mt7921_common]
> [ 17.164976] mt7921_pci_probe+0x1d5/0x210 [mt7921e]
> [ 17.164977] ? __pm_runtime_resume+0x58/0x80
> [ 17.164979] local_pci_probe+0x45/0x80
> [ 17.164981] ? pci_match_device+0xac/0x130
> [ 17.164983] pci_device_probe+0xd2/0x1c0
> [ 17.164984] really_probe+0x1f5/0x3f0
> [ 17.164987] __driver_probe_device+0xfe/0x180
> [ 17.164988] driver_probe_device+0x1e/0x90
> [ 17.164990] __driver_attach+0xc0/0x1c0
> [ 17.164991] ? __device_attach_driver+0xe0/0xe0
> [ 17.164992] ? __device_attach_driver+0xe0/0xe0
> [ 17.164994] bus_for_each_dev+0x78/0xc0
> [ 17.164995] new_id_store+0xfc/0x1d0
> [ 17.164996] kernfs_fop_write_iter+0x11c/0x1b0
> [ 17.164998] new_sync_write+0x11f/0x1b0
> [ 17.165001] vfs_write+0x209/0x2a0
> [ 17.165003] ksys_write+0x5f/0xe0
> [ 17.165004] do_syscall_64+0x3b/0xc0
> [ 17.165006]
>
> Fixes: bf3747ae2e25 ("mt76: mt7921: enable aspm by default")
> Reported-by: Kai-Chuan Hsieh <kaichuan.hsieh at canonical.com>
> Co-developed-by: Sean Wang <sean.wang at mediatek.com>
> Signed-off-by: Sean Wang <sean.wang at mediatek.com>
> Signed-off-by: Deren Wu <deren.wu at mediatek.com>
> ---
> .../net/wireless/mediatek/mt76/mt7921/dma.c | 4 ++++
> .../net/wireless/mediatek/mt76/mt7921/mt7921.h | 1 +
> .../wireless/mediatek/mt76/mt7921/pci_mcu.c | 18 ++++++++++++++----
> 3 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
> index cdff1fd52d93..0c4b0e0e634a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
> @@ -364,6 +364,10 @@ int mt7921_dma_init(struct mt7921_dev *dev)
> if (ret)
> return ret;
>
> + ret = __mt7921e_mcu_drv_pmctrl(dev);
> + if (ret)
> + return ret;
> +
> ret = mt7921_wfsys_reset(dev);
> if (ret)
> return ret;
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index 8b674e042568..63e3c7ef5e89 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -443,6 +443,7 @@ int mt7921e_mcu_init(struct mt7921_dev *dev);
> int mt7921s_wfsys_reset(struct mt7921_dev *dev);
> int mt7921s_mac_reset(struct mt7921_dev *dev);
> int mt7921s_init_reset(struct mt7921_dev *dev);
> +int __mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev);
> int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev);
> int mt7921e_mcu_fw_pmctrl(struct mt7921_dev *dev);
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c
> index f9e350b67fdc..36669e5aeef3 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c
> @@ -59,10 +59,8 @@ int mt7921e_mcu_init(struct mt7921_dev *dev)
> return err;
> }
>
> -int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
> +int __mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
> {
> - struct mt76_phy *mphy = &dev->mt76.phy;
> - struct mt76_connac_pm *pm = &dev->pm;
> int i, err = 0;
>
> for (i = 0; i < MT7921_DRV_OWN_RETRY_COUNT; i++) {
> @@ -75,9 +73,21 @@ int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
> if (i == MT7921_DRV_OWN_RETRY_COUNT) {
> dev_err(dev->mt76.dev, "driver own failed\n");
> err = -EIO;
> - goto out;
> }
>
> + return err;
> +}
> +
> +int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
> +{
> + struct mt76_phy *mphy = &dev->mt76.phy;
> + struct mt76_connac_pm *pm = &dev->pm;
> + int err;
> +
> + err = __mt7921e_mcu_drv_pmctrl(dev);
> + if (err < 0)
> + goto out;
> +
> mt7921_wpdma_reinit_cond(dev);
> clear_bit(MT76_STATE_PM, &mphy->state);
>
> --
> 2.25.1
>
More information about the Linux-mediatek
mailing list