From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753814AbbC0PFQ (ORCPT ); Fri, 27 Mar 2015 11:05:16 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:51929 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752239AbbC0O4f (ORCPT ); Fri, 27 Mar 2015 10:56:35 -0400 From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: Alexey Kardashevskiy , Benjamin Herrenschmidt , Paul Mackerras , Alex Williamson , linux-kernel@vger.kernel.org Subject: [PATCH kernel v7 02/31] vfio: powerpc/spapr: Do cleanup when releasing the group Date: Sat, 28 Mar 2015 01:54:46 +1100 Message-Id: <1427468115-2224-3-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1427468115-2224-1-git-send-email-aik@ozlabs.ru> References: <1427468115-2224-1-git-send-email-aik@ozlabs.ru> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15032714-0025-0000-0000-0000013BEF5B Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This clears the TCE table when a container is being closed as this is a good thing to leave the table clean before passing the ownership back to the host kernel. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index cefaf05..e9b4d7d 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -132,16 +132,24 @@ static void *tce_iommu_open(unsigned long arg) return container; } +static int tce_iommu_clear(struct tce_container *container, + struct iommu_table *tbl, + unsigned long entry, unsigned long pages); + static void tce_iommu_release(void *iommu_data) { struct tce_container *container = iommu_data; + struct iommu_table *tbl = container->tbl; - WARN_ON(container->tbl && !container->tbl->it_group); + WARN_ON(tbl && !tbl->it_group); tce_iommu_disable(container); - if (container->tbl && container->tbl->it_group) - tce_iommu_detach_group(iommu_data, container->tbl->it_group); + if (tbl) { + tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size); + if (tbl->it_group) + tce_iommu_detach_group(iommu_data, tbl->it_group); + } mutex_destroy(&container->lock); kfree(container); -- 2.0.0