diff --git a/android/abi_gki_aarch64_qcom b/android/abi_gki_aarch64_qcom index bba27648556a..1858aaf32128 100644 --- a/android/abi_gki_aarch64_qcom +++ b/android/abi_gki_aarch64_qcom @@ -2099,6 +2099,7 @@ __tracepoint_android_rvh_find_lowest_rq __tracepoint_android_rvh_flush_task __tracepoint_android_rvh_get_nohz_timer_target + __tracepoint_android_rvh_iommu_setup_dma_ops __tracepoint_android_rvh_is_cpu_allowed __tracepoint_android_rvh_migrate_queued_task __tracepoint_android_rvh_new_task_stats diff --git a/arch/arm64/configs/vendor/pineapple_GKI.config b/arch/arm64/configs/vendor/pineapple_GKI.config index b97aca2fd5cd..22d929bc4a24 100644 --- a/arch/arm64/configs/vendor/pineapple_GKI.config +++ b/arch/arm64/configs/vendor/pineapple_GKI.config @@ -45,6 +45,7 @@ CONFIG_INPUT_QCOM_HV_HAPTICS=m CONFIG_INTERCONNECT_QCOM_DEBUG=m CONFIG_INTERCONNECT_QCOM_PINEAPPLE=m CONFIG_INTERCONNECT_TEST=m +CONFIG_IOMMU_IO_PGTABLE_FAST=y CONFIG_IPA3=m CONFIG_IPC_LOGGING=m CONFIG_IPC_LOG_MINIDUMP_BUFFERS=0 diff --git a/drivers/iommu/dma-mapping-fast.c b/drivers/iommu/dma-mapping-fast.c index aa777b60322c..962e81b5e082 100644 --- a/drivers/iommu/dma-mapping-fast.c +++ b/drivers/iommu/dma-mapping-fast.c @@ -980,7 +980,7 @@ static void fast_smmu_reserve_iommu_regions(struct device *dev, bitmap_set(fast->clean_bitmap, lo, hi - lo + 1); } spin_unlock_irqrestore(&mapping->lock, flags); - qcom_iommu_put_resv_regions(dev, &resv_regions); + iommu_put_resv_regions(dev, &resv_regions); fast_smmu_reserve_msi_iova(dev, fast); } @@ -992,8 +992,6 @@ void fast_smmu_put_dma_cookie(struct iommu_domain *domain) if (!fast) return; - iommu_put_dma_cookie(domain); - if (fast->iovad) { put_iova_domain(fast->iovad); kfree(fast->iovad); 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 */ diff --git a/include/linux/qcom-iommu-util.h b/include/linux/qcom-iommu-util.h index db5a07cdda7a..4bbb597dbcf8 100644 --- a/include/linux/qcom-iommu-util.h +++ b/include/linux/qcom-iommu-util.h @@ -112,9 +112,8 @@ int qcom_iommu_get_fast_iova_range(struct device *dev, dma_addr_t *ret_iova_base, dma_addr_t *ret_iova_end); -/* Remove once these functions are exported by upstream kernel */ +/* Remove once this function is exported by upstream kernel */ void qcom_iommu_get_resv_regions(struct device *dev, struct list_head *list); -void qcom_iommu_put_resv_regions(struct device *dev, struct list_head *list); phys_addr_t qcom_iommu_iova_to_phys_hard(struct iommu_domain *domain, struct qcom_iommu_atos_txn *txn);