From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796456549; b=IM1k8Fy+KvWV6ZPgtBnAFjAEKSNFXkZMj++xLrMwRpj4RV7QEo6sAvPSqxsBKNn9/IBr 7LTNyFjZOJqBK4bChQ62Z99dshCeZH7fp0oxWAccRVS56Ndn7wXaHArYEKTDk6nko4ku7 g62HARyNX2qWDOAbBrZlMApGfXH2LMZVcSlF2Fo9jGUW1h60vyK0qIUffo60Zyw1h9PBV x7bzTRGD7dCbjcB9jOIN4DwK/PoO0IgIedGPcUeu4dK9jyS1KAbyAt8KmfALahDq89KDj TZ8694I161CEowwBZMMiQoZAhX1GIoy1zvjrH0bxOja7cmswtS3G4gSyoM0qpq/afLQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796456549; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Cc:Subject:To:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=HUH/xiy3ujTmXLrrhPWKnCzz4sU5x5kr3u9DO9r9MHc=; b=uoxREYtc27EpW4x0pDXGay8RgPKr/PLUa+RPld8TimpkQENcLnceGz+mCpWX7igwx2V3 +Zsa7aXIWv1iHE29WvHL82iPkN4AZC1Mbh+JuSKc5VeejiFoOY+lhFIBFg70tT0NQcKce CUSr43xqC0t5opPGZMHOojLsQSeStm7T5a/DVMpMEZI4czWFcwhmYpPMJ1Wpt4vFLjOpq /CO2EOag9F5dbvaD60Owe5tGcZLj1YJn7TfIyEWVPN+BzHC1bS5efwHqXZ8njJR7LptIK /YjJS1EFA/XQiCx20Q8UF+1gmuOey+9zBw/TNwNYigJ2+ExuZ4nS8LBIyURi4Pnt2XQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lPqdB6xO; arc=none smtp.remote-ip=192.198.163.19 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F849606A330 for ; Sat, 5 Dec 2026 07:42:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4F849606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lPqdB6xO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796456548; x=1827992548; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=HUH/xiy3ujTmXLrrhPWKnCzz4sU5x5kr3u9DO9r9MHc=; b=lPqdB6xONOt82bdvi+3REaJMbFzfIg/SSrMi5DUmp/9YhC3APOmP97iw 5cmdjT4TD4LI5eRZXcx+/d7jWFNj3vIKHELWIej4DvroUthO8qWvL6l7b aVop5DtKdoVKNwLDScVJ9y8ij7qkbtYok5Qf3vG3eEw4hGv16EIuE9Xf3 BnipK1676n2fNwqVYNbM7EcRRNnRvfQQyfSPgWGn5apv1lwTkFQFBxd+v cAGE0hWepuZgYJnN7niAeJhKyYuJWZPREe9nUIGRVKQQ5z31acXx59//S Q0QZ4e8gJ/N4JrBsz0gsU/dvwlFhDcD05Z8tIk5VnuqlQkgpZpEd60xOF A==; X-CSE-ConnectionGUID: RN8QZ9UFTQylcgXabB7kMg== X-CSE-MsgGUID: a0poPl4/TbyJ0EUi8y1p+A== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5453528" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="5453528" 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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