From patchwork Wed Sep 14 14:21:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 76205 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1902544qgf; Wed, 14 Sep 2016 07:23:47 -0700 (PDT) X-Received: by 10.98.61.27 with SMTP id k27mr4985387pfa.27.1473863027078; Wed, 14 Sep 2016 07:23:47 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xy10si4998134pac.60.2016.09.14.07.23.46; Wed, 14 Sep 2016 07:23:47 -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 S933141AbcINOXp (ORCPT + 6 others); Wed, 14 Sep 2016 10:23:45 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:32357 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933122AbcINOXo (ORCPT ); Wed, 14 Sep 2016 10:23:44 -0400 Received: from 172.24.1.136 (EHLO szxeml426-hub.china.huawei.com) ([172.24.1.136]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DNB48937; Wed, 14 Sep 2016 22:23:23 +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:13 +0800 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 02/11] ACPI: platform-msi: retrieve dev id from IORT Date: Wed, 14 Sep 2016 22:21:10 +0800 Message-ID: <1473862879-7769-3-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.57D95D5C.0386, 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: 1619e5167f0f4b02f8c9a3446b15d6c7 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo For devices connecting to ITS, it needs dev id to identify itself, and this dev id is represented in the IORT table in named componant node [1] for platform devices, so in this patch we will scan the IORT to retrieve device's dev id. Introduce iort_pmsi_get_dev_id() with pointer dev passed in for that purpose. [1]: https://static.docs.arm.com/den0049/b/DEN0049B_IO_Remapping_Table.pdf Cc: Marc Zyngier Cc: Lorenzo Pieralisi Cc: Tomasz Nowicki Cc: Thomas Gleixner Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 26 ++++++++++++++++++++++++++ drivers/irqchip/irq-gic-v3-its-platform-msi.c | 4 +++- include/linux/acpi_iort.h | 8 ++++++++ 3 files changed, 37 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/arm64/iort.c b/drivers/acpi/arm64/iort.c index cee82d4..13a1905 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -408,6 +408,32 @@ u32 iort_msi_map_rid(struct device *dev, u32 req_id) } /** + * iort_pmsi_get_dev_id() - Get the device id for a device + * @dev: The device for which the mapping is to be done. + * @dev_id: The device ID found. + * + * Returns: 0 for successful find a dev id, errors otherwise + */ +int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id) +{ + struct acpi_iort_node *node; + + if (!iort_table) + return -ENODEV; + + node = iort_find_dev_node(dev); + if (!node) { + dev_err(dev, "can't find related IORT node\n"); + return -ENODEV; + } + + if( !iort_node_get_id(node, dev_id, IORT_MSI_TYPE, 0)) + return -ENODEV; + + return 0; +} + +/** * iort_dev_find_its_id() - Find the ITS identifier for a device * @dev: The device. * @idx: Index of the ITS identifier list. diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index 3c94278..3646c23 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -56,7 +57,8 @@ static int its_pmsi_prepare(struct irq_domain *domain, struct device *dev, msi_info = msi_get_domain_info(domain->parent); - ret = of_pmsi_get_dev_id(domain, dev, &dev_id); + ret = dev->of_node ? of_pmsi_get_dev_id(domain, dev, &dev_id) : + iort_pmsi_get_dev_id(dev, &dev_id); if (ret) return ret; diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h index 167649a..bfaf75f 100644 --- a/include/linux/acpi_iort.h +++ b/include/linux/acpi_iort.h @@ -32,6 +32,7 @@ struct fwnode_handle *iort_find_domain_token(int trans_id); #ifdef CONFIG_ACPI_IORT void acpi_iort_init(void); u32 iort_msi_map_rid(struct device *dev, u32 req_id); +int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id); struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id); int iort_set_fwnode(struct acpi_iort_node *iort_node, struct fwnode_handle *fwnode); @@ -42,9 +43,16 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev); static inline void acpi_iort_init(void) { } static inline u32 iort_msi_map_rid(struct device *dev, u32 req_id) { return req_id; } + static inline struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id) { return NULL; } + +static inline int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id) +{ + return -ENODEV; +} + static inline int iort_set_fwnode(struct acpi_iort_node *iort_node, struct fwnode_handle *fwnode) { return -ENODEV; }