From patchwork Tue Aug 9 07:06:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 73526 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp342012qga; Tue, 9 Aug 2016 00:12:38 -0700 (PDT) X-Received: by 10.98.73.131 with SMTP id r3mr169046630pfi.112.1470726758517; Tue, 09 Aug 2016 00:12:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4si41294387pfi.181.2016.08.09.00.12.38; Tue, 09 Aug 2016 00:12:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752183AbcHIHMh (ORCPT + 6 others); Tue, 9 Aug 2016 03:12:37 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:13348 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752292AbcHIHLu (ORCPT ); Tue, 9 Aug 2016 03:11:50 -0400 Received: from 172.24.1.60 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.60]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CGB53236; Tue, 09 Aug 2016 15:07:54 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.235.1; Tue, 9 Aug 2016 15:07:43 +0800 From: Hanjun Guo To: , , CC: "Rafael J. Wysocki" , Marc Zyngier , Thomas Gleixner , Bjorn Helgaas , Greg KH , "Lorenzo Pieralisi" , Tomasz Nowicki , "Ma Jun" , Kefeng Wang , , , , "G Gregory" , Charles Garcia-Tobin , , Hanjun Guo Subject: [RFC PATCH 05/10] ACPI: platform: setup MSI domain for ACPI based platform device Date: Tue, 9 Aug 2016 15:06:01 +0800 Message-ID: <1470726366-40809-6-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1470726366-40809-1-git-send-email-guohanjun@huawei.com> References: <1470726366-40809-1-git-send-email-guohanjun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.57A9814A.00FE, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 01f9ecf9bb64544df3e33b899aa68746 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo With the platform msi domain created, we can set up the msi domain for a platform device when it's probed. This patch introduces acpi_configure_msi_domain(), which retrieves the domain from iort and set it to platform device. As some platform devices such as an irqchip needs the msi irqdomain to be the interrupt parent domain, we need to get irqdomain before platform device is probed. Signed-off-by: Hanjun Guo --- drivers/acpi/iort.c | 5 ++++- drivers/base/platform-msi.c | 14 ++++++++++++++ drivers/base/platform.c | 2 ++ include/linux/msi.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) -- 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 diff --git a/drivers/acpi/iort.c b/drivers/acpi/iort.c index cbace4d6..764d25a 100644 --- a/drivers/acpi/iort.c +++ b/drivers/acpi/iort.c @@ -387,6 +387,7 @@ iort_get_device_domain(struct device *dev, u32 req_id) { static struct fwnode_handle *handle; int its_id; + enum irq_domain_bus_token bus_token; if (!iort_table) return NULL; @@ -398,7 +399,9 @@ iort_get_device_domain(struct device *dev, u32 req_id) if (!handle) return NULL; - return irq_find_matching_fwnode(handle, DOMAIN_BUS_PCI_MSI); + bus_token = dev_is_pci(dev) ? + DOMAIN_BUS_PCI_MSI : DOMAIN_BUS_PLATFORM_MSI; + return irq_find_matching_fwnode(handle, bus_token); } void __init iort_table_detect(void) diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c index 279e539..d8b28d3 100644 --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -416,3 +417,16 @@ int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, return err; } + +int acpi_configure_msi_domain(struct device *dev) +{ + struct irq_domain *d = NULL; + + d = iort_get_device_domain(dev, 0); + if (d) { + dev_set_msi_domain(dev, d); + return 0; + } + + return -EINVAL; +} diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 6482d47..ea01a37 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -500,6 +501,7 @@ struct platform_device *platform_device_register_full( pdev->dev.parent = pdevinfo->parent; pdev->dev.fwnode = pdevinfo->fwnode; + acpi_configure_msi_domain(&pdev->dev); if (pdevinfo->dma_mask) { /* * This memory isn't freed when the device is put, diff --git a/include/linux/msi.h b/include/linux/msi.h index 4f0bfe5..2850ae9 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -306,6 +306,7 @@ int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, void platform_msi_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nvec); void *platform_msi_get_host_data(struct irq_domain *domain); +int acpi_configure_msi_domain(struct device *dev); #endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN