Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1726973ybg; Sat, 19 Oct 2019 01:11:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqy74l8IW1uPxHuyiUUE/UcqsDtzKR2GVbrrJfLLeFP2kbD5JxJ2IL+FYcGAxonXhs/sI81F X-Received: by 2002:a05:6402:74b:: with SMTP id p11mr13905993edy.84.1571472663463; Sat, 19 Oct 2019 01:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571472663; cv=none; d=google.com; s=arc-20160816; b=iTORJ3EqIxmNGZQXkeOqKy8Me3LVEbTKw+LU/W2uWmUcijLEsmhQAUB0fn2pTs8U3f I8nTx1j0E1ok3EWN/hkoO4LIrwtxnQkx9xD4RObTxYJcJ2UGmwrw8qO6xjvTZ7F2qq+z /Popwp1EV6HQddl9MhyMbNQHI04jeZtYl1Wto5j5LTdCzSGJrqDhwInrZsJbqu4DTCcT 7IVCVp2QR2RPh6ShmiOEeFCvI5VTpG3R+6fvJxGoFumd+QLaPjMaGptsqGqsUX/4bPHB jRJ1WQRVUU/HNQuWGYjVTJ5sPgjXdm0q028EO0camBbxxAIvb7IzG5dHtBIoKXDchju4 MuDQ== 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=/Ya4YKXyfkx1QEmzFMITpyirHADBegXytF3tgL1Z10s=; b=BYVG1N85FaNi/kVsvHuqXX+Qb0j7FtTJ983pmK8z6bGn5WS7pzlA0Pfyq81NVgcx3F uTzOtcxfo9xq+/uGkMX7cpXzaJIE4bOs+ubyfEtjhgobA6FnggtdFD/tgFTlx8yTDBJ8 Z9nh+FKvkwwZ2nhg59BLSuMRxJXMrFADiLoqWPXp1NQ03WJGrWNzMfZyZld1SFjhqV2t h+W+Y4jL68cmgK/ruv2xuIjOcGuDVcPWwkzWhlKXSW4JQf0ANPzuklKETeak8OZgOQBz yY/FyT18vH5kMAwOZWq/1fSDtmINuWc8pJieFmk2ChDUcBvCiIUReC4Ks5I6PbgwN3MS k1ow== 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 pw26si127736ejb.88.2019.10.19.01.10.40; Sat, 19 Oct 2019 01:11:03 -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 S2442373AbfJRJvK (ORCPT + 99 others); Fri, 18 Oct 2019 05:51:10 -0400 Received: from [217.140.110.172] ([217.140.110.172]:60222 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1730808AbfJRJvK (ORCPT ); Fri, 18 Oct 2019 05:51:10 -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 3540A492; Fri, 18 Oct 2019 02:50:45 -0700 (PDT) Received: from [192.168.1.123] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 235593F6C4; Fri, 18 Oct 2019 02:50:43 -0700 (PDT) Subject: Re: [PATCH] iommu/amd: Pass gfp flags to iommu_map_page() in amd_iommu_map() To: Dan Carpenter , Joerg Roedel Cc: iommu@lists.linux-foundation.org, Joerg Roedel , linux-kernel@vger.kernel.org References: <20191018090736.18819-1-joro@8bytes.org> <20191018092750.GK21344@kadam> From: Robin Murphy Message-ID: <31ba66a3-2435-2fb1-3fc6-782a2f583bf2@arm.com> Date: Fri, 18 Oct 2019 10:50:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20191018092750.GK21344@kadam> 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 2019-10-18 10:27 am, Dan Carpenter wrote: > Did you get a chance to look at iommu_dma_alloc_remap() as well? > > drivers/iommu/dma-iommu.c > 584 static void *iommu_dma_alloc_remap(struct device *dev, size_t size, > 585 dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) > ^^^^^^^^^ > 586 { > 587 struct iommu_domain *domain = iommu_get_dma_domain(dev); > 588 struct iommu_dma_cookie *cookie = domain->iova_cookie; > 589 struct iova_domain *iovad = &cookie->iovad; > 590 bool coherent = dev_is_dma_coherent(dev); > 591 int ioprot = dma_info_to_prot(DMA_BIDIRECTIONAL, coherent, attrs); > 592 pgprot_t prot = dma_pgprot(dev, PAGE_KERNEL, attrs); > 593 unsigned int count, min_size, alloc_sizes = domain->pgsize_bitmap; > 594 struct page **pages; > 595 struct sg_table sgt; > 596 dma_addr_t iova; > 597 void *vaddr; > 598 > 599 *dma_handle = DMA_MAPPING_ERROR; > 600 > 601 if (unlikely(iommu_dma_deferred_attach(dev, domain))) > 602 return NULL; > 603 > 604 min_size = alloc_sizes & -alloc_sizes; > 605 if (min_size < PAGE_SIZE) { > 606 min_size = PAGE_SIZE; > 607 alloc_sizes |= PAGE_SIZE; > 608 } else { > 609 size = ALIGN(size, min_size); > 610 } > 611 if (attrs & DMA_ATTR_ALLOC_SINGLE_PAGES) > 612 alloc_sizes = min_size; > 613 > 614 count = PAGE_ALIGN(size) >> PAGE_SHIFT; > 615 pages = __iommu_dma_alloc_pages(dev, count, alloc_sizes >> PAGE_SHIFT, > 616 gfp); > 617 if (!pages) > 618 return NULL; > 619 > 620 size = iova_align(iovad, size); > 621 iova = iommu_dma_alloc_iova(domain, size, dev->coherent_dma_mask, dev); > 622 if (!iova) > 623 goto out_free_pages; > 624 > 625 if (sg_alloc_table_from_pages(&sgt, pages, count, 0, size, GFP_KERNEL)) > ^^^^^^^^^^ > gfp here instead of GFP_KERNEL? This is, from what I remember, intentional - it's a temporary allocation which doesn't need to have the same restrictions as the actual buffer being allocated (e.g. GFP_DMA32 etc.). We don't need to worry about GFP_ATOMIC since the whole thing is only ever called in sleeping contexts. Robin. > > 626 goto out_free_iova; > 627 > 628 if (!(ioprot & IOMMU_CACHE)) { > > regards, > dan carpenter > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu >