* [PATCH v2] iommu/dma: Rationalise types for DMA masks
@ 2019-12-11 18:33 Robin Murphy
2019-12-11 19:02 ` Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Robin Murphy @ 2019-12-11 18:33 UTC (permalink / raw)
To: joro, hch
Cc: stephan, arnd, linux-kernel, iommu, natechancellor, nsaenzjulienne
Since iommu_dma_alloc_iova() combines incoming masks with the u64 bus
limit, it makes more sense to pass them around in their native u64
rather than converting to dma_addr_t early. Do that, and resolve the
remaining type discrepancy against the domain geometry with a cheeky
cast to keep things simple.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
v2: Reworked from "iommu/dma: Use a better type for dma_limit"
drivers/iommu/dma-iommu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 0cc702a70a96..6e573d1cb8bf 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -399,7 +399,7 @@ static int dma_info_to_prot(enum dma_data_direction dir, bool coherent,
}
static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain,
- size_t size, dma_addr_t dma_limit, struct device *dev)
+ size_t size, u64 dma_limit, struct device *dev)
{
struct iommu_dma_cookie *cookie = domain->iova_cookie;
struct iova_domain *iovad = &cookie->iovad;
@@ -424,7 +424,7 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain,
dma_limit = min_not_zero(dma_limit, dev->bus_dma_limit);
if (domain->geometry.force_aperture)
- dma_limit = min(dma_limit, domain->geometry.aperture_end);
+ dma_limit = min(dma_limit, (u64)domain->geometry.aperture_end);
/* Try to get PCI devices a SAC address */
if (dma_limit > DMA_BIT_MASK(32) && dev_is_pci(dev))
@@ -477,7 +477,7 @@ static void __iommu_dma_unmap(struct device *dev, dma_addr_t dma_addr,
}
static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
- size_t size, int prot, dma_addr_t dma_mask)
+ size_t size, int prot, u64 dma_mask)
{
struct iommu_domain *domain = iommu_get_dma_domain(dev);
struct iommu_dma_cookie *cookie = domain->iova_cookie;
--
2.23.0.dirty
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu/dma: Rationalise types for DMA masks
2019-12-11 18:33 [PATCH v2] iommu/dma: Rationalise types for DMA masks Robin Murphy
@ 2019-12-11 19:02 ` Christoph Hellwig
2019-12-17 10:18 ` Joerg Roedel
2019-12-11 19:07 ` Nathan Chancellor
2019-12-11 19:12 ` Nicolas Saenz Julienne
2 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2019-12-11 19:02 UTC (permalink / raw)
To: Robin Murphy
Cc: arnd, stephan, linux-kernel, iommu, natechancellor, hch, nsaenzjulienne
On Wed, Dec 11, 2019 at 06:33:26PM +0000, Robin Murphy wrote:
> Since iommu_dma_alloc_iova() combines incoming masks with the u64 bus
> limit, it makes more sense to pass them around in their native u64
> rather than converting to dma_addr_t early. Do that, and resolve the
> remaining type discrepancy against the domain geometry with a cheeky
> cast to keep things simple.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Looks good to me:
Reviewed-by: Christoph Hellwig <hch@lst.de>
Joerg, let me know if you want to pick this up through the iommu tree as
it touches the iommu code, or through the dma-mapping tree that
introduced the warning.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu/dma: Rationalise types for DMA masks
2019-12-11 18:33 [PATCH v2] iommu/dma: Rationalise types for DMA masks Robin Murphy
2019-12-11 19:02 ` Christoph Hellwig
@ 2019-12-11 19:07 ` Nathan Chancellor
2019-12-11 19:12 ` Nicolas Saenz Julienne
2 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2019-12-11 19:07 UTC (permalink / raw)
To: Robin Murphy; +Cc: arnd, stephan, linux-kernel, iommu, hch, nsaenzjulienne
On Wed, Dec 11, 2019 at 06:33:26PM +0000, Robin Murphy wrote:
> Since iommu_dma_alloc_iova() combines incoming masks with the u64 bus
> limit, it makes more sense to pass them around in their native u64
> rather than converting to dma_addr_t early. Do that, and resolve the
> remaining type discrepancy against the domain geometry with a cheeky
> cast to keep things simple.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com> # build
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu/dma: Rationalise types for DMA masks
2019-12-11 18:33 [PATCH v2] iommu/dma: Rationalise types for DMA masks Robin Murphy
2019-12-11 19:02 ` Christoph Hellwig
2019-12-11 19:07 ` Nathan Chancellor
@ 2019-12-11 19:12 ` Nicolas Saenz Julienne
2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2019-12-11 19:12 UTC (permalink / raw)
To: Robin Murphy, joro, hch
Cc: natechancellor, iommu, arnd, linux-kernel, stephan
[-- Attachment #1.1: Type: text/plain, Size: 509 bytes --]
On Wed, 2019-12-11 at 18:33 +0000, Robin Murphy wrote:
> Since iommu_dma_alloc_iova() combines incoming masks with the u64 bus
> limit, it makes more sense to pass them around in their native u64
> rather than converting to dma_addr_t early. Do that, and resolve the
> remaining type discrepancy against the domain geometry with a cheeky
> cast to keep things simple.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Thanks!
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 156 bytes --]
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu/dma: Rationalise types for DMA masks
2019-12-11 19:02 ` Christoph Hellwig
@ 2019-12-17 10:18 ` Joerg Roedel
0 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2019-12-17 10:18 UTC (permalink / raw)
To: Christoph Hellwig
Cc: arnd, stephan, linux-kernel, iommu, natechancellor, Robin Murphy,
nsaenzjulienne
On Wed, Dec 11, 2019 at 08:02:35PM +0100, Christoph Hellwig wrote:
> On Wed, Dec 11, 2019 at 06:33:26PM +0000, Robin Murphy wrote:
> > Since iommu_dma_alloc_iova() combines incoming masks with the u64 bus
> > limit, it makes more sense to pass them around in their native u64
> > rather than converting to dma_addr_t early. Do that, and resolve the
> > remaining type discrepancy against the domain geometry with a cheeky
> > cast to keep things simple.
> >
> > Signed-off-by: Robin Murphy <robin.murphy@arm.com>
>
> Looks good to me:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
> Joerg, let me know if you want to pick this up through the iommu tree as
> it touches the iommu code, or through the dma-mapping tree that
> introduced the warning.
I'll take it through my tree, as I am about to collect fixes anyway.
Patch is now applied, thanks everyone.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-12-17 10:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 18:33 [PATCH v2] iommu/dma: Rationalise types for DMA masks Robin Murphy
2019-12-11 19:02 ` Christoph Hellwig
2019-12-17 10:18 ` Joerg Roedel
2019-12-11 19:07 ` Nathan Chancellor
2019-12-11 19:12 ` Nicolas Saenz Julienne
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).