Skip to content

Commit 884d059

Browse files
fujitajoergroedel
authored andcommitted
dma-debug: use sg_dma_len accessor
debug_dma_map_sg() and debug_dma_unmap_sg() use length in struct scatterlist while debug_dma_sync_sg_for_cpu() and debug_dma_sync_sg_for_device() use dma_length. This causes bugs warnings on some IOMMU implementations since these values are not same; the length doesn't represent the dma length. We always need to use sg_dma_len() accessor to get the dma length of a scatterlist entry. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent 15aedea commit 884d059

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎lib/dma-debug.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,15 +839,15 @@ void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
839839
entry->type = dma_debug_sg;
840840
entry->dev = dev;
841841
entry->paddr = sg_phys(s);
842-
entry->size = s->length;
842+
entry->size = sg_dma_len(s);
843843
entry->dev_addr = sg_dma_address(s);
844844
entry->direction = direction;
845845
entry->sg_call_ents = nents;
846846
entry->sg_mapped_ents = mapped_ents;
847847

848848
if (!PageHighMem(sg_page(s))) {
849849
check_for_stack(dev, sg_virt(s));
850-
check_for_illegal_area(dev, sg_virt(s), s->length);
850+
check_for_illegal_area(dev, sg_virt(s), sg_dma_len(s));
851851
}
852852

853853
add_dma_entry(entry);
@@ -873,7 +873,7 @@ void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
873873
.dev = dev,
874874
.paddr = sg_phys(s),
875875
.dev_addr = sg_dma_address(s),
876-
.size = s->length,
876+
.size = sg_dma_len(s),
877877
.direction = dir,
878878
.sg_call_ents = 0,
879879
};
@@ -996,7 +996,7 @@ void debug_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
996996
return;
997997

998998
for_each_sg(sg, s, nelems, i) {
999-
check_sync(dev, sg_dma_address(s), s->dma_length, 0,
999+
check_sync(dev, sg_dma_address(s), sg_dma_len(s), 0,
10001000
direction, true);
10011001
}
10021002
}
@@ -1012,7 +1012,7 @@ void debug_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
10121012
return;
10131013

10141014
for_each_sg(sg, s, nelems, i) {
1015-
check_sync(dev, sg_dma_address(s), s->dma_length, 0,
1015+
check_sync(dev, sg_dma_address(s), sg_dma_len(s), 0,
10161016
direction, false);
10171017
}
10181018
}

0 commit comments

Comments
 (0)