From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6630BC43334 for ; Thu, 7 Jul 2022 09:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233255AbiGGJ7F (ORCPT ); Thu, 7 Jul 2022 05:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234507AbiGGJ7F (ORCPT ); Thu, 7 Jul 2022 05:59:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0F7E94F197; Thu, 7 Jul 2022 02:59:04 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2CC4E1063; Thu, 7 Jul 2022 02:59:04 -0700 (PDT) Received: from [10.57.85.108] (unknown [10.57.85.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 883673F792; Thu, 7 Jul 2022 02:59:01 -0700 (PDT) Message-ID: Date: Thu, 7 Jul 2022 10:58:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 03/15] iommu: Always register bus notifiers Content-Language: en-GB To: "Tian, Kevin" , "joro@8bytes.org" Cc: "will@kernel.org" , "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "baolu.lu@linux.intel.com" , "suravee.suthikulpanit@amd.com" , "vasant.hegde@amd.com" , "mjrosato@linux.ibm.com" , "gerald.schaefer@linux.ibm.com" , "schnelle@linux.ibm.com" , "linux-s390@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <8c380309f264cd0dfc73ba2ec060adc9515af2f2.1657034828.git.robin.murphy@arm.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On 2022-07-07 07:31, Tian, Kevin wrote: >> From: Robin Murphy >> Sent: Wednesday, July 6, 2022 1:08 AM >> >> The number of bus types that the IOMMU subsystem deals with is small and >> manageable, so pull that list into core code as a first step towards >> cleaning up all the boilerplate bus-awareness from drivers. Calling >> iommu_probe_device() before bus->iommu_ops is set will simply return >> -ENODEV and not break the notifier call chain, so there should be no >> harm in proactively registering all our bus notifiers at init time. >> > > Suppose we miss a check on iommu ops in iommu_release_device(): > > if (!dev->iommu) <<<<<<< > return; > > iommu_device_unlink(dev->iommu->iommu_dev, dev); > > ops = dev_iommu_ops(dev); > ops->release_device(dev); > > following the rationale in patch01 a device could be removed when > it's associated with a known but not registered instance. No, because at that point the instance is only known internally to the driver. As long as it isn't erroneously returned from ->probe_device(dev), dev->iommu will remain NULL and the rest of the core code works as expected. Thanks, Robin.