Skip to content

Commit 31eaf61

Browse files
thierryredinggregkh
authored andcommitted
drm/tegra: Fix SMMU support on Tegra124 and Tegra210
[ Upstream commit 501be6c ] When testing whether or not to enable the use of the SMMU, consult the supported DMA mask rather than the actually configured DMA mask, since the latter might already have been restricted. Fixes: 2d9384f ("drm/tegra: Relax IOMMU usage criteria on old Tegra") Tested-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e190ea4 commit 31eaf61

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎drivers/gpu/drm/tegra/drm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt,
10391039

10401040
static bool host1x_drm_wants_iommu(struct host1x_device *dev)
10411041
{
1042+
struct host1x *host1x = dev_get_drvdata(dev->dev.parent);
10421043
struct iommu_domain *domain;
10431044

10441045
/*
@@ -1076,7 +1077,7 @@ static bool host1x_drm_wants_iommu(struct host1x_device *dev)
10761077
* sufficient and whether or not the host1x is attached to an IOMMU
10771078
* doesn't matter.
10781079
*/
1079-
if (!domain && dma_get_mask(dev->dev.parent) <= DMA_BIT_MASK(32))
1080+
if (!domain && host1x_get_dma_mask(host1x) <= DMA_BIT_MASK(32))
10801081
return true;
10811082

10821083
return domain != NULL;

‎drivers/gpu/host1x/dev.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,19 @@ static void __exit tegra_host1x_exit(void)
502502
}
503503
module_exit(tegra_host1x_exit);
504504

505+
/**
506+
* host1x_get_dma_mask() - query the supported DMA mask for host1x
507+
* @host1x: host1x instance
508+
*
509+
* Note that this returns the supported DMA mask for host1x, which can be
510+
* different from the applicable DMA mask under certain circumstances.
511+
*/
512+
u64 host1x_get_dma_mask(struct host1x *host1x)
513+
{
514+
return host1x->info->dma_mask;
515+
}
516+
EXPORT_SYMBOL(host1x_get_dma_mask);
517+
505518
MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>");
506519
MODULE_AUTHOR("Terje Bergstrom <tbergstrom@nvidia.com>");
507520
MODULE_DESCRIPTION("Host1x driver for Tegra products");

‎include/linux/host1x.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ enum host1x_class {
1717
HOST1X_CLASS_GR3D = 0x60,
1818
};
1919

20+
struct host1x;
2021
struct host1x_client;
2122
struct iommu_group;
2223

24+
u64 host1x_get_dma_mask(struct host1x *host1x);
25+
2326
/**
2427
* struct host1x_client_ops - host1x client operations
2528
* @init: host1x client initialization code

0 commit comments

Comments
 (0)