drivers/dma/st_fdma.c
Source file repositories/reference/linux-study-clean/drivers/dma/st_fdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/st_fdma.c- Extension
.c- Size
- 22202 bytes
- Lines
- 869
- 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.
- 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/init.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/property.hlinux/interrupt.hlinux/remoteproc.hlinux/slab.hst_fdma.h
Detected Declarations
function Copyrightfunction st_fdma_dreq_getfunction st_fdma_dreq_putfunction st_fdma_xfer_descfunction st_fdma_ch_sta_updatefunction st_fdma_irq_handlerfunction st_fdma_free_descfunction st_fdma_alloc_chan_resfunction st_fdma_free_chan_resfunction config_reqctrlfunction fill_hw_nodefunction for_each_sgfunction st_fdma_desc_residuefunction st_fdma_tx_statusfunction st_fdma_issue_pendingfunction st_fdma_pausefunction st_fdma_resumefunction st_fdma_terminate_allfunction st_fdma_slave_configfunction st_fdma_parse_dtfunction BITfunction st_fdma_probefunction st_fdma_remove
Annotated Snippet
if (fdev->dreq_mask == ~0L) {
dev_err(fdev->dev, "No req lines available\n");
return -EINVAL;
}
if (try || req_line_cfg >= ST_FDMA_NR_DREQS) {
dev_err(fdev->dev, "Invalid or used req line\n");
return -EINVAL;
} else {
dreq_line = req_line_cfg;
}
try++;
} while (test_and_set_bit(dreq_line, &fdev->dreq_mask));
dev_dbg(fdev->dev, "get dreq_line:%d mask:%#lx\n",
dreq_line, fdev->dreq_mask);
return dreq_line;
}
static void st_fdma_dreq_put(struct st_fdma_chan *fchan)
{
struct st_fdma_dev *fdev = fchan->fdev;
dev_dbg(fdev->dev, "put dreq_line:%#lx\n", fchan->dreq_line);
clear_bit(fchan->dreq_line, &fdev->dreq_mask);
}
static void st_fdma_xfer_desc(struct st_fdma_chan *fchan)
{
struct virt_dma_desc *vdesc;
unsigned long nbytes, ch_cmd, cmd;
vdesc = vchan_next_desc(&fchan->vchan);
if (!vdesc)
return;
fchan->fdesc = to_st_fdma_desc(vdesc);
nbytes = fchan->fdesc->node[0].desc->nbytes;
cmd = FDMA_CMD_START(fchan->vchan.chan.chan_id);
ch_cmd = fchan->fdesc->node[0].pdesc | FDMA_CH_CMD_STA_START;
/* start the channel for the descriptor */
fnode_write(fchan, nbytes, FDMA_CNTN_OFST);
fchan_write(fchan, ch_cmd, FDMA_CH_CMD_OFST);
writel(cmd,
fchan->fdev->slim_rproc->peri + FDMA_CMD_SET_OFST);
dev_dbg(fchan->fdev->dev, "start chan:%d\n", fchan->vchan.chan.chan_id);
}
static void st_fdma_ch_sta_update(struct st_fdma_chan *fchan,
unsigned long int_sta)
{
unsigned long ch_sta, ch_err;
int ch_id = fchan->vchan.chan.chan_id;
struct st_fdma_dev *fdev = fchan->fdev;
ch_sta = fchan_read(fchan, FDMA_CH_CMD_OFST);
ch_err = ch_sta & FDMA_CH_CMD_ERR_MASK;
ch_sta &= FDMA_CH_CMD_STA_MASK;
if (int_sta & FDMA_INT_STA_ERR) {
dev_warn(fdev->dev, "chan:%d, error:%ld\n", ch_id, ch_err);
fchan->status = DMA_ERROR;
return;
}
switch (ch_sta) {
case FDMA_CH_CMD_STA_PAUSED:
fchan->status = DMA_PAUSED;
break;
case FDMA_CH_CMD_STA_RUNNING:
fchan->status = DMA_IN_PROGRESS;
break;
}
}
static irqreturn_t st_fdma_irq_handler(int irq, void *dev_id)
{
struct st_fdma_dev *fdev = dev_id;
irqreturn_t ret = IRQ_NONE;
struct st_fdma_chan *fchan = &fdev->chans[0];
unsigned long int_sta, clr;
int_sta = fdma_read(fdev, FDMA_INT_STA_OFST);
clr = int_sta;
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/of.h`, `linux/of_dma.h`, `linux/platform_device.h`, `linux/property.h`, `linux/interrupt.h`, `linux/remoteproc.h`.
- Detected declarations: `function Copyright`, `function st_fdma_dreq_get`, `function st_fdma_dreq_put`, `function st_fdma_xfer_desc`, `function st_fdma_ch_sta_update`, `function st_fdma_irq_handler`, `function st_fdma_free_desc`, `function st_fdma_alloc_chan_res`, `function st_fdma_free_chan_res`, `function config_reqctrl`.
- 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.
- 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.