Skip to content

Commit d518596

Browse files
digetxthierryreding
authored andcommitted
gpu: host1x: Add back arm_iommu_detach_device()
Host1x DMA buffer isn't mapped properly when CONFIG_ARM_DMA_USE_IOMMU=y. The memory management code of Host1x driver has a longstanding overhaul overdue and it's not obvious where the problem is in this case. Hence let's add back the old workaround which we already had sometime before. It explicitly detaches Host1x device from the offending implicit IOMMU domain. This fixes a completely broken Host1x DMA in case of ARM32 multiplatform kernel config. Cc: [email protected] Fixes: af1cbfb ("gpu: host1x: Support DMA mapping of buffers") Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 58ed47a commit d518596

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/gpu/host1x/dev.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <trace/events/host1x.h>
2323
#undef CREATE_TRACE_POINTS
2424

25+
#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)
26+
#include <asm/dma-iommu.h>
27+
#endif
28+
2529
#include "bus.h"
2630
#include "channel.h"
2731
#include "debug.h"
@@ -263,6 +267,17 @@ static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
263267
struct iommu_domain *domain = iommu_get_domain_for_dev(host->dev);
264268
int err;
265269

270+
#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)
271+
if (host->dev->archdata.mapping) {
272+
struct dma_iommu_mapping *mapping =
273+
to_dma_iommu_mapping(host->dev);
274+
arm_iommu_detach_device(host->dev);
275+
arm_iommu_release_mapping(mapping);
276+
277+
domain = iommu_get_domain_for_dev(host->dev);
278+
}
279+
#endif
280+
266281
/*
267282
* We may not always want to enable IOMMU support (for example if the
268283
* host1x firewall is already enabled and we don't support addressing

0 commit comments

Comments
 (0)