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;