Re: [PATCH] PCI/MSI: pci-xgene-msi: Enable MSI support in ACPI boot for X-Gene v1

From: Mark Salter
Date: Wed Feb 24 2016 - 11:09:18 EST


On Tue, 2016-02-09 at 17:56 -0800, Duc Dang wrote:
> This patch makes pci-xgene-msi driver ACPI-aware and provides
> MSI capability for X-Gene v1 PCIe controllers in ACPI boot mode.
>
> Signed-off-by: Duc Dang <dhdang@xxxxxxx>
> ---
> Âdrivers/pci/host/pci-xgene-msi.c | 35 ++++++++++++++++++++++++++++++++---
> Â1 file changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/host/pci-xgene-msi.c b/drivers/pci/host/pci-xgene-msi.c
> index a6456b5..466aa93 100644
> --- a/drivers/pci/host/pci-xgene-msi.c
> +++ b/drivers/pci/host/pci-xgene-msi.c
> @@ -24,6 +24,7 @@
> Â#include <linux/pci.h>
> Â#include <linux/platform_device.h>
> Â#include <linux/of_pci.h>
> +#include <linux/acpi.h>
> Â
> Â#define MSI_IR0 0x000000
> Â#define MSI_INT0 0x800000
> @@ -39,7 +40,7 @@ struct xgene_msi_group {
> Â};
> Â
> Âstruct xgene_msi {
> - struct device_node *node;
> + struct fwnode_handle *fwnode;
> Â struct irq_domain *inner_domain;
> Â struct irq_domain *msi_domain;
> Â u64 msi_addr;
> @@ -249,6 +250,13 @@ static const struct irq_domain_ops msi_domain_ops = {
> Â .freeÂÂÂ= xgene_irq_domain_free,
> Â};
> Â
> +#ifdef CONFIG_ACPI
> +static struct fwnode_handle *xgene_msi_get_fwnode(struct device *dev)
> +{
> + return xgene_msi_ctrl.fwnode;
> +}
> +#endif
> +
> Âstatic int xgene_allocate_domains(struct xgene_msi *msi)
> Â{
> Â msi->inner_domain = irq_domain_add_linear(NULL, NR_MSI_VEC,
> @@ -256,7 +264,7 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
> Â if (!msi->inner_domain)
> Â return -ENOMEM;
> Â
> - msi->msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(msi->node),
> + msi->msi_domain = pci_msi_create_irq_domain(msi->fwnode,
> Â ÂÂÂÂ&xgene_msi_domain_info,
> Â ÂÂÂÂmsi->inner_domain);

This doesn't work for me (ACPI probing on Mustang) unless I change this
to beÂpci_msi_create_default_irq_domain(). The problem seems to be that
the MSI probe happens after the PCIe RC is probed so there is no MSI domain
at the time the PCIe root is initialized by ACPI.

> Â
> @@ -265,6 +273,9 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
> Â return -ENOMEM;
> Â }
> Â
> +#ifdef CONFIG_ACPI
> + pci_msi_register_fwnode_provider(&xgene_msi_get_fwnode);
> +#endif
> Â return 0;
> Â}
> Â
> @@ -473,6 +484,13 @@ static const struct of_device_id xgene_msi_match_table[] = {
> Â {},
> Â};
> Â
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id xgene_msi_acpi_ids[] = {
> + {"APMC0D0E", 0},
> + { },
> +};
> +#endif
> +
> Âstatic int xgene_msi_probe(struct platform_device *pdev)
> Â{
> Â struct resource *res;
> @@ -494,7 +512,17 @@ static int xgene_msi_probe(struct platform_device *pdev)
> Â goto error;
> Â }
> Â xgene_msi->msi_addr = res->start;
> - xgene_msi->node = pdev->dev.of_node;
> +
> + xgene_msi->fwnode = of_node_to_fwnode(pdev->dev.of_node);
> + if (!xgene_msi->fwnode) {
> + xgene_msi->fwnode = irq_domain_alloc_fwnode(NULL);
> + if (!xgene_msi->fwnode) {
> + dev_err(&pdev->dev, "Failed to create fwnode\n");
> + rc = ENOMEM;
> + goto error;
> + }
> + }
> +
> Â xgene_msi->num_cpus = num_possible_cpus();
> Â
> Â rc = xgene_msi_init_allocator(xgene_msi);
> @@ -571,6 +599,7 @@ static struct platform_driver xgene_msi_driver = {
> Â .driver = {
> Â .name = "xgene-msi",
> Â .of_match_table = xgene_msi_match_table,
> + .acpi_match_table = ACPI_PTR(xgene_msi_acpi_ids),
> Â },
> Â .probe = xgene_msi_probe,
> Â .remove = xgene_msi_remove,