media: saa7134: use sg_dma_len when building pgtable
authorTasos Sahanidis <tasos@tasossah.com>
Wed, 3 Mar 2021 18:30:18 +0000 (19:30 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Mar 2021 10:59:44 +0000 (11:59 +0100)
The new AMD IOMMU DMA implementation concatenates sglist entries under
certain conditions, and because saa7134 accessed the length member
directly, it did not support this scenario.

This fixes IO_PAGE_FAULTs and choppy DMA audio by using the
sg_dma_len macro.

Fixes: be62dbf554c5 ("iommu/amd: Convert AMD iommu driver to the dma-iommu api")
Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/pci/saa7134/saa7134-core.c

index 391572a6ec76a6d8dfa67f44214e2af457ce0453..efb757d5168a637db8a5835f506f26dae7148fa8 100644 (file)
@@ -243,7 +243,7 @@ int saa7134_pgtable_build(struct pci_dev *pci, struct saa7134_pgtable *pt,
 
        ptr = pt->cpu + startpage;
        for (i = 0; i < length; i++, list = sg_next(list)) {
-               for (p = 0; p * 4096 < list->length; p++, ptr++)
+               for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr++)
                        *ptr = cpu_to_le32(sg_dma_address(list) +
                                                list->offset + p * 4096);
        }