lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191025225009.50305-3-john.stultz@linaro.org>
Date:   Fri, 25 Oct 2019 22:50:08 +0000
From:   John Stultz <john.stultz@...aro.org>
To:     lkml <linux-kernel@...r.kernel.org>
Cc:     John Stultz <john.stultz@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Laura Abbott <labbott@...hat.com>,
        Benjamin Gaignard <benjamin.gaignard@...aro.org>,
        Sumit Semwal <sumit.semwal@...aro.org>,
        Liam Mark <lmark@...eaurora.org>,
        Pratik Patel <pratikp@...eaurora.org>,
        Brian Starkey <Brian.Starkey@....com>,
        "Andrew F . Davis" <afd@...com>, Chenbo Feng <fengc@...gle.com>,
        Alistair Strachan <astrachan@...gle.com>,
        Sandeep Patil <sspatil@...gle.com>,
        Hridya Valsaraju <hridya@...gle.com>,
        devicetree@...r.kernel.org, dri-devel@...ts.freedesktop.org
Subject: [RFC][PATCH 2/3] dma-buf: heaps: Allow adding specified non-default CMA heaps

In earlier versions of the dmabuf CMA heap, we added all CMA
areas as CMA heaps. Andrew noted this might not be desired,
and so we changed the code to only add the default CMA area.

This patch extends the earlier effort so that devices can
specifiy which CMA areas they want to add as dmabuf heaps via
DT, and we'll only add those.

This allows multiple CMA areas to be exported via the dmabuf
heaps interface.

Cc: Rob Herring <robh+dt@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Laura Abbott <labbott@...hat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@...aro.org>
Cc: Sumit Semwal <sumit.semwal@...aro.org>
Cc: Liam Mark <lmark@...eaurora.org>
Cc: Pratik Patel <pratikp@...eaurora.org>
Cc: Brian Starkey <Brian.Starkey@....com>
Cc: Andrew F. Davis <afd@...com>
Cc: Chenbo Feng <fengc@...gle.com>
Cc: Alistair Strachan <astrachan@...gle.com>
Cc: Sandeep Patil <sspatil@...gle.com>
Cc: Hridya Valsaraju <hridya@...gle.com>
Cc: devicetree@...r.kernel.org
Cc: dri-devel@...ts.freedesktop.org
Signed-off-by: John Stultz <john.stultz@...aro.org>
---
 drivers/dma-buf/heaps/cma_heap.c | 38 ++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
index 064926b5d735..0d5231a1e561 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -15,6 +15,9 @@
 #include <linux/errno.h>
 #include <linux/highmem.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/sched/signal.h>
@@ -174,5 +177,40 @@ static int add_default_cma_heap(void)
 	return ret;
 }
 module_init(add_default_cma_heap);
+
+static int cma_heaps_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct cma *cma_area;
+	int ret;
+
+	ret = of_reserved_mem_device_init_by_idx(&pdev->dev, np, 0);
+	if (ret) {
+		pr_err("Error %s(): of_reserved_mem_device_init_by_idx failed!\n", __func__);
+		return ret;
+	}
+
+	cma_area = dev_get_cma_area(&pdev->dev);
+	if (cma_area)
+		ret = __add_cma_heap(cma_area, NULL);
+
+	return ret;
+}
+
+static const struct of_device_id cma_heap_dt_ids[] = {
+	{ .compatible = "dmabuf-heap-cma" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, cma_heap_dt_ids);
+
+static struct platform_driver cma_heaps_driver = {
+	.driver	= {
+		.name		= "CMA Heaps",
+		.of_match_table	= cma_heap_dt_ids,
+	},
+	.probe	= cma_heaps_probe,
+};
+
+module_platform_driver(cma_heaps_driver);
 MODULE_DESCRIPTION("DMA-BUF CMA Heap");
 MODULE_LICENSE("GPL v2");
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