From patchwork Wed Sep 27 01:20:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 114307 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4470856qgf; Tue, 26 Sep 2017 18:20:36 -0700 (PDT) X-Received: by 10.84.217.153 with SMTP id p25mr12257221pli.213.1506475236406; Tue, 26 Sep 2017 18:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506475236; cv=none; d=google.com; s=arc-20160816; b=axoUvme+jm6TXfUnrX2J0bQKvTywJ7u2xaDRQjiWmtTMH/xZxvnMHirQzstsAQwS8l YsP4i1pqTE6GgC6SHjAipAWPpdtOpJ5VgJhTZLQOTscx9dHtqfMuNUdF6JrCcpE3DD2q IgrEs1tuTy0vw65eEfW5/WWNLjj0pvSyUYPJp2UrJ79IjfKj6wLIAyuqeCyTVrnL93V/ oDdi2rVi3Ot0eknSyozM9Rmnthg7ailnV/CU9BejI/E1aNn7TX/Re63hhadQiBLLjv8d 4t13egegF1aJy9A7itqkYUNZ2XgrYfAqLK+VtlK/Gaq//0bvMTSKDL2Dg/dskkG+P352 Jq9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=98872GN5QR+Fyjg4elaYnmcaiKgWe7RQYdBUxRepaCA=; b=U+94CtaSZsGQJa2yl7UVsBnBNmz+r3ntJWkwol6RVe88AD4F4SB8pLVT7NrZcfG+IZ 9I/6u/w4isXMQW8xV1db7IwCVt0OvRhm/wTA9nx88uJlL/PSKYjRmi5Pd57IhFmBPU2n bm8OjJebl2etpLqMOOwpnp2VCHPQ8X9Gz/M0WPfCco4wNh+ggvTFfh2MlKsGoi9ChFRL 1/YTXlfjv98efZu29HBfByk9mJ/J5bZZ3W+MlHdHh04sDSt2Hx9kAkO7h6muBLkjCcwZ FmfPCC3veBLbyxlwS17HBSCYWoxciJz8Bc9dDyryxlGMLp3onAjVZvL684G9y05yXqXe EUIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iw1aqmHE; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si2494136pfa.558.2017.09.26.18.20.36; Tue, 26 Sep 2017 18:20:36 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iw1aqmHE; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969091AbdI0BUf (ORCPT + 7 others); Tue, 26 Sep 2017 21:20:35 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:56694 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965519AbdI0BUf (ORCPT ); Tue, 26 Sep 2017 21:20:35 -0400 Received: by mail-pg0-f54.google.com with SMTP id 7so6862824pgd.13 for ; Tue, 26 Sep 2017 18:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Lw+wPNxCo2LYlcvpZDpBBxR52E5JorFAAsAocdL7NY=; b=iw1aqmHE710PCzzDsuNFAt+FU2IGbbB1Iz/sHGY/TIWZKb1XCHbXDx3CZpw6u2O/hq tklWTTyT3bAQACKQ8xVDnyhwvilTg1C+LKhTpeb4xVPP7bizfbd3+W39Wu5TX2P8l66g ZZdcUorbydXG5TAgJz4+Y+70Mn7Q30ix/XdPQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6Lw+wPNxCo2LYlcvpZDpBBxR52E5JorFAAsAocdL7NY=; b=GCxCGZiCoKA6LQWDGhSVDknfHxSyhLwL0RFdMVJrfBMNp1b4rMScA1MmQGH051NBqY tyEnFfupSU1ii6Xqqq7gDDDLwutvrf9iscilOSc338sBOViYXdlOu28nSuS0LKEsd6sq F/Yq9yzwCdtz10Vimt4JpkDrWhO07UZxBjiq6qbEQRqe2gwWrs7Tei4HAWHaHDoG6qh/ 8TuuZ8tJRd0AQrmS2arNYl7Dprgacl6QJ26ZLvmGYE6r/rcqfUqyfppz8PXHrrQY/Sd4 VavSh7xj07D6xc2PibvCqUKtQzuxM1r42f2zD0uPA9BF+WoMzkQdUuYBYA5oakEc+gmy je8A== X-Gm-Message-State: AHPjjUhBqaOq2pMrEdY+zFQ7n+ipgg3Ewyvro+J89RzzwORgghksnkgQ oKEfM57Yps/bAEwWnyXoqCUmxg== X-Google-Smtp-Source: AOwi7QB/mFAvjhN0NdwdMJJTC1YD5SPpjWF5/YBs7wn/rgNQyD1uf1wVX5VZDoy/rHi1Ea4qcDCo4g== X-Received: by 10.99.66.196 with SMTP id p187mr12858454pga.0.1506475234552; Tue, 26 Sep 2017 18:20:34 -0700 (PDT) Received: from localhost ([70.35.39.2]) by smtp.googlemail.com with ESMTPSA id 64sm17300192pge.44.2017.09.26.18.20.33 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 18:20:34 -0700 (PDT) From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy Cc: "Rafael J. Wysocki" , Marc Zyngier , Lv Zheng , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Hanjun Guo Subject: [PATCH 1/4] ACPICA: Add SMMUv3 device ID mapping index support Date: Wed, 27 Sep 2017 09:20:12 +0800 Message-Id: <1506475215-2731-2-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> References: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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.9.1 -- 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 686b6f8..d90277e 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -810,6 +810,7 @@ struct acpi_iort_smmu_v3 { u8 pxm; u8 reserved1; u16 reserved2; + u32 id_mapping_index; }; /* Values for Model field above */ From patchwork Wed Sep 27 01:20:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 114308 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4470911qgf; Tue, 26 Sep 2017 18:20:41 -0700 (PDT) X-Received: by 10.99.186.74 with SMTP id l10mr12982660pgu.355.1506475241294; Tue, 26 Sep 2017 18:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506475241; cv=none; d=google.com; s=arc-20160816; b=QgzPdPGHd2CyYJQzGCj9vp0oCjLO+HFOAqDVsEpmfOY6LhoMWKUkI32p83IhA2sFIU bJn43RVN3k0/G8ODs8jO+yR4DUAfrNSqO7+lcNSwo7x7c7knOljxqbnKNNHfIz3zdTHi qldinjbONw/9syj1J5P1nyXNFB/J/OsiG0IkobWKIPM9TEXd5W8DzRLQfWPlcAjdN8mN PvQdTjqo2zNK7ngCh59cxOto5eWDaxdvlgrsguzxciHZFSQuS6RyIg4ezSmrvt29N30L BI2Sd/CAL5LAUzaC+OVq3j/MX/5NouKeocUfox7l3Y0RaWUcaNodtIqq3YgI4Ijg6ZIY Uwww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=cTgx4RPAA3+0EwR7P22vSCQQoHC5+1z2RWIM8kSpqP4=; b=khY70+huFf1jLg6FsnbsqRzlwBgBOxyFhxa5m8GU7fYsx/W+ulF6Tg1btGfeH06pNc G5YtAlyZdNTv1fRr8Z7vCN47Pyv+5cQQ1UjXZTTJ0XSsC52cqMc8PD3ECd/q2V8Agbcv j5dI2RCvNkjzmRrgxbJmyIyUEi6uiJwo/sJSV+Sde8bjbioJJQ2f/HAtybOWP+5Anxnf pFb4fEk9WW84YHh0dcyE0qxW/r0CiNcsSeVc6H++ZwxHkY8IWve9Xg4OrZFTVZ9oiYT2 gKh9eXm8ykz1yf8OVbd/lzUPjwzJiFNPwLvhonrDcYyT8xSA9tcm8doQuGHjWkEOWltL k42A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JfolW63b; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si2494136pfa.558.2017.09.26.18.20.41; Tue, 26 Sep 2017 18:20:41 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JfolW63b; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969165AbdI0BUk (ORCPT + 7 others); Tue, 26 Sep 2017 21:20:40 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:45270 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965519AbdI0BUg (ORCPT ); Tue, 26 Sep 2017 21:20:36 -0400 Received: by mail-pf0-f177.google.com with SMTP id z84so6425359pfi.2 for ; Tue, 26 Sep 2017 18:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ojJWi4Yc3TKRLR22RpI+1MIaFbShgw5d8BS1Lu3Hxwk=; b=JfolW63brQrtrwyN/VKEt+dy8cumvDHxY1a4z6jOHFBP8hM2ikUw/uLloxZ/1TIqBU wjqrSZxsgxaK0aSK8orDT/NhiYmiNennObtZwSH9UcsRUS6KMBKQCCVFaOS2jtojmTOO nl9seL4NODvNoNfOPg2x2brNQK25huQON9Luc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ojJWi4Yc3TKRLR22RpI+1MIaFbShgw5d8BS1Lu3Hxwk=; b=dFr9bRjiBZ93jdRrugP73rk1Hxo0IiJyyvz2OrSnWnCqfC7owY7MMsvNzdyOYAL2Ce JAYco0rnUmy2U2MqojivntVE01tYnaL4h60tYiIbY9pgPo3WVDAzsZwEKoGR4d4iYTrE jRq5s2SV/Q5wL1AwBEErVi1JJh8zUk7UXwKMMmv26jo3/eMfTgIFTCFd3eEvh+8kKZcn m91sV9UqtDmKZr+iuUhyGiCsg25EIh0ogA/y231BTvJYq38WCkNhGmTtTq9ZqhFT+QAp 8+iWKTiWEX3IgNRQcxSiqhKy3MkECvYerJ5qOKyVliu/2ALPrf0jJcWh/DXRUMjQrrI2 H1Qg== X-Gm-Message-State: AHPjjUiHjR0cMWQ3ANi0ZcZFSSR3wTjF7hHhELSoE1piCP2XjxhA3bIb i1jZCVLIZRs4CWAiH58h76Xi0Q== X-Google-Smtp-Source: AOwi7QDM1XL5CgGOHDsShVW99KeNorRoefazHkCINFbhczWFe/1FpOW0WusN+22ArFzSw+uc1DrC7g== X-Received: by 10.99.164.81 with SMTP id c17mr12894272pgp.445.1506475235867; Tue, 26 Sep 2017 18:20:35 -0700 (PDT) Received: from localhost ([70.35.39.2]) by smtp.googlemail.com with ESMTPSA id r11sm18495718pfg.180.2017.09.26.18.20.35 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 18:20:35 -0700 (PDT) From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy Cc: "Rafael J. Wysocki" , Marc Zyngier , Lv Zheng , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Hanjun Guo Subject: [PATCH 2/4] ACPI: IORT: lookup iort node via fwnode Date: Wed, 27 Sep 2017 09:20:13 +0800 Message-Id: <1506475215-2731-3-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> References: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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.9.1 -- 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 9565d57..db71d7f 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 Sep 27 01:20:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 114309 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4470921qgf; Tue, 26 Sep 2017 18:20:42 -0700 (PDT) X-Received: by 10.159.204.147 with SMTP id t19mr12193896plo.7.1506475242099; Tue, 26 Sep 2017 18:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506475242; cv=none; d=google.com; s=arc-20160816; b=a/6EhgmIeL0JUUCWjZe1VBC5efM3pqz5XaXC5lxS6SORMuTn9ocWj6APeuOjMb8xbJ 63w3jJBmcDGgrWAQyKCmwrpc7EYQ10qGEYMyM8MP6F7SVFsIxN9PalWWM7bVDveeVnuY twozXumy5pS4+27/03DvAF0qvXUmONBVIHsP19XIdjRvybMEkVn4m7jcuFeFuBCbBiPy Pq/sMGHTFLMhddG9YfU8u1MCaul/rSBkeeYHdta9cxejrvHsss7DqX/1vScCxrzB8COJ QlzWCZY/LDS68uUwocXhPknpvoCAkbokOa7hzwMpAUmsR6SVv40pw330QoPf4F87L5XZ eWbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4YJIcV34J5NVqK3siQNtTvPd0umcVdI6fu96WxoIvOQ=; b=PwwzlNvd/isS0ODmcIqqns50BjIxItlQXj8Kbgnhprwtw40bRMpjhODGPkMmHx13NM KSE/uZ+je1xgRX9csqSvklpBeINPDsqHoahqATBbNwmGxHl2Y2phvXNzomx0iAmDXx8x 7p6LBalVIBmHklLfhZqnjVXIIAHDBRzVsgaNt1p9TCAsahayn9UY+QnY4onDrif4si8p /wf+3c2qM+REcEUWy39oo8zQKdMM6xTocBZH8BRHURmaV2L4O1WeXbYO0gWr435ez29K /FG5ciUNV9n60yMxqsAUGGRy4pYiKLSVkG6y38h9PEyUg8+Nep0UnaBkwKmVn7wraDRI kvgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B9aYNe3h; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si2494136pfa.558.2017.09.26.18.20.41; Tue, 26 Sep 2017 18:20:42 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B9aYNe3h; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965519AbdI0BUk (ORCPT + 7 others); Tue, 26 Sep 2017 21:20:40 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:47765 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969162AbdI0BUh (ORCPT ); Tue, 26 Sep 2017 21:20:37 -0400 Received: by mail-pg0-f45.google.com with SMTP id d8so6875389pgt.4 for ; Tue, 26 Sep 2017 18:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LCrVw/tMCQA9Z3zMu4C/+3jm0PyjF+UcxwnmGZ5oECs=; b=B9aYNe3hqoMHMHsNfFATvLVwb+YZIwDSKlP2POGCswd9YZ1IEeY2k9XdCc9opJ+BEA lO2aBcUx2F6ICA1lJ85cQOElEvoyJW9v5E98OfhiiaN/Ea5Ua9T399Xkk3Jd76Kt4bJa OOjYgtp+oNUDVGAsu1rqP3xS7gi8wyI1ctYG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LCrVw/tMCQA9Z3zMu4C/+3jm0PyjF+UcxwnmGZ5oECs=; b=Srx6NsXzDgEeHMFsVKuI85Y2YIU7XwSku/4UYlRQ0o9lIwrTpGVkQp00Fx44BHZuf2 KgvMZsvH6Mexh2ilsFZ4e9lrUA99ax+PxXFxAyXq48bfp2SFFZ1k2g2SgP2GnMAfl0Jz esw/n/WQZsam1NAX54pX695mBmrVmaJEuG/YodvbFFTOQ5M8Sgqn87aJBDt1n1AcZ1WD qc59DUBl1Pg5R/jBkEZU3pqeLQd0TDjdXAnUKDs4HrzBJXjRWtutP3bn5l1zO8aDAwUp dpSrpoUD3o+nfAaEsZN2fdxGFiiN4faey1V3YuFo6hz0Ll4P1lwbxj1mhBcYIJS5/g4B dgFQ== X-Gm-Message-State: AHPjjUjZsUqThD7yttrqczgPcL3ARnf0+fRMo0KnTMx7+q6Wu2j5x+B7 l0u6Ys3QyiifAD0JR/4paqbYlg== X-Google-Smtp-Source: AOwi7QDEzAqThiAjVuW/ET+0J8lct/4fBTp3u44ZU7qRpx0UpZJWET6FaIR+lt4yE3i31go7DcoUHA== X-Received: by 10.101.78.12 with SMTP id r12mr12634008pgt.289.1506475237381; Tue, 26 Sep 2017 18:20:37 -0700 (PDT) Received: from localhost ([70.35.39.2]) by smtp.googlemail.com with ESMTPSA id s27sm18510873pgo.59.2017.09.26.18.20.36 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 18:20:36 -0700 (PDT) From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy Cc: "Rafael J. Wysocki" , Marc Zyngier , Lv Zheng , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Hanjun Guo Subject: [PATCH 3/4] ACPI: IORT: Skip SMMUv3 device ID map for two steps mappings Date: Wed, 27 Sep 2017 09:20:14 +0800 Message-Id: <1506475215-2731-4-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> References: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 special 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. Introduce iort_get_id_mapping_index() to get the index then skip the map entry in iort_node_map_id(), also to get the dev ID directly for iort_pmsi_get_dev_id() for ITS platform MSI preparation. Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 64 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) -- 1.9.1 -- 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 db71d7f..1c1160e 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -357,7 +357,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; } @@ -366,6 +367,40 @@ struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, return NULL; } +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; + } +} + 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 +410,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) @@ -396,8 +431,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, error value + * returned for index will be an invalid value in practical. + */ + index = iort_get_id_mapping_index(node); + /* 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 (i == index) + continue; + if (!iort_id_map(map, node->type, id, &id)) break; } @@ -507,16 +553,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 Wed Sep 27 01:20:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 114310 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4470925qgf; Tue, 26 Sep 2017 18:20:42 -0700 (PDT) X-Received: by 10.99.6.79 with SMTP id 76mr12787993pgg.229.1506475242430; Tue, 26 Sep 2017 18:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506475242; cv=none; d=google.com; s=arc-20160816; b=bsy9ZReYHHO/u6VVhhwzfQ92CCa1prZ9Dyt4urhY+DSB6n/Yq2hcZiloDgW8ItxP7/ A5yPPjTi9GpXUU9yWa39QGK0DdvnuHV21kiC523Asj7FJ0AR25CcKNl30T01iy9mqVvQ 687sgoeFAC3oHEgZINYd9KOSj4/ZS/tWxRj/PxS6nw11n/VMCUjJoJPHd/Ptb4g0O5i3 V6WRoDhO30z3A+EbL3qsyNIxGQnGnLGe9BG+bgPsHcbKWcIY8B3UVgvnlcgh68/kv4Br exmw60f7CLcHKWRTTRlC4KjHWfC8SRrmZx7XCOXG3JvIK3IEE2157a1QlnB/fMm0hvpx o2Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=H6MM77SKR2EkaAiv+8xEZ8o99lyWHciX6ZFSWySs91M=; b=ifcwHk014j1MNQq8/znJFGp3VUXe41QdLcOny6ytX2AdcJxYrX072v2BzjWsvCQip5 NYhBFwyxXFH+D20N1kFe8Zou1kwtHhYL/Qa+yANLG0xP5Wez/sL/w1KpuCJ6dbzGilMx lOsRz6A+stRuVj9VyZMLBMCyeiV0XjFkhQfv4MilftyKi354FxtMvUcf85MgwsBz2r9w zUR9vJifW/qPHuQWtYder7JazJnaz34184KTxxLuRp2QbpOfwJ9TrSWtBOzITYsDSfcs IhFhqiuVS1Epbu6t2b+QZcth92y9Yz6Clzoj9aGrjU/W1DiX7PpSuVFKT9r9xdXIDknD 5HHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hn40YGet; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si2494136pfa.558.2017.09.26.18.20.42; Tue, 26 Sep 2017 18:20:42 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hn40YGet; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969162AbdI0BUl (ORCPT + 7 others); Tue, 26 Sep 2017 21:20:41 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:46472 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969164AbdI0BUj (ORCPT ); Tue, 26 Sep 2017 21:20:39 -0400 Received: by mail-pf0-f169.google.com with SMTP id r68so6420254pfj.3 for ; Tue, 26 Sep 2017 18:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JxUmcNWfBOvcuMFZHaNgUZ0HPgafnQxRqCK687y/6z4=; b=Hn40YGetDrbOfSRMAlLSLstitzC4/gOmaTsDrGQ9OAzgt42osf+qJbEp3t/yoD4Kul k45H3dbtrr7GhmWGhD5tn8etwRUXROfdg6j+H9fzTys1cvMfmgNRfeT8Jv0MFMYhT6C9 Y2CpRqoAoCTn5OkOD41PzRkFQloXDNSgUJs3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JxUmcNWfBOvcuMFZHaNgUZ0HPgafnQxRqCK687y/6z4=; b=gqGoAydTimXotfgAl966GnVUEogvVtu1vZZ+dwWjizbz/GIqFG438OjHyYadRj19rm A32gYr0Z94HtnA8jGw8/QFr11Mzc9DBHtAYUJ6CaNVV1LHt7ycptWMbgsGw9RjTSTrND 50cbMFoVsXAvbq0l4tUY5hZ9jCkZTHipzJiqCsyKjwDSngFzPKT4kfK/C6u1a3T2AHQT 3EmEM9XnQwk4jfh4wHDPhTyf5OWoK4Dm1Ue3+XvKIUVmy3Hgahrui4yfVJWzbC8NOvEQ +wmhe6PNjOvV4E4PYGyMTmXJUT5u/uFJbzg3Pt2KGwN41SH+z8gpSdRr9iwRVwQ+3Y+W XDRA== X-Gm-Message-State: AHPjjUg3Uql8kFMESoPMw/DzifEcTuZggxK9RLkVNK7S4C0dlcyGDULl KgsxOYO9TsWSw9/ncdvwIgkfuQ== X-Google-Smtp-Source: AOwi7QBUs2Gzx9fyPe5AYLypM/zUpIt0dA3D4+fbjkIUYOwOxfjtuEtdQ54WQPtvaHHQ1Ort4BoIoA== X-Received: by 10.99.115.93 with SMTP id d29mr13013319pgn.333.1506475239354; Tue, 26 Sep 2017 18:20:39 -0700 (PDT) Received: from localhost ([70.35.39.2]) by smtp.googlemail.com with ESMTPSA id p1sm18065617pfb.53.2017.09.26.18.20.38 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 18:20:38 -0700 (PDT) From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy Cc: "Rafael J. Wysocki" , Marc Zyngier , Lv Zheng , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Hanjun Guo Subject: [PATCH 4/4] ACPI: IORT: SMMUv3 nodes MSI support Date: Wed, 27 Sep 2017 09:20:15 +0800 Message-Id: <1506475215-2731-5-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> References: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Lorenzo Pieralisi Since we make single mappings valid for SMMUv3 (and PMCG), also we have a mapping index for SMMUv3 MSI, we can directly use that index to get the map entry, then retrieve ITS parent to add SMMUv3 MSI support. Introduce a new API iort_set_device_domain() to find the MSI domain for an SMMUv3 (or any other IORT table node) to reduce the complex of doing that via acpi_configure_pmsi_domain(). Signed-off-by: Lorenzo Pieralisi Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) -- 1.9.1 -- 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 1c1160e..06b38de 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -633,6 +633,49 @@ struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id) return irq_find_matching_fwnode(handle, DOMAIN_BUS_PCI_MSI); } +static void iort_set_device_domain(struct device *dev, + struct acpi_iort_node *node) +{ + struct acpi_iort_its_group *its; + struct acpi_iort_node *msi_parent; + struct acpi_iort_id_mapping *map; + struct fwnode_handle *iort_fwnode; + struct irq_domain *domain; + int index; + + index = iort_get_id_mapping_index(node); + if (index < 0) + return; + + map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, + node->mapping_offset + index * sizeof(*map)); + + /* Firmware bug! */ + if (!map->output_reference || + !(map->flags & ACPI_IORT_ID_SINGLE_MAPPING)) { + pr_err(FW_BUG "[node %p type %d] Invalid MSI mapping\n", + node, node->type); + return; + } + + msi_parent = ACPI_ADD_PTR(struct acpi_iort_node, iort_table, + map->output_reference); + + if (!msi_parent || msi_parent->type != ACPI_IORT_NODE_ITS_GROUP) + return; + + /* Move to ITS specific data */ + its = (struct acpi_iort_its_group *)msi_parent->node_data; + + iort_fwnode = iort_find_domain_token(its->identifiers[0]); + if (!iort_fwnode) + return; + + domain = irq_find_matching_fwnode(iort_fwnode, DOMAIN_BUS_PLATFORM_MSI); + if (domain) + dev_set_msi_domain(dev, domain); +} + /** * iort_get_platform_device_domain() - Find MSI domain related to a * platform device @@ -1259,6 +1302,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); + iort_set_device_domain(&pdev->dev, node); + ret = platform_device_add(pdev); if (ret) goto dma_deconfigure;