All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
To: joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	damm+renesas-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	djkurtz-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Subject: Re: [PATCH 1/2] iommu/dma: Restore scatterlist offsets correctly
Date: Tue, 5 Apr 2016 12:16:10 +0100	[thread overview]
Message-ID: <57039E7A.3090709@arm.com> (raw)
In-Reply-To: <c14a93373a34633f6db89214ca2ddf69b0eaa1c3.1457637385.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>

On 10/03/16 19:28, Robin Murphy wrote:
> With the change to stashing just the IOVA-page-aligned remainder of the
> CPU-page offset rather than the whole thing, the failure path in
> __invalidate_sg() also needs tweaking to account for that in the case of
> differing page sizes where the two offsets may not be equivalent.
> Similarly in __finalise_sg(), lest the architecture-specific wrappers
> later get the wrong address for cache maintenance on sync or unmap.
>
> Fixes: 164afb1d85b8 ("iommu/dma: Use correct offset in map_sg")
> Reported-by: Magnus Damm <damm+renesas-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
> Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
> ---
>   drivers/iommu/dma-iommu.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 72d6182..58f2fe6 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -403,7 +403,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,
>   		unsigned int s_length = sg_dma_len(s);
>   		unsigned int s_dma_len = s->length;
>
> -		s->offset = s_offset;
> +		s->offset += s_offset;
>   		s->length = s_length;
>   		sg_dma_address(s) = dma_addr + s_offset;
>   		dma_addr += s_dma_len;
> @@ -422,7 +422,7 @@ static void __invalidate_sg(struct scatterlist *sg, int nents)
>
>   	for_each_sg(sg, s, nents, i) {
>   		if (sg_dma_address(s) != DMA_ERROR_CODE)
> -			s->offset = sg_dma_address(s);
> +			s->offset += sg_dma_address(s);
>   		if (sg_dma_len(s))
>   			s->length = sg_dma_len(s);
>   		sg_dma_address(s) = DMA_ERROR_CODE;
>

Any comments on these patches? Now that the dust has settled this fix 
really wants to get into 4.6, and folks have been wanting patch 2 for 
ages so it would be nice to get it queued for 4.7.

Robin.

WARNING: multiple messages have this Message-ID (diff)
From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] iommu/dma: Restore scatterlist offsets correctly
Date: Tue, 5 Apr 2016 12:16:10 +0100	[thread overview]
Message-ID: <57039E7A.3090709@arm.com> (raw)
In-Reply-To: <c14a93373a34633f6db89214ca2ddf69b0eaa1c3.1457637385.git.robin.murphy@arm.com>

On 10/03/16 19:28, Robin Murphy wrote:
> With the change to stashing just the IOVA-page-aligned remainder of the
> CPU-page offset rather than the whole thing, the failure path in
> __invalidate_sg() also needs tweaking to account for that in the case of
> differing page sizes where the two offsets may not be equivalent.
> Similarly in __finalise_sg(), lest the architecture-specific wrappers
> later get the wrong address for cache maintenance on sync or unmap.
>
> Fixes: 164afb1d85b8 ("iommu/dma: Use correct offset in map_sg")
> Reported-by: Magnus Damm <damm+renesas@opensource.se>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>   drivers/iommu/dma-iommu.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 72d6182..58f2fe6 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -403,7 +403,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,
>   		unsigned int s_length = sg_dma_len(s);
>   		unsigned int s_dma_len = s->length;
>
> -		s->offset = s_offset;
> +		s->offset += s_offset;
>   		s->length = s_length;
>   		sg_dma_address(s) = dma_addr + s_offset;
>   		dma_addr += s_dma_len;
> @@ -422,7 +422,7 @@ static void __invalidate_sg(struct scatterlist *sg, int nents)
>
>   	for_each_sg(sg, s, nents, i) {
>   		if (sg_dma_address(s) != DMA_ERROR_CODE)
> -			s->offset = sg_dma_address(s);
> +			s->offset += sg_dma_address(s);
>   		if (sg_dma_len(s))
>   			s->length = sg_dma_len(s);
>   		sg_dma_address(s) = DMA_ERROR_CODE;
>

Any comments on these patches? Now that the dust has settled this fix 
really wants to get into 4.6, and folks have been wanting patch 2 for 
ages so it would be nice to get it queued for 4.7.

Robin.

  parent reply	other threads:[~2016-04-05 11:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10 19:28 [PATCH 1/2] iommu/dma: Restore scatterlist offsets correctly Robin Murphy
2016-03-10 19:28 ` Robin Murphy
     [not found] ` <c14a93373a34633f6db89214ca2ddf69b0eaa1c3.1457637385.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2016-03-10 19:28   ` [PATCH 2/2] iommu/dma: Implement scatterlist segment merging Robin Murphy
2016-03-10 19:28     ` Robin Murphy
2016-04-05 11:16   ` Robin Murphy [this message]
2016-04-05 11:16     ` [PATCH 1/2] iommu/dma: Restore scatterlist offsets correctly Robin Murphy
2016-04-05 12:59   ` Joerg Roedel
2016-04-05 12:59     ` Joerg Roedel
     [not found]     ` <20160405125926.GI17838-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2016-04-05 13:11       ` Robin Murphy
2016-04-05 13:11         ` Robin Murphy
     [not found]         ` <5703B98A.6010200-5wv7dgnIgG8@public.gmane.org>
2016-04-05 13:33           ` Joerg Roedel
2016-04-05 13:33             ` Joerg Roedel
     [not found]             ` <20160405133310.GA9516-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2016-04-05 14:06               ` Robin Murphy
2016-04-05 14:06                 ` Robin Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57039E7A.3090709@arm.com \
    --to=robin.murphy-5wv7dgnigg8@public.gmane.org \
    --cc=damm+renesas-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org \
    --cc=djkurtz-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.