From patchwork Fri May 1 07:39:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 186019 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp284833ilf; Fri, 1 May 2020 00:40:07 -0700 (PDT) X-Received: by 2002:aa7:8489:: with SMTP id u9mr3037619pfn.248.1588318806949; Fri, 01 May 2020 00:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588318806; cv=none; d=google.com; s=arc-20160816; b=MJiJuB8ptVwxTQP3XFfX8U4S3OcCRQ4eUbRseBbUxfHY54TZedJXxg8wG6NklJX47f RXSd3lYfu3/M0XhnjHjjfpd1Ma2L0IW+z1AKoltyj01DTTQlCSxiwqnxIPMLN0WiiaNL lgHmGH16OJt2NKDbGZPq2lGNPkvTRiOlD0KUlAM6gC2PhjSeinHtIeHnnqKrAGNJ0Ww1 p92NwnXf89rLQq5c5aAWyWY923sSNjLR56ksVkhbY3UuTB9Hz2wu6y9dZtm3NBgLKugZ GPwLUjzZyObFl0Yp7LCKHtuiUhtg2PQ+bJFK9m6afLcFd0wKZuzoxyX0Ku4h1aSJmz5k vLvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pbJ0rXWHkCLJRyK9vXiUuFPqdQtHbtzqJkW11UYQ0Gg=; b=hylI41iBScIUzRT5utYXufTMSUASV7XeKVn4pveJVvYw64L9u7oOdvsA0NgHDO595q OpSCFtH5xNO9sAR6Om7/HXEsx+hcFN6yYuQswkxQkaqH5cVngAVt9W+tzlvH0MHKm1bp E+L0iU9v4JQJJ1wtG0O75ojPIF4K1dwy2Vi9LcZ5JoDtnA7YvuEZnfohWJjWOcU8VWfL 4aSCQVhInX8OnoJCcvpUGfmzXUM+fKaumOVTCecMp69c86LQ463NKAL5YYLwAz3f3Pp3 /WDFGgEtKdUr0uu2Yp7ZeCGMMfPW0RS4cx9s7l9kKAb+YAuPehR0s7gjKqoyH32LJiTQ IY8g== 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 john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j10sor2912125pll.0.2020.05.01.00.40.06 for (Google Transport Security); Fri, 01 May 2020 00:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vb0wY5RB; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=WfvrdVxNfbvIPLi4pTBoN4VVJFPxpnIPvzAhhZCOlodx/2kt1BsIY6xpLmkE3rb2bp D5FFTbnI+rNGzkWjwel/bWYTby48SL71SvbW2HuSVIkSWFZZ7ZdTIQWAa7jVsZ9kwsNI +49YIWEUNTI96PKW+cF6M32zcYrPeV45b5XwNshHnKuQgwEMMsEaIWUaIoHF1xqbDqMb JKW3JQkoQzcxLC9D+4N+5C9Uv3/FDda6mA1peAJzi9QJTYPAbF0fKgvc7B/6LuILjy6a M3hbi0y8Wb9Ikmf3uTXJPDUPM56ctASmxOUu3Pdh1qzrPR+0mURI+mH2YNNpEFsxW/0d hPhA== X-Gm-Message-State: AGi0PuanxSU01jHjlsS3yjaDCk0tHyXrSzHi5EC+EGBgHtW+UDbfOhYo H3hN0/4POWRwL4nyo9HAVuOAPLJH X-Google-Smtp-Source: APiQypJrHuK513hl/mWNZ3CMK5SALK94WvqJyZlw7ryX0HGGvoYccP4SvWf/0xIaXWcS+grMnsx+6Q== X-Received: by 2002:a17:902:6b01:: with SMTP id o1mr3395641plk.64.1588318806626; Fri, 01 May 2020 00:40:06 -0700 (PDT) Return-Path: 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> 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(+) -- 2.17.1 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];