Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2346055ybx; Fri, 8 Nov 2019 03:06:35 -0800 (PST) X-Google-Smtp-Source: APXvYqysNeYt3SCH4y0txhQ8PNXl7vQbPFkeh7kZf/Q0HP62E5MNFSc/Rs3+L750NUpRWCZ0YFFJ X-Received: by 2002:a17:906:3b06:: with SMTP id g6mr7880608ejf.20.1573211195781; Fri, 08 Nov 2019 03:06:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573211195; cv=none; d=google.com; s=arc-20160816; b=Af/qqLsuJTa5XkO17B/9k1fnMRP8q1i5Tuf24HpmDNuDN41MbJtNoI9BpmbWlkBHnR lgy4Qxtl1h3mfY8jbK4vs3+ifhwy+s+nRDPq5AWxZN0M5zl7JP2tuZF48JXUwJxPWtRZ 5TcZCsGZykG6cI9taJMbnvgpO5m2Y1xo1s3WCi4y0FUZB0UYfmjPJtkGmhGr4B3frXDB pSFCa2lb0CBZTMUUh/wCrYAHXrTXYvccgwOv/rZEp9zXGjnS04TF3RDdIKBQUMQcmsOS PFiIF+LvImJADwRowrNBNNeD1RYYOFlXZuEMJYXrzbbyeC0IcaOEzIWBQV8U9e4w2kWB D4nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XgZdIZU/oqpip0oPmJ2sNpeViidPmi8M4gf49smdZzM=; b=lp0v63I1rmDvzsKbuS3UkDzko+YtODZRuWBwHeHkuFCGqgPcKxzTI1Gduein+Wv7ei JIwYIisJn5/KwpssDTrnx/1UoDja0VQ4KSJ1yQDVoaVZsBqv7izx6+4c9vowwNGcrww7 3IgFbTvGP0PT9HbihB1C2tWGYl6bB99VszNWow1GM5CtNwEflmX96esdYHjkhZSuCIYc D7CQISEOEerAOv0wIWNP2xZJENJqXCbXg2zpoLteWzN36et+1+tj2+ykec06HQNcoJv4 tv6QRiuC75k8/+jPo39izGecwAegJvZ67i1Gxm0QzCM3wdp3WtDZu/DvRYIOgw0GbsqE C5jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GPUpB2qi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si3624153edh.379.2019.11.08.03.06.12; Fri, 08 Nov 2019 03:06:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=GPUpB2qi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731490AbfKHLDP (ORCPT + 99 others); Fri, 8 Nov 2019 06:03:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:39474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbfKHLDP (ORCPT ); Fri, 8 Nov 2019 06:03:15 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C72EF206BA; Fri, 8 Nov 2019 11:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573210994; bh=J/Gsm5N/mj+ik5tmWzF15ve/593DRKXBLK4N9zKCikI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GPUpB2qieVF3EyX+Obw28FlE6xo23nwE/xykonNN3EZtnaxcpvEFeX+8ufsaXb5th +ksXQteLE30PzN2sUWXuJdcrvuV/YqSRLbHtKk9h1qsPcUG586CeeZJJMYvyQclJah tyoRDGyrsSCcnNRNjplrIRLCVouz6GYQbwN+T1LQ= Date: Fri, 8 Nov 2019 11:03:10 +0000 From: Will Deacon To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Robin Murphy , Bjorn Helgaas , Lorenzo Pieralisi Subject: Re: [PATCH 5/7] iommu/arm-smmu-v3: Allow building as a module Message-ID: <20191108110310.GC19153@willie-the-truck> References: <20191030145112.19738-1-will@kernel.org> <20191030145112.19738-6-will@kernel.org> <20191030193148.GA8432@8bytes.org> <20191031154247.GB28061@willie-the-truck> <20191105121508.GA3479@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105121508.GA3479@8bytes.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, On Tue, Nov 05, 2019 at 01:15:08PM +0100, Joerg Roedel wrote: > On Thu, Oct 31, 2019 at 03:42:47PM +0000, Will Deacon wrote: > > Generally, I think unloading the IOMMU driver module while there are > > active users is a pretty bad idea, much like unbinding the driver via > > /sys in the same situation would also be fairly daft. However, I *think* > > the code in __device_release_driver() tries to deal with this by > > iterating over the active consumers and ->remove()ing them first. > > > > I'm without hardware access at the moment, so I haven't been able to > > test this myself. We could nobble the module_exit() hook, but there's > > still the "force unload" option depending on the .config. > > Okay, but besides the force-unload case, can we prevent accidential > unloading by taking a reference to the module in add_device() and release > it in remove_device()? That's probably a sensible starting point, yes. In conjunction with the patch from Jean-Philippe to introduce bus_unset_iommu(), we might have a fighting chance of getting this to work. I'll spin a v2. Thanks! Will