media: saa7146: use sg_dma_len when building pgtable
authorTasos Sahanidis <tasos@tasossah.com>
Wed, 3 Mar 2021 18:52:53 +0000 (19:52 +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 saa7146 accessed the length member
directly, it did not support this scenario.

This fixes IO_PAGE_FAULTs 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/common/saa7146/saa7146_core.c
drivers/media/common/saa7146/saa7146_video.c

index f2d13b71416cbd0a3e7c0488b6bd6c8c997eae25..e50fa0ff7c5d5486fce4548e9fefa40f532bac6a 100644 (file)
@@ -253,7 +253,7 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt
                         i, sg_dma_address(list), sg_dma_len(list),
                         list->offset);
 */
-               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) + p * 4096);
                        nr_pages++;
                }
index 7b8795eca5893c76012b4bac6c7aa6c08c735524..66215d9106a42dd2f392bfb5048451972cac35fa 100644 (file)
@@ -247,9 +247,8 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
 
                /* walk all pages, copy all page addresses to ptr1 */
                for (i = 0; i < length; i++, list++) {
-                       for (p = 0; p * 4096 < list->length; p++, ptr1++) {
+                       for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr1++)
                                *ptr1 = cpu_to_le32(sg_dma_address(list) - list->offset);
-                       }
                }
 /*
                ptr1 = pt1->cpu;