Linux IOMMU Development
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Nathan Chancellor <natechancellor@gmail.com>,
	Joerg Roedel <joro@8bytes.org>, Christoph Hellwig <hch@lst.de>
Cc: clang-built-linux@googlegroups.com,
	iommu@lists.linux-foundation.org,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg
Date: Wed, 29 May 2019 11:12:16 +0100	[thread overview]
Message-ID: <e8c21972-cb70-34ff-949d-5e2555c3a1fb@arm.com> (raw)
In-Reply-To: <20190529081532.73585-1-natechancellor@gmail.com>

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

  reply	other threads:[~2019-05-29 10:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29  8:15 [PATCH] iommu/dma: Fix condition check in iommu_dma_unmap_sg Nathan Chancellor
2019-05-29 10:12 ` Robin Murphy [this message]
2019-05-29 12:14 ` Christoph Hellwig
2019-06-03 10:39 ` Joerg Roedel

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=e8c21972-cb70-34ff-949d-5e2555c3a1fb@arm.com \
    --to=robin.murphy@arm.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox