block/blk-mq-dma.c
Source file repositories/reference/linux-study-clean/block/blk-mq-dma.c
File Facts
- System
- Linux kernel
- Corpus path
block/blk-mq-dma.c- Extension
.c- Size
- 12965 bytes
- Lines
- 439
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blk-integrity.hlinux/blk-mq-dma.hblk.h
Detected Declarations
function Copyrightfunction blk_map_iter_nextfunction granularityfunction blk_dma_map_busfunction blk_dma_map_directfunction blk_rq_dma_map_iovafunction blk_rq_map_iter_initfunction blk_dma_map_iter_startfunction blk_rq_dma_map_coalescefunction blk_rq_dma_map_iter_startfunction blk_next_sgfunction __blk_rq_map_sgfunction blk_rq_dma_map_coalescefunction blk_rq_integrity_dma_map_iter_startfunction blk_rq_map_integrity_sgexport blk_rq_dma_map_iter_startexport blk_rq_dma_map_iter_nextexport __blk_rq_map_sgexport blk_rq_integrity_dma_map_iter_startexport blk_rq_integrity_dma_map_iter_nextexport blk_rq_map_integrity_sg
Annotated Snippet
phys_to_page(vec.paddr))) {
case PCI_P2PDMA_MAP_BUS_ADDR:
return blk_dma_map_bus(iter, &vec);
case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE:
/*
* P2P transfers through the host bridge are treated the
* same as non-P2P transfers below and during unmap.
*/
case PCI_P2PDMA_MAP_NONE:
break;
default:
iter->status = BLK_STS_INVAL;
return false;
}
if (blk_can_dma_map_iova(req, dma_dev) &&
dma_iova_try_alloc(dma_dev, state, vec.paddr, total_len))
return blk_rq_dma_map_iova(req, dma_dev, state, iter, &vec);
memset(state, 0, sizeof(*state));
return blk_dma_map_direct(req, dma_dev, iter, &vec);
}
/**
* blk_rq_dma_map_iter_start - map the first DMA segment for a request
* @req: request to map
* @dma_dev: device to map to
* @state: DMA IOVA state
* @iter: block layer DMA iterator
*
* Start DMA mapping @req to @dma_dev. @state and @iter are provided by the
* caller and don't need to be initialized. @state needs to be stored for use
* at unmap time, @iter is only needed at map time.
*
* Returns %false if there is no segment to map, including due to an error, or
* %true ft it did map a segment.
*
* If a segment was mapped, the DMA address for it is returned in @iter.addr and
* the length in @iter.len. If no segment was mapped the status code is
* returned in @iter.status.
*
* The caller can call blk_rq_dma_map_coalesce() to check if further segments
* need to be mapped after this, or go straight to blk_rq_dma_map_iter_next()
* to try to map the following segments.
*/
bool blk_rq_dma_map_iter_start(struct request *req, struct device *dma_dev,
struct dma_iova_state *state, struct blk_dma_iter *iter)
{
blk_rq_map_iter_init(req, &iter->iter);
return blk_dma_map_iter_start(req, dma_dev, state, iter,
blk_rq_payload_bytes(req));
}
EXPORT_SYMBOL_GPL(blk_rq_dma_map_iter_start);
/**
* blk_rq_dma_map_iter_next - map the next DMA segment for a request
* @req: request to map
* @dma_dev: device to map to
* @iter: block layer DMA iterator
*
* Iterate to the next mapping after a previous call to
* blk_rq_dma_map_iter_start(). See there for a detailed description of the
* arguments.
*
* Returns %false if there is no segment to map, including due to an error, or
* %true ft it did map a segment.
*
* If a segment was mapped, the DMA address for it is returned in @iter.addr and
* the length in @iter.len. If no segment was mapped the status code is
* returned in @iter.status.
*/
bool blk_rq_dma_map_iter_next(struct request *req, struct device *dma_dev,
struct blk_dma_iter *iter)
{
struct phys_vec vec;
if (!blk_map_iter_next(req, &iter->iter, &vec))
return false;
if (iter->p2pdma.map == PCI_P2PDMA_MAP_BUS_ADDR)
return blk_dma_map_bus(iter, &vec);
return blk_dma_map_direct(req, dma_dev, iter, &vec);
}
EXPORT_SYMBOL_GPL(blk_rq_dma_map_iter_next);
static inline struct scatterlist *
blk_next_sg(struct scatterlist **sg, struct scatterlist *sglist)
{
if (!*sg)
return sglist;
Annotation
- Immediate include surface: `linux/blk-integrity.h`, `linux/blk-mq-dma.h`, `blk.h`.
- Detected declarations: `function Copyright`, `function blk_map_iter_next`, `function granularity`, `function blk_dma_map_bus`, `function blk_dma_map_direct`, `function blk_rq_dma_map_iova`, `function blk_rq_map_iter_init`, `function blk_dma_map_iter_start`, `function blk_rq_dma_map_coalesce`, `function blk_rq_dma_map_iter_start`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
- 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.