Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933438AbbGURoZ (ORCPT ); Tue, 21 Jul 2015 13:44:25 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:46184 "EHLO e06smtp17.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755753AbbGURoW (ORCPT ); Tue, 21 Jul 2015 13:44:22 -0400 X-Helo: d06dlp01.portsmouth.uk.ibm.com X-MailFrom: gerald.schaefer@de.ibm.com X-RcptTo: linux-kernel@vger.kernel.org From: Gerald Schaefer To: Alex Williamson Cc: , linux-kernel@vger.kernel.org, Martin Schwidefsky , Sebastian Ott , Gerald Schaefer Subject: [RFC PATCH 1/1] vfio-pci/iommu: Detach iommu group on remove path Date: Tue, 21 Jul 2015 19:44:06 +0200 Message-Id: <1437500646-18031-2-git-send-email-gerald.schaefer@de.ibm.com> X-Mailer: git-send-email 2.3.8 In-Reply-To: <1437500646-18031-1-git-send-email-gerald.schaefer@de.ibm.com> References: <1437500646-18031-1-git-send-email-gerald.schaefer@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15072117-0029-0000-0000-0000058F6FB5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1406 Lines: 41 When a user completes the VFIO_SET_IOMMU ioctl and the vfio-pci device is removed thereafter (before any other ioctl like VFIO_GROUP_GET_DEVICE_FD), then the detach_dev callback of the underlying IOMMU API is never called. This patch adds a call to vfio_group_try_dissolve_container() to the remove path, which will trigger the missing detach_dev callback in this scenario. Signed-off-by: Gerald Schaefer --- drivers/vfio/vfio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2fb29df..9c5c784 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -711,6 +711,8 @@ static bool vfio_dev_present(struct vfio_group *group, struct device *dev) return true; } +static void vfio_group_try_dissolve_container(struct vfio_group *group); + /* * Decrement the device reference count and wait for the device to be * removed. Open file descriptors for the device... */ @@ -785,6 +787,7 @@ void *vfio_del_group_dev(struct device *dev) } } while (ret <= 0); + vfio_group_try_dissolve_container(group); vfio_group_put(group); return device_data; -- 2.3.8 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/