lkml.org 
[lkml]   [2019]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] iommu/amd: fix sg->dma_address for sg->offset bigger than PAGE_SIZE
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

\
 
 \ /
  Last update: 2019-03-12 08:09    [W:0.070 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site