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: 9972903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A607C60365 for ; Wed, 27 Sep 2017 01:33:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9115728D54 for ; Wed, 27 Sep 2017 01:33:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8529128FEE; Wed, 27 Sep 2017 01:33:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9719E2903E for ; Wed, 27 Sep 2017 01:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vYud6xsJZVlrfm6kqygn3efl7N+StybWCkom+hk0Qg8=; b=bZtX/PXFrm3VnwDHNxNnWYIUXW fTnvNkSmyQ0tmIf7K1tidsGQrR18gBQ+VRUcncwraOqJ3mJYrk+p78CRhwlD8uKlWcBJLK2zzVe0S Y1PtcxrKp5/1jit4S5vkaZR4rCPRGVHJ+FKljTNWQLpxIgVA1Plg00JbQNSBUcxZ/zAlULjDRN/7G rHk+ElTDLFjtjpkzmKT4Vtxc8xUfC39nPWcBHk/u8eA+lmcJa2miCy76/zNGfu3pu/vqNo+6uru5j GF9o0Y5t+yP+DPgz1UpGY8F4ivLZ7fNawRnGAqEvltuhP2Vg+gs+bj6MWIdlh66mz8yh0xRcU7acF m9aRR3AA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dx1EL-0001lS-2w; Wed, 27 Sep 2017 01:33:41 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dx120-0002HD-NU for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2017 01:21:01 +0000 Received: by mail-pf0-x22f.google.com with SMTP id n24so6419923pfk.5 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=FhjxXRSpgGpGI8PGHPHpi8WKO27LUlG3rOzdTzQnKz7AZOarA1C2DjtaCEELG6iLD/ h27QDtGXMpYDEiWmw1jA3bZNIK1q7bWkyBTzfBCE5MnVn66f33AxwgcaNyVKofzXAi3p CeLRFMj2FiR2xTJdb/3pAc1zI/H26O8bZ9SvXxjQ0+OvUPWguiOFGVNVE/G/HFrvN6bV tPxefs1agtKjBbx1hpcRNqqOtaetRafevLWDTjwMiExbwR6ps2xu/R7LMVrb+iK33asb d6SW9U2tXlxhwL5bV5PvKyE/W7hn71P+/rwnlYa2HY658RpbKPI2zULLqXA+dErdSJOT Dx1w== X-Gm-Message-State: AHPjjUgFslnwUz1dqs+j2YOqVrbpSACava6kXg3zJUK/D68TOAW2GqLK AJ6noz4RhUDRftzzdAfayFbgKA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170926_182056_856483_B48FD731 X-CRM114-Status: GOOD ( 15.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , "Rafael J. Wysocki" , linuxarm@huawei.com, linux-acpi@vger.kernel.org, Lv Zheng , linux-arm-kernel@lists.infradead.org, Hanjun Guo MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;