From patchwork Fri Oct 13 07:09:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 115702 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp415613qgn; Fri, 13 Oct 2017 00:23:53 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBI5/EDONEmm6IwNki4XD7Jt62N/xCzhWDnONjCXGRxHhXR2vYGWSrhpZLqv32ZIjDckl9G X-Received: by 10.99.114.92 with SMTP id c28mr564676pgn.342.1507879433539; Fri, 13 Oct 2017 00:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507879433; cv=none; d=google.com; s=arc-20160816; b=qw6sSAR+4DFn3t9m+ZXQiUidK9uu2GBPozB9xHrdY1GLepRkMIb1KVdWkXEnenq9PD Tavpsa8ILGwwj8Y9jEslc7zHdI1OzpOruARIklfcHJlAO/iTtEu6kGZeEv18G1zvAHr1 kk8W4nEjcrHUJCT2P97gXV/tkdpg8+CiI0D0JGkJYpXW72MaUyXCWgeiO6f9dljD87pS to4d3DDJlgVsJ0K83eR5G2qmu2fKc+XgIQKA2KUQdVvgWbRAI6Zg5+Up0byGKt0l2Smx CcjhFVLCXWnwcedqtNjkqITYQCTDOd8sjPg2pQYu8jy6nOf5n/f/Q6dnK98u4pkhFuD+ qwpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=vKbix/rBZPjWADYNTELeDvWnZNz1EmrItK4QPJTri5E=; b=ldWlumbA/y/ubHcFCXb/fZH5T9EoVgMjrBVjpMw37jZK/qSp63hTbCiYoz0Bm9v5eo EFTI/es4KAWefVOfvBYXJO4kEovfHDjqrJqG6GlxNT/X08ji2r5yTHQW+eNRJyhsD3pr rVEKI5XpIdcBSnFuhBdWPwgPam5W3bSvwsPe8S/Uf/4rQjNw0+mBK3NDp9Qod48A7HJE fmp7MjMgBO0CrKo8W6HkMTAsRPJpxxOoAojgck0dDYYf89jPL2fEeG51o5gbRyH6gFSM OGv+ekG0v2nLVO8K3ZFlf9INshvG7AXvgFD8DQfPhte2wkQ/m2cZ7zWNrfAgJjgiW1rk R+Cg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si228476pfd.123.2017.10.13.00.23.53; Fri, 13 Oct 2017 00:23:53 -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 S1751551AbdJMHXw (ORCPT + 7 others); Fri, 13 Oct 2017 03:23:52 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7995 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750785AbdJMHXv (ORCPT ); Fri, 13 Oct 2017 03:23:51 -0400 Received: from 172.30.72.59 (EHLO DGGEMS402-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DIZ07849; Fri, 13 Oct 2017 15:20:09 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.301.0; Fri, 13 Oct 2017 15:17:49 +0800 From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy CC: Marc Zyngier , "Rafael J. Wysocki" , , , , Hanjun Guo Subject: [PATCH v2 1/4] ACPI/IORT: Look up IORT node through struct fwnode_handle pointer Date: Fri, 13 Oct 2017 15:09:47 +0800 Message-ID: <1507878590-51066-2-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1507878590-51066-1-git-send-email-guohanjun@huawei.com> References: <1507878590-51066-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.59E06929.006F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d36c15be7f328a9e7c14df19c1198862 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo Current IORT code provides a function (ie iort_get_fwnode()) which looks up a struct fwnode_handle pointer through a struct acpi_iort_node pointer for SMMU components but it lacks a function that implements the reverse look-up, namely struct fwnode_handle* -> struct acpi_iort_node*. Devices that are not IORT named components cannot be retrieved through their associated IORT named component scan interface because they just are not represented in the ACPI namespace; the reverse look-up is therefore required for all platform devices that represent IORT nodes (eg SMMUs) so that the struct acpi_iort_node* can be retrieved from the struct device->fwnode pointer. Signed-off-by: Hanjun Guo [lorenzo.pieralisi@arm.com: re-indented/rewrote the commit log] Signed-off-by: Lorenzo Pieralisi --- drivers/acpi/arm64/iort.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 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 0ff7020..03d3dd2 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -126,6 +126,31 @@ static inline void iort_delete_fwnode(struct acpi_iort_node *node) spin_unlock(&iort_fwnode_lock); } +/** + * iort_get_iort_node() - Retrieve iort_node associated with an fwnode + * + * @fwnode: fwnode associated with device to be looked-up + * + * Returns: iort_node pointer on success, NULL on failure + */ +static inline struct acpi_iort_node *iort_get_iort_node( + struct fwnode_handle *fwnode) +{ + struct iort_fwnode *curr; + struct acpi_iort_node *iort_node = NULL; + + spin_lock(&iort_fwnode_lock); + list_for_each_entry(curr, &iort_fwnode_list, list) { + if (curr->fwnode == fwnode) { + iort_node = curr->iort_node; + break; + } + } + spin_unlock(&iort_fwnode_lock); + + return iort_node; +} + typedef acpi_status (*iort_find_node_callback) (struct acpi_iort_node *node, void *context); @@ -422,9 +447,25 @@ static struct acpi_iort_node *iort_find_dev_node(struct device *dev) { struct pci_bus *pbus; - if (!dev_is_pci(dev)) + if (!dev_is_pci(dev)) { + struct acpi_iort_node *node; + /* + * scan iort_fwnode_list to see if it's an iort platform + * device (such as SMMU, PMCG),its iort node already cached + * and associated with fwnode when iort platform devices + * were initialized. + */ + node = iort_get_iort_node(dev->fwnode); + if (node) + return node; + + /* + * if not, then it should be a platform device defined in + * DSDT/SSDT (with Named Component node in IORT) + */ return iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, iort_match_node_callback, dev); + } /* Find a PCI root bus */ pbus = to_pci_dev(dev)->bus; From patchwork Fri Oct 13 07:09:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 115704 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp415630qgn; Fri, 13 Oct 2017 00:23:55 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC3bTyKVi5TW9UNKzSmDRB8exlIOO8N7RZ+lTf/kpRY4kTK1EkN/Lr3nL6FqZs1E1tjtroM X-Received: by 10.159.244.18 with SMTP id x18mr564452plr.117.1507879435205; Fri, 13 Oct 2017 00:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507879435; cv=none; d=google.com; s=arc-20160816; b=aKB7H65pAD4c7022fXK6Bk7O5yvAS0hzbIsbCugUWKHi1+WhYlwwnJ9IBXG0tZj8oL eWc2xt/BANelhoZ5V8ghb4tUVo4LcV/tLymx8U6yVpncIInQm4sv1HACmmIItawDQ36c msssRUzw4i7kex7ds5246+DOjbVMdCFC2qrrtP36zQrLadg2loZ7o+1iHAw8DMBn+ax2 M4VjDURrNQqKuQN8YyzgA41tFSV8ZHBUF53mudyVD7y/TrHikHqvUjYnpdlz4l8qCAa9 Toi8AuB6s4RMZi0g/Bfps5qgiY6x34qbBcsT4eWj8rOJ5K/CREkUCyiZ1KrAvsz23HNl MHFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=KA32HZLbRP1MbhPDz6PGxRePay7wx9b/EXZD+6nlIdI=; b=D0PRnEOsxdxv7YW3PJ5BdHYHmi6fKvJP0J6OmSHvsPQ2hUN/dpd5nRYG9ozasJGWll C73g2TKFiB3H8GFO8vfan17ufdGarDyOxNdEpGhactZ3uXQQsWaZJzyQWUwrx/gB3BeQ UzLAQ0+sYIKt8Djhjkqz1DjnK+5TEuQXrSzY5GYq0wwb0uQiWYPGOOUKpUrKRTzMms2u AmiYxTxHLo4SW+a3fpU4y5gVahfvrof1B+u1GLI6ehqEmF0pC6Wx2UrVqtjYwLVrb99v 2pSFcxGvP8x/vVle9N4TzdUJB7k30vz7NthJK7Cr+G9c7X3suJ0fEYc2wggMrZdthbQw du5g== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si228476pfd.123.2017.10.13.00.23.55; Fri, 13 Oct 2017 00:23:55 -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 S1750722AbdJMHXy (ORCPT + 7 others); Fri, 13 Oct 2017 03:23:54 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7998 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750785AbdJMHXx (ORCPT ); Fri, 13 Oct 2017 03:23:53 -0400 Received: from 172.30.72.59 (EHLO DGGEMS402-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DIZ07859; Fri, 13 Oct 2017 15:20:09 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.301.0; Fri, 13 Oct 2017 15:17:49 +0800 From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy CC: Marc Zyngier , "Rafael J. Wysocki" , , , , Hanjun Guo Subject: [PATCH v2 2/4] ACPI/IORT: Enable special index ITS group mappings for IORT nodes Date: Fri, 13 Oct 2017 15:09:48 +0800 Message-ID: <1507878590-51066-3-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1507878590-51066-1-git-send-email-guohanjun@huawei.com> References: <1507878590-51066-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.59E0692A.0013, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d3306bc957f527eba0f75c060f917cbb Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo IORT revision C introduced SMMUv3 and PMCG MSI support by adding specific mapping entries in the SMMUv3/PMCG subtables to retrieve the device ID and the ITS group it maps to for a given SMMUv3/PMCG IORT node. Introduce a mapping function (ie iort_get_id_mapping_index()), that for a given IORT node looks up if an ITS specific ID mapping entry exists and if so retrieve the corresponding mapping index in the IORT node mapping array. Since an ITS specific index mapping can be present for an IORT node that is not a leaf node (eg SMMUv3 - to describe its own ITS device ID) special handling is required for two steps mapping cases such as PCI/NamedComponent--->SMMUv3--->ITS because the SMMUv3 ITS specific index mapping entry should be skipped to prevent the IORT API from considering the mapping entry as a regular mapping one. If we take the following IORT topology example: |----------------------| | Root Complex Node | |----------------------| | map entry[x] | |----------------------| | id value | | output_reference | |---|------------------| | | |----------------------| |-->| SMMUv3 | |----------------------| | SMMUv3 dev ID | | mapping index 0 | |----------------------| | map entry[0] | |----------------------| | id value | | output_reference-----------> ITS 1 (SMMU MSI domain) |----------------------| | map entry[1] | |----------------------| | id value | | output_reference-----------> ITS 2 (PCI MSI domain) |----------------------| where the SMMUv3 ITS specific mapping entry is index 0 and it represents the SMMUv3 ITS specific index mapping entry (describing its own ITS device ID), we need to skip that mapping entry while carrying out the Root Complex Node regular mappings to prevent erroneous translations. Reuse the iort_get_id_mapping_index() function to detect the ITS specific mapping index for a specific IORT node and skip it in the IORT mapping API (ie iort_node_map_id()) loop to prevent considering it a normal PCI/Named Component ID mapping entry. Signed-off-by: Hanjun Guo [lorenzo.pieralisi@arm.com: split patch/rewrote commit log] Signed-off-by: Lorenzo Pieralisi --- drivers/acpi/arm64/iort.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) -- 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 03d3dd2..c3f3ac3 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -365,6 +365,11 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, return NULL; } +static inline int iort_get_id_mapping_index(struct acpi_iort_node *node) +{ + return -EINVAL; +} + static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, u32 id_in, u32 *id_out, u8 type_mask) @@ -374,7 +379,7 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, /* Parse the ID mapping tree to find specified node type */ while (node) { struct acpi_iort_id_mapping *map; - int i; + int i, index; if (IORT_TYPE_MASK(node->type) & type_mask) { if (id_out) @@ -395,8 +400,19 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, goto fail_map; } + /* + * Get the special ID mapping index (if any) and skip its + * associated ID map to prevent erroneous multi-stage + * IORT ID translations. + */ + index = iort_get_id_mapping_index(node); + /* Do the ID translation */ for (i = 0; i < node->mapping_count; i++, map++) { + /* if it is special mapping index, skip it */ + if (i == index) + continue; + if (!iort_id_map(map, node->type, id, &id)) break; } @@ -505,16 +521,24 @@ u32 iort_msi_map_rid(struct device *dev, u32 req_id) */ int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id) { - int i; + int i, index; struct acpi_iort_node *node; node = iort_find_dev_node(dev); if (!node) return -ENODEV; - for (i = 0; i < node->mapping_count; i++) { - if (iort_node_map_platform_id(node, dev_id, IORT_MSI_TYPE, i)) + index = iort_get_id_mapping_index(node); + /* if there is a valid index, go get the dev_id directly */ + if (index >= 0) { + if (iort_node_get_id(node, dev_id, index)) return 0; + } else { + for (i = 0; i < node->mapping_count; i++) { + if (iort_node_map_platform_id(node, dev_id, + IORT_MSI_TYPE, i)) + return 0; + } } return -ENODEV; From patchwork Fri Oct 13 07:09:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 115701 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp415601qgn; Fri, 13 Oct 2017 00:23:52 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCfcFwRPBbJYPlduj4aJALYbB8ilm2CSsZvEkeRnis1/Wxriso3qT4W3uEGySqHvbLo5fk+ X-Received: by 10.98.32.12 with SMTP id g12mr584105pfg.196.1507879432733; Fri, 13 Oct 2017 00:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507879432; cv=none; d=google.com; s=arc-20160816; b=f2BbZ2R2qQlHMzlfPmHUP4BhEM0WpGl9944dZ3jvjnQX9chmfd43koq0Il/b//z7bX taRy/ptHYgrS0V96DFDAHxZN2gHE1SPRKli8PREmDddW9q/C2j6zyLEfw339pULwvu+D wyk7zjxTUrZ8cRmIQfaViObDDfXoVXhVgPXl1abFpVIJAAkPCrttahQVlopSSN4iq0NU JLq7LGDldixumIhMWYOMrvzLHsrmbugSk6GsSS3bXSybvBtRiafeHRYcFwWz91nn1N6s S+4kcaObcsbhDjy+JXvDOm3vSKMHB8/OxBbgQt7pui3e+4tOQaq68uG/kLHaTummZ+V0 fGHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=RlmUHs1/2x+CSGYqzJ2kgK27zaTk0FWR0Q379fFa+m8=; b=cPOyUCOy9/64tN4S1Zsdwq2lmwaXa/hQF7CCfDZQcvjlqat3mKUbiYPm8ihLj0DgxX 6HtYJ9FNDLziVDx+xAMVVMnAZnVWZQJSY+vt7iBK9887OxyYsyPBQdkmRsAk8jxZzbID 6Y3MZgpHr/UPqQ+xwwsOFoWqNdGiGZcUAgDzxH6QE5VDe9Heu+73w6CbwzgprDLJiGJF 0xXkH6ip29i8m5evD36qgLtzCaHHhwK44te+QPECcOFx6fYHEzpvTvAmFZN45DSQfXwh AF2nSQg7sc2L7z6Z/wkKXQnj2+MKyPpBZLkEylbut8MJzEO4UtRaontQ1vrB7FWBQ+ne XzNg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si228476pfd.123.2017.10.13.00.23.52; Fri, 13 Oct 2017 00:23:52 -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 S1750973AbdJMHXv (ORCPT + 7 others); Fri, 13 Oct 2017 03:23:51 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7996 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbdJMHXu (ORCPT ); Fri, 13 Oct 2017 03:23:50 -0400 Received: from 172.30.72.59 (EHLO DGGEMS402-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DIZ07857; Fri, 13 Oct 2017 15:20:09 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.301.0; Fri, 13 Oct 2017 15:17:50 +0800 From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy CC: Marc Zyngier , "Rafael J. Wysocki" , , , , Hanjun Guo Subject: [PATCH v2 3/4] ACPI/IORT: Add SMMUv3 specific special index mapping handling Date: Fri, 13 Oct 2017 15:09:49 +0800 Message-ID: <1507878590-51066-4-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1507878590-51066-1-git-send-email-guohanjun@huawei.com> References: <1507878590-51066-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.0A020203.59E06929.00B0, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 4a9a6b3cb1fde9e7a4c2d5c49ec21f6c Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo IORT revision C introduced a mapping entry binding to describe ITS device ID mapping for SMMUv3 MSI interrupts. Enable the single mapping flag (ie that is used by SMMUv3 component for its special index mappings) for the SMMUv3 node in the IORT mapping API and add IORT code to handle special index mapping entry for the SMMUv3 IORT nodes to enable their MSI interrupts. In case the ACPICA for SMMUv3 device ID mapping is not ready, use the ACPICA version as a guard for function iort_get_id_mapping_index(). Signed-off-by: Hanjun Guo [lorenzo.pieralisi@arm.com: split the patch, rewrote the log] Signed-off-by: Lorenzo Pieralisi --- drivers/acpi/arm64/iort.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 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 c3f3ac3..ca5dd21 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -356,7 +356,8 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || - node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { + node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || + node->type == ACPI_IORT_NODE_SMMU_V3) { *id_out = map->output_base; return parent; } @@ -365,10 +366,46 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, return NULL; } +#if (ACPI_CA_VERSION > 0x20170929) +static int iort_get_id_mapping_index(struct acpi_iort_node *node) +{ + struct acpi_iort_smmu_v3 *smmu; + + switch (node->type) { + case ACPI_IORT_NODE_SMMU_V3: + /* + * SMMUv3 dev ID mapping index was introdueced in revision 1 + * table, not available in revision 0 + */ + if (node->revision < 1) + return -EINVAL; + + smmu = (struct acpi_iort_smmu_v3 *)node->node_data; + /* + * ID mapping index is only ignored if all interrupts are + * GSIV based + */ + if (smmu->event_gsiv && smmu->pri_gsiv && smmu->gerr_gsiv + && smmu->sync_gsiv) + return -EINVAL; + + if (smmu->id_mapping_index >= node->mapping_count) { + pr_err(FW_BUG "[node %p type %d] ID mapping index overflows valid mappings\n", + node, node->type); + return -EINVAL; + } + + return smmu->id_mapping_index; + default: + return -EINVAL; + } +} +#else static inline int iort_get_id_mapping_index(struct acpi_iort_node *node) { return -EINVAL; } +#endif static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, u32 id_in, u32 *id_out,