diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 27500abe8ca7cf731ede1ca4e84c3fd115c937cb..0b3877681e4a337106a3d3cf62b4304ec36e6893 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2543,7 +2543,12 @@ static int map_sg(struct device *dev, struct scatterlist *sglist, /* Everything is mapped - write the right values into s->dma_address */ for_each_sg(sglist, s, nelems, i) { - s->dma_address += address + s->offset; + /* + * Add in the remaining piece of the scatter-gather offset that + * was masked out when we were determining the physical address + * via (sg_phys(s) & PAGE_MASK) earlier. + */ + s->dma_address += address + (s->offset & ~PAGE_MASK); s->dma_length = s->length; }