Received: by 10.223.164.221 with SMTP id h29csp939847wrb; Fri, 13 Oct 2017 08:49:29 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBZTv10oTsCANne1NLxbmlEaSKPD3Kqe5qmrDmeT2X2O5DrnqXCwrgQNVabfG225AVEHQAn X-Received: by 10.99.180.3 with SMTP id s3mr1635727pgf.174.1507909768998; Fri, 13 Oct 2017 08:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507909768; cv=none; d=google.com; s=arc-20160816; b=mNsyaZIcBuaF1drKkFZ/eDAseg5R8VEt9BIp9siDgonQH0DcQCYLZQkUMhwTIDrTMP apkX/0er3g+0Cly2HXKUT+E+YeVusj3JCE0DT7BGYuNHG2k6c82yuRq0KrcOqeVNwNF7 Ne1nSLa5RslW6DTZbFVS9iJZ4dUCnzhTfj+WZWqpPTC3BV5/+snkG1t9OaKvYq1AO92C Hh3j1oy/KG9Eio63EJ24qQKyDK9e0f8r8b92KsFIzEKpF8sSFdUOf1wkpGcjl/VSRcRW 1zytI+04lkwBuzdx435CN2kH0Dm9pCtebV/zqkVqU1sg/bOA4V8Ph1lVj5Mo1ANiPGLB ClUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=5El42jFFkM0w4dcTcJomVpxKSvR0nq7tOL/nyuPrReA=; b=y72auTCYLGUym5upM/5hTtDDn2KmhueYOym5GgymRpUty0+CxKChkHpos5UVOq3K+k Mj8sUEMuJQRYIyzWqxcD8jml/wJ/1PqQ3cLWLBIeakqMI4D0TZnJ1eMpMUASMos+ufMJ QSmW0XD+6KyLmTI3vycx65wY1H+/ZKOYQWdApJwq1gAw9s0v/MiDRT70lENc/W83O18n 4rlrfOAlePSea3E4d1bA1zmhCquJMr+AH5UHFBDxR0I8jzoJaPoRxHyq4PnmlG8Enaad ZiNUpuAzIHrSqTnmhNm/+wTCVXome4iIoYog86Fv47aXbBmvoohZBPjqVsqdLSwttBw1 oWFA== 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 t9si720788pgf.185.2017.10.13.08.49.12; Fri, 13 Oct 2017 08:49:28 -0700 (PDT) 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 S1758412AbdJMPsu (ORCPT + 99 others); Fri, 13 Oct 2017 11:48:50 -0400 Received: from foss.arm.com ([217.140.101.70]:35424 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758309AbdJMPss (ORCPT ); Fri, 13 Oct 2017 11:48:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7FF4C1435; Fri, 13 Oct 2017 08:48:48 -0700 (PDT) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 238FA3F3E1; Fri, 13 Oct 2017 08:48:46 -0700 (PDT) Subject: Re: [PATCH v2] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init. To: Joerg Roedel Cc: Liviu Dudau , Laurent Pinchart , Geert Uytterhoeven , Shawn Lin , Magnus Damm , LKML , IOMMU ML References: <20170918100444.21878-1-Liviu.Dudau@arm.com> <20170920141352.29377-1-Liviu.Dudau@arm.com> From: Robin Murphy Message-ID: <938d213c-f207-218e-554f-08035eaa1e6d@arm.com> Date: Fri, 13 Oct 2017 16:48:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170920141352.29377-1-Liviu.Dudau@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, On 20/09/17 15:13, 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). > > 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. Are you OK with taking this patch as a fix for 4.14, or would you rather have something that can safely backport past 4.12 without implicit dependencies? This is a config/link-order dependent thing that's been lurking since the beginning, but only coming to light now that other drivers are changing their behaviour, so I don't think there's really a single Fixes: commit that can be singled out. Robin. > 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 195d6e93ac718..31912997bffdf 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -966,10 +966,11 @@ static int ipmmu_probe(struct platform_device *pdev) > return ret; > > /* > - * 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); > > platform_set_drvdata(pdev, mmu); > > @@ -1006,27 +1007,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 "); > From 1579068298221211124@xxx Wed Sep 20 14:14:39 +0000 2017 X-GM-THRID: 1578902883289057090 X-Gmail-Labels: Inbox,Category Forums