Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp947309ybl; Fri, 10 Jan 2020 09:21:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyx8Y/RJAIw2A0iN/+HM4S9arfDEo/BCf3TMcXSvj18a/5G5Zq5uiaGnQXtVkphpb/oZr4O X-Received: by 2002:a05:6830:1e8a:: with SMTP id n10mr3438863otr.303.1578676876005; Fri, 10 Jan 2020 09:21:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578676875; cv=none; d=google.com; s=arc-20160816; b=OuQIpVt7nez02/28OLrFGgBkoGMTJoOPGlrEAComzYEtjannBNO5wD/OyyH2aPRx+6 Bmmjo6/SJYc5iB8yNSDzKHl2BqAFJVkiA905WBPBw532fDgQHTNdTr0PXaiyHeFZNQ4n rS8tG7LxUPntyjmgbJGtG/qN13LAuKJH5pQLyovRRrqrGMEVjZmqvBLhKh3fO52TWPxI m3EEuU8337zeGtsU+F6w9g9ocVD8I3Mstjpq+JcTR395JhKumd/+to8PecJ7Oc4c48cZ UfnnbTbfyxdZ1itOEsFrJFxa0OZeEJbPyfd66hxwpE/z/s8+PDpitcSmVVLKlKXAU2B1 8tug== 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:mime-version :message-id:date:subject:cc:to:from; bh=IBAff3YcFkJj2TdLyecuBVPufyy4l9MBComZdBZqLIQ=; b=YjaB3qM5ZQnVKFf9X9mrKeiFrOiq21EMFD9lgFKJBaYQ3b0r6SQsYRCCf5UysBxtbB 24bB63H+Dbj2qnuHqJFgZQuIPbcNSuCwIw3vKSk21WW2PCFtpKemDDdk4NWuWdLdqtpL Wg2d8I749mz25pDltYT1l38kwuHliExu9llPDz79ilSwi6UpAVIFh7tA/FWXP/dxo8x8 b4ipjtNWkGpfUSS+pv1t3VkwVFBkh8fBL0oncMgJ6zt0V/z35WXsEbujdKbyErvL1uen IAUbODENkhk8q5KAGUf22qzAOT9x/6pHmoCDJbvTVG9BQK9kxZvOiWRAr3mjWmhjoeOT HsdA== 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 r2si1307881oif.83.2020.01.10.09.21.03; Fri, 10 Jan 2020 09:21:15 -0800 (PST) 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 S1726696AbgAJRT4 (ORCPT + 99 others); Fri, 10 Jan 2020 12:19:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:53260 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgAJRTz (ORCPT ); Fri, 10 Jan 2020 12:19:55 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D9D29B2B7; Fri, 10 Jan 2020 17:19:53 +0000 (UTC) From: Nicolas Saenz Julienne To: Christoph Hellwig , Marek Szyprowski , Robin Murphy Cc: phil@raspberrypi.org, Nicolas Saenz Julienne , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] dma-contiguous: CMA: give precedence to cmdline Date: Fri, 10 Jan 2020 18:19:33 +0100 Message-Id: <20200110171933.15014-1-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although the device tree might contain a reserved-memory DT node dedicated as the default CMA pool, users might want to change CMA's parameters using the kernel command line for debugging purposes and whatnot. Honor this by bypassing the reserved memory CMA setup, which will ultimately end up freeing the memblock and allow the command line CMA configuration routine to run. Signed-off-by: Nicolas Saenz Julienne --- NOTE: Tested this on arm and arm64 with the Raspberry Pi 4. kernel/dma/contiguous.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index daa4e6eefdde..8bc6f2d670f9 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -302,9 +302,16 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) phys_addr_t align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order); phys_addr_t mask = align - 1; unsigned long node = rmem->fdt_node; + bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL); struct cma *cma; int err; + if (size_cmdline != -1 && default_cma) { + pr_info("Reserved memory: bypass %s node, using cmdline CMA params instead\n", + rmem->name); + return -EBUSY; + } + if (!of_get_flat_dt_prop(node, "reusable", NULL) || of_get_flat_dt_prop(node, "no-map", NULL)) return -EINVAL; @@ -322,7 +329,7 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) /* Architecture specific contiguous memory fixup. */ dma_contiguous_early_fixup(rmem->base, rmem->size); - if (of_get_flat_dt_prop(node, "linux,cma-default", NULL)) + if (default_cma) dma_contiguous_set_default(cma); rmem->ops = &rmem_cma_ops; -- 2.24.1