From patchwork Thu Apr 14 17:25:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 8840181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED21FC0553 for ; Thu, 14 Apr 2016 17:26:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28462202F0 for ; Thu, 14 Apr 2016 17:26:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47F22200F3 for ; Thu, 14 Apr 2016 17:26:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aql0f-00074u-U3; Thu, 14 Apr 2016 17:24:53 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aqkzY-0006K6-TB for linux-arm-kernel@lists.infradead.org; Thu, 14 Apr 2016 17:23:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6B6FA5B1; Thu, 14 Apr 2016 10:22:10 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.203.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3BC0B3F25F; Thu, 14 Apr 2016 10:23:22 -0700 (PDT) From: Lorenzo Pieralisi To: iommu@lists.linux-foundation.org Subject: [RFC PATCH 07/11] drivers: iommu: arm-smmu: allow ACPI based streamid translation Date: Thu, 14 Apr 2016 18:25:39 +0100 Message-Id: <1460654743-7896-8-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1460654743-7896-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1460654743-7896-1-git-send-email-lorenzo.pieralisi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160414_102345_089251_3AAE24DF X-CRM114-Status: UNSURE ( 9.33 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.9 (-------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Lorenzo Pieralisi , Marc Zyngier , "Rafael J. Wysocki" , Joerg Roedel , Will Deacon , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Sinan Kaya , linux-acpi@vger.kernel.org, Hanjun Guo , Tomasz Nowicki , Robin Murphy , Jon Masters MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ACPI IORT table provides data to ARM IOMMU drivers to carry out streamid mappings and the kernel has the infrastructure to implement it through the fw_xlate() struct iommu_ops hook. By relying on the DT agnostic struct iommu_fwspec fields, this patch adds code in the ARM SMMU fw_xlate() callback that allows streamid translation on ACPI based ARM system. Signed-off-by: Lorenzo Pieralisi Cc: Will Deacon Cc: Robin Murphy --- drivers/iommu/arm-smmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 84bcff7..0f1e784 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1440,6 +1440,20 @@ out_unlock: return ret; } +static int arm_smmu_dev_node_match(struct device *dev, void *data) +{ + return is_fwnode_iommu(dev->fwnode) && dev->fwnode == data; +} + +static struct platform_device *arm_smmu_get_dev(struct fwnode_handle *fwnode) +{ + struct device *dev; + + dev = bus_find_device(&platform_bus_type, NULL, fwnode, + arm_smmu_dev_node_match); + return dev ? to_platform_device(dev) : NULL; +} + static int arm_smmu_fw_xlate(struct device *dev, struct iommu_fwspec *args) { struct arm_smmu_device *smmu; @@ -1447,6 +1461,8 @@ static int arm_smmu_fw_xlate(struct device *dev, struct iommu_fwspec *args) if (is_of_node(args->fwnode)) smmu_pdev = of_find_device_by_node(to_of_node(args->fwnode)); + else if (is_fwnode_iommu(args->fwnode)) + smmu_pdev = arm_smmu_get_dev(args->fwnode); if (!smmu_pdev) return -ENODEV;