Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933520AbcKOPLg (ORCPT ); Tue, 15 Nov 2016 10:11:36 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:8706 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752020AbcKOPLd (ORCPT ); Tue, 15 Nov 2016 10:11:33 -0500 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 14 Nov 2016 19:10:35 -0800 Subject: Re: [PATCH v12 11/22] vfio iommu: Add blocking notifier to notify DMA_UNMAP To: Alex Williamson References: <1479138156-28905-1-git-send-email-kwankhede@nvidia.com> <1479138156-28905-12-git-send-email-kwankhede@nvidia.com> <20161114165844.52537988@t450s.home> CC: , , , , , , , , X-Nvconfidentiality: public From: Kirti Wankhede Message-ID: <2015af0a-cd66-8092-b075-10a1b434d35c@nvidia.com> Date: Tue, 15 Nov 2016 20:41:26 +0530 MIME-Version: 1.0 In-Reply-To: <20161114165844.52537988@t450s.home> X-Originating-IP: [10.24.216.210] X-ClientProxiedBy: DRHKMAIL103.nvidia.com (10.25.59.17) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 983 Lines: 32 >> @@ -854,15 +857,29 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu, >> if (dma->task->mm != current->mm) >> break; >> unmapped += dma->size; >> + >> + mutex_unlock(&iommu->lock); >> + if (iommu->external_domain && !RB_EMPTY_ROOT(&dma->pfn_list)) { >> + struct vfio_iommu_type1_dma_unmap nb_unmap; >> + >> + nb_unmap.iova = dma->iova; >> + nb_unmap.size = dma->size; >> + blocking_notifier_call_chain(&iommu->notifier, >> + VFIO_IOMMU_NOTIFY_DMA_UNMAP, >> + &nb_unmap); >> + >> + if (WARN_ON(!RB_EMPTY_ROOT(&dma->pfn_list))) >> + goto unmap_exit; >> + } >> + mutex_lock(&iommu->lock); > > Why are the mutexes pushed out so far, we are referencing way too much > stuff outside of the mutex here. The notifier head has its own > semaphore, so we should be able to squeeze the mutex opening to just > around the notifier call, in which case we only worry about the iommu > itself going way. > Right. Updating. Thanks, Kirti