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>] [day] [month] [year] [list]
Message-ID: <561B6233.9090008@baylibre.com>
Date:	Mon, 12 Oct 2015 09:33:07 +0200
From:	Neil Armstrong <narmstrong@...libre.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
	Grant Likely <grant.likely@...aro.org>,
	Josh Cartwright <joshc@...eaurora.org>,
	Marek Szyprowski <m.szyprowski@...sung.com>
Subject: [PATCH 1/2] base: dma-coherent: Add DT property for non exclusive
 shared-dma-pool

In order to have the ability to declare a non exclusive shared-dma-pool,
i.e. without the DMA_MEMORY_EXCLUSIVE flag, add the 'no-exclusive' DT
optional parameter to initialize the coherent memory without the flag.

Leave exclusive memory as default.

Signed-off-by: Neil Armstrong <narmstrong@...libre.com>
---
 drivers/base/dma-coherent.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 55b8398..e32d3cc 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -276,13 +276,14 @@ EXPORT_SYMBOL(dma_mmap_from_coherent);
 #include <linux/of_fdt.h>
 #include <linux/of_reserved_mem.h>

-static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
+static int rmem_dma_device_flags_init(struct reserved_mem *rmem,
+				      struct device *dev, int flags)
 {
 	struct dma_coherent_mem *mem = rmem->priv;

 	if (!mem &&
 	    dma_init_coherent_memory(rmem->base, rmem->base, rmem->size,
-				     DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE,
+				     DMA_MEMORY_MAP | flags,
 				     &mem) != DMA_MEMORY_MAP) {
 		pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n",
 			&rmem->base, (unsigned long)rmem->size / SZ_1M);
@@ -293,6 +294,17 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 	return 0;
 }

+static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
+{
+	return rmem_dma_device_flags_init(rmem, dev, 0);
+}
+
+static int rmem_dma_device_exclusive_init(struct reserved_mem *rmem,
+					  struct device *dev)
+{
+	return rmem_dma_device_flags_init(rmem, dev, DMA_MEMORY_EXCLUSIVE);
+}
+
 static void rmem_dma_device_release(struct reserved_mem *rmem,
 				    struct device *dev)
 {
@@ -304,6 +316,11 @@ static const struct reserved_mem_ops rmem_dma_ops = {
 	.device_release	= rmem_dma_device_release,
 };

+static const struct reserved_mem_ops rmem_dma_exclusive_ops = {
+	.device_init	= rmem_dma_device_exclusive_init,
+	.device_release	= rmem_dma_device_release,
+};
+
 static int __init rmem_dma_setup(struct reserved_mem *rmem)
 {
 	unsigned long node = rmem->fdt_node;
@@ -318,7 +335,10 @@ static int __init rmem_dma_setup(struct reserved_mem *rmem)
 	}
 #endif

-	rmem->ops = &rmem_dma_ops;
+	if (of_get_flat_dt_prop(node, "no-exclusive", NULL))
+		rmem->ops = &rmem_dma_ops;
+	else
+		rmem->ops = &rmem_dma_exclusive_ops;
 	pr_info("Reserved memory: created DMA memory pool at %pa, size %ld MiB\n",
 		&rmem->base, (unsigned long)rmem->size / SZ_1M);
 	return 0;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