arch/arm/kernel/dma.c
Source file repositories/reference/linux-study-clean/arch/arm/kernel/dma.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/kernel/dma.c- Extension
.c- Size
- 5220 bytes
- Lines
- 284
- Domain
- Architecture Layer
- Bucket
- arch/arm
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/init.hlinux/spinlock.hlinux/errno.hlinux/scatterlist.hlinux/seq_file.hlinux/proc_fs.hasm/dma.hasm/mach/dma.h
Detected Declarations
function isa_dma_addfunction request_dmafunction free_dmafunction set_dma_sgfunction __set_dma_addrfunction set_dma_countfunction set_dma_modefunction enable_dmafunction disable_dmafunction dma_channel_activefunction set_dma_pagefunction set_dma_speedfunction get_dma_residuefunction proc_dma_showfunction proc_dma_initexport dma_spin_lockexport request_dmaexport free_dmaexport set_dma_sgexport __set_dma_addrexport set_dma_countexport set_dma_modeexport enable_dmaexport disable_dmaexport dma_channel_activeexport set_dma_pageexport set_dma_speedexport get_dma_residue
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* linux/arch/arm/kernel/dma.c
*
* Copyright (C) 1995-2000 Russell King
*
* Front-end to the DMA handling. This handles the allocation/freeing
* of DMA channels, and provides a unified interface to the machines
* DMA facilities.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/errno.h>
#include <linux/scatterlist.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include <asm/dma.h>
#include <asm/mach/dma.h>
DEFINE_RAW_SPINLOCK(dma_spin_lock);
EXPORT_SYMBOL(dma_spin_lock);
static dma_t *dma_chan[MAX_DMA_CHANNELS];
static inline dma_t *dma_channel(unsigned int chan)
{
if (chan >= MAX_DMA_CHANNELS)
return NULL;
return dma_chan[chan];
}
int __init isa_dma_add(unsigned int chan, dma_t *dma)
{
if (!dma->d_ops)
return -EINVAL;
sg_init_table(&dma->buf, 1);
if (dma_chan[chan])
return -EBUSY;
dma_chan[chan] = dma;
return 0;
}
/*
* Request DMA channel
*
* On certain platforms, we have to allocate an interrupt as well...
*/
int request_dma(unsigned int chan, const char *device_id)
{
dma_t *dma = dma_channel(chan);
int ret;
if (!dma)
goto bad_dma;
if (xchg(&dma->lock, 1) != 0)
goto busy;
dma->device_id = device_id;
dma->active = 0;
dma->invalid = 1;
ret = 0;
if (dma->d_ops->request)
ret = dma->d_ops->request(chan, dma);
if (ret)
xchg(&dma->lock, 0);
return ret;
bad_dma:
pr_err("dma: trying to allocate DMA%d\n", chan);
return -EINVAL;
busy:
return -EBUSY;
}
EXPORT_SYMBOL(request_dma);
/*
* Free DMA channel
*
* On certain platforms, we have to free interrupt as well...
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/spinlock.h`, `linux/errno.h`, `linux/scatterlist.h`, `linux/seq_file.h`, `linux/proc_fs.h`, `asm/dma.h`.
- Detected declarations: `function isa_dma_add`, `function request_dma`, `function free_dma`, `function set_dma_sg`, `function __set_dma_addr`, `function set_dma_count`, `function set_dma_mode`, `function enable_dma`, `function disable_dma`, `function dma_channel_active`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: integration 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.