* [PATCH] iommu: fix min_not_zero() type mismatch warning
@ 2019-12-10 19:57 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2019-12-10 19:57 UTC (permalink / raw)
To: Christoph Hellwig, Joerg Roedel, Robin Murphy, Nicolas Saenz Julienne
Cc: Arnd Bergmann, Tom Murphy, Julien Grall, iommu, linux-kernel
min()/max() require the arguments to be of the same type.
When dma_addr_t is not compatible with __u64, this causes
a warning:
In file included from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/linux/acpi_iort.h:10,
from drivers/iommu/dma-iommu.c:11:
drivers/iommu/dma-iommu.c: In function 'iommu_dma_alloc_iova':
include/linux/kernel.h:844:29: error: comparison of distinct pointer types lacks a cast [-Werror]
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^~
include/linux/kernel.h:858:4: note: in expansion of macro '__typecheck'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~
include/linux/kernel.h:868:24: note: in expansion of macro '__safe_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~
include/linux/kernel.h:877:19: note: in expansion of macro '__careful_cmp'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~
include/linux/kernel.h:910:39: note: in expansion of macro 'min'
__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
^~~
drivers/iommu/dma-iommu.c:424:14: note: in expansion of macro 'min_not_zero'
dma_limit = min_not_zero(dma_limit, dev->bus_dma_limit);
^~~~~~~~~~~~
Add an explicit cast to work around it, as there is no min_not_zero_t()
equivalent of min_t().
Fixes: a7ba70f1787f ("dma-mapping: treat dev->bus_dma_mask as a DMA limit")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
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 0cc702a70a96..6fa32231dc9f 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -421,7 +421,7 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain,
if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1)))
iova_len = roundup_pow_of_two(iova_len);
- dma_limit = min_not_zero(dma_limit, dev->bus_dma_limit);
+ dma_limit = min_not_zero((u64)dma_limit, dev->bus_dma_limit);
if (domain->geometry.force_aperture)
dma_limit = min(dma_limit, domain->geometry.aperture_end);
--
2.20.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] iommu: fix min_not_zero() type mismatch warning
@ 2019-12-10 19:57 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2019-12-10 19:57 UTC (permalink / raw)
To: Christoph Hellwig, Joerg Roedel, Robin Murphy, Nicolas Saenz Julienne
Cc: Julien Grall, iommu, Tom Murphy, Arnd Bergmann, linux-kernel
min()/max() require the arguments to be of the same type.
When dma_addr_t is not compatible with __u64, this causes
a warning:
In file included from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/linux/acpi_iort.h:10,
from drivers/iommu/dma-iommu.c:11:
drivers/iommu/dma-iommu.c: In function 'iommu_dma_alloc_iova':
include/linux/kernel.h:844:29: error: comparison of distinct pointer types lacks a cast [-Werror]
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^~
include/linux/kernel.h:858:4: note: in expansion of macro '__typecheck'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~
include/linux/kernel.h:868:24: note: in expansion of macro '__safe_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~
include/linux/kernel.h:877:19: note: in expansion of macro '__careful_cmp'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~
include/linux/kernel.h:910:39: note: in expansion of macro 'min'
__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
^~~
drivers/iommu/dma-iommu.c:424:14: note: in expansion of macro 'min_not_zero'
dma_limit = min_not_zero(dma_limit, dev->bus_dma_limit);
^~~~~~~~~~~~
Add an explicit cast to work around it, as there is no min_not_zero_t()
equivalent of min_t().
Fixes: a7ba70f1787f ("dma-mapping: treat dev->bus_dma_mask as a DMA limit")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
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 0cc702a70a96..6fa32231dc9f 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -421,7 +421,7 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain,
if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1)))
iova_len = roundup_pow_of_two(iova_len);
- dma_limit = min_not_zero(dma_limit, dev->bus_dma_limit);
+ dma_limit = min_not_zero((u64)dma_limit, dev->bus_dma_limit);
if (domain->geometry.force_aperture)
dma_limit = min(dma_limit, domain->geometry.aperture_end);
--
2.20.0
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: fix min_not_zero() type mismatch warning
2019-12-10 19:57 ` Arnd Bergmann
@ 2019-12-11 7:43 ` Christoph Hellwig
-1 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2019-12-11 7:43 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Christoph Hellwig, Joerg Roedel, Robin Murphy,
Nicolas Saenz Julienne, Tom Murphy, Julien Grall, iommu,
linux-kernel
I think we agree that the parameter should be a u64 instead, and either
Nicolas or Robin (sorry, fading memory) promised to send me a patch for
that.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: fix min_not_zero() type mismatch warning
@ 2019-12-11 7:43 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2019-12-11 7:43 UTC (permalink / raw)
To: Arnd Bergmann
Cc: iommu, Tom Murphy, linux-kernel, Julien Grall, Robin Murphy,
Christoph Hellwig, Nicolas Saenz Julienne
I think we agree that the parameter should be a u64 instead, and either
Nicolas or Robin (sorry, fading memory) promised to send me a patch for
that.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-12-11 7:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 19:57 [PATCH] iommu: fix min_not_zero() type mismatch warning Arnd Bergmann
2019-12-10 19:57 ` Arnd Bergmann
2019-12-11 7:43 ` Christoph Hellwig
2019-12-11 7:43 ` Christoph Hellwig
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.