From patchwork Wed Sep 14 14:21:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 76213 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1903628qgf; Wed, 14 Sep 2016 07:26:06 -0700 (PDT) X-Received: by 10.66.72.69 with SMTP id b5mr4998172pav.98.1473863166072; Wed, 14 Sep 2016 07:26:06 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id lv5si4998399pab.152.2016.09.14.07.26.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Sep 2016 07:26:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkB7W-0006JS-29; Wed, 14 Sep 2016 14:25:02 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkB74-0005mG-4G for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2016 14:24:38 +0000 Received: from 172.24.1.60 (EHLO szxeml426-hub.china.huawei.com) ([172.24.1.60]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DNB48947; Wed, 14 Sep 2016 22:23:26 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.235.1; Wed, 14 Sep 2016 22:23:15 +0800 From: Hanjun Guo To: "Rafael J. Wysocki" , Marc Zyngier , Lorenzo Pieralisi Subject: [RFC PATCH v2 05/11] ACPI: platform: setup MSI domain for ACPI based platform device Date: Wed, 14 Sep 2016 22:21:13 +0800 Message-ID: <1473862879-7769-6-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 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.57D95D5F.0055, 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: e4bf10753fe9e0e94ee437a92380ea2f X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160914_072434_625641_E86014F4 X-CRM114-Status: GOOD ( 14.46 ) X-Spam-Score: -5.6 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [119.145.14.65 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [119.145.14.65 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kefeng Wang , Greg KH , linux-kernel@vger.kernel.org, linuxarm@huawei.com, linux-acpi@vger.kernel.org, Hanjun Guo , Tomasz Nowicki , Bjorn Helgaas , Thomas Gleixner , Charles Garcia-Tobin , linux-arm-kernel@lists.infradead.org, Ma Jun Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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. Cc: Marc Zyngier Cc: Greg KH Cc: Thomas Gleixner Cc: Bjorn Helgaas Cc: Lorenzo Pieralisi Cc: Tomasz Nowicki Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 5 ++++- drivers/base/platform-msi.c | 15 ++++++++++++++- drivers/base/platform.c | 2 ++ include/linux/msi.h | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) -- 1.7.12.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 13a1905..bccd3cc 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -478,6 +478,7 @@ struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id) { struct fwnode_handle *handle; int its_id; + enum irq_domain_bus_token bus_token; if (iort_dev_find_its_id(dev, req_id, 0, &its_id)) return NULL; @@ -486,7 +487,9 @@ struct irq_domain *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); } static int __get_pci_rid(struct pci_dev *pdev, u16 alias, void *data) diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c index 279e539..f6eae18 100644 --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -17,8 +17,8 @@ * along with this program. If not, see . */ +#include #include -#include #include #include #include @@ -416,3 +416,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 e8c81fb..1e93a78 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -308,6 +308,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