Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1714732pxj; Wed, 19 May 2021 12:10:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0/2ARe5a7PMufYqZ5F/sI1czBqRPN3zC8FCtIzNzsXJchFnnvfYvN9TT21i4/ig2mtAp6 X-Received: by 2002:a05:6e02:1d1a:: with SMTP id i26mr667144ila.180.1621451405023; Wed, 19 May 2021 12:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621451405; cv=none; d=google.com; s=arc-20160816; b=o4rVgZZ+IBLeEvDW27v+E3FmuorYLCHyj1HjSZs+39mAMEUgBV70IQZmnTkM5RMNws XhQofTWwXhhRJgeQJZHk8ag8Kbm6mPWC4kns7pstMpVcEe1HDl390razex82m9I1lJK3 ZSb41+WB4mJKUzH5J70kdwMLQn51GC0sOhJCu0Ndbet0OlWKLv7pomCKQ/mSH8jPuj/S M10LtXq52+5FSP1VmY4BHxXrMJ7nF/3ZYeRKbPzPZUJghe8jbRDfAYGlJBn6P1Kq/FKm xNHrcIiK4jpOJsSNij6TyrfmfgC5Ze/yqvA61TKlJKMMsuCcgs4g0fsldAtLzyDgf9vo ekFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HhI/6V9NfoJZk78Xj3HSIgGBenrGacrIrQhkazt2/Pg=; b=a3nAgA/i2lX6mg+ILHucPrbJGbEynVh7b9fKLMufrJELMN034/+NKxINSm60W7CkzD eP0VKG3iNpzVJCVA/Ojyq85o9mqAJXMqAtD/GHb4wjn3n1mLV2lCMfVGsZgtXcZAkf6y WOjtCJXpXne85ZPsWPDPVccq3O/6EtnhAkrS4znraZdqbzhD1N/mm1lTF28cV7ysJSAu W6BRC6r+6cUaAKi1A4FYehDTj9Mh1Cab6zy1QsuXmhAKQ0sfj7uX/Ww49SpBWLKm+0Fb 9sfNHp7PtLT3XZwC773Vh4qAaB1yKzZL+ARwekLV5rjBQlTaLbPKNPCe+7m8f9MtBCTV OwiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BDabwLgl; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si140275jat.97.2021.05.19.12.09.52; Wed, 19 May 2021 12:10:05 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BDabwLgl; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353256AbhESD5U (ORCPT + 99 others); Tue, 18 May 2021 23:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235703AbhESD5U (ORCPT ); Tue, 18 May 2021 23:57:20 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749B9C06175F for ; Tue, 18 May 2021 20:56:00 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id d3-20020a9d29030000b029027e8019067fso10559810otb.13 for ; Tue, 18 May 2021 20:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HhI/6V9NfoJZk78Xj3HSIgGBenrGacrIrQhkazt2/Pg=; b=BDabwLgl6MZS4U8XrrFfu4+rhJeSJnpXyXKVfXeCBYYzg6RwPFuTQUgwemNDEpr1u5 0MOMW4AxeFPbDMVv7pPJL90+WLZm0edmQl2boNfWalW9tn1lcBGFQxOGwJfRHSo2XFW5 BrWESt0MqZgnRAE9FJShc8MbG9Qt8GnzeAaUQFGE7Qs+19jLWg2Wp9EC4VFfeE7ezmdG GV/fR0iVhT8T7+hT8+6DvdP7JkKyWmfHRQR50XuE0RHlnvbR0/s6fxeF5IXXGlfPN4vc fAr0KmaSIZCfhtexblbMFReAvS1w7z2uv5rwGnkHMZ7Kp25fYRuJvIZrsUaitszkaL8I wmZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HhI/6V9NfoJZk78Xj3HSIgGBenrGacrIrQhkazt2/Pg=; b=BUaChGMmT2MUJdjbn7T9k4LExaOWGx6yKucRChEOHFDZP8pdKu0k+j/F1Ysjm4lJYw mG37umd0UWaP7q1xJaXTAqd1R7kH5P5SRBfNg160KvelSIk+QqgB3Zp7uzCj2owqboJ6 zMjPbasXjrBMtQWZDzy7icf1f5Q4IqD3+24iOuqWumIgtexCwdpwZ0St3dNYx0e8+oqc azBpLUojL105bFHgkCiluenjY38FSXYQ9+sE9yRWS5qbB37EMqnpQIMR3NCqPk1pXmWM WV/JxvV0Ty3eiqTU8btSS/1th7JoXx7zOGL/0qVDKvM9bIwt78K2sWTtsCDnhoVQOVZR fpQQ== X-Gm-Message-State: AOAM530jWisMDR8jFsCS0qPtGB2Qo7qGWmzeZkhsrbKrEWa84HCnO23s 2l/m3e5ETx/lTsAwndYnbOBPUQ2F6lbMX0plgIJt0g+O X-Received: by 2002:a9d:4115:: with SMTP id o21mr7143864ote.52.1621396559845; Tue, 18 May 2021 20:55:59 -0700 (PDT) MIME-Version: 1.0 References: <20210518112857.1198415-1-aisheng.dong@nxp.com> In-Reply-To: From: Dong Aisheng Date: Wed, 19 May 2021 11:54:56 +0800 Message-ID: Subject: Re: [PATCH 1/1] dma-contiguous: return early for dt case in dma_contiguous_reserve To: Robin Murphy Cc: Dong Aisheng , iommu@lists.linux-foundation.org, open list , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 19, 2021 at 2:51 AM Robin Murphy wrote: > > On 2021-05-18 12:28, Dong Aisheng wrote: > > dma_contiguous_reserve() aims to support cmdline case for CMA memory > > reserve. But if users define reserved memory in DT, > > 'dma_contiguous_default_area' will not be 0, then it's meaningless > > to continue to run dma_contiguous_reserve(). So we return early > > if detect 'dma_contiguous_default_area' is unzero. > > But dma_contiguous_default_area *shouldn't* be set if the command-line > argument is present - see the "if (size_cmdline != -1 && default_cma)" > part of rmem_cma_setup(). Are you seeing something different in practice? > yes, you're right. > > Cc: Christoph Hellwig > > Cc: Marek Szyprowski > > Cc: Robin Murphy > > Signed-off-by: Dong Aisheng > > --- > > kernel/dma/contiguous.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c > > index 3d63d91cba5c..ebade9f43eff 100644 > > --- a/kernel/dma/contiguous.c > > +++ b/kernel/dma/contiguous.c > > @@ -171,6 +171,9 @@ void __init dma_contiguous_reserve(phys_addr_t limit) > > phys_addr_t selected_limit = limit; > > bool fixed = false; > > > > + if (dma_contiguous_default_area) > > + return; > > + > > pr_debug("%s(limit %08lx)\n", __func__, (unsigned long)limit); > > > > if (size_cmdline != -1) { > > @@ -191,7 +194,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit) > > #endif > > } > > > > - if (selected_size && !dma_contiguous_default_area) { > > + if (selected_size) { > > Either way, does skipping a handful of trivial calculations and a > debugging message really matter even when it is redundant? I can't > imagine it has any measurable effect on boot times... > I think it's not about performance. It aims to improve the code readability as it's meaningless to continue to execute cmdline CMA reserve logic once DT is used successfully which is a bit confusing when people first read this part of code. Does it make sense to you? Regards Aisheng > Robin. > > > pr_debug("%s: reserving %ld MiB for global area\n", __func__, > > (unsigned long)selected_size / SZ_1M); > > > >