From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hanjun Guo Subject: [RFC PATCH v2 04/11] irqchip: gicv3-its: platform-msi: scan MADT to create platform msi domain Date: Wed, 14 Sep 2016 22:21:12 +0800 Message-ID: <1473862879-7769-5-git-send-email-guohanjun@huawei.com> References: <1473862879-7769-1-git-send-email-guohanjun@huawei.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1473862879-7769-1-git-send-email-guohanjun@huawei.com> Sender: linux-kernel-owner@vger.kernel.org To: "Rafael J. Wysocki" , Marc Zyngier , Lorenzo Pieralisi Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Bjorn Helgaas , Greg KH , Tomasz Nowicki , Ma Jun , Kefeng Wang , Charles Garcia-Tobin , linuxarm@huawei.com, Hanjun Guo List-Id: linux-acpi@vger.kernel.org From: Hanjun Guo With the introduction of its_pmsi_init_one(), we can add some code on top for ACPI support of platform MSI. We are scanning the MADT table to get the ITS entry(ies), then use the information to create the platform msi domain for devices connect to it, just like the PCI MSI for ITS did. Cc: Marc Zyngier Cc: Tomasz Nowicki Cc: Thomas Gleixner Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-gic-v3-its-platform-msi.c | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index a80ecd7..e9dade9 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -105,6 +106,41 @@ static int __init its_pmsi_init_one(struct fwnode_handle *fwnode, return 0; } +#ifdef CONFIG_ACPI +static int __init +its_pmsi_parse_madt(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct acpi_madt_generic_translator *its_entry; + struct fwnode_handle *domain_handle; + const char *node_name; + int err = -ENXIO; + + its_entry = (struct acpi_madt_generic_translator *)header; + node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx", + (long)its_entry->base_address); + domain_handle = iort_find_domain_token(its_entry->translation_id); + if (!domain_handle) { + pr_err("%s: Unable to locate ITS domain handle\n", node_name); + goto out; + } + + err = its_pmsi_init_one(domain_handle, node_name); + +out: + kfree(node_name); + return err; +} + +static void __init its_acpi_pmsi_init(void) +{ + acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, + its_pmsi_parse_madt, 0); +} +#else +static inline void its_acpi_pmsi_init(void) { } +#endif + static void __init its_pmsi_of_init(void) { struct device_node *np; @@ -121,6 +157,7 @@ static void __init its_pmsi_of_init(void) static int __init its_pmsi_init(void) { its_pmsi_of_init(); + its_acpi_pmsi_init(); return 0; } early_initcall(its_pmsi_init); -- 1.7.12.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933326AbcINOYR (ORCPT ); Wed, 14 Sep 2016 10:24:17 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:32462 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933144AbcINOYF (ORCPT ); Wed, 14 Sep 2016 10:24:05 -0400 From: Hanjun Guo To: "Rafael J. Wysocki" , Marc Zyngier , Lorenzo Pieralisi CC: , , , Thomas Gleixner , "Bjorn Helgaas" , Greg KH , "Tomasz Nowicki" , Ma Jun , Kefeng Wang , Charles Garcia-Tobin , , Hanjun Guo Subject: [RFC PATCH v2 04/11] irqchip: gicv3-its: platform-msi: scan MADT to create platform msi domain Date: Wed, 14 Sep 2016 22:21:12 +0800 Message-ID: <1473862879-7769-5-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1473862879-7769-1-git-send-email-guohanjun@huawei.com> References: <1473862879-7769-1-git-send-email-guohanjun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.57D95D5D.0294,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e4865d6738849f3535e457c3862adad8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hanjun Guo With the introduction of its_pmsi_init_one(), we can add some code on top for ACPI support of platform MSI. We are scanning the MADT table to get the ITS entry(ies), then use the information to create the platform msi domain for devices connect to it, just like the PCI MSI for ITS did. Cc: Marc Zyngier Cc: Tomasz Nowicki Cc: Thomas Gleixner Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-gic-v3-its-platform-msi.c | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index a80ecd7..e9dade9 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -105,6 +106,41 @@ static int __init its_pmsi_init_one(struct fwnode_handle *fwnode, return 0; } +#ifdef CONFIG_ACPI +static int __init +its_pmsi_parse_madt(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct acpi_madt_generic_translator *its_entry; + struct fwnode_handle *domain_handle; + const char *node_name; + int err = -ENXIO; + + its_entry = (struct acpi_madt_generic_translator *)header; + node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx", + (long)its_entry->base_address); + domain_handle = iort_find_domain_token(its_entry->translation_id); + if (!domain_handle) { + pr_err("%s: Unable to locate ITS domain handle\n", node_name); + goto out; + } + + err = its_pmsi_init_one(domain_handle, node_name); + +out: + kfree(node_name); + return err; +} + +static void __init its_acpi_pmsi_init(void) +{ + acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, + its_pmsi_parse_madt, 0); +} +#else +static inline void its_acpi_pmsi_init(void) { } +#endif + static void __init its_pmsi_of_init(void) { struct device_node *np; @@ -121,6 +157,7 @@ static void __init its_pmsi_of_init(void) static int __init its_pmsi_init(void) { its_pmsi_of_init(); + its_acpi_pmsi_init(); return 0; } early_initcall(its_pmsi_init); -- 1.7.12.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: guohanjun@huawei.com (Hanjun Guo) Date: Wed, 14 Sep 2016 22:21:12 +0800 Subject: [RFC PATCH v2 04/11] irqchip: gicv3-its: platform-msi: scan MADT to create platform msi domain In-Reply-To: <1473862879-7769-1-git-send-email-guohanjun@huawei.com> References: <1473862879-7769-1-git-send-email-guohanjun@huawei.com> Message-ID: <1473862879-7769-5-git-send-email-guohanjun@huawei.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org From: Hanjun Guo With the introduction of its_pmsi_init_one(), we can add some code on top for ACPI support of platform MSI. We are scanning the MADT table to get the ITS entry(ies), then use the information to create the platform msi domain for devices connect to it, just like the PCI MSI for ITS did. Cc: Marc Zyngier Cc: Tomasz Nowicki Cc: Thomas Gleixner Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-gic-v3-its-platform-msi.c | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index a80ecd7..e9dade9 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -105,6 +106,41 @@ static int __init its_pmsi_init_one(struct fwnode_handle *fwnode, return 0; } +#ifdef CONFIG_ACPI +static int __init +its_pmsi_parse_madt(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct acpi_madt_generic_translator *its_entry; + struct fwnode_handle *domain_handle; + const char *node_name; + int err = -ENXIO; + + its_entry = (struct acpi_madt_generic_translator *)header; + node_name = kasprintf(GFP_KERNEL, "ITS at 0x%lx", + (long)its_entry->base_address); + domain_handle = iort_find_domain_token(its_entry->translation_id); + if (!domain_handle) { + pr_err("%s: Unable to locate ITS domain handle\n", node_name); + goto out; + } + + err = its_pmsi_init_one(domain_handle, node_name); + +out: + kfree(node_name); + return err; +} + +static void __init its_acpi_pmsi_init(void) +{ + acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, + its_pmsi_parse_madt, 0); +} +#else +static inline void its_acpi_pmsi_init(void) { } +#endif + static void __init its_pmsi_of_init(void) { struct device_node *np; @@ -121,6 +157,7 @@ static void __init its_pmsi_of_init(void) static int __init its_pmsi_init(void) { its_pmsi_of_init(); + its_acpi_pmsi_init(); return 0; } early_initcall(its_pmsi_init); -- 1.7.12.4