drivers/dma/virt-dma.h
Source file repositories/reference/linux-study-clean/drivers/dma/virt-dma.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/virt-dma.h- Extension
.h- Size
- 6214 bytes
- Lines
- 238
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dmaengine.hlinux/interrupt.hdmaengine.h
Detected Declarations
struct virt_dma_descstruct virt_dma_chanfunction vchan_issue_pendingfunction vchan_cookie_completefunction vchan_vdesc_finifunction vchan_cyclic_callbackfunction vchan_terminate_vdescfunction vchan_get_all_descriptorsfunction vchan_free_chan_resourcesfunction vchan_synchronize
Annotated Snippet
struct virt_dma_desc {
struct dma_async_tx_descriptor tx;
struct dmaengine_result tx_result;
/* protected by vc.lock */
struct list_head node;
};
struct virt_dma_chan {
struct dma_chan chan;
struct tasklet_struct task;
void (*desc_free)(struct virt_dma_desc *);
spinlock_t lock;
/* protected by vc.lock */
struct list_head desc_allocated;
struct list_head desc_submitted;
struct list_head desc_issued;
struct list_head desc_completed;
struct list_head desc_terminated;
struct virt_dma_desc *cyclic;
};
static inline struct virt_dma_chan *to_virt_chan(struct dma_chan *chan)
{
return container_of(chan, struct virt_dma_chan, chan);
}
void vchan_dma_desc_free_list(struct virt_dma_chan *vc, struct list_head *head);
void vchan_init(struct virt_dma_chan *vc, struct dma_device *dmadev);
struct virt_dma_desc *vchan_find_desc(struct virt_dma_chan *, dma_cookie_t);
extern dma_cookie_t vchan_tx_submit(struct dma_async_tx_descriptor *);
extern int vchan_tx_desc_free(struct dma_async_tx_descriptor *);
/**
* vchan_tx_prep - prepare a descriptor
* @vc: virtual channel allocating this descriptor
* @vd: virtual descriptor to prepare
* @tx_flags: flags argument passed in to prepare function
*/
static inline struct dma_async_tx_descriptor *vchan_tx_prep(struct virt_dma_chan *vc,
struct virt_dma_desc *vd, unsigned long tx_flags)
{
unsigned long flags;
dma_async_tx_descriptor_init(&vd->tx, &vc->chan);
vd->tx.flags = tx_flags;
vd->tx.tx_submit = vchan_tx_submit;
vd->tx.desc_free = vchan_tx_desc_free;
vd->tx_result.result = DMA_TRANS_NOERROR;
vd->tx_result.residue = 0;
spin_lock_irqsave(&vc->lock, flags);
list_add_tail(&vd->node, &vc->desc_allocated);
spin_unlock_irqrestore(&vc->lock, flags);
return &vd->tx;
}
/**
* vchan_issue_pending - move submitted descriptors to issued list
* @vc: virtual channel to update
*
* vc.lock must be held by caller
*/
static inline bool vchan_issue_pending(struct virt_dma_chan *vc)
{
lockdep_assert_held(&vc->lock);
list_splice_tail_init(&vc->desc_submitted, &vc->desc_issued);
return !list_empty(&vc->desc_issued);
}
/**
* vchan_cookie_complete - report completion of a descriptor
* @vd: virtual descriptor to update
*
* vc.lock must be held by caller
*/
static inline void vchan_cookie_complete(struct virt_dma_desc *vd)
{
struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
dma_cookie_t cookie;
lockdep_assert_held(&vc->lock);
cookie = vd->tx.cookie;
dma_cookie_complete(&vd->tx);
Annotation
- Immediate include surface: `linux/dmaengine.h`, `linux/interrupt.h`, `dmaengine.h`.
- Detected declarations: `struct virt_dma_desc`, `struct virt_dma_chan`, `function vchan_issue_pending`, `function vchan_cookie_complete`, `function vchan_vdesc_fini`, `function vchan_cyclic_callback`, `function vchan_terminate_vdesc`, `function vchan_get_all_descriptors`, `function vchan_free_chan_resources`, `function vchan_synchronize`.
- 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.