Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1408143pxk; Thu, 10 Sep 2020 14:44:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZvUrbixQ2TmZEptMjRJe9aJHn3Q1T5kgPy7w2ugJyAW2Weaz0zMToq1qL53bG95UCdInX X-Received: by 2002:a17:907:432b:: with SMTP id ob19mr11045472ejb.400.1599774255052; Thu, 10 Sep 2020 14:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599774255; cv=none; d=google.com; s=arc-20160816; b=EOkO10W/vZSF9HhThTWyYRZ1tvLpPCOcLU9YMFsYQAGhGNus2sH3ImCvt/i8H52tmT puuqO0Ta1LUZdGvVoLdAMYRt4unkvNUaVHmt79mrnRm6i6kkVV6TavMr5Cd6iIQAwn0z Wl1gaojbQAHD39YLdcM0MCbYls5Artxw9bD1rPj3SZsf8UgOI9phNU6k+YY+AxbVZQU8 Ka/ixD3RZWtwEXLwiVJIYOeRCDcqFpFxZVsshnyqJCs3X/LRBLiZ3kTrrWrkIVh7wJpT 9jCVtY6w5OzSJZikTZVSQUUiIkKUDCyAG6dpX7Kc8YFRGvcDCN5F8iE3gWSlFMDHppKU H3mA== 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=kS/eLJ/nw9viKBfJvaSUpwvyjuAWgCVkvfvDa3KEliE=; b=qOG93zcarccD/SeHbfnDp9MvzLaVi3vYfRLFzZsmKWZBW+RSwn3Ut5FgwuyWq2Vle5 7SbGBAYVYnaiOf9xCmnSihS4axCv/hrl4W2Z9aV1fmrLfLwLqeGC7R9rtsKuEo9+bXqs DBftUwTW7wZ/17C6oh9ZzwumU/qbeeoU0DpkTe7IoaKhPSg4hd1ok5pBa03/wv3fd/DX GKJYehqp/R3GR/ph+Zah0on1t06DAsWIM7lXn+KULxSP8Sha1cqCxYLlG7KZSJqvGjzE rWUtLYIrWpfo49DUzXaOsLnBlO1b/xRnj5OqD/UQmhdhZIRUs2CwNQI7Jnmy/jy9ZvYn R/CA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si4685216edv.439.2020.09.10.14.43.51; Thu, 10 Sep 2020 14:44:15 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727930AbgIJVms (ORCPT + 99 others); Thu, 10 Sep 2020 17:42:48 -0400 Received: from foss.arm.com ([217.140.110.172]:35488 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730715AbgIJNCV (ORCPT ); Thu, 10 Sep 2020 09:02:21 -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 205931063; Thu, 10 Sep 2020 06:02:05 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 71A813F66E; Thu, 10 Sep 2020 06:02:03 -0700 (PDT) Subject: Re: [PATCH 07/12] dma-direct: lift gfp_t manipulation out of__dma_direct_alloc_pages To: Christoph Hellwig , Tony Luck , Fenghua Yu , Thomas Bogendoerfer , iommu@lists.linux-foundation.org Cc: linux-ia64@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org References: <20200908164758.3177341-1-hch@lst.de> <20200908164758.3177341-8-hch@lst.de> From: Robin Murphy Message-ID: <3658a0b7-c2b7-8b03-86c6-219f77799999@arm.com> Date: Thu, 10 Sep 2020 14:02:01 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200908164758.3177341-8-hch@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 2020-09-08 17:47, Christoph Hellwig wrote: > Move the detailed gfp_t setup from __dma_direct_alloc_pages into the > caller to clean things up a little. Other than a mild nitpick that it might be nicer to spend one extra line to keep both gfp adjustments next to each other, Reviewed-by: Robin Murphy > Signed-off-by: Christoph Hellwig > --- > kernel/dma/direct.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > index 1d564bea58571b..12e9f5f75dfe4b 100644 > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -108,7 +108,7 @@ static inline bool dma_should_free_from_pool(struct device *dev, > } > > static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, > - gfp_t gfp, unsigned long attrs) > + gfp_t gfp) > { > int node = dev_to_node(dev); > struct page *page = NULL; > @@ -116,11 +116,6 @@ static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, > > WARN_ON_ONCE(!PAGE_ALIGNED(size)); > > - if (attrs & DMA_ATTR_NO_WARN) > - gfp |= __GFP_NOWARN; > - > - /* we always manually zero the memory once we are done: */ > - gfp &= ~__GFP_ZERO; > gfp |= dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask, > &phys_limit); > page = dma_alloc_contiguous(dev, size, gfp); > @@ -164,6 +159,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, > return arch_dma_alloc(dev, size, dma_handle, gfp, attrs); > > size = PAGE_ALIGN(size); > + if (attrs & DMA_ATTR_NO_WARN) > + gfp |= __GFP_NOWARN; > > if (dma_should_alloc_from_pool(dev, gfp, attrs)) { > u64 phys_mask; > @@ -177,7 +174,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, > goto done; > } > > - page = __dma_direct_alloc_pages(dev, size, gfp, attrs); > + /* we always manually zero the memory once we are done */ > + page = __dma_direct_alloc_pages(dev, size, gfp & ~__GFP_ZERO); > if (!page) > return NULL; > >