arch/powerpc/platforms/pasemi/dma_lib.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pasemi/dma_lib.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pasemi/dma_lib.c- Extension
.c- Size
- 15633 bytes
- Lines
- 622
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- 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/kernel.hlinux/export.hlinux/pci.hlinux/slab.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/sched.hasm/pasemi_dma.h
Detected Declarations
function pasemi_read_iob_regfunction pasemi_write_iob_regfunction pasemi_read_mac_regfunction pasemi_write_mac_regfunction pasemi_read_dma_regfunction pasemi_write_dma_regfunction pasemi_alloc_tx_chanfunction pasemi_free_tx_chanfunction pasemi_alloc_rx_chanfunction pasemi_free_rx_chanfunction tofunction pasemi_dma_free_chanfunction pasemi_dma_alloc_ringfunction pasemi_dma_free_ringfunction Enablesfunction Stopsfunction dma_alloc_coherentfunction pasemi_dma_free_buffunction synchronizationfunction pasemi_dma_free_flagfunction pasemi_dma_set_flagfunction pasemi_dma_clear_flagfunction enginefunction pasemi_dma_free_funfunction pasemi_dma_initexport pasemi_read_iob_regexport pasemi_write_iob_regexport pasemi_read_mac_regexport pasemi_write_mac_regexport pasemi_read_dma_regexport pasemi_write_dma_regexport pasemi_dma_alloc_chanexport pasemi_dma_free_chanexport pasemi_dma_alloc_ringexport pasemi_dma_free_ringexport pasemi_dma_start_chanexport pasemi_dma_stop_chanexport pasemi_dma_alloc_bufexport pasemi_dma_free_bufexport pasemi_dma_alloc_flagexport pasemi_dma_free_flagexport pasemi_dma_set_flagexport pasemi_dma_clear_flagexport pasemi_dma_alloc_funexport pasemi_dma_free_funexport pasemi_dma_init
Annotated Snippet
if (!(sta & PAS_DMA_RXCHAN_CCMDSTA_ACT)) {
pasemi_write_dma_reg(reg, 0);
return 1;
}
cond_resched();
}
} else {
reg = PAS_DMA_TXCHAN_TCMDSTA(chan->chno);
pasemi_write_dma_reg(reg, PAS_DMA_TXCHAN_TCMDSTA_ST);
for (retries = 0; retries < MAX_RETRIES; retries++) {
sta = pasemi_read_dma_reg(reg);
if (!(sta & PAS_DMA_TXCHAN_TCMDSTA_ACT)) {
pasemi_write_dma_reg(reg, 0);
return 1;
}
cond_resched();
}
}
return 0;
}
EXPORT_SYMBOL(pasemi_dma_stop_chan);
/* pasemi_dma_alloc_buf - Allocate a buffer to use for DMA
* @chan: Channel to allocate for
* @size: Size of buffer in bytes
* @handle: DMA handle
*
* Allocate a buffer to be used by the DMA engine for read/write,
* similar to dma_alloc_coherent().
*
* Returns the virtual address of the buffer, or NULL in case of failure.
*/
void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
dma_addr_t *handle)
{
return dma_alloc_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL);
}
EXPORT_SYMBOL(pasemi_dma_alloc_buf);
/* pasemi_dma_free_buf - Free a buffer used for DMA
* @chan: Channel the buffer was allocated for
* @size: Size of buffer in bytes
* @handle: DMA handle
*
* Frees a previously allocated buffer.
*/
void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
dma_addr_t *handle)
{
dma_free_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL);
}
EXPORT_SYMBOL(pasemi_dma_free_buf);
/* pasemi_dma_alloc_flag - Allocate a flag (event) for channel synchronization
*
* Allocates a flag for use with channel synchronization (event descriptors).
* Returns allocated flag (0-63), < 0 on error.
*/
int pasemi_dma_alloc_flag(void)
{
int bit;
retry:
bit = find_first_bit(flags_free, MAX_FLAGS);
if (bit >= MAX_FLAGS)
return -ENOSPC;
if (!test_and_clear_bit(bit, flags_free))
goto retry;
return bit;
}
EXPORT_SYMBOL(pasemi_dma_alloc_flag);
/* pasemi_dma_free_flag - Deallocates a flag (event)
* @flag: Flag number to deallocate
*
* Frees up a flag so it can be reused for other purposes.
*/
void pasemi_dma_free_flag(int flag)
{
BUG_ON(test_bit(flag, flags_free));
BUG_ON(flag >= MAX_FLAGS);
set_bit(flag, flags_free);
}
EXPORT_SYMBOL(pasemi_dma_free_flag);
/* pasemi_dma_set_flag - Sets a flag (event) to 1
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/pci.h`, `linux/slab.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/sched.h`.
- Detected declarations: `function pasemi_read_iob_reg`, `function pasemi_write_iob_reg`, `function pasemi_read_mac_reg`, `function pasemi_write_mac_reg`, `function pasemi_read_dma_reg`, `function pasemi_write_dma_reg`, `function pasemi_alloc_tx_chan`, `function pasemi_free_tx_chan`, `function pasemi_alloc_rx_chan`, `function pasemi_free_rx_chan`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration 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.