Skip to contentSkip to conversation

PCI ACS is broken for ARM SMMU v3?

Question Zhou Wang 2 participants 5 messages Aug 31, 2017 – Sep 6, 2017

Subsystems (3)
lore
Share & tools
lore

Zhou Wang

author
#0 lore raw

Hi Will and Alex,

pci_request_acs is called in drivers/iommu/arm-smmu-v3.c to set pci_acs_enable.

PCI subsystem tries to enable ACS as below:

	pci_device_add
		--> pci_init_capabilities
			--> pci_enable_acs

in ACPI PCI driver. However, ACPI PCI driver will be called before SMMU v3 driver, which will lead pci_enable_acs to return directly as pci_acs_enable is not set before SMMU v3 driver loading.

I think this is a bug, what do you think about this problem?

Best,
Zhou

author
#1 lore raw

+to: Lorenzo

Quoted 25 lines · Zhou Wang

Hi Will and Alex,

pci_request_acs is called in drivers/iommu/arm-smmu-v3.c to set pci_acs_enable.

PCI subsystem tries to enable ACS as below:

	pci_device_add
		--> pci_init_capabilities
			--> pci_enable_acs

in ACPI PCI driver. However, ACPI PCI driver will be called before SMMU v3 driver, which will lead pci_enable_acs to return directly as pci_acs_enable is not set before SMMU v3 driver loading.

I think this is a bug, what do you think about this problem?

Best,
Zhou

.

#2 lore raw
Quoted 18 lines · Zhou Wang

+to: Lorenzo

Quoted 15 lines · Zhou Wang

Hi Will and Alex,

pci_request_acs is called in drivers/iommu/arm-smmu-v3.c to set pci_acs_enable.

PCI subsystem tries to enable ACS as below:

	pci_device_add
		--> pci_init_capabilities
			--> pci_enable_acs

in ACPI PCI driver. However, ACPI PCI driver will be called before SMMU v3 driver, which will lead pci_enable_acs to return directly as pci_acs_enable is not set before SMMU v3 driver loading.

I think this is a bug, what do you think about this problem?

I think that it is a bug that affects OF/ACPI alike. One way of solving it is requesting ACS at IORT init following appropriate checks (ie mappings PCI->IOMMU - that would not solve the OF path though). I can put together a quick fix, the overall problem needs some thinking though.

Lorenzo

author
#3 lore raw
Quoted 14 lines · Lorenzo Pieralisi
Quoted 13 lines · Zhou Wang

+to: Lorenzo

Quoted 10 lines · Zhou Wang

Hi Will and Alex,

pci_request_acs is called in drivers/iommu/arm-smmu-v3.c to set pci_acs_enable.

PCI subsystem tries to enable ACS as below:

	pci_device_add
		--> pci_init_capabilities
			--> pci_enable_acs
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

in ACPI PCI driver. However, ACPI PCI driver will be called before SMMU v3 driver, which will lead pci_enable_acs to return directly as pci_acs_enable is not set before SMMU v3 driver loading.

I think this is a bug, what do you think about this problem?

I think that it is a bug that affects OF/ACPI alike. One way of solving

Yes, DT also has this problem.

Quoted 4 lines

it is requesting ACS at IORT init following appropriate checks (ie mappings PCI->IOMMU - that would not solve the OF path though). I can put together a quick fix, the overall problem needs some thinking though.

I am not familiar with IORT init, but can we do it like:

drivers/acpi/arm64/iort.c +0 -0
index a3215ee..a6f1a21 100644
@@ -1131,6 +1131,7 @@ static void __init iort_init_platform_devices(void)
				acpi_free_fwnode_static(fwnode);
				return;
			}
+ 			pci_request_acs();
		}

		iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort_node,

Best,
Zhou

Quoted 5 lines

Lorenzo

.

#4 lore raw
Quoted 38 lines · Zhou Wang
Quoted 14 lines · Lorenzo Pieralisi
Quoted 13 lines · Zhou Wang

+to: Lorenzo

Quoted 10 lines · Zhou Wang

Hi Will and Alex,

pci_request_acs is called in drivers/iommu/arm-smmu-v3.c to set pci_acs_enable.

PCI subsystem tries to enable ACS as below:

	pci_device_add
		--> pci_init_capabilities
			--> pci_enable_acs
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

in ACPI PCI driver. However, ACPI PCI driver will be called before SMMU v3 driver, which will lead pci_enable_acs to return directly as pci_acs_enable is not set before SMMU v3 driver loading.

I think this is a bug, what do you think about this problem?

I think that it is a bug that affects OF/ACPI alike. One way of solving

Yes, DT also has this problem.

Quoted 4 lines

it is requesting ACS at IORT init following appropriate checks (ie mappings PCI->IOMMU - that would not solve the OF path though). I can put together a quick fix, the overall problem needs some thinking though.

I am not familiar with IORT init, but can we do it like:

drivers/acpi/arm64/iort.c +0 -0
index a3215ee..a6f1a21 100644

drivers/acpi/arm64/iort.c static void __init iort_init_platform_devices(void) · line 1137

Quoted 7 lines
drivers/acpi/arm64/iort.c +1 -0
@@ -1131,6 +1131,7 @@ static void __init iort_init_platform_devices(void)
 				acpi_free_fwnode_static(fwnode);
 				return;
 			}
+ 			pci_request_acs();
 		}
 
 		iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort_node,

Yep, will send something similar shortly.

Thanks,
Lorenzo