From patchwork Tue Nov 21 14:02:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 119362 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp5133166edl; Tue, 21 Nov 2017 06:03:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMYMm+iQSQ29baMbVdjgGA6fU4coknWZjcFivyUtFW7v51KCPUJirgMBwmmlVaXN7VHiOUlk X-Received: by 10.99.127.87 with SMTP id p23mr16283477pgn.400.1511273005823; Tue, 21 Nov 2017 06:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511273005; cv=none; d=google.com; s=arc-20160816; b=0FDB69pwaTyoQtJGIEYhUaR/KfU7bC0bjk1RWz4CMXhNBbwvdJiMz2/Pi8UqOKBYZZ VP08JoU0Q8Vnctu3YEi2SqYc8t28gEh7vcSevImQPZ0ULF75okioeP9pVvA3r1yO8kzg 1UYzPQCp+La7MM6hum2dybg2W3xeoTj9NQ+tTYfIdNg5QoUtKNe9WM97jGwWKGjpjYXm G5YfjTPAUR8QPmOYrdhNyq13NIcyy4g6FHfZ7tG4+02CwCxAKWexjzQ3aJSxZHGdmoqm WgSFcV7eiV/5OHCsKsw8PsRxIwfSD/8VA1BdxIr69ntDqtk3zb2tq+68maeDmiTnp9kx gIqA== 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:arc-authentication-results; bh=QQXM1zVwFsVvbvTsiatP9iaJYq5LdDQHat+NrcYOa+c=; b=nhq2v0+oZluHWPmZWhyy0ffSCJ8qfb6njfA5ZQes74FtO9MdU/YXiUdTln/t68eOQY SDu/LBDHCV2HCNt7jDDdU06POcFWqbYSORAVtdQFQOAzR6fAAO1vm+pYGX/4Si11fW04 iLOEQHPYbbCz+7ZSpoWmYCMUsEq4OlncWAyAcmv4o9RjUZUOwNeuiRKd/A0v8ECabQ/g kJrsE6ILrFrkGchVkbwMtc5RfAi7Zn4EsWexNR7Qz7wg1buBQcllh66D4+laFlxMXqor rasvondHpVa8dJdRUnuiNKcdGBUvPfzeY+nqn6D8vXSdhRHWPa2T+OoXwXvdD9PIamkq SKMQ== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u26si10821002pgo.182.2017.11.21.06.03.25; Tue, 21 Nov 2017 06:03:25 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751517AbdKUODY (ORCPT + 26 others); Tue, 21 Nov 2017 09:03:24 -0500 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140]:58734 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751191AbdKUODW (ORCPT ); Tue, 21 Nov 2017 09:03:22 -0500 Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.60]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id vALE2vdq009221; Tue, 21 Nov 2017 14:02:57 GMT From: Liviu Dudau To: Magnus Damm Cc: Geert Uytterhoeven , Joerg Roedel , IOMMU ML , LKML , Liviu Dudau , Laurent Pinchart , Alex Williamson Subject: [PATCH] iommu/ipmmu-vmsa: Simplify driver probing. Date: Tue, 21 Nov 2017 14:02:57 +0000 Message-Id: <20171121140257.934-1-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171121120801.GK5165@e110455-lin.cambridge.arm.com> References: <20171121120801.GK5165@e110455-lin.cambridge.arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IPMMU driver still uses initcalls to do its initialisation, while other IOMMU drivers have moved to probe deferal mechanism. Update the IPMMU driver so that it can use modern driver probing which allows for it to be compiled together with other IOMMU drivers and not trying at boot time to replace bus masters for platforms that don't use IPMMU. Signed-off-by: Liviu Dudau Cc: Laurent Pinchart Cc: Magnus Damm Cc: Alex Williamson --- drivers/iommu/ipmmu-vmsa.c | 47 +++------------------------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) -- 2.15.0 diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 8dce3a9de9d86..6eea75ca3c92e 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -1039,18 +1039,10 @@ static int ipmmu_probe(struct platform_device *pdev) if (ret) return ret; -#if defined(CONFIG_IOMMU_DMA) if (!iommu_present(&platform_bus_type)) bus_set_iommu(&platform_bus_type, &ipmmu_ops); -#endif } - /* - * We can't create the ARM mapping here as it requires the bus to have - * an IOMMU, which only happens when bus_set_iommu() is called in - * ipmmu_init() after the probe function returns. - */ - platform_set_drvdata(pdev, mmu); return 0; @@ -1079,46 +1071,13 @@ static struct platform_driver ipmmu_driver = { .remove = ipmmu_remove, }; -static int __init ipmmu_init(void) -{ - static bool setup_done; - int ret; - - if (setup_done) - return 0; - - ret = platform_driver_register(&ipmmu_driver); - if (ret < 0) - return ret; - -#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA) - if (!iommu_present(&platform_bus_type)) - bus_set_iommu(&platform_bus_type, &ipmmu_ops); -#endif - - setup_done = true; - return 0; -} - -static void __exit ipmmu_exit(void) -{ - return platform_driver_unregister(&ipmmu_driver); -} - -subsys_initcall(ipmmu_init); -module_exit(ipmmu_exit); +module_platform_driver(ipmmu_driver); #ifdef CONFIG_IOMMU_DMA -static int __init ipmmu_vmsa_iommu_of_setup(struct device_node *np) -{ - ipmmu_init(); - return 0; -} -IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "renesas,ipmmu-vmsa", - ipmmu_vmsa_iommu_of_setup); +IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "renesas,ipmmu-vmsa", NULL); IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795", - ipmmu_vmsa_iommu_of_setup); + NULL); #endif MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");