From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932692AbcGLLIm (ORCPT ); Tue, 12 Jul 2016 07:08:42 -0400 Received: from 8bytes.org ([81.169.241.247]:43487 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753426AbcGLLIl (ORCPT ); Tue, 12 Jul 2016 07:08:41 -0400 Date: Tue, 12 Jul 2016 13:08:39 +0200 From: Joerg Roedel To: Robin Murphy Cc: iommu@lists.linux-foundation.org, Vincent.Wan@amd.com, Joerg Roedel , linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/20] iommu/amd: Remove special mapping code for dma_ops path Message-ID: <20160712110839.GF12639@8bytes.org> References: <1467978311-28322-1-git-send-email-joro@8bytes.org> <1467978311-28322-8-git-send-email-joro@8bytes.org> <5784CCAB.8000007@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5784CCAB.8000007@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, On Tue, Jul 12, 2016 at 11:55:39AM +0100, Robin Murphy wrote: > > start = address; > > for (i = 0; i < pages; ++i) { > > - ret = dma_ops_domain_map(dma_dom, start, paddr, dir); > > - if (ret == DMA_ERROR_CODE) > > + ret = iommu_map_page(&dma_dom->domain, start, paddr, > > + PAGE_SIZE, prot, GFP_ATOMIC); > > I see that amd_iommu_map/unmap() takes a lock around calling > iommu_map/unmap_page(), but we don't appear to do that here. That seems > to suggest that either one is unsafe or the other is unnecessary. At this point no locking is required, because in this code path we know that we own the memory range and that nobody else is mapping that range. In the IOMMU-API path we can't make that assumption, so locking is required there. Both code-path use different types of domains, so there is also no chance that a domain is used in both code-paths (except when a dma-ops domain is set up). Joerg