diff --git a/drivers/iommu/qcom-iommu-debug-user.c b/drivers/iommu/qcom-iommu-debug-user.c index c991a2030f80..71993447d9f1 100644 --- a/drivers/iommu/qcom-iommu-debug-user.c +++ b/drivers/iommu/qcom-iommu-debug-user.c @@ -1203,6 +1203,22 @@ static int iommu_debug_functional_fast_dma_api_show(struct seq_file *s, void *ignored) { int ret = 0; + struct iommu_debug_device *ddev = s->private; + + if (!ddev->test_dev) { + pr_err("%s:Have you selected a uscase?\n", __func__); + return -EINVAL; + } + + if (!ddev->fastmap_usecase) { + ps_printf(dev_name(ddev->test_dev), s, + "Not a fastmap usecase\n"); + return 0; + } else if (!IS_ENABLED(CONFIG_IOMMU_IO_PGTABLE_FAST)) { + ps_printf(dev_name(ddev->test_dev), s, + "CONFIG_IOMMU_IO_PGTABLE_FAST not enabled\n"); + return 0; + } ret |= __apply_to_new_mapping(s, __functional_dma_api_alloc_test, NULL); ret |= __apply_to_new_mapping(s, __functional_dma_api_basic_test, NULL); diff --git a/drivers/iommu/qcom-iommu-debug.c b/drivers/iommu/qcom-iommu-debug.c index feb51650662b..f30ef09aa390 100644 --- a/drivers/iommu/qcom-iommu-debug.c +++ b/drivers/iommu/qcom-iommu-debug.c @@ -133,6 +133,7 @@ iommu_debug_switch_usecase(struct iommu_debug_device *ddev, u32 usecase_nr) { struct platform_device *test_pdev; struct device_node *child; + const char *str; int child_nr = 0; int ret; @@ -169,6 +170,10 @@ iommu_debug_switch_usecase(struct iommu_debug_device *ddev, u32 usecase_nr) goto out; } + if (of_property_read_string(child, "qcom,iommu-dma", &str)) + str = "default"; + + ddev->fastmap_usecase = !strcmp(str, "fastmap"); ddev->usecase_nr = usecase_nr; ddev->test_dev = &test_pdev->dev; ddev->domain = iommu_get_domain_for_dev(ddev->test_dev); diff --git a/drivers/iommu/qcom-iommu-debug.h b/drivers/iommu/qcom-iommu-debug.h index 41e06082e01b..78f3106ea9eb 100644 --- a/drivers/iommu/qcom-iommu-debug.h +++ b/drivers/iommu/qcom-iommu-debug.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. - * + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __DRIVERS_IOMMU_QCOM_IOMMU_DEBUG_H__ @@ -26,6 +26,7 @@ struct iommu_debug_device { struct device *test_dev; struct iommu_domain *domain; u32 usecase_nr; + bool fastmap_usecase; /* Protects test_dev */ struct mutex state_lock; /* For waiting for child probe to complete */