iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/mediatek: fix out-of-range warning with clang
@ 2021-09-27 12:18 Arnd Bergmann
  2021-09-28  1:21 ` Yong Wu
  2021-09-28  9:59 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-09-27 12:18 UTC (permalink / raw)
  To: Yong Wu, Joerg Roedel, Will Deacon, Matthias Brugger
  Cc: Arnd Bergmann, llvm, Nick Desaulniers, linux-kernel,
	Nathan Chancellor, iommu, linux-mediatek, Robin Murphy,
	linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

clang-14 notices that a comparison is never true when
CONFIG_PHYS_ADDR_T_64BIT is disabled:

drivers/iommu/mtk_iommu.c:553:34: error: result of comparison of constant 5368709120 with expression of type 'phys_addr_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (dom->data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE)
                                     ~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add an explicit check for the type of the variable to skip the check
and the warning in that case.

Fixes: b4dad40e4f35 ("iommu/mediatek: Adjust the PA for the 4GB Mode")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/iommu/mtk_iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index d837adfd1da5..25b834104790 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -550,7 +550,9 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
 	phys_addr_t pa;
 
 	pa = dom->iop->iova_to_phys(dom->iop, iova);
-	if (dom->data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE)
+	if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) &&
+	    dom->data->enable_4GB &&
+	    pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE)
 		pa &= ~BIT_ULL(32);
 
 	return pa;
-- 
2.29.2

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/mediatek: fix out-of-range warning with clang
  2021-09-27 12:18 [PATCH] iommu/mediatek: fix out-of-range warning with clang Arnd Bergmann
@ 2021-09-28  1:21 ` Yong Wu
  2021-09-28  9:59 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Yong Wu @ 2021-09-28  1:21 UTC (permalink / raw)
  To: Arnd Bergmann, Joerg Roedel, Will Deacon, Matthias Brugger
  Cc: Arnd Bergmann, llvm, Nick Desaulniers, linux-kernel,
	Nathan Chancellor, iommu, linux-mediatek, Robin Murphy,
	linux-arm-kernel

On Mon, 2021-09-27 at 14:18 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang-14 notices that a comparison is never true when
> CONFIG_PHYS_ADDR_T_64BIT is disabled:
> 
> drivers/iommu/mtk_iommu.c:553:34: error: result of comparison of
> constant 5368709120 with expression of type 'phys_addr_t' (aka
> 'unsigned int') is always false [-Werror,-Wtautological-constant-out-
> of-range-compare]
>         if (dom->data->enable_4GB && pa >=
> MTK_IOMMU_4GB_MODE_REMAP_BASE)
>                                      ~~
> ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Add an explicit check for the type of the variable to skip the check
> and the warning in that case.
> 
> Fixes: b4dad40e4f35 ("iommu/mediatek: Adjust the PA for the 4GB
> Mode")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Yong Wu <yong.wu@mediatek.com>

Thanks.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/mediatek: fix out-of-range warning with clang
  2021-09-27 12:18 [PATCH] iommu/mediatek: fix out-of-range warning with clang Arnd Bergmann
  2021-09-28  1:21 ` Yong Wu
@ 2021-09-28  9:59 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2021-09-28  9:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Robin Murphy, llvm, Nick Desaulniers, linux-kernel,
	Nathan Chancellor, iommu, linux-mediatek, linux-arm-kernel,
	Matthias Brugger, Will Deacon

On Mon, Sep 27, 2021 at 02:18:44PM +0200, Arnd Bergmann wrote:
>  drivers/iommu/mtk_iommu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-28 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-27 12:18 [PATCH] iommu/mediatek: fix out-of-range warning with clang Arnd Bergmann
2021-09-28  1:21 ` Yong Wu
2021-09-28  9:59 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).