Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp397704ybz; Fri, 1 May 2020 00:41:51 -0700 (PDT) X-Google-Smtp-Source: APiQypKfVo8+T7NqQZ0rogEcZ+odenZJtf9wsgAnVESInWDduTrllECyGz9nMbRobhKFxT49Vid+ X-Received: by 2002:a50:9f23:: with SMTP id b32mr2249870edf.183.1588318910991; Fri, 01 May 2020 00:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588318910; cv=none; d=google.com; s=arc-20160816; b=ZuYNhoHM2TC/8trT3CPI9x8x9UmcaAZfmpEi5IWraorE6JRERHiBBa8F8fzMsY3q6+ i+tBZRgR5e0fXS5JHTxt/aE88GlnRpDMf8WHQJ3J66kd1Y71w29R2plWxCgmq85epL95 Y91Fv/RrcAkURXTd4YKW+N23Uk4CybJPuGlioMkoe/EhXmbYTiekAlDm701sjd81SV2/ eGjQk/C7qop51c67FE2x7YaNHdZLdx+nTt4JGb0eFjl1AguLW7ZeDdh34IFLOJHlbgiV dG3Y1hAJTGp5w2aai6GMV8JTLPT9Xq5BxcsgQeQM/6KnCKhuRpSHrclPzlTR+Yu4wTl0 IGiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=pbJ0rXWHkCLJRyK9vXiUuFPqdQtHbtzqJkW11UYQ0Gg=; b=NdJWFD/HKQrCuGTS6qdeOMziknEleMLi93mirRBwSPg7izhhIfcNNM62/tnqD+N1I4 /zVlgSZchJ2JdG2eapo+c21WBZHX/Y3IJRwDuADIlN1L9BUflzn9P2qmAO+O1sl/mzL8 zR1Pp2XbC2aQcuoPwBPJTWpnXFzBr5JVrobi8mFhQAat8LyHh+WTwSuZKqhRbJN72OXz MA2pwh2VZA0ZvZ5QMh2zoLd/Vv/0+VnCj0WdIPltY4NdEf8Q2ovC7bXZ3QpuanftbGx9 FewzSiQfRMWHfj9M605ZOccg8lFzirH7F3rUvmcERpsyjG/FZJ/sdrH5kTt3VFdCLFxa Z8Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vb0wY5RB; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si1226473ejv.375.2020.05.01.00.41.28; Fri, 01 May 2020 00:41:50 -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=@linaro.org header.s=google header.b=vb0wY5RB; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728359AbgEAHkI (ORCPT + 99 others); Fri, 1 May 2020 03:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728352AbgEAHkH (ORCPT ); Fri, 1 May 2020 03:40:07 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 421E6C035495 for ; Fri, 1 May 2020 00:40:07 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id u22so3396562plq.12 for ; Fri, 01 May 2020 00:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pbJ0rXWHkCLJRyK9vXiUuFPqdQtHbtzqJkW11UYQ0Gg=; b=vb0wY5RB7Avh9W40PInSuMIMfqVVX8c5gNx4ovRY8kJyxvZpFLdww15R4N6GP0BdJO kgrgqAzooQ68Q9h97J83Z4uygdncUlx9LUQNXlDR83RSSuYlXcMHM61ShwEckSNa/w7j zGeH7KfIJLwO4jcDE+hc8uyeYhlVyv3TJoSE5JPRSbPgtGRPc13KO8L6QoWmL398HqVa 3w+KMqQFA5upozNshMJzy7mU+yY6mts1x0PnRbUfUkevtqmFalyAtIiDrHPV6U79ju0B RGvaj1qzRpkf+1dHg8hx94nkYH28ELKWwg+2aR17hsgwFDSTrgW0H37OI6J/sl2XNoQk 7nXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pbJ0rXWHkCLJRyK9vXiUuFPqdQtHbtzqJkW11UYQ0Gg=; b=DXDtl1mf+ewYrxHm6iyKuqq7qAU4K4BemjKHVZ2cgtIEAAIUycu5e1ZipICfGWC6un WRwXyCmeFV93MIPyL+imEwQe0YCkMqMpBESinabPSHzK729HuYM4Q1DsAaV+SfDB5WFB IqW1yZc4zip4D4mLiglxaUJV62qPCwUk/ltCNKjuBzzPbgpthhv3/3V+HDZiO+/FEAYZ /XQczK4BC1zugKbVzJ6ZOH9BjHiy8Mld7kimzf46Ypl6VV1OF9KBhGT8/faeeIDESj6J gPs1MhZiISkz9BsCtwgxcZZ4vFoIYSE/EaSOqfNMgkCfsZ8tpRUnegumxtvEsq4NvTO9 zC8A== X-Gm-Message-State: AGi0PuZAQ9Rh2NKB0WjXFSVw01dacDBKkyhbJlVWPJGI54xSVtarfHOS nZPTRGTIBnS0RksxN22nZoP8NMj5C2k= X-Received: by 2002:a17:902:6b01:: with SMTP id o1mr3395641plk.64.1588318806626; Fri, 01 May 2020 00:40:06 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id w12sm1557841pfq.133.2020.05.01.00.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 00:40:06 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Rob Herring , Sumit Semwal , "Andrew F. Davis" , Benjamin Gaignard , Liam Mark , Pratik Patel , Laura Abbott , Brian Starkey , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Andrew Morton , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org Subject: [RFC][PATCH 2/4] mm: cma: Add dma_heap flag to cma structure Date: Fri, 1 May 2020 07:39:47 +0000 Message-Id: <20200501073949.120396-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501073949.120396-1-john.stultz@linaro.org> References: <20200501073949.120396-1-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a dma_heap flag on the cma structure, along with accessors to set and read the flag. This is then used to process and store the "linux,cma-heap" property documented in the previous patch. Cc: Rob Herring Cc: Sumit Semwal Cc: "Andrew F. Davis" Cc: Benjamin Gaignard Cc: Liam Mark Cc: Pratik Patel Cc: Laura Abbott Cc: Brian Starkey Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Andrew Morton Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-mm@kvack.org Signed-off-by: John Stultz --- include/linux/cma.h | 3 +++ kernel/dma/contiguous.c | 3 +++ mm/cma.c | 11 +++++++++++ mm/cma.h | 1 + 4 files changed, 18 insertions(+) diff --git a/include/linux/cma.h b/include/linux/cma.h index 6ff79fefd01f..d8b8e6ce221c 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -25,6 +25,9 @@ extern phys_addr_t cma_get_base(const struct cma *cma); extern unsigned long cma_get_size(const struct cma *cma); extern const char *cma_get_name(const struct cma *cma); +extern void __init cma_enable_dma_heap(struct cma *cma, bool enabled); +extern bool cma_dma_heap_enabled(struct cma *cma); + extern int __init cma_declare_contiguous_nid(phys_addr_t base, phys_addr_t size, phys_addr_t limit, phys_addr_t alignment, unsigned int order_per_bit, diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 8bc6f2d670f9..f667fd51daa2 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -303,6 +303,7 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) 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); + bool heap_exported = of_get_flat_dt_prop(node, "linux,cma-heap", NULL); struct cma *cma; int err; @@ -332,6 +333,8 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) if (default_cma) dma_contiguous_set_default(cma); + cma_enable_dma_heap(cma, heap_exported); + rmem->ops = &rmem_cma_ops; rmem->priv = cma; diff --git a/mm/cma.c b/mm/cma.c index 0463ad2ce06b..ec671bd8f66e 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -55,6 +55,16 @@ const char *cma_get_name(const struct cma *cma) return cma->name ? cma->name : "(undefined)"; } +void __init cma_enable_dma_heap(struct cma *cma, bool enabled) +{ + cma->dma_heap = enabled; +} + +bool cma_dma_heap_enabled(struct cma *cma) +{ + return !!cma->dma_heap; +} + static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, unsigned int align_order) { @@ -157,6 +167,7 @@ static int __init cma_init_reserved_areas(void) } core_initcall(cma_init_reserved_areas); + /** * cma_init_reserved_mem() - create custom contiguous area from reserved memory * @base: Base address of the reserved area diff --git a/mm/cma.h b/mm/cma.h index 33c0b517733c..6fe2242c724f 100644 --- a/mm/cma.h +++ b/mm/cma.h @@ -13,6 +13,7 @@ struct cma { spinlock_t mem_head_lock; #endif const char *name; + bool dma_heap; }; extern struct cma cma_areas[MAX_CMA_AREAS]; -- 2.17.1