[U-Boot] [PATCH v2 04/11] dm: core: Support allocating driver-private data for DMA
Simon Glass
sjg at chromium.org
Mon Apr 6 00:07:36 CEST 2015
Some driver want to put DMA buffers in their private data. Add a flag
to tell driver model to align driver-private data to a cache boundary so
that DMA will work correctly in this case.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
This patch can be dropped once this one is applied:
http://patchwork.ozlabs.org/patch/454670/
Changes in v2: None
drivers/core/device.c | 11 ++++++++++-
include/dm/device.h | 3 +++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 7483405..872b703 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -182,7 +182,16 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
/* Allocate private data if requested */
if (drv->priv_auto_alloc_size) {
- dev->priv = calloc(1, drv->priv_auto_alloc_size);
+ if (drv->flags & DM_FLAG_ALLOC_PRIV_DMA) {
+ dev->priv = memalign(ARCH_DMA_MINALIGN,
+ drv->priv_auto_alloc_size);
+ if (dev->priv) {
+ memset(dev->priv, '\0',
+ drv->priv_auto_alloc_size);
+ }
+ } else {
+ dev->priv = calloc(1, drv->priv_auto_alloc_size);
+ }
if (!dev->priv) {
ret = -ENOMEM;
goto fail;
diff --git a/include/dm/device.h b/include/dm/device.h
index 6980954..f27b34b 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -30,6 +30,9 @@ struct driver_info;
/* DM is responsible for allocating and freeing parent_platdata */
#define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3)
+/* Allocate driver private data on a DMA boundary */
+#define DM_FLAG_ALLOC_PRIV_DMA (1 << 4)
+
/**
* struct udevice - An instance of a driver
*
--
2.2.0.rc0.207.ga3a616c
More information about the U-Boot
mailing list