diff mbox

[v4,09/10] PCI: ACPI: Bind GIC MSI frame to PCI host bridge

Message ID 1438164539-29256-10-git-send-email-hanjun.guo@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Hanjun Guo July 29, 2015, 10:08 a.m. UTC
From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>

This patch introduces pci_host_bridge_acpi_msi_domain(), which queries
a GIC MSI irq-domain token and use it to retrieve an irq_domain with
DOMAIN_BUS_PCI_MSI bus type, and bind it to PCI host-bridge.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 drivers/pci/pci-acpi.c   | 18 ++++++++++++++++++
 drivers/pci/probe.c      |  3 +++
 include/linux/pci-acpi.h |  4 ++++
 3 files changed, 25 insertions(+)

Comments

Marc Zyngier Aug. 4, 2015, 2:04 p.m. UTC | #1
On 29/07/15 11:08, Hanjun Guo wrote:
> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> 
> This patch introduces pci_host_bridge_acpi_msi_domain(), which queries
> a GIC MSI irq-domain token and use it to retrieve an irq_domain with
> DOMAIN_BUS_PCI_MSI bus type, and bind it to PCI host-bridge.
> 
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  drivers/pci/pci-acpi.c   | 18 ++++++++++++++++++
>  drivers/pci/probe.c      |  3 +++
>  include/linux/pci-acpi.h |  4 ++++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index 314a625..5f11653 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -9,6 +9,7 @@
>  
>  #include <linux/delay.h>
>  #include <linux/init.h>
> +#include <linux/irqdomain.h>
>  #include <linux/pci.h>
>  #include <linux/pci_hotplug.h>
>  #include <linux/module.h>
> @@ -16,6 +17,7 @@
>  #include <linux/pci-acpi.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/pm_qos.h>
> +#include <acpi/acpi_gic.h>
>  #include "pci.h"
>  
>  /*
> @@ -681,6 +683,22 @@ static bool pci_acpi_bus_match(struct device *dev)
>  	return dev_is_pci(dev);
>  }
>  
> +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
> +{
> +	struct irq_domain *d = NULL;
> +	void *token = acpi_gic_get_msi_token(&bus->dev);

Do you see why I positively *hate* having hardware details in generic
layers? They propagate everywhere...

> +
> +	if (token)
> +		d = irq_find_matching_host(token, DOMAIN_BUS_PCI_MSI);
> +
> +	if (!d)
> +		pr_debug("Fail to find domain for MSI\n");
> +
> +	return d;
> +}
> +#endif /*CONFIG_GENERIC_MSI_IRQ_DOMAIN*/
> +
>  static struct acpi_bus_type acpi_pci_bus = {
>  	.name = "PCI",
>  	.match = pci_acpi_bus_match,
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index a7afeac..8c1204c 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -12,6 +12,7 @@
>  #include <linux/module.h>
>  #include <linux/cpumask.h>
>  #include <linux/pci-aspm.h>
> +#include <linux/pci-acpi.h>
>  #include <asm-generic/pci-bridge.h>
>  #include "pci.h"
>  
> @@ -670,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
>  	 * should be called from here.
>  	 */
>  	d = pci_host_bridge_of_msi_domain(bus);
> +	if (!d)
> +		d = pci_host_bridge_acpi_msi_domain(bus);
>  
>  	return d;
>  }
> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
> index a965efa..766d045 100644
> --- a/include/linux/pci-acpi.h
> +++ b/include/linux/pci-acpi.h
> @@ -77,6 +77,8 @@ static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
>  static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
>  #endif
>  
> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
> +
>  extern const u8 pci_acpi_dsm_uuid[];
>  #define DEVICE_LABEL_DSM	0x07
>  #define RESET_DELAY_DSM		0x08
> @@ -85,6 +87,8 @@ extern const u8 pci_acpi_dsm_uuid[];
>  #else	/* CONFIG_ACPI */
>  static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
>  static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
> +static inline struct irq_domain *
> +pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
>  #endif	/* CONFIG_ACPI */
>  
>  #ifdef CONFIG_ACPI_APEI
> 

