public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 04/11] dm: core: Support allocating driver-private data for DMA
Date: Sun,  5 Apr 2015 16:07:36 -0600	[thread overview]
Message-ID: <1428271663-3814-5-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1428271663-3814-1-git-send-email-sjg@chromium.org>

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>
---
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

  parent reply	other threads:[~2015-04-05 22:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-05 22:07 [U-Boot] [PATCH v2 0/11] dm: net: Conversion patches for sunxi driver model Ethernet Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 01/11] sunxi: Replace the pcDuino3 config with FDT version Simon Glass
2015-04-09  3:00   ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 02/11] Kconfig: Move CONFIG_DESIGNWARE_ETH to Kconfig Simon Glass
2015-04-09  3:04   ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 03/11] dts: sunxi: Bring in Ethernet device tree bindings Simon Glass
2015-04-09  3:04   ` Simon Glass
2015-04-05 22:07 ` Simon Glass [this message]
2015-04-05 22:07 ` [U-Boot] [PATCH v2 05/11] dm: net: Use existing Ethernet init for driver model Simon Glass
2015-04-09  3:04   ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 06/11] Avoid calling print_eths() with " Simon Glass
2015-04-09  3:04   ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 07/11] dm: net: Adjust PHY interface to work with CONFIG_DM_ETH Simon Glass
2015-04-09  3:04   ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 08/11] dm: net: Tidy up designware driver ready for driver model Simon Glass
2015-04-09  3:04   ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 09/11] dm: net: Adjust designware driver to support " Simon Glass
2015-04-06 21:09   ` Joe Hershberger
2015-04-09  3:04     ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 10/11] dm: sunxi: Support driver model for Ethernet Simon Glass
2015-04-09  3:04   ` Simon Glass
2015-04-05 22:07 ` [U-Boot] [PATCH v2 11/11] dm: sunxi: Use driver model for Ethernet on Linksprite pcDuino3 Simon Glass
2015-04-09  3:04   ` Simon Glass

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=1428271663-3814-5-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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