[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190312070832.GA2483@redhat.com>
Date: Tue, 12 Mar 2019 08:08:33 +0100
From: Stanislaw Gruszka <sgruszka@...hat.com>
To: Alexander Duyck <alexander.h.duyck@...ux.intel.com>
Cc: Rosen Penev <rosenp@...il.com>, Joerg Roedel <joro@...tes.org>,
Lorenzo Bianconi <lorenzo.bianconi@...hat.com>,
linux-wireless <linux-wireless@...r.kernel.org>,
Samuel Sieb <samuel@...b.net>,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
linux-nvme@...ts.infradead.org, jan.viktorin@...il.com
Subject: Re: [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
Powered by blists - more mailing lists