From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27E39606A322 for ; Sat, 5 Dec 2026 07:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=XxHOoSIr; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VCCOcRfc DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:Cc:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=HUH/xiy3ujTmXLrrhPWKnCzz4sU5x5kr3u9DO9r9MHc=; b=XxHOoSIrDirgTC CfNA3jyHF0VNma14x4wOhoOxNNNFR7BpSeN2i/cZdFQBg9vm2pBsarsYVTmvC1S6xUfcQk2VttGbI gV8hk50GRUSoU6NcJaahXZ0shIeJBo/YJ1jiNdfQKCqFHKiSQkOsxU2Pcolwv2ACwZRUKuDhDzXqY g/DINIs7Yl/Llsb8/v6e93j4Y3xfPv8zvWmcPJ55PUUvpxsbSp9ViyXY1iHli3Gyspqwlfs2ma7uF lPregLYXZja4vpPyOu5+wT/1eXFuTSv7aFT46rZWf8yGNTO5TP1Y+NXcIpMlJTejG9wEXg94BS80O BqdKDmebh9Vs05uIKzHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZkPh-000000027lw-23Zo; Sat, 05 Dec 2026 07:42:33 +0000 Received: from mgamail.intel.com ([192.198.163.19]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZkPe-000000027lY-0LLF for linux-arm-kernel@lists.infradead.org; Sat, 05 Dec 2026 07:42:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796456550; x=1827992550; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=HUH/xiy3ujTmXLrrhPWKnCzz4sU5x5kr3u9DO9r9MHc=; b=VCCOcRfcNCQhPDfQCIXCiYZVyfw0YNKuA3MVT0z+BCOfPJ1m3e2QchYm /kdKH1alsrrtvcG5svI89YL+vhiywQwfirflKXcc/cweXYRKnlwaF9nV+ FxtzUkGRpf8vPmjx+qxRBdl2vVWGz/zEldlbFDW2Fk/OSU3RuO9as1JJR uPlwhjpFLurjD/W/ANf0FtL6UFBbtjcfQuLkyLRRp81VQGUrpNIRMtDBp BdqVUA9JNEg4VlumtCZkK7nKKSO0/7Lc5n/qKez9CArafg/PBW4AdBvdA d+JSqT08xevrEOwBwxMARGwDfIrEsjt9cqaNs0GZFaUABC7wDJpzzdfQC w==; X-CSE-ConnectionGUID: DLLnzsXnQeipGl+8RSYUCA== X-CSE-MsgGUID: V+/g8Vo/Qd+WPvHPncxoOg== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5453537" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="5453537" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 23:42:27 -0800 X-CSE-ConnectionGUID: y6ckf4pIRBW/mRq0x9SCmw== X-CSE-MsgGUID: SaFyA9+ATqaXpFW0FtkEOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="14076951" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.124.249.52]) ([10.124.249.52]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 23:42:24 -0800 Message-ID: <538b7bd3-8c4d-4054-b7d2-61635d82d616@linux.intel.com> Date: Sat, 5 Dec 2026 15:42:21 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, robin.murphy@arm.com, joro@8bytes.org, praan@google.com, kevin.tian@intel.com, smostafa@google.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, jamien@nvidia.com, kas@kernel.org, Cristian Prundeanu , Breno Leitao , xueshuai@linux.alibaba.com, john.garry@arm.com Subject: Re: [PATCH v13 01/12] iommu: Pass in NULL old_domain when attaching a deferred device To: Nicolin Chen , will@kernel.org, jgg@nvidia.com References: Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_234230_171771_5B1FFCA0 X-CRM114-Status: GOOD ( 19.01 ) X-Spam-Score: -4.3 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 11/18/2026 3:21 AM, Nicolin Chen wrote: > When a driver defers the default domain attachment of a device, the IOMMU > core skips the attachment in __iommu_device_set_domain() but still sets the > group->domain to the group->default_domain. Since the driver has not seen > this attachment, iommu_deferred_attach() later finalizes it by passing in a > NULL old_domain. > > However, two other paths pass in the group->domain as the old_domain for a > deferred device: > - __iommu_device_set_domain(), when attaching a non-default domain > - pci_dev_reset_iommu_prepare(), when attaching the group->blocking_domain > > A driver uses the given old_domain to clean up the device's state in that > domain. However, a deferred device has no state in the group->domain, since > the driver has never attached the device to it. So, the driver would end up > cleaning up a state that does not exist. > > In practice, the first path is unlikely, since it requires the device to be > attached to a non-default domain before its first DMA mapping. The second > path is reachable when an ATS supported device gets reset before its first > DMA mapping. > > Pass in a NULL old_domain on both paths for a deferred device. > > Note that pci_dev_reset_iommu_done() can keep using the group->domain for > recovering the device, because pci_dev_reset_iommu_prepare() has unset the > attach_deferred flag. > > This will be needed for the SMMUv3 driver to support the kdump mode, where > it relies on the given old_domain to unreference the invalidation entries > of a master. > > Signed-off-by: Nicolin Chen > --- > drivers/iommu/iommu.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) Reviewed-by: Lu Baolu