Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751709AbdISHH4 (ORCPT ); Tue, 19 Sep 2017 03:07:56 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:35218 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751445AbdISHHy (ORCPT ); Tue, 19 Sep 2017 03:07:54 -0400 From: Laurent Pinchart To: Liviu Dudau Cc: Laurent Pinchart , Magnus Damm , Geert Uytterhoeven , Shawn Lin , Joerg Roedel , IOMMU ML , LKML Subject: Re: [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. Date: Tue, 19 Sep 2017 10:07:58 +0300 Message-ID: <2550948.Yqn2DEl6fn@avalon> In-Reply-To: <20170918100444.21878-1-Liviu.Dudau@arm.com> References: <20170918100444.21878-1-Liviu.Dudau@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3019 Lines: 86 Hi Liviu, Thank you for the patch. On Monday, 18 September 2017 13:04:44 EEST Liviu Dudau wrote: > If the IPMMU driver is compiled in the kernel it will replace the > platform bus IOMMU ops on running the ipmmu_init() function, regardless > if there is any IPMMU hardware present or not. This screws up systems > that just want to build a generic kernel that runs on multiple platforms > and use a different IOMMU implementation. > > Move the bus_set_iommu() call at the end of the ipmmu_probe() function > when we know that hardware is present. With current IOMMU framework it > should be safe (at least for OF case). If I recall correctly the issue is that the IPMMU might be probed after bus master devices when using the legacy IOMMU DT integration, which the ipmmu- vmsa driver does on ARM32. Calling bus_set_iommu() from the probe function will then result in some devices losing IOMMU support. > Now that the ipmmu_init() and ipmmu_exit() functions are simple calls to > platform_driver_register() and platform_driver_unregister(), replace > them with the module_platform_driver() macro call. > > Signed-off-by: Liviu Dudau > Cc: Laurent Pinchart > --- > drivers/iommu/ipmmu-vmsa.c | 29 +++++------------------------ > 1 file changed, 5 insertions(+), 24 deletions(-) > > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index 2a38aa15be17d..c60569c74678d 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -1055,10 +1055,11 @@ static int ipmmu_probe(struct platform_device *pdev) > ipmmu_device_reset(mmu); > > /* > - * 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. > + * Now that we have validated the presence of the hardware, set > + * the bus IOMMU ops to enable future domain and device setup. > */ > + if (!iommu_present(&platform_bus_type)) > + bus_set_iommu(&platform_bus_type, &ipmmu_ops); > > spin_lock(&ipmmu_devices_lock); > list_add(&mmu->list, &ipmmu_devices); What branch is this patch based on ? ipmmu_devices_lock isn't in mainline. > @@ -1100,27 +1101,7 @@ static struct platform_driver ipmmu_driver = { > .remove = ipmmu_remove, > }; > > -static int __init ipmmu_init(void) > -{ > - int ret; > - > - ret = platform_driver_register(&ipmmu_driver); > - if (ret < 0) > - return ret; > - > - if (!iommu_present(&platform_bus_type)) > - bus_set_iommu(&platform_bus_type, &ipmmu_ops); > - > - 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); > > MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU"); > MODULE_AUTHOR("Laurent Pinchart "); -- Regards, Laurent Pinchart