drivers/net/wireless/marvell/mwifiex/pcie.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/marvell/mwifiex/pcie.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/marvell/mwifiex/pcie.c- Extension
.c- Size
- 89980 bytes
- Lines
- 3284
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/iopoll.hlinux/firmware.hdecl.hioctl.hutil.hfw.hmain.hwmm.h11n.hpcie.hpcie_quirks.h
Detected Declarations
function mwifiex_pcie_probe_offunction mwifiex_map_pci_memoryfunction mwifiex_unmap_pci_memoryfunction mwifiex_write_regfunction mwifiex_write_reg_rptfunction mwifiex_read_regfunction mwifiex_read_reg_bytefunction mwifiex_pcie_ok_to_access_hwfunction mwifiex_pcie_suspendfunction mwifiex_pcie_resumefunction mwifiex_pcie_probefunction mwifiex_pcie_removefunction mwifiex_pcie_shutdownfunction mwifiex_pcie_coredumpfunction mwifiex_pcie_reset_preparefunction mwifiex_pcie_reset_donefunction mwifiex_pcie_dev_wakeup_delayfunction mwifiex_delay_for_sleep_cookiefunction mwifiex_pm_wakeup_cardfunction READ_ONCEfunction mwifiex_pm_wakeup_card_completefunction mwifiex_pcie_disable_host_intfunction mwifiex_pcie_enable_host_intfunction mwifiex_init_txq_ringfunction mwifiex_init_rxq_ringfunction mwifiex_pcie_init_evt_ringfunction mwifiex_cleanup_txq_ringfunction mwifiex_cleanup_rxq_ringfunction mwifiex_cleanup_evt_ringfunction mwifiex_pcie_create_txbd_ringfunction mwifiex_pcie_delete_txbd_ringfunction mwifiex_pcie_create_rxbd_ringfunction mwifiex_pcie_delete_rxbd_ringfunction mwifiex_pcie_create_evtbd_ringfunction mwifiex_pcie_delete_evtbd_ringfunction mwifiex_pcie_alloc_cmdrsp_buffunction mwifiex_pcie_delete_cmdrsp_buffunction mwifiex_pcie_alloc_sleep_cookie_buffunction mwifiex_pcie_delete_sleep_cookie_buffunction mwifiex_clean_pcie_ring_buffunction mwifiex_pcie_send_data_completefunction mwifiex_pcie_send_datafunction mwifiex_pcie_process_recv_datafunction mwifiex_pcie_send_boot_cmdfunction mwifiex_pcie_init_fw_portfunction mwifiex_pcie_send_cmdfunction packetfunction mwifiex_pcie_process_cmd_complete
Annotated Snippet
static struct pci_driver mwifiex_pcie = {
.name = "mwifiex_pcie",
.id_table = mwifiex_ids,
.probe = mwifiex_pcie_probe,
.remove = mwifiex_pcie_remove,
.driver = {
.coredump = mwifiex_pcie_coredump,
#ifdef CONFIG_PM_SLEEP
.pm = &mwifiex_pcie_pm_ops,
#endif
},
.shutdown = mwifiex_pcie_shutdown,
.err_handler = &mwifiex_pcie_err_handler,
};
/*
* This function adds delay loop to ensure FW is awake before proceeding.
*/
static void mwifiex_pcie_dev_wakeup_delay(struct mwifiex_adapter *adapter)
{
int i = 0;
while (mwifiex_pcie_ok_to_access_hw(adapter)) {
i++;
usleep_range(10, 20);
/* 50ms max wait */
if (i == 5000)
break;
}
return;
}
static void mwifiex_delay_for_sleep_cookie(struct mwifiex_adapter *adapter,
u32 max_delay_loop_cnt)
{
struct pcie_service_card *card = adapter->card;
u8 *buffer;
u32 sleep_cookie, count;
struct sk_buff *cmdrsp = card->cmdrsp_buf;
for (count = 0; count < max_delay_loop_cnt; count++) {
dma_sync_single_for_cpu(&card->dev->dev,
MWIFIEX_SKB_DMA_ADDR(cmdrsp),
sizeof(sleep_cookie), DMA_FROM_DEVICE);
buffer = cmdrsp->data;
sleep_cookie = get_unaligned_le32(buffer);
if (sleep_cookie == MWIFIEX_DEF_SLEEP_COOKIE) {
mwifiex_dbg(adapter, INFO,
"sleep cookie found at count %d\n", count);
break;
}
dma_sync_single_for_device(&card->dev->dev,
MWIFIEX_SKB_DMA_ADDR(cmdrsp),
sizeof(sleep_cookie),
DMA_FROM_DEVICE);
usleep_range(20, 30);
}
if (count >= max_delay_loop_cnt)
mwifiex_dbg(adapter, INFO,
"max count reached while accessing sleep cookie\n");
}
#define N_WAKEUP_TRIES_SHORT_INTERVAL 15
#define N_WAKEUP_TRIES_LONG_INTERVAL 35
/* This function wakes up the card by reading fw_status register. */
static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
{
struct pcie_service_card *card = adapter->card;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
int retval __maybe_unused;
mwifiex_dbg(adapter, EVENT,
"event: Wakeup device...\n");
if (reg->sleep_cookie)
mwifiex_pcie_dev_wakeup_delay(adapter);
/* The 88W8897 PCIe+USB firmware (latest version 15.68.19.p21) sometimes
* appears to ignore or miss our wakeup request, so we continue trying
* until we receive an interrupt from the card.
*/
if (read_poll_timeout(mwifiex_write_reg_rpt, retval,
READ_ONCE(adapter->int_status) != 0,
500, 500 * N_WAKEUP_TRIES_SHORT_INTERVAL,
false,
adapter, reg->fw_status, FIRMWARE_READY_PCIE)) {
Annotation
- Immediate include surface: `linux/iopoll.h`, `linux/firmware.h`, `decl.h`, `ioctl.h`, `util.h`, `fw.h`, `main.h`, `wmm.h`.
- Detected declarations: `function mwifiex_pcie_probe_of`, `function mwifiex_map_pci_memory`, `function mwifiex_unmap_pci_memory`, `function mwifiex_write_reg`, `function mwifiex_write_reg_rpt`, `function mwifiex_read_reg`, `function mwifiex_read_reg_byte`, `function mwifiex_pcie_ok_to_access_hw`, `function mwifiex_pcie_suspend`, `function mwifiex_pcie_resume`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.