From patchwork Wed Apr 12 05:21:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 97281 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp114964qgf; Tue, 11 Apr 2017 22:21:46 -0700 (PDT) X-Received: by 10.98.151.10 with SMTP id n10mr27060763pfe.67.1491974506206; Tue, 11 Apr 2017 22:21:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z95si8495582plh.321.2017.04.11.22.21.46; Tue, 11 Apr 2017 22:21:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752170AbdDLFVo (ORCPT + 3 others); Wed, 12 Apr 2017 01:21:44 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:51960 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752010AbdDLFVm (ORCPT ); Wed, 12 Apr 2017 01:21:42 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3C5LYNG013781; 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=dh+UBFA5kvBnDh7kj9Enttdg973T25BlaXUQwT3/VXg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=diSaRX6SGn5UyJaNWty+y8PvNlP4frvWT3POVdAKIwc5RVsb+YYPQRs9X3JUjZ+Wu pVnXL+/13brOY0O8+gtwyLfKI5y++RN+n7Vt5Ggtyx0gswqxkPI5FC503fdVgRdGXl vaXO6fz8qP5cH2nCFhzVnlhHaLeBY6CgJMCXXkcA= Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LY9g027063; Wed, 12 Apr 2017 00:21:34 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) 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 dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LYWK028110; 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 v3C5LY304063; Wed, 12 Apr 2017 00:21:34 -0500 (CDT) From: Suman Anna To: Joerg Roedel CC: , Laurent Pinchart , Suman Anna , , Subject: [PATCH v3 2/7] iommu/omap: Drop legacy-style device support Date: Wed, 12 Apr 2017 00:21:27 -0500 Message-ID: <20170412052132.14406-3-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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org All the supported boards that have OMAP IOMMU devices do support DT boot only now. So, drop the support for the non-DT legacy-style devices from the OMAP IOMMU driver. Couple of the fields from the iommu platform data would no longer be required, so they have also been cleaned up. The IOMMU platform data is still needed though for performing reset management properly in a multi-arch environment. Signed-off-by: Suman Anna --- v3: New patch drivers/iommu/omap-iommu.c | 30 ++++++++++++++---------------- include/linux/platform_data/iommu-omap.h | 3 --- 2 files changed, 14 insertions(+), 19 deletions(-) -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 54556713c8d1..febd4fbe3445 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -928,28 +928,26 @@ static int omap_iommu_probe(struct platform_device *pdev) int irq; struct omap_iommu *obj; struct resource *res; - struct iommu_platform_data *pdata = dev_get_platdata(&pdev->dev); struct device_node *of = pdev->dev.of_node; + if (!of) { + pr_err("%s: only DT-based devices are supported\n", __func__); + return -ENODEV; + } + obj = devm_kzalloc(&pdev->dev, sizeof(*obj) + MMU_REG_SIZE, GFP_KERNEL); if (!obj) return -ENOMEM; - if (of) { - obj->name = dev_name(&pdev->dev); - obj->nr_tlb_entries = 32; - err = of_property_read_u32(of, "ti,#tlb-entries", - &obj->nr_tlb_entries); - if (err && err != -EINVAL) - return err; - if (obj->nr_tlb_entries != 32 && obj->nr_tlb_entries != 8) - return -EINVAL; - if (of_find_property(of, "ti,iommu-bus-err-back", NULL)) - obj->has_bus_err_back = MMU_GP_REG_BUS_ERR_BACK_EN; - } else { - obj->nr_tlb_entries = pdata->nr_tlb_entries; - obj->name = pdata->name; - } + obj->name = dev_name(&pdev->dev); + obj->nr_tlb_entries = 32; + err = of_property_read_u32(of, "ti,#tlb-entries", &obj->nr_tlb_entries); + if (err && err != -EINVAL) + return err; + if (obj->nr_tlb_entries != 32 && obj->nr_tlb_entries != 8) + return -EINVAL; + if (of_find_property(of, "ti,iommu-bus-err-back", NULL)) + obj->has_bus_err_back = MMU_GP_REG_BUS_ERR_BACK_EN; obj->dev = &pdev->dev; obj->ctx = (void *)obj + sizeof(*obj); diff --git a/include/linux/platform_data/iommu-omap.h b/include/linux/platform_data/iommu-omap.h index 0496d171700a..a40fc0f4f9de 100644 --- a/include/linux/platform_data/iommu-omap.h +++ b/include/linux/platform_data/iommu-omap.h @@ -30,10 +30,7 @@ struct omap_iommu_arch_data { }; struct iommu_platform_data { - const char *name; const char *reset_name; - int nr_tlb_entries; - int (*assert_reset)(struct platform_device *pdev, const char *name); int (*deassert_reset)(struct platform_device *pdev, const char *name); }; From patchwork Wed Apr 12 05:21:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 97288 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp115500qgf; Tue, 11 Apr 2017 22:23:59 -0700 (PDT) X-Received: by 10.99.96.72 with SMTP id u69mr65836528pgb.194.1491974639743; Tue, 11 Apr 2017 22:23:59 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si19136409pli.193.2017.04.11.22.23.59; Tue, 11 Apr 2017 22:23:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752458AbdDLFX5 (ORCPT + 3 others); Wed, 12 Apr 2017 01:23:57 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:51970 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752633AbdDLFVo (ORCPT ); Wed, 12 Apr 2017 01:21:44 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3C5LZUh013789; Wed, 12 Apr 2017 00:21:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1491974495; bh=w0wB9TdjGxXc+K7gM633DHN9redQP5eZU/zStzLPu7E=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=iLEiBQuMsDP5Ub2bAp01r8uc/8WM+ETqYtUjpbBzYAwAh9kmNbbIN2roDEeYJlvRw EuAqYr0SSj6HJ+ME31b7YXJblEdhDMJXWiQJYUjRxGPe81yrjN3ykEicH451qHwOMz zRnRASIpLgilrRzdOsBSv2suiKPTSaeZKF5omhHg= Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LZl5027075; Wed, 12 Apr 2017 00:21:35 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) 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 dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LYxM007603; 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 v3C5LY304075; Wed, 12 Apr 2017 00:21:34 -0500 (CDT) From: Suman Anna To: Joerg Roedel CC: , Laurent Pinchart , Suman Anna , , , Joerg Roedel Subject: [PATCH v3 5/7] iommu/omap: Make use of 'struct iommu_device' Date: Wed, 12 Apr 2017 00:21:30 -0500 Message-ID: <20170412052132.14406-6-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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Joerg Roedel Modify the driver to register individual iommus and establish links between devices and iommus in sysfs. Signed-off-by: Joerg Roedel [s-anna@ti.com: fix some cleanup issues during failures] Signed-off-by: Suman Anna --- v3 w.r.t v1: - moved the iommu_device calls in probe above the pm_runtime API invocations to simplify cleanup - added the cleanup on iommu_device_register() failure (code moved from patch 5 from v1) - arch_data also freed upon iommu_device_link failure in add_device drivers/iommu/omap-iommu.c | 30 ++++++++++++++++++++++++++++++ drivers/iommu/omap-iommu.h | 2 ++ 2 files changed, 32 insertions(+) -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 0553b0381e2a..ef44fc740da7 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -36,6 +36,8 @@ #include "omap-iopgtable.h" #include "omap-iommu.h" +static const struct iommu_ops omap_iommu_ops; + #define to_iommu(dev) \ ((struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))) @@ -941,6 +943,16 @@ static int omap_iommu_probe(struct platform_device *pdev) return err; platform_set_drvdata(pdev, obj); + err = iommu_device_sysfs_add(&obj->iommu, obj->dev, NULL, obj->name); + if (err) + return err; + + iommu_device_set_ops(&obj->iommu, &omap_iommu_ops); + + err = iommu_device_register(&obj->iommu); + if (err) + goto out_sysfs; + pm_runtime_irq_safe(obj->dev); pm_runtime_enable(obj->dev); @@ -948,12 +960,19 @@ static int omap_iommu_probe(struct platform_device *pdev) dev_info(&pdev->dev, "%s registered\n", obj->name); return 0; + +out_sysfs: + iommu_device_sysfs_remove(&obj->iommu); + return err; } static int omap_iommu_remove(struct platform_device *pdev) { struct omap_iommu *obj = platform_get_drvdata(pdev); + iommu_device_sysfs_remove(&obj->iommu); + iommu_device_unregister(&obj->iommu); + omap_iommu_debugfs_remove(obj); pm_runtime_disable(obj->dev); @@ -1200,6 +1219,7 @@ static int omap_iommu_add_device(struct device *dev) struct omap_iommu *oiommu; struct device_node *np; struct platform_device *pdev; + int ret; /* * Allocate the archdata iommu structure for DT-based devices. @@ -1232,6 +1252,13 @@ static int omap_iommu_add_device(struct device *dev) return -ENOMEM; } + ret = iommu_device_link(&oiommu->iommu, dev); + if (ret) { + kfree(arch_data); + of_node_put(np); + return ret; + } + arch_data->iommu_dev = oiommu; dev->archdata.iommu = arch_data; @@ -1247,8 +1274,11 @@ static void omap_iommu_remove_device(struct device *dev) if (!dev->of_node || !arch_data) return; + iommu_device_unlink(&arch_data->iommu_dev->iommu, dev); + dev->archdata.iommu = NULL; kfree(arch_data); + } static const struct iommu_ops omap_iommu_ops = { diff --git a/drivers/iommu/omap-iommu.h b/drivers/iommu/omap-iommu.h index f81184b549ec..758958a4712c 100644 --- a/drivers/iommu/omap-iommu.h +++ b/drivers/iommu/omap-iommu.h @@ -68,6 +68,8 @@ struct omap_iommu { int has_bus_err_back; u32 id; + + struct iommu_device iommu; }; /** From patchwork Wed Apr 12 05:21:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 97284 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp115179qgf; Tue, 11 Apr 2017 22:22:35 -0700 (PDT) X-Received: by 10.84.195.1 with SMTP id i1mr79625640pld.175.1491974555241; Tue, 11 Apr 2017 22:22:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 188si19158465pgj.71.2017.04.11.22.22.35; Tue, 11 Apr 2017 22:22:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751374AbdDLFWa (ORCPT + 3 others); Wed, 12 Apr 2017 01:22:30 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:11697 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753085AbdDLFW1 (ORCPT ); Wed, 12 Apr 2017 01:22:27 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3C5LenS021509; Wed, 12 Apr 2017 00:21:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1491974500; bh=UBjF9VOtK/w4Svof5bZrgSrXokdYEpH6A7zh0NPrIzI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Mg/3+hMPLeHpoRjiw7feJ1aWgrJx6Vi63Hi1LD+UmgIiF0JNYIgnhI6zKesKgDItm PhLwFq13n64joheS8ba6OHqPiuPOV6IiPpGx1+FUGiDn2HnOo7MMOKY/oEm8KBN9Pi xtEWwMjkeTZYO7s6hILyZv1dUY0O78ltFDe1S7WY= Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LZdn027078; Wed, 12 Apr 2017 00:21:35 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) 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 dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3C5LZVa017114; Wed, 12 Apr 2017 00:21:35 -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 v3C5LZ304083; Wed, 12 Apr 2017 00:21:35 -0500 (CDT) From: Suman Anna To: Joerg Roedel CC: , Laurent Pinchart , Suman Anna , , Subject: [PATCH v3 7/7] [media] omap3isp: Remove iommu_group related code Date: Wed, 12 Apr 2017 00:21:32 -0500 Message-ID: <20170412052132.14406-8-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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The OMAP IOMMU driver has added the support for IOMMU groups internally, and the ISP device is automatically linked to the appropriate IOMMU group. So, remove the explicit function calls that creates/deletes an iommu_group and adds the ISP device to this group. Cc: Laurent Pinchart Signed-off-by: Suman Anna --- v3: new patch drivers/media/platform/omap3isp/isp.c | 17 ----------------- drivers/media/platform/omap3isp/isp.h | 1 - 2 files changed, 18 deletions(-) -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 084ecf4aa9a4..0d984a28a003 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1943,30 +1943,13 @@ static void isp_detach_iommu(struct isp_device *isp) { arm_iommu_release_mapping(isp->mapping); isp->mapping = NULL; - iommu_group_remove_device(isp->dev); } static int isp_attach_iommu(struct isp_device *isp) { struct dma_iommu_mapping *mapping; - struct iommu_group *group; int ret; - /* Create a device group and add the device to it. */ - group = iommu_group_alloc(); - if (IS_ERR(group)) { - dev_err(isp->dev, "failed to allocate IOMMU group\n"); - return PTR_ERR(group); - } - - ret = iommu_group_add_device(group, isp->dev); - iommu_group_put(group); - - if (ret < 0) { - dev_err(isp->dev, "failed to add device to IPMMU group\n"); - return ret; - } - /* * Create the ARM mapping, used by the ARM DMA mapping core to allocate * VAs. This will allocate a corresponding IOMMU domain. diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h index 7e6f6638433b..2f2ae609c548 100644 --- a/drivers/media/platform/omap3isp/isp.h +++ b/drivers/media/platform/omap3isp/isp.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include