On Mon, Mar 11, 2019 at 08:47:44AM -0700, Alexander Duyck wrote: > > drivers/iommu/amd_iommu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > > index 6b0760dafb3e..949621f33624 100644 > > --- a/drivers/iommu/amd_iommu.c > > +++ b/drivers/iommu/amd_iommu.c > > @@ -2604,7 +2604,7 @@ 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; > > + s->dma_address += address + (s->offset & ~PAGE_MASK); > > s->dma_length = s->length; > > } > > > > You should add a comment calling out that this is needed because the > sg_phys(s) call above this is masked with PAGE_MASK. Then this makes > much more sense. Otherwise I would have assumed you needed either the > full offset or none. Would something like this /* * Everything is mapped - write the right values into s->dma_address. * Take into account s->offset can be bigger than page size and sg_phys(s) * address has to be aligned to page granularity. */ be appropriate ? Stanislaw