From: Maxime Ripard <mripard@kernel.org>
To: "Rob Herring" <robh@kernel.org>,
"Saravana Kannan" <saravanak@google.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
"Brian Starkey" <Brian.Starkey@arm.com>,
"John Stultz" <jstultz@google.com>,
"T.J. Mercier" <tjmercier@google.com>,
"Christian König" <christian.koenig@amd.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org,
Maxime Ripard <mripard@kernel.org>
Subject: [PATCH 8/8] dma-buf: heaps: carveout: Handle ECC flags
Date: Wed, 15 May 2024 15:57:03 +0200 [thread overview]
Message-ID: <20240515-dma-buf-ecc-heap-v1-8-54cbbd049511@kernel.org> (raw)
In-Reply-To: <20240515-dma-buf-ecc-heap-v1-0-54cbbd049511@kernel.org>
Now that we have introduced ECC-related flags for the dma-heaps buffer
allocations, let's honour these flags depending on the memory setup.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/dma-buf/heaps/carveout_heap.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/dma-buf/heaps/carveout_heap.c b/drivers/dma-buf/heaps/carveout_heap.c
index 896ca67e6bd9..81b167785999 100644
--- a/drivers/dma-buf/heaps/carveout_heap.c
+++ b/drivers/dma-buf/heaps/carveout_heap.c
@@ -6,10 +6,11 @@
#include <linux/of_reserved_mem.h>
struct carveout_heap_priv {
struct dma_heap *heap;
struct gen_pool *pool;
+ bool ecc_enabled;
};
struct carveout_heap_buffer_priv {
struct mutex lock;
struct list_head attachments;
@@ -182,10 +183,16 @@ static struct dma_buf *carveout_heap_allocate(struct dma_heap *heap,
struct dma_buf *buf;
dma_addr_t daddr;
void *buffer;
int ret;
+ if (!heap_priv->ecc_enabled && (heap_flags & DMA_HEAP_FLAG_ECC_PROTECTED))
+ return ERR_PTR(-EINVAL);
+
+ if (heap_priv->ecc_enabled && (heap_flags & DMA_HEAP_FLAG_ECC_UNPROTECTED))
+ return ERR_PTR(-EINVAL);
+
buffer_priv = kzalloc(sizeof(*buffer_priv), GFP_KERNEL);
if (!buffer_priv)
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&buffer_priv->attachments);
@@ -235,20 +242,29 @@ static int __init carveout_heap_setup(struct device_node *node)
const struct reserved_mem *rmem;
struct carveout_heap_priv *priv;
struct dma_heap *heap;
struct gen_pool *pool;
void *base;
+ u32 val = 0;
int ret;
rmem = of_reserved_mem_lookup(node);
if (!rmem)
return -EINVAL;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
+ of_property_read_u32(node, "ecc-correction-bits", &val);
+ if (val <= 0) {
+ if (of_memory_get_ecc_correction_bits() > 0)
+ priv->ecc_enabled = true;
+ } else {
+ priv->ecc_enabled = true;
+ }
+
pool = gen_pool_create(PAGE_SHIFT, NUMA_NO_NODE);
if (!pool) {
ret = -ENOMEM;
goto err_cleanup_heap;
}
--
2.44.0
next prev parent reply other threads:[~2024-05-15 13:58 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 13:56 [PATCH 0/8] dma-buf: heaps: Support carved-out heaps and ECC related-flags Maxime Ripard
2024-05-15 13:56 ` [PATCH 1/8] dma-buf: heaps: Introduce a new heap for reserved memory Maxime Ripard
2024-05-15 13:56 ` [PATCH 2/8] of: Add helper to retrieve ECC memory bits Maxime Ripard
2024-05-15 13:56 ` [PATCH 3/8] dma-buf: heaps: Import uAPI header Maxime Ripard
2024-05-16 8:14 ` Christian König
2024-05-15 13:56 ` [PATCH 4/8] dma-buf: heaps: Add ECC protection flags Maxime Ripard
2024-05-15 13:57 ` [PATCH 5/8] dma-buf: heaps: system: Remove global variable Maxime Ripard
2024-05-15 13:57 ` [PATCH 6/8] dma-buf: heaps: system: Handle ECC flags Maxime Ripard
2024-05-15 13:57 ` [PATCH 7/8] dma-buf: heaps: cma: " Maxime Ripard
2024-05-16 5:55 ` kernel test robot
2024-05-16 12:48 ` kernel test robot
2024-05-15 13:57 ` Maxime Ripard [this message]
2024-05-15 18:42 ` [PATCH 0/8] dma-buf: heaps: Support carved-out heaps and ECC related-flags John Stultz
2024-05-16 10:56 ` Daniel Vetter
2024-05-16 12:41 ` Maxime Ripard
2024-05-16 16:51 ` John Stultz
2024-05-21 12:06 ` Daniel Vetter
2024-05-22 13:18 ` Maxime Ripard
2024-05-23 9:45 ` Daniel Vetter
2024-06-28 11:29 ` Thierry Reding
2024-06-28 13:08 ` Maxime Ripard
2024-06-28 14:42 ` Thierry Reding
2024-07-04 12:24 ` Maxime Ripard
2024-07-05 14:31 ` Thierry Reding
2024-07-05 15:35 ` Daniel Vetter
2024-07-08 7:14 ` [Linaro-mm-sig] " Christian König
2024-07-11 12:44 ` Thierry Reding
2024-07-10 12:10 ` Maxime Ripard
2024-07-11 12:43 ` Thierry Reding
2024-07-12 10:37 ` Thierry Reding
2024-05-16 12:21 ` Maxime Ripard
2024-05-16 17:09 ` John Stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240515-dma-buf-ecc-heap-v1-8-54cbbd049511@kernel.org \
--to=mripard@kernel.org \
--cc=Brian.Starkey@arm.com \
--cc=benjamin.gaignard@collabora.com \
--cc=christian.koenig@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jstultz@google.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mkorpershoek@baylibre.com \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=sumit.semwal@linaro.org \
--cc=tjmercier@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).