From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC5zZ-0003pS-E1 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 08:59:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC5zU-0002PG-FF for qemu-devel@nongnu.org; Mon, 06 Jul 2015 08:59:25 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC5zU-0002OQ-AK for qemu-devel@nongnu.org; Mon, 06 Jul 2015 08:59:20 -0400 Received: by pactm7 with SMTP id tm7so95344961pac.2 for ; Mon, 06 Jul 2015 05:59:19 -0700 (PDT) References: <1436148670-6592-1-git-send-email-aik@ozlabs.ru> <1436148670-6592-13-git-send-email-aik@ozlabs.ru> <20150706103306.GE17857@voom.redhat.com> <1436186979.3909.41.camel@redhat.com> From: Alexey Kardashevskiy Message-ID: <559A7BA1.2050901@ozlabs.ru> Date: Mon, 6 Jul 2015 22:59:13 +1000 MIME-Version: 1.0 In-Reply-To: <1436186979.3909.41.camel@redhat.com> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit 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: Alex Williamson , David Gibson Cc: Michael Roth , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Gavin Shan On 07/06/2015 10:49 PM, Alex Williamson wrote: > On Mon, 2015-07-06 at 20:33 +1000, David Gibson wrote: >> 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. >>> >>> This unregisters IOMMU memory region notifier when a container is >>> destroyed. >>> >>> 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? > > Yes, confusingly this patch was sent twice yesterday, once in this > series and once separately. AFAICT they're identical, so I'll add your > R-b and add the patch to my pull request for 2.4-rc0. Thanks, Yes, these are identical, sorry for the confusion. btw what was the right to do with this patch? > > Alex > >>> --- >>> Changes: >>> v10: >>> * new to the patchset >>> --- >>> hw/vfio/common.c | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> 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 *group) >>> >>> if (QLIST_EMPTY(&container->group_list)) { >>> VFIOAddressSpace *space = container->space; >>> + VFIOGuestIOMMU *giommu, *tmp; >>> >>> 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); >> > > > -- Alexey