Once you solve the HW abstraction issue, this will be OK.

Thanks,

	M.
Hanjun Guo Aug. 7, 2015, 8:42 a.m. UTC | #2
On 08/04/2015 10:04 PM, Marc Zyngier wrote:
> On 29/07/15 11:08, Hanjun Guo wrote:
>> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>>
>> This patch introduces pci_host_bridge_acpi_msi_domain(), which queries
>> a GIC MSI irq-domain token and use it to retrieve an irq_domain with
>> DOMAIN_BUS_PCI_MSI bus type, and bind it to PCI host-bridge.
>>
>> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>   drivers/pci/pci-acpi.c   | 18 ++++++++++++++++++
>>   drivers/pci/probe.c      |  3 +++
>>   include/linux/pci-acpi.h |  4 ++++
>>   3 files changed, 25 insertions(+)
>>
>> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
>> index 314a625..5f11653 100644
>> --- a/drivers/pci/pci-acpi.c
>> +++ b/drivers/pci/pci-acpi.c
>> @@ -9,6 +9,7 @@
>>
>>   #include <linux/delay.h>
>>   #include <linux/init.h>
>> +#include <linux/irqdomain.h>
>>   #include <linux/pci.h>
>>   #include <linux/pci_hotplug.h>
>>   #include <linux/module.h>
>> @@ -16,6 +17,7 @@
>>   #include <linux/pci-acpi.h>
>>   #include <linux/pm_runtime.h>
>>   #include <linux/pm_qos.h>
>> +#include <acpi/acpi_gic.h>
>>   #include "pci.h"
>>
>>   /*
>> @@ -681,6 +683,22 @@ static bool pci_acpi_bus_match(struct device *dev)
>>   	return dev_is_pci(dev);
>>   }
>>
>> +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
>> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
>> +{
>> +	struct irq_domain *d = NULL;
>> +	void *token = acpi_gic_get_msi_token(&bus->dev);
>
> Do you see why I positively *hate* having hardware details in generic
> layers? They propagate everywhere...
>
>> +
>> +	if (token)
>> +		d = irq_find_matching_host(token, DOMAIN_BUS_PCI_MSI);
>> +
>> +	if (!d)
>> +		pr_debug("Fail to find domain for MSI\n");
>> +
>> +	return d;
>> +}
>> +#endif /*CONFIG_GENERIC_MSI_IRQ_DOMAIN*/
>> +
>>   static struct acpi_bus_type acpi_pci_bus = {
>>   	.name = "PCI",
>>   	.match = pci_acpi_bus_match,
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index a7afeac..8c1204c 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -12,6 +12,7 @@
>>   #include <linux/module.h>
>>   #include <linux/cpumask.h>
>>   #include <linux/pci-aspm.h>
>> +#include <linux/pci-acpi.h>
>>   #include <asm-generic/pci-bridge.h>
>>   #include "pci.h"
>>
>> @@ -670,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
>>   	 * should be called from here.
>>   	 */
>>   	d = pci_host_bridge_of_msi_domain(bus);
>> +	if (!d)
>> +		d = pci_host_bridge_acpi_msi_domain(bus);
>>
>>   	return d;
>>   }
>> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
>> index a965efa..766d045 100644
>> --- a/include/linux/pci-acpi.h
>> +++ b/include/linux/pci-acpi.h
>> @@ -77,6 +77,8 @@ static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
>>   static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
>>   #endif
>>
>> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
>> +
>>   extern const u8 pci_acpi_dsm_uuid[];
>>   #define DEVICE_LABEL_DSM	0x07
>>   #define RESET_DELAY_DSM		0x08
>> @@ -85,6 +87,8 @@ extern const u8 pci_acpi_dsm_uuid[];
>>   #else	/* CONFIG_ACPI */
>>   static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
>>   static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
>> +static inline struct irq_domain *
>> +pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
>>   #endif	/* CONFIG_ACPI */
>>
>>   #ifdef CONFIG_ACPI_APEI
>>
>
> Once you solve the HW abstraction issue, this will be OK.

