From patchwork Mon Aug 15 15:23:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9281369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2FF826086A for ; Mon, 15 Aug 2016 15:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215C428D26 for ; Mon, 15 Aug 2016 15:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15EFB28D2C; Mon, 15 Aug 2016 15:26:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6461628D2A for ; Mon, 15 Aug 2016 15:26:47 +0000 (UTC) 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 1bZJlT-0006iM-Qw; Mon, 15 Aug 2016 15:25:23 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZJkP-0005U8-D5 for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2016 15:24:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D1EB7BBC; Mon, 15 Aug 2016 08:25:29 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.206.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 321D43F32C; Mon, 15 Aug 2016 08:23:55 -0700 (PDT) From: Lorenzo Pieralisi To: iommu@lists.linux-foundation.org Subject: [PATCH v4 04/15] drivers: acpi: iort: add support for IOMMU fwnode registration Date: Mon, 15 Aug 2016 16:23:29 +0100 Message-Id: <1471274620-20754-5-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1471274620-20754-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1471274620-20754-1-git-send-email-lorenzo.pieralisi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160815_082417_537275_1C4FD72B X-CRM114-Status: GOOD ( 13.23 ) 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: linux-arm-kernel@lists.infradead.org, Lorenzo Pieralisi , Marc Zyngier , Tomasz Nowicki , Joerg Roedel , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Will Deacon , Sinan Kaya , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Hanjun Guo , Jon Masters , Dennis Chen , Robin Murphy , Nate Watterson MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The ACPI IORT table provide entries for IOMMU (aka SMMU in ARM world) components that allow creating the kernel data structures required to probe and initialize the IOMMU devices. This patch provides support in the IORT kernel code to register IOMMU components and their respective fwnode. Signed-off-by: Lorenzo Pieralisi Cc: Hanjun Guo Cc: Tomasz Nowicki Cc: "Rafael J. Wysocki" Reviewed-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/iort.h | 8 ++++++ 2 files changed, 73 insertions(+) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index cad7d1d..01a5258 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -20,7 +20,9 @@ #include #include +#include #include +#include struct iort_its_msi_chip { struct list_head list; @@ -28,6 +30,69 @@ struct iort_its_msi_chip { u32 translation_id; }; +struct iort_fwnode { + struct list_head list; + struct acpi_iort_node *iort_node; + struct fwnode_handle *fwnode; +}; +static LIST_HEAD(iort_fwnode_list); +static DEFINE_SPINLOCK(iort_fwnode_lock); + +/** + * iort_set_fwnode() - Create iort_fwnode and use it to register + * iommu data in the iort_fwnode_list + * + * @node: IORT table node associated with the IOMMU + * @fwnode: fwnode associated with the IORT node + * + * Returns: 0 on success + * <0 on failure + */ +int iort_set_fwnode(struct acpi_iort_node *iort_node, + struct fwnode_handle *fwnode) +{ + struct iort_fwnode *np; + + np = kzalloc(sizeof(struct iort_fwnode), GFP_ATOMIC); + + if (WARN_ON(!np)) + return -ENOMEM; + + INIT_LIST_HEAD(&np->list); + np->iort_node = iort_node; + np->fwnode = fwnode; + + spin_lock(&iort_fwnode_lock); + list_add_tail(&np->list, &iort_fwnode_list); + spin_unlock(&iort_fwnode_lock); + + return 0; +} + +/** + * iort_get_fwnode() - Retrieve fwnode associated with an IORT node + * + * @node: IORT table node to be looked-up + * + * Returns: fwnode_handle pointer on success, NULL on failure +*/ +struct fwnode_handle *iort_get_fwnode(struct acpi_iort_node *node) +{ + struct iort_fwnode *curr; + struct fwnode_handle *fwnode = NULL; + + spin_lock(&iort_fwnode_lock); + list_for_each_entry(curr, &iort_fwnode_list, list) { + if (curr->iort_node == node) { + fwnode = curr->fwnode; + break; + } + } + spin_unlock(&iort_fwnode_lock); + + return fwnode; +} + typedef acpi_status (*iort_find_node_callback) (struct acpi_iort_node *node, void *context); diff --git a/include/linux/iort.h b/include/linux/iort.h index 9bb30c5..666a3de 100644 --- a/include/linux/iort.h +++ b/include/linux/iort.h @@ -30,12 +30,20 @@ struct fwnode_handle *iort_find_domain_token(int trans_id); void iort_table_detect(void); u32 iort_msi_map_rid(struct device *dev, u32 req_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); +struct fwnode_handle *iort_get_fwnode(struct acpi_iort_node *node); #else static inline void iort_table_detect(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_set_fwnode(struct acpi_iort_node *iort_node, + struct fwnode_handle *fwnode) +{ return -ENODEV; } +static inline struct fwnode_handle * +iort_get_fwnode(struct acpi_iort_node *node) { return NULL; } #endif #define IORT_ACPI_DECLARE(name, table_id, fn) \