drivers/dma/cv1800b-dmamux.c
Source file repositories/reference/linux-study-clean/drivers/dma/cv1800b-dmamux.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/cv1800b-dmamux.c- Extension
.c- Size
- 6846 bytes
- Lines
- 263
- Domain
- Driver Families
- Bucket
- drivers/dma
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/bitops.hlinux/cleanup.hlinux/module.hlinux/of_dma.hlinux/of_address.hlinux/of_platform.hlinux/platform_device.hlinux/llist.hlinux/regmap.hlinux/spinlock.hlinux/mfd/syscon.h
Detected Declarations
struct cv1800_dmamux_datastruct cv1800_dmamux_mapfunction cv1800_dmamux_freefunction cv1800_dmamux_probefunction cv1800_dmamux_remove
Annotated Snippet
struct cv1800_dmamux_data {
struct dma_router dmarouter;
struct regmap *regmap;
spinlock_t lock;
struct llist_head free_maps;
struct llist_head reserve_maps;
DECLARE_BITMAP(mapped_peripherals, MAX_DMA_MAPPING_ID);
};
struct cv1800_dmamux_map {
struct llist_node node;
unsigned int channel;
unsigned int peripheral;
unsigned int cpu;
};
static void cv1800_dmamux_free(struct device *dev, void *route_data)
{
struct cv1800_dmamux_data *dmamux = dev_get_drvdata(dev);
struct cv1800_dmamux_map *map = route_data;
guard(spinlock_irqsave)(&dmamux->lock);
regmap_update_bits(dmamux->regmap,
DMAMUX_CH_REG(map->channel),
DMAMUX_CH_MASK(map->channel),
DMAMUX_CH_UPDATE_BIT);
regmap_update_bits(dmamux->regmap, REG_DMA_INT_MUX,
DMAMUX_INT_CH_MASK(map->channel, map->cpu),
DMAMUX_INTEN_BIT(map->cpu));
dev_dbg(dev, "free channel %u for req %u (cpu %u)\n",
map->channel, map->peripheral, map->cpu);
}
static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec,
struct of_dma *ofdma)
{
struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
struct cv1800_dmamux_data *dmamux = platform_get_drvdata(pdev);
struct cv1800_dmamux_map *map;
struct llist_node *node;
unsigned long flags;
unsigned int chid, devid, cpuid;
int ret = -EINVAL;
if (dma_spec->args_count != DMAMUX_NCELLS) {
dev_err(&pdev->dev, "invalid number of dma mux args\n");
goto err_put_pdev;
}
devid = dma_spec->args[0];
cpuid = dma_spec->args[1];
dma_spec->args_count = 1;
if (devid > MAX_DMA_MAPPING_ID) {
dev_err(&pdev->dev, "invalid device id: %u\n", devid);
goto err_put_pdev;
}
if (cpuid > MAX_DMA_CPU_ID) {
dev_err(&pdev->dev, "invalid cpu id: %u\n", cpuid);
goto err_put_pdev;
}
dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
if (!dma_spec->np) {
dev_err(&pdev->dev, "can't get dma master\n");
goto err_put_pdev;
}
spin_lock_irqsave(&dmamux->lock, flags);
if (test_bit(devid, dmamux->mapped_peripherals)) {
llist_for_each_entry(map, dmamux->reserve_maps.first, node) {
if (map->peripheral == devid && map->cpu == cpuid)
goto found;
}
goto failed;
} else {
node = llist_del_first(&dmamux->free_maps);
if (!node) {
ret = -ENODEV;
goto failed;
}
map = llist_entry(node, struct cv1800_dmamux_map, node);
llist_add(&map->node, &dmamux->reserve_maps);
set_bit(devid, dmamux->mapped_peripherals);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/cleanup.h`, `linux/module.h`, `linux/of_dma.h`, `linux/of_address.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/llist.h`.
- Detected declarations: `struct cv1800_dmamux_data`, `struct cv1800_dmamux_map`, `function cv1800_dmamux_free`, `function cv1800_dmamux_probe`, `function cv1800_dmamux_remove`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.