Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iommu/tegra241-cmdqv: Decouple driver from ACPI

A platform device is created by acpi_create_platform_device() per CMDQV's
adev. That means there is no point in going through _CRS of ACPI.

Replace all the ACPI functions with standard platform functions. And drop
all ACPI dependencies. This will make the driver compatible with DT also.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Nicolin Chen and committed by
Will Deacon
eb20758f 14e9a138

+14 -74
-1
drivers/iommu/arm/Kconfig
··· 121 121 122 122 config TEGRA241_CMDQV 123 123 bool "NVIDIA Tegra241 CMDQ-V extension support for ARM SMMUv3" 124 - depends on ACPI 125 124 help 126 125 Support for NVIDIA CMDQ-Virtualization extension for ARM SMMUv3. The 127 126 CMDQ-V extension is similar to v3.3 ECMDQ for multi command queues
+2 -1
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
··· 4545 4545 adev = acpi_dev_get_first_match_dev("NVDA200C", uid, -1); 4546 4546 if (adev) { 4547 4547 /* Tegra241 CMDQV driver is responsible for put_device() */ 4548 - smmu->impl_dev = &adev->dev; 4548 + smmu->impl_dev = get_device(acpi_get_first_physical_node(adev)); 4549 4549 smmu->options |= ARM_SMMU_OPT_TEGRA241_CMDQV; 4550 4550 dev_info(smmu->dev, "found companion CMDQV device: %s\n", 4551 4551 dev_name(smmu->impl_dev)); 4552 + acpi_dev_put(adev); 4552 4553 } 4553 4554 kfree(uid); 4554 4555 }
+12 -72
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
··· 3 3 4 4 #define dev_fmt(fmt) "tegra241_cmdqv: " fmt 5 5 6 - #include <linux/acpi.h> 7 6 #include <linux/debugfs.h> 8 7 #include <linux/dma-mapping.h> 9 8 #include <linux/interrupt.h> 10 9 #include <linux/iommu.h> 11 10 #include <linux/iommufd.h> 12 11 #include <linux/iopoll.h> 12 + #include <linux/platform_device.h> 13 13 #include <uapi/linux/iommufd.h> 14 - 15 - #include <acpi/acpixf.h> 16 14 17 15 #include "arm-smmu-v3.h" 18 16 ··· 852 854 853 855 /* Probe Functions */ 854 856 855 - static int tegra241_cmdqv_acpi_is_memory(struct acpi_resource *res, void *data) 856 - { 857 - struct resource_win win; 858 - 859 - return !acpi_dev_resource_address_space(res, &win); 860 - } 861 - 862 - static int tegra241_cmdqv_acpi_get_irqs(struct acpi_resource *ares, void *data) 863 - { 864 - struct resource r; 865 - int *irq = data; 866 - 867 - if (*irq <= 0 && acpi_dev_resource_interrupt(ares, 0, &r)) 868 - *irq = r.start; 869 - return 1; /* No need to add resource to the list */ 870 - } 871 - 872 - static struct resource * 873 - tegra241_cmdqv_find_acpi_resource(struct device *dev, int *irq) 874 - { 875 - struct acpi_device *adev = to_acpi_device(dev); 876 - struct list_head resource_list; 877 - struct resource_entry *rentry; 878 - struct resource *res = NULL; 879 - int ret; 880 - 881 - INIT_LIST_HEAD(&resource_list); 882 - ret = acpi_dev_get_resources(adev, &resource_list, 883 - tegra241_cmdqv_acpi_is_memory, NULL); 884 - if (ret < 0) { 885 - dev_err(dev, "failed to get memory resource: %d\n", ret); 886 - return NULL; 887 - } 888 - 889 - rentry = list_first_entry_or_null(&resource_list, 890 - struct resource_entry, node); 891 - if (!rentry) { 892 - dev_err(dev, "failed to get memory resource entry\n"); 893 - goto free_list; 894 - } 895 - 896 - /* Caller must free the res */ 897 - res = kzalloc(sizeof(*res), GFP_KERNEL); 898 - if (!res) 899 - goto free_list; 900 - 901 - *res = *rentry->res; 902 - 903 - acpi_dev_free_resource_list(&resource_list); 904 - 905 - INIT_LIST_HEAD(&resource_list); 906 - 907 - if (irq) 908 - ret = acpi_dev_get_resources(adev, &resource_list, 909 - tegra241_cmdqv_acpi_get_irqs, irq); 910 - if (ret < 0 || !irq || *irq <= 0) 911 - dev_warn(dev, "no interrupt. errors will not be reported\n"); 912 - 913 - free_list: 914 - acpi_dev_free_resource_list(&resource_list); 915 - return res; 916 - } 917 - 918 857 static int tegra241_cmdqv_init_structures(struct arm_smmu_device *smmu) 919 858 { 920 859 struct tegra241_cmdqv *cmdqv = ··· 977 1042 978 1043 struct arm_smmu_device *tegra241_cmdqv_probe(struct arm_smmu_device *smmu) 979 1044 { 1045 + struct platform_device *pdev = to_platform_device(smmu->impl_dev); 980 1046 struct arm_smmu_device *new_smmu; 981 - struct resource *res = NULL; 1047 + struct resource *res; 982 1048 int irq; 983 1049 984 - if (!smmu->dev->of_node) 985 - res = tegra241_cmdqv_find_acpi_resource(smmu->impl_dev, &irq); 986 - if (!res) 1050 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1051 + if (!res) { 1052 + dev_err(&pdev->dev, "no memory resource found for CMDQV\n"); 987 1053 goto out_fallback; 1054 + } 1055 + 1056 + irq = platform_get_irq_optional(pdev, 0); 1057 + if (irq <= 0) 1058 + dev_warn(&pdev->dev, 1059 + "no interrupt. errors will not be reported\n"); 988 1060 989 1061 new_smmu = __tegra241_cmdqv_probe(smmu, res, irq); 990 - kfree(res); 991 - 992 1062 if (new_smmu) 993 1063 return new_smmu; 994 1064