Skip to content

Commit

Permalink
wifi: mt76: mt792x: fix scheduler interference in drv own process
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit d53ab629cff57e450fe69fc90eb1ddc372e8da2d)
Signed-off-by: Wentao Guan <otgwt@outlook.com>
  • Loading branch information
michaello316 authored and opsiff committed Aug 24, 2024
1 parent 8fb48ea commit d2ddd97
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ bool ____mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,

void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs);
void mt76_pci_disable_aspm(struct pci_dev *pdev);
bool mt76_pci_aspm_supported(struct pci_dev *pdev);

static inline u16 mt76_chip(struct mt76_dev *dev)
{
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt7921/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
bus_ops->rmw = mt7921_rmw;
dev->mt76.bus = bus_ops;

if (!mt7921_disable_aspm && mt76_pci_aspm_supported(pdev))
dev->aspm_supported = true;

ret = mt792xe_mcu_fw_pmctrl(dev);
if (ret)
goto err_free_dev;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt7925/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ static int mt7925_pci_probe(struct pci_dev *pdev,
bus_ops->rmw = mt7925_rmw;
dev->mt76.bus = bus_ops;

if (!mt7925_disable_aspm && mt76_pci_aspm_supported(pdev))
dev->aspm_supported = true;

ret = __mt792x_mcu_fw_pmctrl(dev);
if (ret)
goto err_free_dev;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt792x.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct mt792x_dev {
bool hw_init_done:1;
bool fw_assert:1;
bool has_eht:1;
bool aspm_supported:1;

struct work_struct init_work;

Expand Down
4 changes: 4 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt792x_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,10 @@ int __mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev)

for (i = 0; i < MT792x_DRV_OWN_RETRY_COUNT; i++) {
mt76_wr(dev, MT_CONN_ON_LPCTL, PCIE_LPCR_HOST_CLR_OWN);

if (dev->aspm_supported)
usleep_range(2000, 3000);

if (mt76_poll_msec_tick(dev, MT_CONN_ON_LPCTL,
PCIE_LPCR_HOST_OWN_SYNC, 0, 50, 1))
break;
Expand Down
23 changes: 23 additions & 0 deletions drivers/net/wireless/mediatek/mt76/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ void mt76_pci_disable_aspm(struct pci_dev *pdev)
aspm_conf);
}
EXPORT_SYMBOL_GPL(mt76_pci_disable_aspm);

bool mt76_pci_aspm_supported(struct pci_dev *pdev)
{
struct pci_dev *parent = pdev->bus->self;
u16 aspm_conf, parent_aspm_conf = 0;
bool result = true;

pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspm_conf);
aspm_conf &= PCI_EXP_LNKCTL_ASPMC;
if (parent) {
pcie_capability_read_word(parent, PCI_EXP_LNKCTL,
&parent_aspm_conf);
parent_aspm_conf &= PCI_EXP_LNKCTL_ASPMC;
}

if (!aspm_conf && (!parent || !parent_aspm_conf)) {
/* aspm already disabled */
result = false;
}

return result;
}
EXPORT_SYMBOL_GPL(mt76_pci_aspm_supported);

0 comments on commit d2ddd97

Please sign in to comment.