From patchwork Wed Apr 12 05:21:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 97287 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp115451qgf; Tue, 11 Apr 2017 22:23:46 -0700 (PDT) X-Received: by 10.84.191.165 with SMTP id a34mr80663469pld.62.1491974625963; Tue, 11 Apr 2017 22:23:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u19si19128656plj.273.2017.04.11.22.23.45; Tue, 11 Apr 2017 22:23:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753017AbdDLFXj (ORCPT + 21 others); Wed, 12 Apr 2017 01:23:39 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:27299 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752781AbdDLFVr (ORCPT ); Wed, 12 Apr 2017 01:21:47 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3C5LYvH009700; Wed, 12 Apr 2017 00:21:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1491974494; bh=NqWW5lI1wxOb2L/zJHkiN/7zi61NA6sd8aQKC8gFx0w=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nKJqkqiDKtv/8cT2o5jGXzWH0UlMArtG3DTkbmEg52Zj6eQUK+7Ma23vYCV7fMOL6 /Q8xVk9fj7oopHvS/2smqnE2VhQVT/O0o0LuJCoi0q56grB+ClQhsvuqP+rl3M47+g 0TfuXXksc6wGlBwkiHOPfeB4/PAEr99Y3zNwES7w= Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LYhf027057; Wed, 12 Apr 2017 00:21:34 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Wed, 12 Apr 2017 00:21:34 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LYC6025854; Wed, 12 Apr 2017 00:21:34 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.83.68]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id v3C5LX304059; Wed, 12 Apr 2017 00:21:33 -0500 (CDT) From: Suman Anna To: Joerg Roedel CC: , Laurent Pinchart , Suman Anna , , Subject: [PATCH v3 1/7] iommu/omap: Register driver before setting IOMMU ops Date: Wed, 12 Apr 2017 00:21:26 -0500 Message-ID: <20170412052132.14406-2-s-anna@ti.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170412052132.14406-1-s-anna@ti.com> References: <20170412052132.14406-1-s-anna@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the registration of the OMAP IOMMU platform driver before setting the IOMMU callbacks on the platform bus. This causes the IOMMU devices to be probed first before the .add_device() callback is invoked for all registered devices, and allows the iommu_group support to be added to the OMAP IOMMU driver. While at this, also check for the return status from bus_set_iommu. Signed-off-by: Suman Anna --- v3: New patch drivers/iommu/omap-iommu.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) -- 2.12.0 diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index e2583cce2cc1..54556713c8d1 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1299,6 +1299,7 @@ static int __init omap_iommu_init(void) const unsigned long flags = SLAB_HWCACHE_ALIGN; size_t align = 1 << 10; /* L2 pagetable alignement */ struct device_node *np; + int ret; np = of_find_matching_node(NULL, omap_iommu_of_match); if (!np) @@ -1312,11 +1313,25 @@ static int __init omap_iommu_init(void) return -ENOMEM; iopte_cachep = p; - bus_set_iommu(&platform_bus_type, &omap_iommu_ops); - omap_iommu_debugfs_init(); - return platform_driver_register(&omap_iommu_driver); + ret = platform_driver_register(&omap_iommu_driver); + if (ret) { + pr_err("%s: failed to register driver\n", __func__); + goto fail_driver; + } + + ret = bus_set_iommu(&platform_bus_type, &omap_iommu_ops); + if (ret) + goto fail_bus; + + return 0; + +fail_bus: + platform_driver_unregister(&omap_iommu_driver); +fail_driver: + kmem_cache_destroy(iopte_cachep); + return ret; } subsys_initcall(omap_iommu_init); /* must be ready before omap3isp is probed */