* [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
@ 2019-05-29 8:15 ` Nathan Chancellor
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2019-05-29 8:15 UTC (permalink / raw)
To: Joerg Roedel, Christoph Hellwig
Cc: Robin Murphy, iommu, linux-kernel, Nick Desaulniers,
clang-built-linux, Nathan Chancellor
Clang warns:
drivers/iommu/dma-iommu.c:897:6: warning: logical not is only applied to
the left hand side of this comparison [-Wlogical-not-parentheses]
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
^ ~~
drivers/iommu/dma-iommu.c:897:6: note: add parentheses after the '!' to
evaluate the comparison first
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
^
( )
drivers/iommu/dma-iommu.c:897:6: note: add parentheses around left hand
side expression to silence this warning
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
^
( )
1 warning generated.
Judging from the rest of the commit and the conditional in
iommu_dma_map_sg, either
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
or
if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
was intended, not a combination of the two.
I personally think that the former is easier to understand so use that.
Fixes: 06d60728ff5c ("iommu/dma: move the arm64 wrappers to common code")
Link: https://github.com/ClangBuiltLinux/linux/issues/497
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/iommu/dma-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 0cd49c2d3770..0dee374fc64a 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -894,7 +894,7 @@ static void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
struct scatterlist *tmp;
int i;
- if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
+ if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
iommu_dma_sync_sg_for_cpu(dev, sg, nents, dir);
/*
--
2.22.0.rc1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
@ 2019-05-29 8:15 ` Nathan Chancellor
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2019-05-29 8:15 UTC (permalink / raw)
To: Joerg Roedel, Christoph Hellwig
Cc: Nick Desaulniers, linux-kernel, clang-built-linux, iommu,
Nathan Chancellor, Robin Murphy
Clang warns:
drivers/iommu/dma-iommu.c:897:6: warning: logical not is only applied to
the left hand side of this comparison [-Wlogical-not-parentheses]
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
^ ~~
drivers/iommu/dma-iommu.c:897:6: note: add parentheses after the '!' to
evaluate the comparison first
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
^
( )
drivers/iommu/dma-iommu.c:897:6: note: add parentheses around left hand
side expression to silence this warning
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
^
( )
1 warning generated.
Judging from the rest of the commit and the conditional in
iommu_dma_map_sg, either
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
or
if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
was intended, not a combination of the two.
I personally think that the former is easier to understand so use that.
Fixes: 06d60728ff5c ("iommu/dma: move the arm64 wrappers to common code")
Link: https://github.com/ClangBuiltLinux/linux/issues/497
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/iommu/dma-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 0cd49c2d3770..0dee374fc64a 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -894,7 +894,7 @@ static void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
struct scatterlist *tmp;
int i;
- if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
+ if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
iommu_dma_sync_sg_for_cpu(dev, sg, nents, dir);
/*
--
2.22.0.rc1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
2019-05-29 8:15 ` Nathan Chancellor
@ 2019-05-29 10:12 ` Robin Murphy
-1 siblings, 0 replies; 8+ messages in thread
From: Robin Murphy @ 2019-05-29 10:12 UTC (permalink / raw)
To: Nathan Chancellor, Joerg Roedel, Christoph Hellwig
Cc: iommu, linux-kernel, Nick Desaulniers, clang-built-linux
On 29/05/2019 09:15, Nathan Chancellor wrote:
> Clang warns:
>
> drivers/iommu/dma-iommu.c:897:6: warning: logical not is only applied to
> the left hand side of this comparison [-Wlogical-not-parentheses]
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> ^ ~~
> drivers/iommu/dma-iommu.c:897:6: note: add parentheses after the '!' to
> evaluate the comparison first
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> ^
> ( )
> drivers/iommu/dma-iommu.c:897:6: note: add parentheses around left hand
> side expression to silence this warning
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> ^
> ( )
> 1 warning generated.
>
> Judging from the rest of the commit and the conditional in
> iommu_dma_map_sg, either
>
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
>
> or
> if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
>
> was intended, not a combination of the two.
>
> I personally think that the former is easier to understand so use that.
Good catch, thanks Nathan. Looks like this was an unintentional mangling
while ratifying the couple of odd "x == 0" instances to "!x" in the
move. The effective double-negation is not what we want at all.
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Fixes: 06d60728ff5c ("iommu/dma: move the arm64 wrappers to common code")
> Link: https://github.com/ClangBuiltLinux/linux/issues/497
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/iommu/dma-iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 0cd49c2d3770..0dee374fc64a 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -894,7 +894,7 @@ static void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
> struct scatterlist *tmp;
> int i;
>
> - if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> iommu_dma_sync_sg_for_cpu(dev, sg, nents, dir);
>
> /*
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
@ 2019-05-29 10:12 ` Robin Murphy
0 siblings, 0 replies; 8+ messages in thread
From: Robin Murphy @ 2019-05-29 10:12 UTC (permalink / raw)
To: Nathan Chancellor, Joerg Roedel, Christoph Hellwig
Cc: clang-built-linux, iommu, Nick Desaulniers, linux-kernel
On 29/05/2019 09:15, Nathan Chancellor wrote:
> Clang warns:
>
> drivers/iommu/dma-iommu.c:897:6: warning: logical not is only applied to
> the left hand side of this comparison [-Wlogical-not-parentheses]
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> ^ ~~
> drivers/iommu/dma-iommu.c:897:6: note: add parentheses after the '!' to
> evaluate the comparison first
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> ^
> ( )
> drivers/iommu/dma-iommu.c:897:6: note: add parentheses around left hand
> side expression to silence this warning
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> ^
> ( )
> 1 warning generated.
>
> Judging from the rest of the commit and the conditional in
> iommu_dma_map_sg, either
>
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
>
> or
> if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
>
> was intended, not a combination of the two.
>
> I personally think that the former is easier to understand so use that.
Good catch, thanks Nathan. Looks like this was an unintentional mangling
while ratifying the couple of odd "x == 0" instances to "!x" in the
move. The effective double-negation is not what we want at all.
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Fixes: 06d60728ff5c ("iommu/dma: move the arm64 wrappers to common code")
> Link: https://github.com/ClangBuiltLinux/linux/issues/497
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/iommu/dma-iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 0cd49c2d3770..0dee374fc64a 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -894,7 +894,7 @@ static void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
> struct scatterlist *tmp;
> int i;
>
> - if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> iommu_dma_sync_sg_for_cpu(dev, sg, nents, dir);
>
> /*
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
2019-05-29 8:15 ` Nathan Chancellor
@ 2019-05-29 12:14 ` Christoph Hellwig
-1 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-05-29 12:14 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Joerg Roedel, Christoph Hellwig, Robin Murphy, iommu,
linux-kernel, Nick Desaulniers, clang-built-linux
Ooops, thanks for catching this:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
@ 2019-05-29 12:14 ` Christoph Hellwig
0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-05-29 12:14 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nick Desaulniers, linux-kernel, clang-built-linux, iommu,
Robin Murphy, Christoph Hellwig
Ooops, thanks for catching this:
Reviewed-by: Christoph Hellwig <hch@lst.de>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
2019-05-29 8:15 ` Nathan Chancellor
@ 2019-06-03 10:39 ` Joerg Roedel
-1 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2019-06-03 10:39 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Christoph Hellwig, Robin Murphy, iommu, linux-kernel,
Nick Desaulniers, clang-built-linux
On Wed, May 29, 2019 at 01:15:32AM -0700, Nathan Chancellor wrote:
> Fixes: 06d60728ff5c ("iommu/dma: move the arm64 wrappers to common code")
> Link: https://github.com/ClangBuiltLinux/linux/issues/497
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/iommu/dma-iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
@ 2019-06-03 10:39 ` Joerg Roedel
0 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2019-06-03 10:39 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nick Desaulniers, linux-kernel, clang-built-linux, iommu,
Robin Murphy, Christoph Hellwig
On Wed, May 29, 2019 at 01:15:32AM -0700, Nathan Chancellor wrote:
> Fixes: 06d60728ff5c ("iommu/dma: move the arm64 wrappers to common code")
> Link: https://github.com/ClangBuiltLinux/linux/issues/497
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/iommu/dma-iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-06-03 10:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29 8:15 [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg Nathan Chancellor
2019-05-29 8:15 ` Nathan Chancellor
2019-05-29 10:12 ` Robin Murphy
2019-05-29 10:12 ` Robin Murphy
2019-05-29 12:14 ` Christoph Hellwig
2019-05-29 12:14 ` Christoph Hellwig
2019-06-03 10:39 ` Joerg Roedel
2019-06-03 10:39 ` Joerg Roedel
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.