Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp632231ybz; Wed, 29 Apr 2020 06:43:15 -0700 (PDT) X-Google-Smtp-Source: APiQypKv3sa0Kkq7XV7beK7W7sdkq2qiP9LW34btKeKJ1z2VAgLCKkmXXZ1r9fGGm73suI9U2FW8 X-Received: by 2002:a17:906:359b:: with SMTP id o27mr2708096ejb.282.1588167795572; Wed, 29 Apr 2020 06:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588167795; cv=none; d=google.com; s=arc-20160816; b=DTNQCHBemhLak/ChcPXt57fZ8oQaPpI0D0lEb8q7Eflw56nAxsbP3GyUp/xjd57IoU C+/2yNayzuyiwH10G9lcWf7oI/n166FbICnRDK+t9w8VMQZ0x41H4ueekI3BWoPyB1f0 /PGfMyT3AMxuwmz3eMOiCQ/O9smVphLOIQc8VUKzckQTb/nNauj/CrZm+MrHXdvDp55o LaagU1eYRwSN7PZTk1IYbUCwsrDm6w90kq1LzYQuQHcuTH0xX3uRBFiRVTii4uGA/DBW F9F6rsyIvPI0m4zrBEbomU5ZCtuGGZVEtAAUuUsedFb7a303AZ2zSH/QsgdKx1zbqyB6 sB4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=8OMS5OZF40NZgo4ES6TI/qsxM9U8is/bDK/hFu3h9Ds=; b=jBLlNkY7bNfPJQ3QrzaYVhlTJFnkEgJk9jvLgVXCTLUCEailGTlT12qxHjjQa8y3rS ukERn9BnSdanMBE+9U0+CvlAUMB4bJ5VNluOcIxILChk1UL+G3TPwQv2FQC04PtXF7hw SjpW2p/V+Z+jQdcMk/QI1fZRCk5z2+uoqBCZIQdqPnyZ/felRzlvNbGJ3A32nusww615 cjp3g371waKgy6SbFa7sjKTMI/EXTRADZYSalu1Bu/4+C5msfAEepCAd6ctVr38BjlMr kP4lRKHZ8KJ3bL5TFNEmGLgKbLRl0RfH0Htia/yrh4lRINr4F6DtKoYnUQZ5dlG6GPmR CtoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u7si3864529edp.132.2020.04.29.06.42.51; Wed, 29 Apr 2020 06:43:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728253AbgD2Niq (ORCPT + 99 others); Wed, 29 Apr 2020 09:38:46 -0400 Received: from 8bytes.org ([81.169.241.247]:40166 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727965AbgD2Nhy (ORCPT ); Wed, 29 Apr 2020 09:37:54 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id D7F8BF09; Wed, 29 Apr 2020 15:37:40 +0200 (CEST) From: Joerg Roedel To: Joerg Roedel , Will Deacon , Robin Murphy , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , David Woodhouse , Lu Baolu , Andy Gross , Bjorn Andersson , Matthias Brugger , Rob Clark , Heiko Stuebner , Gerald Schaefer , Thierry Reding , Jonathan Hunter , Jean-Philippe Brucker Cc: Daniel Drake , jonathan.derrick@intel.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel Subject: [PATCH v3 29/34] iommu/omap: Convert to probe/release_device() call-backs Date: Wed, 29 Apr 2020 15:37:07 +0200 Message-Id: <20200429133712.31431-30-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429133712.31431-1-joro@8bytes.org> References: <20200429133712.31431-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Convert the OMAP IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 49 ++++++++++---------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index ecc9d0829a91..6699fe6d9e06 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1640,15 +1640,13 @@ static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain *domain, return ret; } -static int omap_iommu_add_device(struct device *dev) +static struct iommu_device *omap_iommu_probe_device(struct device *dev) { struct omap_iommu_arch_data *arch_data, *tmp; + struct platform_device *pdev; struct omap_iommu *oiommu; - struct iommu_group *group; struct device_node *np; - struct platform_device *pdev; int num_iommus, i; - int ret; /* * Allocate the archdata iommu structure for DT-based devices. @@ -1657,7 +1655,7 @@ static int omap_iommu_add_device(struct device *dev) * IOMMU users. */ if (!dev->of_node) - return 0; + return ERR_PTR(-ENODEV); /* * retrieve the count of IOMMU nodes using phandle size as element size @@ -1670,27 +1668,27 @@ static int omap_iommu_add_device(struct device *dev) arch_data = kcalloc(num_iommus + 1, sizeof(*arch_data), GFP_KERNEL); if (!arch_data) - return -ENOMEM; + return ERR_PTR(-ENOMEM); for (i = 0, tmp = arch_data; i < num_iommus; i++, tmp++) { np = of_parse_phandle(dev->of_node, "iommus", i); if (!np) { kfree(arch_data); - return -EINVAL; + return ERR_PTR(-EINVAL); } pdev = of_find_device_by_node(np); if (!pdev) { of_node_put(np); kfree(arch_data); - return -ENODEV; + return ERR_PTR(-ENODEV); } oiommu = platform_get_drvdata(pdev); if (!oiommu) { of_node_put(np); kfree(arch_data); - return -EINVAL; + return ERR_PTR(-EINVAL); } tmp->iommu_dev = oiommu; @@ -1699,46 +1697,25 @@ static int omap_iommu_add_device(struct device *dev) of_node_put(np); } + dev->archdata.iommu = arch_data; + /* * use the first IOMMU alone for the sysfs device linking. * TODO: Evaluate if a single iommu_group needs to be * maintained for both IOMMUs */ oiommu = arch_data->iommu_dev; - ret = iommu_device_link(&oiommu->iommu, dev); - if (ret) { - kfree(arch_data); - return ret; - } - - dev->archdata.iommu = arch_data; - - /* - * IOMMU group initialization calls into omap_iommu_device_group, which - * needs a valid dev->archdata.iommu pointer - */ - group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) { - iommu_device_unlink(&oiommu->iommu, dev); - dev->archdata.iommu = NULL; - kfree(arch_data); - return PTR_ERR(group); - } - iommu_group_put(group); - return 0; + return &oiommu->iommu; } -static void omap_iommu_remove_device(struct device *dev) +static void omap_iommu_release_device(struct device *dev) { struct omap_iommu_arch_data *arch_data = dev->archdata.iommu; if (!dev->of_node || !arch_data) return; - iommu_device_unlink(&arch_data->iommu_dev->iommu, dev); - iommu_group_remove_device(dev); - dev->archdata.iommu = NULL; kfree(arch_data); @@ -1763,8 +1740,8 @@ static const struct iommu_ops omap_iommu_ops = { .map = omap_iommu_map, .unmap = omap_iommu_unmap, .iova_to_phys = omap_iommu_iova_to_phys, - .add_device = omap_iommu_add_device, - .remove_device = omap_iommu_remove_device, + .probe_device = omap_iommu_probe_device, + .release_device = omap_iommu_release_device, .device_group = omap_iommu_device_group, .pgsize_bitmap = OMAP_IOMMU_PGSIZES, }; -- 2.17.1