Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp631482ybz; Wed, 29 Apr 2020 06:42:30 -0700 (PDT) X-Google-Smtp-Source: APiQypLTzJAs1zavqZxAemLDnfz7CH85/8EhCi/CTmTU+/L3XqQG+uBFQcW+w6yomqXCUxhFhoAv X-Received: by 2002:a17:906:3492:: with SMTP id g18mr2530557ejb.112.1588167749870; Wed, 29 Apr 2020 06:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588167749; cv=none; d=google.com; s=arc-20160816; b=iZDEAdrKtRhEvSLUfDtkLme0I8zpBbo+qsoVgrHXXX2JVUN7Pfwnjyd+8WXTh3CqS4 xfyTh17XaNwrHhdmh4ACmW3KwMYOoXvUcZWn65BKpedS/v1cwXg++RgnkNDkKVeLt3Ic TLdAruKDkpzkdHL2o5rr9RzFhLq9h211YHYJkxttkuV8kyGUcZo0+2xJsJlJMxsCGEMk sRA7d16lElFSEyVROZm8sx1bMrtoJFVEwTWKsETfoE2YoJIi7OquW7/ENC9NYfIsrqNs nfI93BwTKZquwLlaSxhbhpNzMXd4FHYkHjWwxu9qreUBNCOx4dAaji0GaOVZNU/js2bk ytWA== 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=R14dpopxU1+71l9KPXA8mEnokBzhrXW/HtbqMpv1HZk=; b=e2ss8nMssIAZQ5xW+8tMsTUW2lueiuxlpNMBO3YwUug0Ei2RZfSxj8WxSaDlQnEVJH vOwvJ5lWf/zAHhXmPH1JcpwBDUzUfd54FbVnGtqovPJ+IAlmf4zGYQgMISxoh3GAgadw xqY8tY2ROnSyAKa+Kwlxc9zdh8SNtZAsjwwJrpJT7kEX1Ud6cXlOhe5sWLbmhaAwVgWm YB3+gRxkIN0++nleMxYE7qBzCl9HaEhwEbs7MUF1V82JqzNteDFV6fP4liuP1JaQiVFd tYxyZkSingLP6lM3EZShDW3jxQIWjeLzDyhfHvdrahr71XyDeYlDN7lgV5Z2GyRDjkoD moOw== 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 j34si3297793edc.516.2020.04.29.06.42.06; Wed, 29 Apr 2020 06:42:29 -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 S1728112AbgD2NiC (ORCPT + 99 others); Wed, 29 Apr 2020 09:38:02 -0400 Received: from 8bytes.org ([81.169.241.247]:39874 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728032AbgD2Nhw (ORCPT ); Wed, 29 Apr 2020 09:37:52 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 7A310F07; 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 27/34] iommu/renesas: Convert to probe/release_device() call-backs Date: Wed, 29 Apr 2020 15:37:05 +0200 Message-Id: <20200429133712.31431-28-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 Renesas 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/ipmmu-vmsa.c | 60 +++++++++++++------------------------- 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 310cf09feea3..fb7e702dee23 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -805,24 +805,8 @@ static int ipmmu_of_xlate(struct device *dev, static int ipmmu_init_arm_mapping(struct device *dev) { struct ipmmu_vmsa_device *mmu = to_ipmmu(dev); - 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(dev, "Failed to allocate IOMMU group\n"); - return PTR_ERR(group); - } - - ret = iommu_group_add_device(group, dev); - iommu_group_put(group); - - if (ret < 0) { - dev_err(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. @@ -856,48 +840,39 @@ static int ipmmu_init_arm_mapping(struct device *dev) return 0; error: - iommu_group_remove_device(dev); if (mmu->mapping) arm_iommu_release_mapping(mmu->mapping); return ret; } -static int ipmmu_add_device(struct device *dev) +static struct iommu_device *ipmmu_probe_device(struct device *dev) { struct ipmmu_vmsa_device *mmu = to_ipmmu(dev); - struct iommu_group *group; - int ret; /* * Only let through devices that have been verified in xlate() */ if (!mmu) - return -ENODEV; + return ERR_PTR(-ENODEV); - if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA)) { - ret = ipmmu_init_arm_mapping(dev); - if (ret) - return ret; - } else { - group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + return &mmu->iommu; +} - iommu_group_put(group); - } +static void ipmmu_probe_finalize(struct device *dev) +{ + int ret = 0; - iommu_device_link(&mmu->iommu, dev); - return 0; + if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA)) + ret = ipmmu_init_arm_mapping(dev); + + if (ret) + dev_err(dev, "Can't create IOMMU mapping - DMA-OPS will not work\n"); } -static void ipmmu_remove_device(struct device *dev) +static void ipmmu_release_device(struct device *dev) { - struct ipmmu_vmsa_device *mmu = to_ipmmu(dev); - - iommu_device_unlink(&mmu->iommu, dev); arm_iommu_detach_device(dev); - iommu_group_remove_device(dev); } static struct iommu_group *ipmmu_find_group(struct device *dev) @@ -925,9 +900,14 @@ static const struct iommu_ops ipmmu_ops = { .flush_iotlb_all = ipmmu_flush_iotlb_all, .iotlb_sync = ipmmu_iotlb_sync, .iova_to_phys = ipmmu_iova_to_phys, - .add_device = ipmmu_add_device, - .remove_device = ipmmu_remove_device, + .probe_device = ipmmu_probe_device, + .release_device = ipmmu_release_device, + .probe_finalize = ipmmu_probe_finalize, +#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA) + .device_group = generic_device_group, +#else .device_group = ipmmu_find_group, +#endif .pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K, .of_xlate = ipmmu_of_xlate, }; -- 2.17.1