From: Arnd Bergmann <arnd@arndb.de>
To: Christoph Hellwig <hch@lst.de>, Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Julien Grall <julien.grall@arm.com>,
iommu@lists.linux-foundation.org, Tom Murphy <murphyt7@tcd.ie>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH] iommu: fix min_not_zero() type mismatch warning
Date: Tue, 10 Dec 2019 20:57:56 +0100 [thread overview]
Message-ID: <20191210195803.866126-1-arnd@arndb.de> (raw)
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
next reply other threads:[~2019-12-10 19:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-10 19:57 Arnd Bergmann [this message]
2019-12-11 7:43 ` [PATCH] iommu: fix min_not_zero() type mismatch warning Christoph Hellwig
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=20191210195803.866126-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=julien.grall@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=murphyt7@tcd.ie \
--cc=nsaenzjulienne@suse.de \
--cc=robin.murphy@arm.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