Sure, I will sync with Suravee to fix that.

Thanks for you comments!
Hanjun
Tomasz Nowicki Aug. 7, 2015, 10:03 a.m. UTC | #3
On 29.07.2015 12:08, Hanjun Guo wrote:
> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>
> This patch introduces pci_host_bridge_acpi_msi_domain(), which queries
> a GIC MSI irq-domain token and use it to retrieve an irq_domain with
> DOMAIN_BUS_PCI_MSI bus type, and bind it to PCI host-bridge.
>
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>   drivers/pci/pci-acpi.c   | 18 ++++++++++++++++++
>   drivers/pci/probe.c      |  3 +++
>   include/linux/pci-acpi.h |  4 ++++
>   3 files changed, 25 insertions(+)
>
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index 314a625..5f11653 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -9,6 +9,7 @@
>
>   #include <linux/delay.h>
>   #include <linux/init.h>
> +#include <linux/irqdomain.h>
>   #include <linux/pci.h>
>   #include <linux/pci_hotplug.h>
>   #include <linux/module.h>
> @@ -16,6 +17,7 @@
>   #include <linux/pci-acpi.h>
>   #include <linux/pm_runtime.h>
>   #include <linux/pm_qos.h>
> +#include <acpi/acpi_gic.h>
>   #include "pci.h"
>
>   /*
> @@ -681,6 +683,22 @@ static bool pci_acpi_bus_match(struct device *dev)
>   	return dev_is_pci(dev);
>   }
>
> +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
> +{
> +	struct irq_domain *d = NULL;
> +	void *token = acpi_gic_get_msi_token(&bus->dev);
> +
> +	if (token)
> +		d = irq_find_matching_host(token, DOMAIN_BUS_PCI_MSI);
> +
> +	if (!d)
> +		pr_debug("Fail to find domain for MSI\n");
> +
> +	return d;
> +}
> +#endif /*CONFIG_GENERIC_MSI_IRQ_DOMAIN*/
> +
>   static struct acpi_bus_type acpi_pci_bus = {
>   	.name = "PCI",
>   	.match = pci_acpi_bus_match,
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index a7afeac..8c1204c 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -12,6 +12,7 @@
>   #include <linux/module.h>
>   #include <linux/cpumask.h>
>   #include <linux/pci-aspm.h>
> +#include <linux/pci-acpi.h>
>   #include <asm-generic/pci-bridge.h>
>   #include "pci.h"
>
> @@ -670,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
>   	 * should be called from here.
>   	 */
>   	d = pci_host_bridge_of_msi_domain(bus);
> +	if (!d)
> +		d = pci_host_bridge_acpi_msi_domain(bus);

Please use acpi_disabled here.

BTW. This is another place where we need to know our firmware - DT vs 
ACPI. I know we can use acpi_disabled but I think more about generic 
solution. Since we already have:
struct fwnode_handle	*fwnode;
we can create macro which identify h/w description style, something like:

#define FWNODE_TYPE(dev)	dev_fwnode(dev)->type

and then:

switch (FWNODE_TYPE(&bus->dev)) {
case FWNODE_OF:
...
case FWNODE_ACPI:
...
case FWNODE_XXX:
...
}

Root bus is special case since it has no frimware type but we could 
factor out pci_set_bus_of_node(). For platform devices we have all we 
need. Just thinking aloud, let me know your thoughts.

Regards,
Tomasz





>
>   	return d;
>   }
> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
> index a965efa..766d045 100644
> --- a/include/linux/pci-acpi.h
> +++ b/include/linux/pci-acpi.h
> @@ -77,6 +77,8 @@ static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
>   static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
>   #endif
>
> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
> +
>   extern const u8 pci_acpi_dsm_uuid[];
>   #define DEVICE_LABEL_DSM	0x07
>   #define RESET_DELAY_DSM		0x08
> @@ -85,6 +87,8 @@ extern const u8 pci_acpi_dsm_uuid[];
>   #else	/* CONFIG_ACPI */
>   static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
>   static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
> +static inline struct irq_domain *
> +pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
>   #endif	/* CONFIG_ACPI */
>
>   #ifdef CONFIG_ACPI_APEI
>
Mark Brown Aug. 7, 2015, 10:48 a.m. UTC | #4
On Fri, Aug 07, 2015 at 12:03:24PM +0200, Tomasz Nowicki wrote:

