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;