Skip to content

Commit eb20758

Browse files
nicolincwilldeacon
authored andcommitted
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>
1 parent 14e9a13 commit eb20758

3 files changed

Lines changed: 14 additions & 74 deletions

File tree

drivers/iommu/arm/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ config ARM_SMMU_V3_KUNIT_TEST
121121

122122
config TEGRA241_CMDQV
123123
bool "NVIDIA Tegra241 CMDQ-V extension support for ARM SMMUv3"
124-
depends on ACPI
125124
help
126125
Support for NVIDIA CMDQ-Virtualization extension for ARM SMMUv3. The
127126
CMDQ-V extension is similar to v3.3 ECMDQ for multi command queues

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4545,10 +4545,11 @@ static void acpi_smmu_dsdt_probe_tegra241_cmdqv(struct acpi_iort_node *node,
45454545
adev = acpi_dev_get_first_match_dev("NVDA200C", uid, -1);
45464546
if (adev) {
45474547
/* 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));
45494549
smmu->options |= ARM_SMMU_OPT_TEGRA241_CMDQV;
45504550
dev_info(smmu->dev, "found companion CMDQV device: %s\n",
45514551
dev_name(smmu->impl_dev));
4552+
acpi_dev_put(adev);
45524553
}
45534554
kfree(uid);
45544555
}

drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c

Lines changed: 12 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33

44
#define dev_fmt(fmt) "tegra241_cmdqv: " fmt
55

6-
#include <linux/acpi.h>
76
#include <linux/debugfs.h>
87
#include <linux/dma-mapping.h>
98
#include <linux/interrupt.h>
109
#include <linux/iommu.h>
1110
#include <linux/iommufd.h>
1211
#include <linux/iopoll.h>
12+
#include <linux/platform_device.h>
1313
#include <uapi/linux/iommufd.h>
1414

15-
#include <acpi/acpixf.h>
16-
1715
#include "arm-smmu-v3.h"
1816

1917
/* CMDQV register page base and size defines */
@@ -854,69 +852,6 @@ static struct arm_smmu_impl_ops tegra241_cmdqv_impl_ops = {
854852

855853
/* Probe Functions */
856854

857-
static int tegra241_cmdqv_acpi_is_memory(struct acpi_resource *res, void *data)
858-
{
859-
struct resource_win win;
860-
861-
return !acpi_dev_resource_address_space(res, &win);
862-
}
863-
864-
static int tegra241_cmdqv_acpi_get_irqs(struct acpi_resource *ares, void *data)
865-
{
866-
struct resource r;
867-
int *irq = data;
868-
869-
if (*irq <= 0 && acpi_dev_resource_interrupt(ares, 0, &r))
870-
*irq = r.start;
871-
return 1; /* No need to add resource to the list */
872-
}
873-
874-
static struct resource *
875-
tegra241_cmdqv_find_acpi_resource(struct device *dev, int *irq)
876-
{
877-
struct acpi_device *adev = to_acpi_device(dev);
878-
struct list_head resource_list;
879-
struct resource_entry *rentry;
880-
struct resource *res = NULL;
881-
int ret;
882-
883-
INIT_LIST_HEAD(&resource_list);
884-
ret = acpi_dev_get_resources(adev, &resource_list,
885-
tegra241_cmdqv_acpi_is_memory, NULL);
886-
if (ret < 0) {
887-
dev_err(dev, "failed to get memory resource: %d\n", ret);
888-
return NULL;
889-
}
890-
891-
rentry = list_first_entry_or_null(&resource_list,
892-
struct resource_entry, node);
893-
if (!rentry) {
894-
dev_err(dev, "failed to get memory resource entry\n");
895-
goto free_list;
896-
}
897-
898-
/* Caller must free the res */
899-
res = kzalloc(sizeof(*res), GFP_KERNEL);
900-
if (!res)
901-
goto free_list;
902-
903-
*res = *rentry->res;
904-
905-
acpi_dev_free_resource_list(&resource_list);
906-
907-
INIT_LIST_HEAD(&resource_list);
908-
909-
if (irq)
910-
ret = acpi_dev_get_resources(adev, &resource_list,
911-
tegra241_cmdqv_acpi_get_irqs, irq);
912-
if (ret < 0 || !irq || *irq <= 0)
913-
dev_warn(dev, "no interrupt. errors will not be reported\n");
914-
915-
free_list:
916-
acpi_dev_free_resource_list(&resource_list);
917-
return res;
918-
}
919-
920855
static int tegra241_cmdqv_init_structures(struct arm_smmu_device *smmu)
921856
{
922857
struct tegra241_cmdqv *cmdqv =
@@ -1042,18 +977,23 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res,
1042977

1043978
struct arm_smmu_device *tegra241_cmdqv_probe(struct arm_smmu_device *smmu)
1044979
{
980+
struct platform_device *pdev = to_platform_device(smmu->impl_dev);
1045981
struct arm_smmu_device *new_smmu;
1046-
struct resource *res = NULL;
982+
struct resource *res;
1047983
int irq;
1048984

1049-
if (!smmu->dev->of_node)
1050-
res = tegra241_cmdqv_find_acpi_resource(smmu->impl_dev, &irq);
1051-
if (!res)
985+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
986+
if (!res) {
987+
dev_err(&pdev->dev, "no memory resource found for CMDQV\n");
1052988
goto out_fallback;
989+
}
1053990

1054-
new_smmu = __tegra241_cmdqv_probe(smmu, res, irq);
1055-
kfree(res);
991+
irq = platform_get_irq_optional(pdev, 0);
992+
if (irq <= 0)
993+
dev_warn(&pdev->dev,
994+
"no interrupt. errors will not be reported\n");
1056995

996+
new_smmu = __tegra241_cmdqv_probe(smmu, res, irq);
1057997
if (new_smmu)
1058998
return new_smmu;
1059999

0 commit comments

Comments
 (0)