Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp635394pxv; Thu, 8 Jul 2021 10:24:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrcg0jRl0FBfOCBQbRpjEiLbdoauVMyGa+d3ipdrbe81WBdTAdW0mMYTUmNTIlORqxcbx5 X-Received: by 2002:a92:de12:: with SMTP id x18mr23204553ilm.302.1625765044588; Thu, 08 Jul 2021 10:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625765044; cv=none; d=google.com; s=arc-20160816; b=lStsylFmSYoO1/2/Pi+2jcOBWspzWjAGxAk9z8gOa900o8EFbFEpgbU/MzpQAhnNMP HYOWlbbFSOYThaFhsNfUu0JA1QlcdlLP3mSzmZU/vRqKqgcSMb3CYdmUOE2pryJNRaD7 oH0cYv5i/Lltmnb93+2uLl76U5i53X2u6rTIlzNgQMGMkL5KUG9TwarAfq2OQPMO13F+ /xg9OlyzQs/IpSOLM4rhwB/eZCO7qxTOylL4kvNtvvAqswcslqmN5FWOqVNphIYpO4hd ciHt4yYJwCn2h+QPQ2xy81iL4aUsq9GVHPLAv1OxnavBtkczFURWTfV0Goc5z2Z595lD 1jzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=+fHBUWuOf7HjtV/A8/Htv7ENfPla4KMlMkaYRSi5JaM=; b=mUzQ45J83yC89EvHkVEkXm3hhsDQtG1QOp+0m7ISVn3V0k7wdIneP8llytz4dqGWy5 ibJKZG5DMXP0NgtRR4jnp25oLggMA/juFEg9BOWxQdPw/qSm1Um1jHFKsSaXzGx5wxNJ bqtjI6jw8cdZXXQ44PhGeCCE7U/G9pL0cgMZsfeRRomA3tAjNlqF/ehv/p+rypVc3MFJ ZaiEugZzjjtQ69TJvKG3YM6boZXTmaiPsYavcbRhJYfaeO5rnEg3fXnHm3+WL7XsXUgG 5VRawUQVP5b0J86DHKjqp6C+d6mzQYTMvWG5fQDEflyIRmBKIxVRdKWZTtdYxThBlo72 x0BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si2588391iot.72.2021.07.08.10.23.52; Thu, 08 Jul 2021 10:24:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbhGHRZG (ORCPT + 99 others); Thu, 8 Jul 2021 13:25:06 -0400 Received: from foss.arm.com ([217.140.110.172]:35038 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbhGHRZF (ORCPT ); Thu, 8 Jul 2021 13:25:05 -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 4415FED1; Thu, 8 Jul 2021 10:22:23 -0700 (PDT) Received: from [10.57.35.192] (unknown [10.57.35.192]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27E413F73B; Thu, 8 Jul 2021 10:22:22 -0700 (PDT) Subject: Re: [PATCH 1/4] dma-iommu: add kalloc gfp flag to alloc helper To: David Stevens , Joerg Roedel , Will Deacon Cc: Sergey Senozhatsky , iommu@lists.linux-foundation.org, Christoph Hellwig , linux-kernel@vger.kernel.org References: <20210707075505.2896824-1-stevensd@google.com> <20210707075505.2896824-2-stevensd@google.com> From: Robin Murphy Message-ID: <8cdbcbbb-5064-ae7f-af4a-abb0e4203b6d@arm.com> Date: Thu, 8 Jul 2021 18:22:17 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210707075505.2896824-2-stevensd@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-07-07 08:55, David Stevens wrote: > From: David Stevens > > Add gfp flag for kalloc calls within __iommu_dma_alloc_pages, so the > function can be called from atomic contexts. Why bother? If you need GFP_ATOMIC for allocating the pages array, then you don't not need it for allocating the pages themselves. It's hardly rocket science to infer one from the other. Robin. > Signed-off-by: David Stevens > --- > drivers/iommu/dma-iommu.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 614f0dd86b08..00993b56c977 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -593,7 +593,8 @@ static void __iommu_dma_free_pages(struct page **pages, int count) > } > > static struct page **__iommu_dma_alloc_pages(struct device *dev, > - unsigned int count, unsigned long order_mask, gfp_t gfp) > + unsigned int count, unsigned long order_mask, > + gfp_t page_gfp, gfp_t kalloc_gfp) > { > struct page **pages; > unsigned int i = 0, nid = dev_to_node(dev); > @@ -602,15 +603,15 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev, > if (!order_mask) > return NULL; > > - pages = kvzalloc(count * sizeof(*pages), GFP_KERNEL); > + pages = kvzalloc(count * sizeof(*pages), kalloc_gfp); > if (!pages) > return NULL; > > /* IOMMU can map any pages, so himem can also be used here */ > - gfp |= __GFP_NOWARN | __GFP_HIGHMEM; > + page_gfp |= __GFP_NOWARN | __GFP_HIGHMEM; > > /* It makes no sense to muck about with huge pages */ > - gfp &= ~__GFP_COMP; > + page_gfp &= ~__GFP_COMP; > > while (count) { > struct page *page = NULL; > @@ -624,7 +625,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev, > for (order_mask &= (2U << __fls(count)) - 1; > order_mask; order_mask &= ~order_size) { > unsigned int order = __fls(order_mask); > - gfp_t alloc_flags = gfp; > + gfp_t alloc_flags = page_gfp; > > order_size = 1U << order; > if (order_mask > order_size) > @@ -680,7 +681,7 @@ static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev, > > count = PAGE_ALIGN(size) >> PAGE_SHIFT; > pages = __iommu_dma_alloc_pages(dev, count, alloc_sizes >> PAGE_SHIFT, > - gfp); > + gfp, GFP_KERNEL); > if (!pages) > return NULL; > >