drivers/mailbox/bcm-pdc-mailbox.c
Source file repositories/reference/linux-study-clean/drivers/mailbox/bcm-pdc-mailbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mailbox/bcm-pdc-mailbox.c- Extension
.c- Size
- 48558 bytes
- Lines
- 1632
- Domain
- Driver Families
- Bucket
- drivers/mailbox
- 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.
- 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/errno.hlinux/module.hlinux/init.hlinux/slab.hlinux/debugfs.hlinux/interrupt.hlinux/wait.hlinux/platform_device.hlinux/property.hlinux/io.hlinux/of.hlinux/of_irq.hlinux/mailbox_controller.hlinux/mailbox/brcm-message.hlinux/scatterlist.hlinux/dma-direction.hlinux/dma-mapping.hlinux/dmapool.hlinux/workqueue.h
Detected Declarations
struct dma64ddstruct dma64_regsstruct dma64struct pdc_regsstruct pdc_ring_allocstruct pdc_rx_ctxstruct pdc_statestruct pdc_globalsenum pdc_hwfunction pdc_debugfs_readfunction pdc_setup_debugfsfunction pdc_free_debugfsfunction pdc_build_rxdfunction pdc_build_txdfunction pdc_receive_onefunction pdc_receivefunction pdc_tx_list_sg_addfunction pdc_tx_list_finalfunction pdc_rx_list_initfunction pdc_rx_list_sg_addfunction pdc_irq_handlerfunction pdc_work_cbfunction pdc_ring_initfunction pdc_ring_freefunction pdc_desc_countfunction pdc_rings_fullfunction pdc_last_tx_donefunction pdc_send_datafunction pdc_startupfunction pdc_shutdownfunction pdc_hw_initfunction pdc_hw_disablefunction pdc_rx_buf_pool_createfunction pdc_interrupts_initfunction pdc_mb_initfunction pdc_dt_readfunction pdc_probefunction pdc_remove
Annotated Snippet
static const struct file_operations pdc_debugfs_stats = {
.owner = THIS_MODULE,
.open = simple_open,
.read = pdc_debugfs_read,
};
/**
* pdc_setup_debugfs() - Create the debug FS directories. If the top-level
* directory has not yet been created, create it now. Create a stats file in
* this directory for a SPU.
* @pdcs: PDC state structure
*/
static void pdc_setup_debugfs(struct pdc_state *pdcs)
{
char spu_stats_name[16];
if (!debugfs_initialized())
return;
snprintf(spu_stats_name, 16, "pdc%d_stats", pdcs->pdc_idx);
if (!debugfs_dir)
debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
/* S_IRUSR == 0400 */
debugfs_create_file(spu_stats_name, 0400, debugfs_dir, pdcs,
&pdc_debugfs_stats);
}
static void pdc_free_debugfs(void)
{
debugfs_remove_recursive(debugfs_dir);
debugfs_dir = NULL;
}
/**
* pdc_build_rxd() - Build DMA descriptor to receive SPU result.
* @pdcs: PDC state for SPU that will generate result
* @dma_addr: DMA address of buffer that descriptor is being built for
* @buf_len: Length of the receive buffer, in bytes
* @flags: Flags to be stored in descriptor
*/
static inline void
pdc_build_rxd(struct pdc_state *pdcs, dma_addr_t dma_addr,
u32 buf_len, u32 flags)
{
struct device *dev = &pdcs->pdev->dev;
struct dma64dd *rxd = &pdcs->rxd_64[pdcs->rxout];
dev_dbg(dev,
"Writing rx descriptor for PDC %u at index %u with length %u. flags %#x\n",
pdcs->pdc_idx, pdcs->rxout, buf_len, flags);
rxd->addrlow = cpu_to_le32(lower_32_bits(dma_addr));
rxd->addrhigh = cpu_to_le32(upper_32_bits(dma_addr));
rxd->ctrl1 = cpu_to_le32(flags);
rxd->ctrl2 = cpu_to_le32(buf_len);
/* bump ring index and return */
pdcs->rxout = NEXTRXD(pdcs->rxout, pdcs->nrxpost);
}
/**
* pdc_build_txd() - Build a DMA descriptor to transmit a SPU request to
* hardware.
* @pdcs: PDC state for the SPU that will process this request
* @dma_addr: DMA address of packet to be transmitted
* @buf_len: Length of tx buffer, in bytes
* @flags: Flags to be stored in descriptor
*/
static inline void
pdc_build_txd(struct pdc_state *pdcs, dma_addr_t dma_addr, u32 buf_len,
u32 flags)
{
struct device *dev = &pdcs->pdev->dev;
struct dma64dd *txd = &pdcs->txd_64[pdcs->txout];
dev_dbg(dev,
"Writing tx descriptor for PDC %u at index %u with length %u, flags %#x\n",
pdcs->pdc_idx, pdcs->txout, buf_len, flags);
txd->addrlow = cpu_to_le32(lower_32_bits(dma_addr));
txd->addrhigh = cpu_to_le32(upper_32_bits(dma_addr));
txd->ctrl1 = cpu_to_le32(flags);
txd->ctrl2 = cpu_to_le32(buf_len);
/* bump ring index and return */
pdcs->txout = NEXTTXD(pdcs->txout, pdcs->ntxpost);
}
/**
Annotation
- Immediate include surface: `linux/errno.h`, `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/debugfs.h`, `linux/interrupt.h`, `linux/wait.h`, `linux/platform_device.h`.
- Detected declarations: `struct dma64dd`, `struct dma64_regs`, `struct dma64`, `struct pdc_regs`, `struct pdc_ring_alloc`, `struct pdc_rx_ctx`, `struct pdc_state`, `struct pdc_globals`, `enum pdc_hw`, `function pdc_debugfs_read`.
- Atlas domain: Driver Families / drivers/mailbox.
- Implementation status: pattern implementation candidate.
- 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.