From patchwork Wed Aug 9 10:53:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 109715 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp717793obb; Wed, 9 Aug 2017 04:06:12 -0700 (PDT) X-Received: by 10.84.168.5 with SMTP id e5mr8726152plb.468.1502276651149; Wed, 09 Aug 2017 04:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502276651; cv=none; d=google.com; s=arc-20160816; b=CU/q6GHSvBlJ40hMqPuWsqP4cEBwIwd7jXx9nDIQQA2VwfJPPtbFMLNHuEuM68WcOG cuF5d4chuw1RvJyvvLolXOE0Jxn8vJQHAA+lgf6L/ZwvD1/P1nHH2ooOcQC8K5WIeY9M hU7I5vHeeDVUv5uDIMBgvjhNYqZxNeg4wnIb45anKQdcHg59+Nwj6oXsmC0QqSN/aZY1 r9PBthvoXwFvG33W6GdVKlWd6ZZnMjiPf502tKJKf+jxAcrFh1FgiEThLzj4jFtG+VGH gtNgqZh6Iq5fBJ4MT58VaHkCAJyUyaEfOQbsJfQKE6X5M9xD+yYZkBPTg77NhjYG8u96 zA5Q== 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=81VsI0596NvIzlOTQAhx419IJAJDyIODep+lRR9sPeg=; b=YVIqUm/Rvd5DgRc8bnv4GzNHoQnyk+Q9s1MBgiIDdkvsJPW+f1fcQEE50F1afyGpzX dAFcZ53Zx9JIakGq0v7vKvGo8G8Ndq6lK0Ljpz4etHsu6ZOU9Io4AFlM79cu60yU/SiK 4TTqXar6IXoKBLsqM4tgACSi6d5La2xnPUTHP687OiLaJQdsnxNj2qczKlMETjitJXj+ D5TCwJppXw6Yb1W1gPejyg+ZiWiY3C6zxwxq8mjj/afZjXrZUrldg+1h+9jWnD8VzNhW UBsd61dNBSjjKO5xH147hflhYI+gCo4KC74XNtNXxGDFfe4vL26W2rPehtbrIdXZzJgB pX2Q== 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 x69si2401191pfj.283.2017.08.09.04.04.10; Wed, 09 Aug 2017 04:04:11 -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 S1752110AbdHILEJ (ORCPT + 7 others); Wed, 9 Aug 2017 07:04:09 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3482 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751995AbdHILEJ (ORCPT ); Wed, 9 Aug 2017 07:04:09 -0400 Received: from 172.30.72.59 (EHLO DGGEMS411-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DEU08683; Wed, 09 Aug 2017 19:00:42 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.301.0; Wed, 9 Aug 2017 19:00:32 +0800 From: Hanjun Guo To: Lorenzo Pieralisi CC: , , , Sinan Kaya , "Rafael J. Wysocki" , Marc Zyngier , Hanjun Guo Subject: [RFC PATCH 1/4] ACPICA: Add SMMUv3 device ID mapping index support Date: Wed, 9 Aug 2017 18:53:34 +0800 Message-ID: <1502276017-63108-2-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1502276017-63108-1-git-send-email-guohanjun@huawei.com> References: <1502276017-63108-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.0A020201.598AEB5B.010F, 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: 78caa4aea100313578d176e34dcdefca Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo SMMUv3 device ID mapping index is used for SMMUv3 MSIs, update the IORT to support that. Signed-off-by: Hanjun Guo --- include/acpi/actbl2.h | 1 + 1 file changed, 1 insertion(+) -- 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/include/acpi/actbl2.h b/include/acpi/actbl2.h index d568948..e9a9842 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -809,6 +809,7 @@ struct acpi_iort_smmu_v3 { u8 pxm; u8 reserved1; u16 reserved2; + u32 id_mapping_index; }; /* Values for Model field above */ From patchwork Wed Aug 9 10:53:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 109713 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp706452qge; Wed, 9 Aug 2017 04:04:08 -0700 (PDT) X-Received: by 10.99.0.77 with SMTP id 74mr7271797pga.299.1502276648414; Wed, 09 Aug 2017 04:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502276648; cv=none; d=google.com; s=arc-20160816; b=SHKQpI7JCF/eKw+CqDCKy7Vas5tGquJSyuGX3kYOxFiUftJoS97adcjyYyJ1Cg2oVQ /3E8mN9oJH62Cj+nVNaH1Q3oPkn6mXv161FJDPa5sYieowftFPzCFjoF/Es8uyPSvtZG LYC4AhD8GsZsIv0taVPzASxZrwNCRsTtpl/HRg93brFpKq6JXeBPoVwhVsmcIaHjNQkk vtIRtsELNKb59UgjxYuMsAfy6/LSaPIwvjZJd8qZjwr+899ybXzgsuU371YUY5KGiY9F uCV41NfTWyK2JjVfdjmQhNUVaD8HNKuxofjtA/lgTH4MyJN4230hj5Wvj88S3WWPg/TC AEBg== 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=jgwRgg6dmiXfiK1BHvA4Zfqg53YTtLNxTiuWPtFoK3g=; b=HdJlseasgO/kD6/bSfUBejzqfVR+lMkiKE7492RYln4jvDoN08MzQyCALk9OqbvNIA GN1PXeOhr7EYG5hl0z4ZiYuZhjFKaCP9diGtfpgAj1dt3fpguvSz+yoggxwfqA2C/Mhc Q6ap5hQ0E69F0KcB5J3tQdNummeCNPmwrusB6tELsXaHae6UJ2zYoC4zRfyEWoYWxkVp 4Avzt6IPnolKxJSTdwFi+0ue8FaOZezV6/2HtVELNkGz/rLxQlLS2cJlcaAshxGUQ7M1 WCcBjUYefkBDk9Ckd36OiDCWtOeL+6MeQxC4lMEbgBfNjrVGUUmEQZ4DZy1W4FZnrgDE o8AQ== 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 x69si2401191pfj.283.2017.08.09.04.04.08; Wed, 09 Aug 2017 04:04:08 -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 S1752049AbdHILEH (ORCPT + 7 others); Wed, 9 Aug 2017 07:04:07 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3481 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751995AbdHILEH (ORCPT ); Wed, 9 Aug 2017 07:04:07 -0400 Received: from 172.30.72.59 (EHLO DGGEMS411-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DEU08678; Wed, 09 Aug 2017 19:00:42 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.301.0; Wed, 9 Aug 2017 19:00:33 +0800 From: Hanjun Guo To: Lorenzo Pieralisi CC: , , , Sinan Kaya , "Rafael J. Wysocki" , Marc Zyngier , Hanjun Guo Subject: [RFC PATCH 2/4] ACPI: IORT: lookup iort node via fwnode Date: Wed, 9 Aug 2017 18:53:35 +0800 Message-ID: <1502276017-63108-3-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1502276017-63108-1-git-send-email-guohanjun@huawei.com> References: <1502276017-63108-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.598AEB5A.02CE, 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: 76834548841793c0429aa72f18786820 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo Now we have a helper function iort_get_fwnode() which lookup fwnode via iort node for SMMU, but sometimes we just need something exctly the opposite, which means we need to get the iort node via fwnode. For example, we need to get SMMU's iort node when adding support for SMMU MSI, but SMMU is not a named component which has a associated device node in DSDT, that means we can't match the ACPI full path name to get the iort node for SMMU. But with SMMU or other devices in IORT probed as platform device, it created a fwnode to associate with the iort node, so we introduce iort_get_iort_node() to get the iort node via fwnode. This can be extended to PMCG node usage in IORT too. Signed-off-by: Hanjun Guo --- 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 fa99798..32bd4a4 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); @@ -424,9 +449,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 Wed Aug 9 10:53:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 109710 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp702130qge; Wed, 9 Aug 2017 04:00:58 -0700 (PDT) X-Received: by 10.99.62.75 with SMTP id l72mr7143196pga.316.1502276458453; Wed, 09 Aug 2017 04:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502276458; cv=none; d=google.com; s=arc-20160816; b=sBrXw4xiH3m2TSi+ZBuHanbeKQ3cH5OECEwIKwUs3/P+gAYZKsPxZCJERF51k8PawN 3bhg28FZAS94oXr3l5br47UCllDYfClgLUlocYvDdvaYOEKn0ArpNjj2/4xxDPHUnfkj LnovW9MrkvinVAeZ6UWs5GeM/GNsxfHt2W7CaepiexCveHKQYBH+tY1p7XAFUZuE1xme +ujf2IjOO4JCDCXdh/xPPhkr25NgxmGuLT08o6ANduosPnrLqBp9lEvrOOQrTuMXCrAZ hOb32CGYk+O/RieBydYVAX7+TgZwEBsRPeMfyINVTG0Jhs6r3CJGmxZ/umWyV7fa2tvF L14w== 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=ERvE9xu9WnOP+zONJNuMRakbiNjZEMfQ85QQkhHlX7I=; b=luaPDo1f22rIc34NkEHE2G5/I0IbpvKILzafTU6b4NuyrBc4+Bu/EJO+K2zVNr585Z Ymldql1R3e06Qw4VpbW0iuTXoE/WbIwtJXNh53fs1PfBFmiTnMRu8typKaLM+mVA6Bmf EkheluNkekSDL+TPt+j79RmBUY/9oSs3/4H8BCDgKjyh49Gg5h7RS24xHza5FnDdDxCV RXnqv135ObMOf0e5UUT5k0TpJ/EWwSv/1b8kFYPeoxDA9Z3LOX8LoGugmzvxqMoiMtsr dPZPX6905lJU7wXwX6vU1LStCoSzjr7x1O5k1hRA5IpWr0BKwJEsOlK7kIVKfX7MwNOZ 6lsA== 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 p125si2216902pga.768.2017.08.09.04.00.58; Wed, 09 Aug 2017 04:00:58 -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 S1752023AbdHILA5 (ORCPT + 7 others); Wed, 9 Aug 2017 07:00:57 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3480 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbdHILA5 (ORCPT ); Wed, 9 Aug 2017 07:00:57 -0400 Received: from 172.30.72.59 (EHLO DGGEMS411-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DEU08682; Wed, 09 Aug 2017 19:00:42 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.301.0; Wed, 9 Aug 2017 19:00:33 +0800 From: Hanjun Guo To: Lorenzo Pieralisi CC: , , , Sinan Kaya , "Rafael J. Wysocki" , Marc Zyngier , Hanjun Guo Subject: [RFC PATCH 3/4] ACPI: IORT: Skip SMMUv3 device ID map for two steps mappings Date: Wed, 9 Aug 2017 18:53:36 +0800 Message-ID: <1502276017-63108-4-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1502276017-63108-1-git-send-email-guohanjun@huawei.com> References: <1502276017-63108-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.598AEB5B.0015, 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: a4fd5c54077771bfe64bcab8605a44cb 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 MSI support which adding a device ID mapping index in SMMUv3 sub table, to get the SMMUv3 device ID mapping for the output ID (dev ID for ITS) and the link to which ITS. So if a platform supports SMMUv3 MSI for control interrupt, there will be a additional single map entry under SMMU, this will not introduce any difference for devices just use one step map to get its output ID and parent (ITS or SMMU), such as PCI/NC/PMCG ---> ITS or PCI/NC ---> SMMU, but we need to do the spcial handling for two steps map case such as PCI/NC--->SMMUv3--->ITS. Take a PCI hostbridge for example, |----------------------| | Root Complex Node | |----------------------| | map entry[x] | |----------------------| | id value | | output_reference | |---|------------------| | | |----------------------| |-->| SMMUv3 | |----------------------| | SMMU 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) |----------------------| When the SMMU dev ID mapping index is 0, there is entry[0] to map to a ITS, we need to skip that map entry for PCI or NC (named component), or we may get the wrong ITS parent. For now we have two APIs for ID mapping, iort_node_map_id() and iort_node_map_platform_id(), and iort_node_map_id() is used for optional two steps mapping, so we just need to skip the map entry in iort_node_map_id() for non-SMMUv3 devices. Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 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 Signed-off-by: Hanjun Guo diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 32bd4a4..9439f02 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -366,6 +366,28 @@ struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, return NULL; } +static int iort_get_smmu_v3_id_mapping_index(struct acpi_iort_node *node, + u32 *index) +{ + struct acpi_iort_smmu_v3 *smmu; + + /* + * SMMUv3 dev ID mapping index was introdueced in revision 1 + * table, not avaible in revision 0 + */ + if (node->revision < 1) + return -EINVAL; + + smmu = (struct acpi_iort_smmu_v3 *)node->node_data; + /* if any of the gsi for control interrupts is not 0, ignore the MSI */ + if (smmu->event_gsiv || smmu->pri_gsiv || smmu->gerr_gsiv + || smmu->sync_gsiv) + return -EINVAL; + + *index = smmu->id_mapping_index; + return 0; +} + static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, u32 id_in, u32 *id_out, u8 type_mask) @@ -375,7 +397,9 @@ 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, ret = -EINVAL; + /* big enough for an invalid id index in practical */ + u32 index = U32_MAX; if (IORT_TYPE_MASK(node->type) & type_mask) { if (id_out) @@ -396,8 +420,19 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, goto fail_map; } + /* + * we need to get SMMUv3 dev ID mapping index and skip its + * associated ID map for single mapping cases. + */ + if (node->type == ACPI_IORT_NODE_SMMU_V3) + ret = iort_get_smmu_v3_id_mapping_index(node, &index); + /* Do the ID translation */ for (i = 0; i < node->mapping_count; i++, map++) { + /* if it's a SMMUv3 device id mapping index, skip it */ + if (!ret && i == index) + continue; + if (!iort_id_map(map, node->type, id, &id)) break; } From patchwork Wed Aug 9 10:53:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 109712 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp706559qge; Wed, 9 Aug 2017 04:04:13 -0700 (PDT) X-Received: by 10.99.158.10 with SMTP id s10mr7405450pgd.113.1502276651964; Wed, 09 Aug 2017 04:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502276651; cv=none; d=google.com; s=arc-20160816; b=en/oBK19UHc2Uh6SPr34X5syiWcft7KXDhR5k0FC6zS2UjE24MlncTBf4dc2xeSubt 8d91K+/ut9nD2aGAeha4VKMLDOkYx6hJ2OcVYg1Dcr/2U8u5pTY1SxAzgB3gVds6vEGP QIZhwyNO3ZwJC8keucQf+FiOSRPXqtHgCj6+O7qGPxPkEniRdEYhiylViUUQjkH9PWvT 62yFX8xr6D45Da/rIxXP0h2YFSCdyjJ1VtSopnWV69pEAMn3th+/KdRPJ26Kh6ExL15O HCZQmd1HXxzYhUPwQ5LocV/X9K5H2Scl5EnZp/QwP6sOAw8bwGGplhL5GaoFMNI0dsAf sPNw== 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=9ljagKbY6wqT1/yB90hF46hcKEo6OZwWFhilj1dYfl0=; b=yG1Kl4ctnn9CaGjnPYel4lbigNCkxIHpQZ8Ompr+MgauzF4tvzfgDAN7t5ZXsIaZ/t 99fO4SR3D0xpM2iBNhGAv1NbYSb6DLCux2tTMpN0LBzeNlttTYB3zkEUYxx2/GFt0MSE /WHWlA00okngbL8DKOZUzstyL/qObhHq/rNgx/50VeJtfMM8NAG+IH4Gs/A3kkdXMEAK Hd5IiXIMODSLqyofU1AOfIG0fwVvhpYNCX5zGbF+p12abJGqVgKhMuj59Y3lUwCbi/Kf +1FsS6XHBbW4/2yYC63Nz+shS2qP31R+3tVx7qknR72B9COsotbZ5FZTCsM9uBnx6tuw oCGQ== 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 x69si2401191pfj.283.2017.08.09.04.04.11; Wed, 09 Aug 2017 04:04:11 -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 S1751995AbdHILEK (ORCPT + 7 others); Wed, 9 Aug 2017 07:04:10 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3483 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbdHILEJ (ORCPT ); Wed, 9 Aug 2017 07:04:09 -0400 Received: from 172.30.72.59 (EHLO DGGEMS411-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DEU08680; Wed, 09 Aug 2017 19:00:42 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.301.0; Wed, 9 Aug 2017 19:00:34 +0800 From: Hanjun Guo To: Lorenzo Pieralisi CC: , , , Sinan Kaya , "Rafael J. Wysocki" , Marc Zyngier , Hanjun Guo Subject: [RFC PATCH 4/4] ACPI: IORT: Add SMMUv3 MSI support Date: Wed, 9 Aug 2017 18:53:37 +0800 Message-ID: <1502276017-63108-5-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1502276017-63108-1-git-send-email-guohanjun@huawei.com> References: <1502276017-63108-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.598AEB5B.0010, 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: 124749991c9fca4264660572aa01ccb9 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo Since we have a mapping index for SMMUv3 MSI, we can directly use that index to get the map entry, then retrieve dev ID and ITS parent to add SMMUv3 MSI support. Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 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 Signed-off-by: Lorenzo Pieralisi diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 9439f02..ce03298 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -313,7 +313,8 @@ static int iort_id_map(struct acpi_iort_id_mapping *map, u8 type, u32 rid_in, /* Single mapping does not care for input id */ if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { if (type == ACPI_IORT_NODE_NAMED_COMPONENT || - type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { + type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || + type == ACPI_IORT_NODE_SMMU_V3) { *rid_out = map->output_base; return 0; } @@ -357,7 +358,8 @@ 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; } @@ -549,9 +551,21 @@ int iort_pmsi_get_dev_id(struct device *dev, u32 *dev_id) 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)) + if (node->type == ACPI_IORT_NODE_SMMU_V3) { + u32 index; + + if (iort_get_smmu_v3_id_mapping_index(node, &index)) + return -ENODEV; + + if (iort_node_map_platform_id(node, dev_id, IORT_MSI_TYPE, + 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; @@ -626,20 +640,30 @@ static struct irq_domain *iort_get_platform_device_domain(struct device *dev) struct acpi_iort_node *node, *msi_parent; struct fwnode_handle *iort_fwnode; struct acpi_iort_its_group *its; - int i; /* find its associated iort node */ - node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, - iort_match_node_callback, dev); + node = iort_find_dev_node(dev); if (!node) return NULL; /* then find its msi parent node */ - for (i = 0; i < node->mapping_count; i++) { + if (node->type == ACPI_IORT_NODE_SMMU_V3) { + u32 index; + + if (iort_get_smmu_v3_id_mapping_index(node, &index)) + return NULL; + msi_parent = iort_node_map_platform_id(node, NULL, + IORT_MSI_TYPE, index); + } else { + int i; + + for (i = 0; i < node->mapping_count; i++) { + msi_parent = iort_node_map_platform_id(node, NULL, IORT_MSI_TYPE, i); - if (msi_parent) - break; + if (msi_parent) + break; + } } if (!msi_parent) @@ -1233,6 +1257,8 @@ static int __init iort_add_smmu_platform_device(struct acpi_iort_node *node) /* Configure DMA for the page table walker */ acpi_dma_configure(&pdev->dev, attr); + acpi_configure_pmsi_domain(&pdev->dev); + ret = platform_device_add(pdev); if (ret) goto dma_deconfigure;