drivers/net/wireless/mediatek/mt76/pci.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/pci.c- Extension
.c- Size
- 1962 bytes
- Lines
- 77
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
mt76.hlinux/pci.h
Detected Declarations
function Copyrightfunction mt76_pci_aspm_supportedexport mt76_pci_disable_aspmexport mt76_pci_aspm_supported
Annotated Snippet
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (C) 2019 Lorenzo Bianconi <lorenzo@kernel.org>
*/
#include "mt76.h"
#include <linux/pci.h>
void mt76_pci_disable_aspm(struct pci_dev *pdev)
{
struct pci_dev *parent = pdev->bus->self;
u16 aspm_conf, parent_aspm_conf = 0;
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 */
return;
}
dev_info(&pdev->dev, "disabling ASPM %s %s\n",
(aspm_conf & PCI_EXP_LNKCTL_ASPM_L0S) ? "L0s" : "",
(aspm_conf & PCI_EXP_LNKCTL_ASPM_L1) ? "L1" : "");
if (IS_ENABLED(CONFIG_PCIEASPM)) {
int err;
int state = 0;
if (aspm_conf & PCI_EXP_LNKCTL_ASPM_L0S)
state |= PCIE_LINK_STATE_L0S;
if (aspm_conf & PCI_EXP_LNKCTL_ASPM_L1)
state |= PCIE_LINK_STATE_L1;
err = pci_disable_link_state(pdev, state);
if (!err)
return;
}
/* both device and parent should have the same ASPM setting.
* disable ASPM in downstream component first and then upstream.
*/
pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_conf);
if (parent)
pcie_capability_clear_word(parent, PCI_EXP_LNKCTL,
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);
Annotation
- Immediate include surface: `mt76.h`, `linux/pci.h`.
- Detected declarations: `function Copyright`, `function mt76_pci_aspm_supported`, `export mt76_pci_disable_aspm`, `export mt76_pci_aspm_supported`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.