@@ -190,7 +190,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;
@@ -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
*
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@chromium.org> --- drivers/core/device.c | 11 ++++++++++- include/dm/device.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-)