From 587bab2818ab5f8775fa32ada882977a7da5453b Mon Sep 17 00:00:00 2001 From: Zhou Guanghui Date: Tue, 21 May 2019 21:47:10 +0800 Subject: [PATCH] iort: Clean up compiling errors/warnings for sva hulk inclusion category: bugfix bugzilla: 16081 CVE: NA ------------------- 1. use CONFIG_IOMMU_SVA macro to isolate iommu-sva related code in iort. 2. move struct page_response_msg,enum page_response_code and iopf_queue_flush_t out of macro CONFIG_IOMMU_API, since these are always used by iommu api. Fixes: 676917d8930e ("iommu/sva: Track mm changes with an MMU notifier") Fixes: 615753b31ae4 ("ACPI/IORT: Check ATS capability in root complex nodes") Fixes: e741c308b09f ("iort: Read ACPI configure to get streamid.") Signed-off-by: Zhou Guanghui Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/acpi/arm64/iort.c | 9 +++++++- include/linux/iommu.h | 46 +++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 5cf4bfa0f4b4..a789147d4a04 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -1030,6 +1030,7 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size) dev_dbg(dev, "dma_pfn_offset(%#08llx)\n", offset); } +#ifdef CONFIG_IOMMU_SVA static bool iort_pci_rc_supports_ats(struct acpi_iort_node *node) { struct acpi_iort_root_complex *pci_rc; @@ -1037,6 +1038,7 @@ static bool iort_pci_rc_supports_ats(struct acpi_iort_node *node) pci_rc = (struct acpi_iort_root_complex *)node->node_data; return pci_rc->ats_attribute & ACPI_IORT_ATS_SUPPORTED; } +#endif /** * iort_iommu_configure - Set-up IOMMU configuration for a device. @@ -1073,9 +1075,10 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) info.node = node; err = pci_for_each_dma_alias(to_pci_dev(dev), iort_pci_iommu_init, &info); - +#ifdef CONFIG_IOMMU_SVA if (!err && !iort_pci_rc_supports_ats(node)) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_NO_ATS; +#endif } else { int i = 0; @@ -1085,7 +1088,9 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) return NULL; do { +#ifdef CONFIG_IOMMU_SVA u32 sid; +#endif parent = iort_node_map_platform_id(node, &streamid, IORT_IOMMU_TYPE, i++); @@ -1093,6 +1098,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) if (parent) err = iort_iommu_xlate(dev, parent, streamid); +#ifdef CONFIG_IOMMU_SVA if (!acpi_dev_prop_read_single(ACPI_COMPANION(dev), "streamid", DEV_PROP_U32, &sid)) { err = iommu_fwspec_add_ids(dev, &sid, 1); @@ -1101,6 +1107,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) dev->iommu_fwspec->can_stall = true; dev->iommu_fwspec->num_pasid_bits = 0x10; } +#endif } while (parent && !err); } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 1ca5bd542d82..7edde72f1f09 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -184,8 +184,6 @@ struct iommu_resv_region { enum iommu_resv_type type; }; -#ifdef CONFIG_IOMMU_API - /** * enum page_response_code - Return status of fault handlers, telling the IOMMU * driver how to proceed with the fault. @@ -203,19 +201,6 @@ enum page_response_code { IOMMU_PAGE_RESP_FAILURE, }; -/** - * enum page_request_handle_t - Return page request/response handler status - * - * @IOMMU_FAULT_STATUS_HANDLED: Stop processing the fault, and do not send a - * reply to the device. - * @IOMMU_FAULT_STATUS_CONTINUE: Fault was not handled. Call the next handler, - * or terminate. - */ -enum page_request_handle_t { - IOMMU_PAGE_RESP_HANDLED = 0, - IOMMU_PAGE_RESP_CONTINUE, -}; - /** * Generic page response information based on PCI ATS and PASID spec. * @addr: servicing page address @@ -235,6 +220,29 @@ struct page_response_msg { u64 private_data; }; +/** + * iopf_queue_flush_t - Flush low-level page fault queue + * + * Report all faults currently pending in the low-level page fault queue + */ +struct iopf_queue; +typedef int (*iopf_queue_flush_t)(void *cookie, struct device *dev); + +#ifdef CONFIG_IOMMU_API + +/** + * enum page_request_handle_t - Return page request/response handler status + * + * @IOMMU_FAULT_STATUS_HANDLED: Stop processing the fault, and do not send a + * reply to the device. + * @IOMMU_FAULT_STATUS_CONTINUE: Fault was not handled. Call the next handler, + * or terminate. + */ +enum page_request_handle_t { + IOMMU_PAGE_RESP_HANDLED = 0, + IOMMU_PAGE_RESP_CONTINUE, +}; + struct iommu_sva_param { unsigned long features; unsigned int min_pasid; @@ -459,14 +467,6 @@ struct iommu_fault_param { void *data; }; -/** - * iopf_queue_flush_t - Flush low-level page fault queue - * - * Report all faults currently pending in the low-level page fault queue - */ -struct iopf_queue; -typedef int (*iopf_queue_flush_t)(void *cookie, struct device *dev); - /** * struct iommu_param - collection of per-device IOMMU data * -- GitLab