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;