Skip to content

Commit c5e8e93

Browse files
Pranjal Ramajor Asha Kanojiyaquic-jhugo
authored andcommitted
accel/qaic: Fix the for loop used to walk SG table
Only for_each_sgtable_dma_sg() should be used to walk through a SG table to grab correct bus address and length pair after calling DMA MAP API on a SG table as DMA MAP APIs updates the SG table and for_each_sgtable_sg() walks through the original SG table. Fixes: ff13be8 ("accel/qaic: Add datapath") Fixes: 129776a ("accel/qaic: Add control path") Signed-off-by: Pranjal Ramajor Asha Kanojiya <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Jeffrey Hugo <[email protected]> Reviewed-by: Jacek Lawrynowicz <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f07fd95 commit c5e8e93

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/accel/qaic/qaic_control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ static int encode_addr_size_pairs(struct dma_xfer *xfer, struct wrapper_list *wr
496496
nents = sgt->nents;
497497
nents_dma = nents;
498498
*size = QAIC_MANAGE_EXT_MSG_LENGTH - msg_hdr_len - sizeof(**out_trans);
499-
for_each_sgtable_sg(sgt, sg, i) {
499+
for_each_sgtable_dma_sg(sgt, sg, i) {
500500
*size -= sizeof(*asp);
501501
/* Save 1K for possible follow-up transactions. */
502502
if (*size < SZ_1K) {

drivers/accel/qaic/qaic_data.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl
184184
nents = 0;
185185

186186
size = size ? size : PAGE_SIZE;
187-
for (sg = sgt_in->sgl; sg; sg = sg_next(sg)) {
187+
for_each_sgtable_dma_sg(sgt_in, sg, j) {
188188
len = sg_dma_len(sg);
189189

190190
if (!len)
@@ -221,7 +221,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl
221221

222222
/* copy relevant sg node and fix page and length */
223223
sgn = sgf;
224-
for_each_sgtable_sg(sgt, sg, j) {
224+
for_each_sgtable_dma_sg(sgt, sg, j) {
225225
memcpy(sg, sgn, sizeof(*sg));
226226
if (sgn == sgf) {
227227
sg_dma_address(sg) += offf;
@@ -301,7 +301,7 @@ static int encode_reqs(struct qaic_device *qdev, struct bo_slice *slice,
301301
* fence.
302302
*/
303303
dev_addr = req->dev_addr;
304-
for_each_sgtable_sg(slice->sgt, sg, i) {
304+
for_each_sgtable_dma_sg(slice->sgt, sg, i) {
305305
slice->reqs[i].cmd = cmd;
306306
slice->reqs[i].src_addr = cpu_to_le64(slice->dir == DMA_TO_DEVICE ?
307307
sg_dma_address(sg) : dev_addr);

0 commit comments

Comments
 (0)