Skip to content

Commit d005100

Browse files
keithbuschkawasaki
authored andcommitted
blk-mq-dma: move common dma start code to a helper
In preparing for dma mapping integrity metadata, move the common dma setup to a helper. Signed-off-by: Keith Busch <[email protected]>
1 parent 2b2b24c commit d005100

1 file changed

Lines changed: 33 additions & 27 deletions

File tree

block/blk-mq-dma.c

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -135,36 +135,12 @@ static struct blk_map_iter blk_rq_map_iter(struct request *rq)
135135
};
136136
}
137137

138-
/**
139-
* blk_rq_dma_map_iter_start - map the first DMA segment for a request
140-
* @req: request to map
141-
* @dma_dev: device to map to
142-
* @state: DMA IOVA state
143-
* @iter: block layer DMA iterator
144-
*
145-
* Start DMA mapping @req to @dma_dev. @state and @iter are provided by the
146-
* caller and don't need to be initialized. @state needs to be stored for use
147-
* at unmap time, @iter is only needed at map time.
148-
*
149-
* Returns %false if there is no segment to map, including due to an error, or
150-
* %true ft it did map a segment.
151-
*
152-
* If a segment was mapped, the DMA address for it is returned in @iter.addr and
153-
* the length in @iter.len. If no segment was mapped the status code is
154-
* returned in @iter.status.
155-
*
156-
* The caller can call blk_rq_dma_map_coalesce() to check if further segments
157-
* need to be mapped after this, or go straight to blk_rq_dma_map_iter_next()
158-
* to try to map the following segments.
159-
*/
160-
bool blk_rq_dma_map_iter_start(struct request *req, struct device *dma_dev,
161-
struct dma_iova_state *state, struct blk_dma_iter *iter)
138+
static bool blk_dma_map_iter_start(struct request *req, struct device *dma_dev,
139+
struct dma_iova_state *state, struct blk_dma_iter *iter,
140+
unsigned int total_len)
162141
{
163-
unsigned int total_len = blk_rq_payload_bytes(req);
164-
165142
memset(&iter->p2pdma, 0, sizeof(iter->p2pdma));
166143
iter->status = BLK_STS_OK;
167-
iter->iter = blk_rq_map_iter(req);
168144

169145
/*
170146
* Grab the first segment ASAP because we'll need it to check for P2P
@@ -194,6 +170,36 @@ bool blk_rq_dma_map_iter_start(struct request *req, struct device *dma_dev,
194170
return blk_rq_dma_map_iova(req, dma_dev, state, iter);
195171
return blk_dma_map_direct(req, dma_dev, iter);
196172
}
173+
174+
/**
175+
* blk_rq_dma_map_iter_start - map the first DMA segment for a request
176+
* @req: request to map
177+
* @dma_dev: device to map to
178+
* @state: DMA IOVA state
179+
* @iter: block layer DMA iterator
180+
*
181+
* Start DMA mapping @req to @dma_dev. @state and @iter are provided by the
182+
* caller and don't need to be initialized. @state needs to be stored for use
183+
* at unmap time, @iter is only needed at map time.
184+
*
185+
* Returns %false if there is no segment to map, including due to an error, or
186+
* %true ft it did map a segment.
187+
*
188+
* If a segment was mapped, the DMA address for it is returned in @iter.addr and
189+
* the length in @iter.len. If no segment was mapped the status code is
190+
* returned in @iter.status.
191+
*
192+
* The caller can call blk_rq_dma_map_coalesce() to check if further segments
193+
* need to be mapped after this, or go straight to blk_rq_dma_map_iter_next()
194+
* to try to map the following segments.
195+
*/
196+
bool blk_rq_dma_map_iter_start(struct request *req, struct device *dma_dev,
197+
struct dma_iova_state *state, struct blk_dma_iter *iter)
198+
{
199+
iter->iter = blk_rq_map_iter(req);
200+
return blk_dma_map_iter_start(req, dma_dev, state, iter,
201+
blk_rq_payload_bytes(req));
202+
}
197203
EXPORT_SYMBOL_GPL(blk_rq_dma_map_iter_start);
198204

199205
/**

0 commit comments

Comments
 (0)