Message ID | 1507878590-51066-4-git-send-email-guohanjun@huawei.com |
---|---|
State | New |
Headers | show |
Series | IORT SMMUv3 MSI support | expand |
On Friday, October 13, 2017 3:04:45 PM CEST Lorenzo Pieralisi wrote: > [+Robert, Will] > > Rafael, Robert, > > On Fri, Oct 13, 2017 at 03:09:49PM +0800, Hanjun Guo wrote: > > [...] > > > +#if (ACPI_CA_VERSION > 0x20170929) > > Any objection to handling 4.15 trees dependency by using ACPICA > version as a temporary guard (that I will promptly remove at -rc1) ? Well, fine by me, as long as you take care of dropping this going forward. Thanks, Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[+Robert, Will] Rafael, Robert, On Fri, Oct 13, 2017 at 03:09:49PM +0800, Hanjun Guo wrote: [...] > +#if (ACPI_CA_VERSION > 0x20170929) Any objection to handling 4.15 trees dependency by using ACPICA version as a temporary guard (that I will promptly remove at -rc1) ? This series will go via arm64 tree and I see no other obvious way of handling the dependency with ACPICA, unless I can send an ACPI IORT pull request to Rafael and ACPICA changes go via Rafael's tree too. Please let me know, I would like to send the pull request to arm64 shortly. Thanks, Lorenzo > +static int iort_get_id_mapping_index(struct acpi_iort_node *node) > +{ > + struct acpi_iort_smmu_v3 *smmu; > + > + switch (node->type) { > + case ACPI_IORT_NODE_SMMU_V3: > + /* > + * SMMUv3 dev ID mapping index was introdueced in revision 1 > + * table, not available in revision 0 > + */ > + if (node->revision < 1) > + return -EINVAL; > + > + smmu = (struct acpi_iort_smmu_v3 *)node->node_data; > + /* > + * ID mapping index is only ignored if all interrupts are > + * GSIV based > + */ > + if (smmu->event_gsiv && smmu->pri_gsiv && smmu->gerr_gsiv > + && smmu->sync_gsiv) > + return -EINVAL; > + > + if (smmu->id_mapping_index >= node->mapping_count) { > + pr_err(FW_BUG "[node %p type %d] ID mapping index overflows valid mappings\n", > + node, node->type); > + return -EINVAL; > + } > + > + return smmu->id_mapping_index; > + default: > + return -EINVAL; > + } > +} > +#else > static inline int iort_get_id_mapping_index(struct acpi_iort_node *node) > { > return -EINVAL; > } > +#endif > > static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, > u32 id_in, u32 *id_out, > -- > 1.7.12.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index c3f3ac3..ca5dd21 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -356,7 +356,8 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || - node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { + node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || + node->type == ACPI_IORT_NODE_SMMU_V3) { *id_out = map->output_base; return parent; } @@ -365,10 +366,46 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, return NULL; } +#if (ACPI_CA_VERSION > 0x20170929) +static int iort_get_id_mapping_index(struct acpi_iort_node *node) +{ + struct acpi_iort_smmu_v3 *smmu; + + switch (node->type) { + case ACPI_IORT_NODE_SMMU_V3: + /* + * SMMUv3 dev ID mapping index was introdueced in revision 1 + * table, not available in revision 0 + */ + if (node->revision < 1) + return -EINVAL; + + smmu = (struct acpi_iort_smmu_v3 *)node->node_data; + /* + * ID mapping index is only ignored if all interrupts are + * GSIV based + */ + if (smmu->event_gsiv && smmu->pri_gsiv && smmu->gerr_gsiv + && smmu->sync_gsiv) + return -EINVAL; + + if (smmu->id_mapping_index >= node->mapping_count) { + pr_err(FW_BUG "[node %p type %d] ID mapping index overflows valid mappings\n", + node, node->type); + return -EINVAL; + } + + return smmu->id_mapping_index; + default: + return -EINVAL; + } +} +#else static inline int iort_get_id_mapping_index(struct acpi_iort_node *node) { return -EINVAL; } +#endif static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, u32 id_in, u32 *id_out,