Re: [PATCH 2/2] iommu/vt-d: Only remove domain when device is removed
From: Joerg Roedel
Date: Tue Dec 09 2014 - 07:15:32 EST
On Thu, Nov 06, 2014 at 09:16:05AM -0700, Alex Williamson wrote:
> But the domains are unlinked from device_domain_list using
> unlink_domain_info() which is called from both domain_remove_dev_info()
> and domain_remove_one_dev_info() which are both part of that more
> likely, unlikely branch in intel_iommu_attach_device(). So it seems
> like any time we switch a device from the DMA-API to the IOMMU-API, we
> lose the reference to the domain. Is that incorrect? I'll try to test.
Okay, I thought a while about that and it looks like a real fix needs a
rewrite of the domain handling code in the VT-d driver to better handle
domain lifetime. We'll get this for free when we add default domains and
more domain handling logic to the iommu core, so I think we don't need
to start rewriting the VT-d driver for this.
But for the time being, here is a simple fix for the leak in
iommu_attach_domain: