From patchwork Sun Mar 1 16:33:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 444841 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5BEF314010F for ; Mon, 2 Mar 2015 07:41:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 314B0A74FB; Sun, 1 Mar 2015 21:26:31 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F7Z5sC_FSnsj; Sun, 1 Mar 2015 21:26:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AD978A74F7; Sun, 1 Mar 2015 21:26:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 33DC74A03B for ; Sun, 1 Mar 2015 17:33:58 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FvgCl64Joi21 for ; Sun, 1 Mar 2015 17:33:58 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ie0-f202.google.com (mail-ie0-f202.google.com [209.85.223.202]) by theia.denx.de (Postfix) with ESMTPS id 35ABC4A02E for ; Sun, 1 Mar 2015 17:33:55 +0100 (CET) Received: by iecrl12 with SMTP id rl12so8127256iec.0 for ; Sun, 01 Mar 2015 08:33:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rsvhxsoBACudaLLy9H/CTi4N/D5/gnFWbHsUoyBrfr8=; b=j0P4iT8Tr1VbFnHJR1SZfighDkiRnbCT1R8TcjgQu0WUNp3bzpmpsb+PFlJ12I4JdB AzmBfmAvLFuhJ3H+VUTVTzHi/w3NUga5LBBfnXpglJMEXCXpZQzIl/E9IKVJ8p1LLNPo Iaxf7Pmqp2M2NTIaTXVN2HLfBxHiaWMAKkxi4TLkrV+bdhFCQQqo8pp2mUrMcZzF2bvv 0S+vuUodGfOsuqqGdxLtnLPjTPCfK8d4v+wRhAU8WsdHomDc9B0GucE9iPNR37zNJere TtFkpj1eAnynQU0RfY3UoFQqW0N8YrT71l0SPxHGVtw8gdrzIt6PWbMVPNbFYHgXKaGL UkeA== X-Gm-Message-State: ALoCoQlp6VjfY4Lts3rzcXY37hGukXHGEAmS0vA4j74EPUFrdxKb1B5N7wxcvZSkoAA1+RiOJ0Zb X-Received: by 10.43.118.5 with SMTP id fo5mr23400536icc.18.1425227633432; Sun, 01 Mar 2015 08:33:53 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id 3si387736yhe.0.2015.03.01.08.33.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Mar 2015 08:33:53 -0800 (PST) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id Z1qRQldM.1; Sun, 01 Mar 2015 08:33:53 -0800 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id C6986220A87; Sun, 1 Mar 2015 09:33:52 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 1 Mar 2015 09:33:32 -0700 Message-Id: <1425227620-6656-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1425227620-6656-1-git-send-email-sjg@chromium.org> References: <1425227620-6656-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [RFC PATCH 06/13] dm: core: Support allocating driver-private data for DMA X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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 37dc882..b7a5654 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -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; diff --git a/include/dm/device.h b/include/dm/device.h index 7a48eb8..7f810ed 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 *