Skip to content

Commit 94ba1a6

Browse files
michaello316nbd168
authored andcommitted
wifi: mt76: mt792x: fix scheduler interference in drv own process
Add some time to wait for LP engine to complete its operation before polling pmctrl register. Signed-off-by: Michael Lo <michael.lo@mediatek.com> Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Tested-by: David Ruth <druth@chromium.org> Acked-by: Sean Wang <sean.wang@mediatek.com> Link: https://patch.msgid.link/20240523112131.31437-1-mingyen.hsieh@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent eb6b0c0 commit 94ba1a6

6 files changed

Lines changed: 35 additions & 0 deletions

File tree

drivers/net/wireless/mediatek/mt76/mt76.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,7 @@ bool ____mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,
10851085

10861086
void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs);
10871087
void mt76_pci_disable_aspm(struct pci_dev *pdev);
1088+
bool mt76_pci_aspm_supported(struct pci_dev *pdev);
10881089

10891090
static inline u16 mt76_chip(struct mt76_dev *dev)
10901091
{

drivers/net/wireless/mediatek/mt76/mt7921/pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
339339
bus_ops->rmw = mt7921_rmw;
340340
dev->mt76.bus = bus_ops;
341341

342+
if (!mt7921_disable_aspm && mt76_pci_aspm_supported(pdev))
343+
dev->aspm_supported = true;
344+
342345
ret = mt792xe_mcu_fw_pmctrl(dev);
343346
if (ret)
344347
goto err_free_dev;

drivers/net/wireless/mediatek/mt76/mt7925/pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ static int mt7925_pci_probe(struct pci_dev *pdev,
373373
bus_ops->rmw = mt7925_rmw;
374374
dev->mt76.bus = bus_ops;
375375

376+
if (!mt7925_disable_aspm && mt76_pci_aspm_supported(pdev))
377+
dev->aspm_supported = true;
378+
376379
ret = __mt792x_mcu_fw_pmctrl(dev);
377380
if (ret)
378381
goto err_free_dev;

drivers/net/wireless/mediatek/mt76/mt792x.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ struct mt792x_dev {
215215
bool fw_assert:1;
216216
bool has_eht:1;
217217
bool regd_in_progress:1;
218+
bool aspm_supported:1;
218219
wait_queue_head_t wait;
219220

220221
struct work_struct init_work;

drivers/net/wireless/mediatek/mt76/mt792x_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,10 @@ int __mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev)
809809

810810
for (i = 0; i < MT792x_DRV_OWN_RETRY_COUNT; i++) {
811811
mt76_wr(dev, MT_CONN_ON_LPCTL, PCIE_LPCR_HOST_CLR_OWN);
812+
813+
if (dev->aspm_supported)
814+
usleep_range(2000, 3000);
815+
812816
if (mt76_poll_msec_tick(dev, MT_CONN_ON_LPCTL,
813817
PCIE_LPCR_HOST_OWN_SYNC, 0, 50, 1))
814818
break;

drivers/net/wireless/mediatek/mt76/pci.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,26 @@ void mt76_pci_disable_aspm(struct pci_dev *pdev)
4545
aspm_conf);
4646
}
4747
EXPORT_SYMBOL_GPL(mt76_pci_disable_aspm);
48+
49+
bool mt76_pci_aspm_supported(struct pci_dev *pdev)
50+
{
51+
struct pci_dev *parent = pdev->bus->self;
52+
u16 aspm_conf, parent_aspm_conf = 0;
53+
bool result = true;
54+
55+
pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspm_conf);
56+
aspm_conf &= PCI_EXP_LNKCTL_ASPMC;
57+
if (parent) {
58+
pcie_capability_read_word(parent, PCI_EXP_LNKCTL,
59+
&parent_aspm_conf);
60+
parent_aspm_conf &= PCI_EXP_LNKCTL_ASPMC;
61+
}
62+
63+
if (!aspm_conf && (!parent || !parent_aspm_conf)) {
64+
/* aspm already disabled */
65+
result = false;
66+
}
67+
68+
return result;
69+
}
70+
EXPORT_SYMBOL_GPL(mt76_pci_aspm_supported);

0 commit comments

Comments
 (0)