Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3392540yba; Tue, 23 Apr 2019 03:03:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJxjl7IWbm5mu8VUl3Rk+R4eGIn+7uaHuAUiwI4Y4fe8ZOy/xErlqkBk6h+m9zBkZ0mMjy X-Received: by 2002:aa7:85cc:: with SMTP id z12mr25899470pfn.142.1556013818499; Tue, 23 Apr 2019 03:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556013818; cv=none; d=google.com; s=arc-20160816; b=YPqDtHf9ipFoLW2OeLA9Pp5jEicf19wsa58wHzWHA2Ihy+Op0Mjp/CSgVq/+blXX7z 8Xj0vmvqmAVn0iYmP6KdWn66nGbRH7b3UleKM+w78J2gFO1ljB60hnjnlmQGMzszBkXt B5CYhvwBWzADGopJQVzCSDwAVkNT9WXK+dBHssGXEcgg6YZZiJWcR4sUV2+N8eRb9FFu YxrHkaMZaGeS8meACJ51qQ7vMue6p2ye6mzpLHXvUz9Jllk2jOq0s0fCzdp8ey4SQCZg SieUfsNxfdOq9+qPoIMYOrfQdPrjg2r7ofCXvOU6AGq9PyLOkFgILbesL8xJrFabWg7M kMJg== 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=QAvJZOlfmfnZCBULgRsPz0SJFv42nsql32VHyCU9K0w=; b=x8i2JBiD6VL6K2v1dkLKGX34RcmlQM04q3P7XOKV5Q97FZ3Hstl25M8Lw8g8VELvwn vel5I4kp5BZ69yGg0SkpyyWHFSNjIQHhk84fODsWJ5JHfx3JBnoJSHFsNGOUy6wLCc61 R1sOGexBvXm31c2QVJC3vsVfsLfhY/yyQhylgEGNQhW95XlltzrVIMOdqq2H7Rplb2hd FfaTP6s33NM/D2SVVSFlGAv/3I+3134jIWXOiRjzsDoB0VRGifkaAjxqmJfDi6QuoeHP nwpVOEPv7Rd9eiPYT/BJLqB7JzVQU5qX4vq3gRqQyE/AXz2WbX7c/4QnawdpInwXKmF1 7ISw== 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 i1si15129292plt.68.2019.04.23.03.03.23; Tue, 23 Apr 2019 03:03:38 -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 S1727377AbfDWKBt (ORCPT + 99 others); Tue, 23 Apr 2019 06:01:49 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53138 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDWKBs (ORCPT ); Tue, 23 Apr 2019 06:01:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B2A0374; Tue, 23 Apr 2019 03:01:48 -0700 (PDT) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E75913F557; Tue, 23 Apr 2019 03:01:46 -0700 (PDT) Subject: Re: [PATCH 12/21] dma-iommu: factor atomic pool allocations into helpers To: Christoph Hellwig Cc: Joerg Roedel , Catalin Marinas , Will Deacon , Tom Lendacky , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20190327080448.5500-1-hch@lst.de> <20190327080448.5500-13-hch@lst.de> <20190410061157.GA5278@lst.de> <20190417063358.GA24139@lst.de> <83615173-a8b4-e0eb-bac3-1a58d61ea4ef@arm.com> <20190418163512.GA25347@lst.de> <228ee57a-d7b2-48e0-a34e-81d5fba0a090@arm.com> <20190419082348.GA22299@lst.de> From: Robin Murphy Message-ID: <0a6b3f53-79e5-af83-be39-f04c9acd8384@arm.com> Date: Tue, 23 Apr 2019 11:01:44 +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: <20190419082348.GA22299@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/04/2019 09:23, Christoph Hellwig wrote: > On Thu, Apr 18, 2019 at 07:15:00PM +0100, Robin Murphy wrote: >> Still, I've worked in the vm_map_pages() stuff pending in MM and given them >> the same treatment to finish the picture. Both x86_64_defconfig and >> i386_defconfig do indeed compile and link fine as I expected, so I really >> would like to understand the concern around #ifdefs better. > > This looks generally fine to me. One thing I'd like to do is to > generally make use of the fact that __iommu_dma_get_pages returns NULL > for the force contigous case as that cleans up a few things. Also > for the !DMA_REMAP case we need to try the page allocator when > dma_alloc_from_contiguous does not return a page. What do you thing > of the following incremental diff? If that is fine with you I can > fold that in and add back in the remaining patches from my series > not obsoleted by your patches and resend. Wouldn't this suffice? Since we also use alloc_pages() in the coherent atomic case, the free path should already be able to deal with it. Let me take a proper look at v3 and see how it all looks in context. Robin. ----->8----- diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 1bc8d1de1a1d..0a02ddc27862 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -944,6 +944,8 @@ static void *iommu_dma_alloc(struct device *dev, size_t size, (attrs & DMA_ATTR_FORCE_CONTIGUOUS)) { page = dma_alloc_from_contiguous(dev, count, page_order, gfp & __GFP_NOWARN); + if (!page) + page = alloc_pages(gfp, page_order); } else { return iommu_dma_alloc_remap(dev, size, handle, gfp, attrs); }