Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3526976imw; Thu, 7 Jul 2022 03:21:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1suczDKfO8eytazmzGpK0SoRHDnbc5gkPwNO4C/CslAAvlPVQmWLtrhvg3CbPf/wTy930gH X-Received: by 2002:a17:906:5053:b0:70d:a0cc:b3fd with SMTP id e19-20020a170906505300b0070da0ccb3fdmr7323752ejk.162.1657189301728; Thu, 07 Jul 2022 03:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657189301; cv=none; d=google.com; s=arc-20160816; b=f+b624wTbCuM3jY2yB1Wcv5nj/UWGkPy0z3pV+GZeP4l2yRxANXFKUxULz2veHAi8l wpGyDiD1ogEPrC3qjq0wqJd8MPEv51jGo7J6lcBVTTpurR81Tc5IGkczT+Boo5C6Mt/n E7Gvls0OYXs5qeweeQDaf8DHVQ66BPM0dmyOlpG4uN/HiEIUJizMjTCXfI1Ao4yA1Aw6 6R5CHpFS7S3LysemHlH9eOxBAexb8h7ehapuE3cmzQdKdnvcAWczNqHyEyHq68YRT4Hg Ma6wbYSx4oVrmZlVsHX84aWDZHj2xg8sDDMIQoz+oH3ucYYhgnHHbgJclJTd8gP3EoMq uyWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=7wU9C5Xs2CqWF6Fgc6cECKOgH6S1iZ+Y2UQ2vfsdgOs=; b=m0aG0mnM/r0SXGw/XHnPu28UQaZvnCDHX6He3sEl1eGAyUHiJ9Xi7SM0iyJq6xNv3k mH9HejvSNQyKsiNW0cGcnkWvbhEiTsndb5VPCvda+IXsW6zBrMX3jnMaYuHGbtupONQW 7XxUFOR4UuYr9oHn01ol1DPM0goVnxJNRrr9nimBiKJuc6DR50BmOi6u+E0gpHoi1w7q yGeaiLzuncA9TY/Ez4PghdqkRIbX5SSdtWCxFfNt15j+LDzQanUEioMaSqao/QVpAoqQ vt3N4VFMZ7y6SdGwbiEJoMVohUtWBzDgORh4pxad4PYaTF9kZRzjtfJjwyhHejNGeFaA Tykw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf28-20020a1709077f1c00b0070ebb93abe4si22238348ejc.117.2022.07.07.03.21.14; Thu, 07 Jul 2022 03:21:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234847AbiGGJ7G (ORCPT + 99 others); Thu, 7 Jul 2022 05:59:06 -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 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.