> >@@ -670,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
> >  	 * should be called from here.
> >  	 */
> >  	d = pci_host_bridge_of_msi_domain(bus);
> >+	if (!d)
> >+		d = pci_host_bridge_acpi_msi_domain(bus);
> 
> Please use acpi_disabled here.

> BTW. This is another place where we need to know our firmware - DT vs ACPI.
> I know we can use acpi_disabled but I think more about generic solution.
> Since we already have:
> struct fwnode_handle	*fwnode;
> we can create macro which identify h/w description style, something like:

> #define FWNODE_TYPE(dev)	dev_fwnode(dev)->type

> and then:

> switch (FWNODE_TYPE(&bus->dev)) {
> case FWNODE_OF:
> ...
> case FWNODE_ACPI:
> ...
> case FWNODE_XXX:
> ...
> }

> Root bus is special case since it has no frimware type but we could factor
> out pci_set_bus_of_node(). For platform devices we have all we need. Just
> thinking aloud, let me know your thoughts.

Not knowing the particular detail here but can we not go a step further
than that and have a fwnode_disabled() for this which does appropriate
things for both ACPI and DT?
Marc Zyngier Aug. 7, 2015, 12:06 p.m. UTC | #5
On 07/08/15 11:03, Tomasz Nowicki wrote:
> On 29.07.2015 12:08, Hanjun Guo wrote:
>> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>>
>> This patch introduces pci_host_bridge_acpi_msi_domain(), which queries
>> a GIC MSI irq-domain token and use it to retrieve an irq_domain with
>> DOMAIN_BUS_PCI_MSI bus type, and bind it to PCI host-bridge.
>>
>> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>   drivers/pci/pci-acpi.c   | 18 ++++++++++++++++++
>>   drivers/pci/probe.c      |  3 +++
>>   include/linux/pci-acpi.h |  4 ++++
>>   3 files changed, 25 insertions(+)
>>
>> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
>> index 314a625..5f11653 100644
>> --- a/drivers/pci/pci-acpi.c
>> +++ b/drivers/pci/pci-acpi.c
>> @@ -9,6 +9,7 @@
>>
>>   #include <linux/delay.h>
>>   #include <linux/init.h>
>> +#include <linux/irqdomain.h>
>>   #include <linux/pci.h>
>>   #include <linux/pci_hotplug.h>
>>   #include <linux/module.h>
>> @@ -16,6 +17,7 @@
>>   #include <linux/pci-acpi.h>
>>   #include <linux/pm_runtime.h>
>>   #include <linux/pm_qos.h>
>> +#include <acpi/acpi_gic.h>
>>   #include "pci.h"
>>
>>   /*
>> @@ -681,6 +683,22 @@ static bool pci_acpi_bus_match(struct device *dev)
>>   	return dev_is_pci(dev);
>>   }
>>
>> +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
>> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
>> +{
>> +	struct irq_domain *d = NULL;
>> +	void *token = acpi_gic_get_msi_token(&bus->dev);
>> +
>> +	if (token)
>> +		d = irq_find_matching_host(token, DOMAIN_BUS_PCI_MSI);
>> +
>> +	if (!d)
>> +		pr_debug("Fail to find domain for MSI\n");
>> +
>> +	return d;
>> +}
>> +#endif /*CONFIG_GENERIC_MSI_IRQ_DOMAIN*/
>> +
>>   static struct acpi_bus_type acpi_pci_bus = {
>>   	.name = "PCI",
>>   	.match = pci_acpi_bus_match,
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index a7afeac..8c1204c 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -12,6 +12,7 @@
>>   #include <linux/module.h>
>>   #include <linux/cpumask.h>
>>   #include <linux/pci-aspm.h>
>> +#include <linux/pci-acpi.h>
>>   #include <asm-generic/pci-bridge.h>
>>   #include "pci.h"
>>
>> @@ -670,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
>>   	 * should be called from here.
>>   	 */
>>   	d = pci_host_bridge_of_msi_domain(bus);
>> +	if (!d)
>> +		d = pci_host_bridge_acpi_msi_domain(bus);
> 
> Please use acpi_disabled here.

No, thanks. pci_host_bridge_acpi_msi_domain() can return NULL if ACPI is
disabled, just like pci_host_bridge_of_msi_domain will return NULL if
there is no domain to be found (or no OF support).

Littering various firmware predicates all over the place hardly seem
like a scalable solution, and I'd expect the ACPI backends to be self
contained.

> BTW. This is another place where we need to know our firmware - DT vs 
> ACPI. I know we can use acpi_disabled but I think more about generic 
> solution. Since we already have:
> struct fwnode_handle	*fwnode;
> we can create macro which identify h/w description style, something like:
> 
> #define FWNODE_TYPE(dev)	dev_fwnode(dev)->type
> 
> and then:
> 
> switch (FWNODE_TYPE(&bus->dev)) {
> case FWNODE_OF:
> ...
> case FWNODE_ACPI:
> ...
> case FWNODE_XXX:
> ...
> }
> 
> Root bus is special case since it has no frimware type but we could 
> factor out pci_set_bus_of_node(). For platform devices we have all we 
> need. Just thinking aloud, let me know your thoughts.

For that to work, we'd need to start converging device_node and
fwnode_handle. Having both feels quite redundant at the moment.

Thanks,

	M.
Suravee Suthikulpanit Aug. 9, 2015, 8:02 a.m. UTC | #6
Hi Marc,

On 8/4/15 21:04, Marc Zyngier wrote:
> On 29/07/15 11:08, Hanjun Guo wrote:
>> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>>
>> This patch introduces pci_host_bridge_acpi_msi_domain(), which queries
>> a GIC MSI irq-domain token and use it to retrieve an irq_domain with
>> DOMAIN_BUS_PCI_MSI bus type, and bind it to PCI host-bridge.
>>
>> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>   drivers/pci/pci-acpi.c   | 18 ++++++++++++++++++
>>   drivers/pci/probe.c      |  3 +++
>>   include/linux/pci-acpi.h |  4 ++++
>>   3 files changed, 25 insertions(+)
>>
>> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
>> index 314a625..5f11653 100644
>> --- a/drivers/pci/pci-acpi.c
>> +++ b/drivers/pci/pci-acpi.c
>> @@ -9,6 +9,7 @@
>>
>>   #include <linux/delay.h>
>>   #include <linux/init.h>
>> +#include <linux/irqdomain.h>
>>   #include <linux/pci.h>
>>   #include <linux/pci_hotplug.h>
>>   #include <linux/module.h>
>> @@ -16,6 +17,7 @@
>>   #include <linux/pci-acpi.h>
>>   #include <linux/pm_runtime.h>
>>   #include <linux/pm_qos.h>
>> +#include <acpi/acpi_gic.h>
>>   #include "pci.h"
>>
>>   /*
>> @@ -681,6 +683,22 @@ static bool pci_acpi_bus_match(struct device *dev)
>>   	return dev_is_pci(dev);
>>   }
>>
>> +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
>> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
>> +{
>> +	struct irq_domain *d = NULL;
>> +	void *token = acpi_gic_get_msi_token(&bus->dev);
>
> Do you see why I positively *hate* having hardware details in generic
> layers? They propagate everywhere...
>
>> +
>> +	if (token)
>> +		d = irq_find_matching_host(token, DOMAIN_BUS_PCI_MSI);
>> +
>> +	if (!d)
>> +		pr_debug("Fail to find domain for MSI\n");
>> +
>> +	return d;
>> +}
>> +#endif /*CONFIG_GENERIC_MSI_IRQ_DOMAIN*/
>> +
>>   static struct acpi_bus_type acpi_pci_bus = {
>>   	.name = "PCI",
>>   	.match = pci_acpi_bus_match,
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index a7afeac..8c1204c 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -12,6 +12,7 @@
>>   #include <linux/module.h>
>>   #include <linux/cpumask.h>
>>   #include <linux/pci-aspm.h>
>> +#include <linux/pci-acpi.h>
>>   #include <asm-generic/pci-bridge.h>
>>   #include "pci.h"
>>
>> @@ -670,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
>>   	 * should be called from here.
>>   	 */
>>   	d = pci_host_bridge_of_msi_domain(bus);
>> +	if (!d)
>> +		d = pci_host_bridge_acpi_msi_domain(bus);
>>
>>   	return d;
>>   }
>> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
>> index a965efa..766d045 100644
>> --- a/include/linux/pci-acpi.h
>> +++ b/include/linux/pci-acpi.h
>> @@ -77,6 +77,8 @@ static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
>>   static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
>>   #endif
>>
>> +struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
>> +
>>   extern const u8 pci_acpi_dsm_uuid[];
>>   #define DEVICE_LABEL_DSM	0x07
>>   #define RESET_DELAY_DSM		0x08
>> @@ -85,6 +87,8 @@ extern const u8 pci_acpi_dsm_uuid[];
>>   #else	/* CONFIG_ACPI */
>>   static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
>>   static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
>> +static inline struct irq_domain *
>> +pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
>>   #endif	/* CONFIG_ACPI */
>>
>>   #ifdef CONFIG_ACPI_APEI
>>
>
> Once you solve the HW abstraction issue, this will be OK.
>
> Thanks,
>
> 	M.
>

Ok. Thanks,

Suravee
diff mbox

Patch

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 314a625..5f11653 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -9,6 +9,7 @@ 
 
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/irqdomain.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
 #include <linux/module.h>
@@ -16,6 +17,7 @@ 
 #include <linux/pci-acpi.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_qos.h>
+#include <acpi/acpi_gic.h>
 #include "pci.h"
 
 /*
@@ -681,6 +683,22 @@  static bool pci_acpi_bus_match(struct device *dev)
 	return dev_is_pci(dev);
 }
 
+#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
+{
+	struct irq_domain *d = NULL;
+	void *token = acpi_gic_get_msi_token(&bus->dev);
+
+	if (token)
+		d = irq_find_matching_host(token, DOMAIN_BUS_PCI_MSI);
+
+	if (!d)
+		pr_debug("Fail to find domain for MSI\n");
+
+	return d;
+}
+#endif /*CONFIG_GENERIC_MSI_IRQ_DOMAIN*/
+
 static struct acpi_bus_type acpi_pci_bus = {
 	.name = "PCI",
 	.match = pci_acpi_bus_match,
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index a7afeac..8c1204c 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -12,6 +12,7 @@ 
 #include <linux/module.h>
 #include <linux/cpumask.h>
 #include <linux/pci-aspm.h>
+#include <linux/pci-acpi.h>
 #include <asm-generic/pci-bridge.h>
 #include "pci.h"
 
@@ -670,6 +671,8 @@  static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
 	 * should be called from here.
 	 */
 	d = pci_host_bridge_of_msi_domain(bus);
+	if (!d)
+		d = pci_host_bridge_acpi_msi_domain(bus);
 
 	return d;
 }
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index a965efa..766d045 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -77,6 +77,8 @@  static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
 static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
 #endif
 
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
+
 extern const u8 pci_acpi_dsm_uuid[];
 #define DEVICE_LABEL_DSM	0x07
 #define RESET_DELAY_DSM		0x08
@@ -85,6 +87,8 @@  extern const u8 pci_acpi_dsm_uuid[];
 #else	/* CONFIG_ACPI */
 static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
 static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
+static inline struct irq_domain *
+pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
 #endif	/* CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI_APEI