From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC4ON-0006hi-G7 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 07:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC4OI-0006Sd-H7 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 07:16:55 -0400 Date: Mon, 6 Jul 2015 20:33:06 +1000 From: David Gibson Message-ID: <20150706103306.GE17857@voom.redhat.com> References: <1436148670-6592-1-git-send-email-aik@ozlabs.ru> <1436148670-6592-13-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9l24NVCWtSuIVIod" Content-Disposition: inline In-Reply-To: <1436148670-6592-13-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH qemu v10 12/14] vfio: Unregister IOMMU notifiers when container is destroyed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Michael Roth , Alex Williamson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Gavin Shan --9l24NVCWtSuIVIod Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 06, 2015 at 12:11:08PM +1000, Alexey Kardashevskiy wrote: > On systems with guest visible IOMMU, adding a new memory region onto > PCI bus calls vfio_listener_region_add() for every DMA window. This > installs a notifier for IOMMU memory regions. The notifier is supposed > to be removed by vfio_listener_region_del(), however in the case of mixed > PHB (emulated + VFIO devices) when last VFIO device is unplugged and > container gets destroyed, all existing DMA windows stay alive altogether > with the notifiers which are on the linked list which head was in > the destroyed container. >=20 > This unregisters IOMMU memory region notifier when a container is > destroyed. >=20 > Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Alex, I think this is correct, but you've probably got a better understanding of it. Will you take this through your tree? > --- > Changes: > v10: > * new to the patchset > --- > hw/vfio/common.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > index 89ef37b..8eacfd7 100644 > --- a/hw/vfio/common.c > +++ b/hw/vfio/common.c > @@ -772,11 +772,19 @@ static void vfio_disconnect_container(VFIOGroup *gr= oup) > =20 > if (QLIST_EMPTY(&container->group_list)) { > VFIOAddressSpace *space =3D container->space; > + VFIOGuestIOMMU *giommu, *tmp; > =20 > if (container->iommu_data.release) { > container->iommu_data.release(container); > } > QLIST_REMOVE(container, next); > + > + QLIST_FOREACH_SAFE(giommu, &container->giommu_list, giommu_next,= tmp) { > + memory_region_unregister_iommu_notifier(&giommu->n); > + QLIST_REMOVE(giommu, giommu_next); > + g_free(giommu); > + } > + > trace_vfio_disconnect_container(container->fd); > close(container->fd); > g_free(container); --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --9l24NVCWtSuIVIod Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVmlliAAoJEGw4ysog2bOS5ekP/2uOo+6q0qW/Thfp+IE9ppRz S1yVRYTjtxqxGm+WhU3SL/Mnn1B4Pc1wxWWHgemlf1aRSQRg0mM083quedHh/TFL RSaoO+a+cAiRRm0VFGbu4awxd3rjEBg+/sEVILjN1HZgS1ml+mrg6aohGSqqVhmg /jku2gkFTQMP4NfMC1+jMX+eJyTVnPyFkopp6mJ+/19RzB+13fcFpRCqhivgJub0 jzkfc1YDyyvaIr3c1UVUzP6GvejP0CwPOQo8BHF3JBJ+CNNFjQaj8wKPRJBOpBsd GtaddVbGmDklfCIRCbx96ixG70dy5CEX8bSSiOQeHImbnsHPzfKq1xfkLKztilcZ GG9dYkKkEuy1rg0VAuqZCN+ZbEKFqFRyuFhYuPcixQhYNJZmIzXVkqs353m/QSrN xVruZsWzTSq5/scwTHeRPkfeGY9FxrIDH+4FUSf85pkEsaYlLLqQ4Q3AzmnzRuvJ dCzJaBR+Ra+FxdLL1hn4bR8LMQZGOFJ+/pjQmPRp2t54iV0VNhUuZZ3QocOwYwuD tkxLb8vqjPy20n7XMUwBa7PFQUJbhOtPF1w5PB0QSmoPFSbjmXB7NPGfF6M7hssI z+FvuQeMKqXlM6mlerzEdISicade0DmEkWlPtJIi4VBB/wRFF86YSt89R/+Kyaby OeIHFke9B/3KljrfStq0 =6ErU -----END PGP SIGNATURE----- --9l24NVCWtSuIVIod--