From patchwork Fri Jul 17 16:53:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 6818071 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 BCB02C05AC for ; Fri, 17 Jul 2015 16:56:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D57D3207BD for ; Fri, 17 Jul 2015 16:56:45 +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 00036207B2 for ; Fri, 17 Jul 2015 16:56:44 +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 1ZG8ty-0001tI-2x; Fri, 17 Jul 2015 16:54:22 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZG8td-0001jR-9N for linux-arm-kernel@lists.infradead.org; Fri, 17 Jul 2015 16:54:02 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 931F01405E8; Fri, 17 Jul 2015 16:53:42 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 827031405EB; Fri, 17 Jul 2015 16:53:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from blr-ubuntu-32.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5C6781405E8; Fri, 17 Jul 2015 16:53:39 +0000 (UTC) From: Sricharan R To: linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, will.deacon@arm.com, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, mitchelh@codeaurora.org Subject: [RFC PATCH 2/4] iommu/arm-smmu: Add xlate callback for initializing master devices from dt Date: Fri, 17 Jul 2015 22:23:23 +0530 Message-Id: <1437152005-25092-3-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1437152005-25092-1-git-send-email-sricharan@codeaurora.org> References: <1437152005-25092-1-git-send-email-sricharan@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150717_095401_390546_0462251D X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -3.1 (---) 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: sricharan@codeaurora.org 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 This adds of_xlate callback to arm-smmu driver. xlate callback is called during device registration from DT for those master devices attached to iommus using generic iommu bindings. Signed-off-by: Sricharan R --- drivers/iommu/arm-smmu.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 8c4eb43..2cf65ab 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -321,6 +321,7 @@ struct arm_smmu_device { unsigned int *irqs; struct list_head list; + struct device_node *node; struct rb_root masters; }; @@ -1434,6 +1435,38 @@ out_unlock: return ret; } +static int arm_smmu_of_xlate(struct device *dev, + struct of_phandle_args *spec) +{ + struct arm_smmu_device *smmu; + struct arm_smmu_master *master; + int streamid; + + spin_lock(&arm_smmu_devices_lock); + list_for_each_entry(smmu, &arm_smmu_devices, list) { + if (smmu->node == spec->np) + break; + } + spin_unlock(&arm_smmu_devices_lock); + + if (!smmu || (smmu->node != spec->np)) + return -ENODEV; + + spec->np = dev->of_node; + + master = find_smmu_master(smmu, spec->np); + if (!master) { + if (register_smmu_master(smmu, smmu->dev, spec)) + return -ENODEV; + } else { + streamid = master->cfg.num_streamids; + master->cfg.streamids[streamid] = spec->args[0]; + master->cfg.num_streamids++; + } + + return 0; +} + static struct iommu_ops arm_smmu_ops = { .capable = arm_smmu_capable, .domain_init = arm_smmu_domain_init, @@ -1449,6 +1482,7 @@ static struct iommu_ops arm_smmu_ops = { .domain_get_attr = arm_smmu_domain_get_attr, .domain_set_attr = arm_smmu_domain_set_attr, .pgsize_bitmap = -1UL, /* Restricted during device attach */ + .of_xlate = arm_smmu_of_xlate, }; static void arm_smmu_device_reset(struct arm_smmu_device *smmu) @@ -1782,6 +1816,8 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev) } } + smmu->node = dev->of_node; + INIT_LIST_HEAD(&smmu->list); spin_lock(&arm_smmu_devices_lock); list_add(&smmu->list, &arm_smmu_devices);