Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp910439ybp; Thu, 17 Oct 2019 05:28:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQiqRA0E3ZfMEj4bQ6b82BvmkTC3CPVUfQXnZGjSb3Jy7+5Pacl8dQOenI0LqlueNuJ30d X-Received: by 2002:a17:906:1911:: with SMTP id a17mr3210944eje.14.1571315295479; Thu, 17 Oct 2019 05:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571315295; cv=none; d=google.com; s=arc-20160816; b=ChxJIj0YffeUs8Qu/KGrp0MEsW3actkoyQrKcpZCyd3/mk5W38qa+dSe2uKscFSUGC 26Z5WtI38vBvpdygj3FY4ItIS11axwHqGEnqjhvGs7ueWOSYbQc2XVDuWk81P7sHWd3G P4Dtu5Hz9yVd9dd7DNntNI7KZTS44Va54qn3kncVtHcoMy3zSS6k84f4RwjVDSqDKa1l KaDZ3i1/GlevGKraEIEbokZYCXOJAagJ4f2nu+I1tCy24nNZROJyHUsZ2dKyC1TZ/xss 3oY9RHiLXzYUZt73fDkEWFBZ8yg0sgHwU9bw+bpbAHT0HigEeQUO9Aw9uN0u83YFgvXV 6l2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Nmq3igF1Zo+kY8Qjlw1UzOe9+M0fIu+IjKmBURnkbdY=; b=HLEjMWZgrO9/xr0gOu9Jm1Uj9Zd2spZKKVqdNS69bMYJ2c0L/NHcl30vdWcxV8wh/g Djh7ezlXm3fqf78rV0jGJdi4yXAVF9KNGXQqVQraWG8HP1TlE8GbzwvnFnWje0S7lf3Z 3BqEtL56mpOjmEh3oEDNmROsOUR7leI0fvkhv1f652ksckKEoURTXRv3JAOLnca5r3i0 5rrihnE8j+PapPBd6fzEpBaZ6pD+5/DxdWv3L1lXotqMtDch779EQBMHxLG6rka+LC/P sLnW6zUBIQdhTH5TE18W6N2FaZS0yg7OB1+iw9nqhFynbo4hGgube7v0W2oZqvzAh3wF Ky7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si1428258ejj.402.2019.10.17.05.27.52; Thu, 17 Oct 2019 05:28:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393648AbfJPQ01 (ORCPT + 99 others); Wed, 16 Oct 2019 12:26:27 -0400 Received: from foss.arm.com ([217.140.110.172]:44882 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390184AbfJPQ01 (ORCPT ); Wed, 16 Oct 2019 12:26:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B92ED28; Wed, 16 Oct 2019 09:26:26 -0700 (PDT) Received: from [10.1.197.57] (e110467-lin.cambridge.arm.com [10.1.197.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D3D0D3F68E; Wed, 16 Oct 2019 09:26:25 -0700 (PDT) Subject: Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy To: Qian Cai , Joerg Roedel Cc: Tom Murphy , Christoph Hellwig , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <1571237707.5937.58.camel@lca.pw> <1571237982.5937.60.camel@lca.pw> <20191016153112.GF4695@suse.de> <1571241213.5937.64.camel@lca.pw> <20191016160314.GH4695@suse.de> <1571242287.5937.66.camel@lca.pw> From: Robin Murphy Message-ID: <2912dd38-72c5-93a1-1185-46b681473a62@arm.com> Date: Wed, 16 Oct 2019 17:26:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1571242287.5937.66.camel@lca.pw> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/10/2019 17:11, Qian Cai wrote: > On Wed, 2019-10-16 at 18:03 +0200, Joerg Roedel wrote: >> On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote: >>> On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote: >>> The x86 one might just be a mistake. >>> >>> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c >>> index ad05484d0c80..63c4b894751d 100644 >>> --- a/drivers/iommu/amd_iommu.c >>> +++ b/drivers/iommu/amd_iommu.c >>> @@ -2542,7 +2542,7 @@ static int amd_iommu_map(struct iommu_domain *dom, >>> unsigned long iova, >>>         if (iommu_prot & IOMMU_WRITE) >>>                 prot |= IOMMU_PROT_IW; >>> >>> -       ret = iommu_map_page(domain, iova, paddr, page_size, prot, GFP_KERNEL); >>> +       ret = iommu_map_page(domain, iova, paddr, page_size, prot, gfp); >> >> Yeah, that is a bug, I spotted that too. >> >>> @@ -1185,7 +1185,7 @@ static struct iommu_dma_msi_page >>> *iommu_dma_get_msi_page(struct device *dev, >>>         if (!iova) >>>                 goto out_free_page; >>> >>> -       if (iommu_map(domain, iova, msi_addr, size, prot)) >>> +       if (iommu_map_atomic(domain, iova, msi_addr, size, prot)) >>>                 goto out_free_iova; >> >> Not so sure this is a bug, this code is only about setting up MSIs on >> ARM. It probably doesn't need to be atomic. > > The patch "iommu: Add gfp parameter to iommu_ops::map" does this. It could be > called from an atomic context as showed in the arm64 call traces, > > +int iommu_map(struct iommu_domain *domain, unsigned long iova, > +             phys_addr_t paddr, size_t size, int prot) > +{ > +       might_sleep(); > +       return __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL); > +} Also note that it's *only* the might_sleep() at issue here - none of the arm64 IOMMU drivers have been converted to look at the new gfp argument yet, so anything they actually allocate while mapping will still be GFP_ATOMIC anyway. (Carrying that flag down through the whole io-pgtable stack is on my to-do list...) Robin.