From patchwork Sun Apr 5 22:07:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 458290 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 DA39514012F for ; Mon, 6 Apr 2015 08:08:13 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 261A74A03B; Mon, 6 Apr 2015 00:08:12 +0200 (CEST) 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 NZ3eXjpSs2ZW; Mon, 6 Apr 2015 00:08:11 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 52E29B37B1; Mon, 6 Apr 2015 00:08:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9C29EB37B7 for ; Mon, 6 Apr 2015 00:08:08 +0200 (CEST) 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 xFQ4qooqP9_X for ; Mon, 6 Apr 2015 00:08:08 +0200 (CEST) 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-qk0-f202.google.com (mail-qk0-f202.google.com [209.85.220.202]) by theia.denx.de (Postfix) with ESMTPS id 42261B37B1 for ; Mon, 6 Apr 2015 00:08:06 +0200 (CEST) Received: by qkbx78 with SMTP id x78so2808098qkb.0 for ; Sun, 05 Apr 2015 15:08:06 -0700 (PDT) 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=OnvYFQwvLaCNiHH+iYGfi4HkXHjDR7IgZjmPhUq4wOM=; b=DG/QB0Kcm2ExsZiC1jaCP+7rIiqD/l2NWnaDj/xpi3jUaWszTYBgwJR6G6jmRz6iOy /R01n8UGXUTkV3IFdQ1V4sh8pNriWBNVbsQKQW7hKwvo8Gid2DHdbCjZKoq5mIIu11lD DKcRwJKJ1pdB5dNOmbFanVOH5juDnYAgVFkSYYD/bd8b/2Zm15mNnyMnk6MyqNZhx5DP 0Kq2S7DgqjDBTTQM74NK3P21YAY/gLo+myYsbisOY77JgK8mhXYPPqphYbwIDv5Vw7Tw ziB1Q9a0bpUt4e6OFWSr8Z+pHg0vwlrFn9AuMWJZDJEW03XvQFY+06PxdYWThXdIQHAo tIrw== X-Gm-Message-State: ALoCoQnDNLHoPM/SjUWTOOUxEXJgGjkMkDbqawCmEgyAC3+dsHJu5FQX5GIiLSnVkrV01VhpK8ky X-Received: by 10.182.245.169 with SMTP id xp9mr15033014obc.44.1428271686053; Sun, 05 Apr 2015 15:08:06 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id z21si121657yhc.5.2015.04.05.15.08.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Apr 2015 15:08:05 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id 77AOaCSl.1; Sun, 05 Apr 2015 15:08:05 -0700 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 5C3F1220C40; Sun, 5 Apr 2015 16:08:05 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 5 Apr 2015 16:07:36 -0600 Message-Id: <1428271663-3814-5-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1428271663-3814-1-git-send-email-sjg@chromium.org> References: <1428271663-3814-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH v2 04/11] 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 --- 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 *