Message ID | 20190313090316.GA2663@redhat.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Johannes Berg |
Headers | show |
Series | [v2] iommu/amd: fix sg->dma_address for sg->offset bigger than PAGE_SIZE | expand |
Hi Stanislaw, thanks a lot for looking into this and tracking it down! On Wed, Mar 13, 2019 at 10:03:17AM +0100, Stanislaw Gruszka wrote: > - 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; Applied the patch for v5.1 (with an added Fixes-tag and a minor coding style change) and will send it upstream soon. Thanks again, Joerg
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 6b0760dafb3e..696c78225dd1 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2604,7 +2604,11 @@ 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; }