From patchwork Wed Jun 4 16:14:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 4295441 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 238F49F326 for ; Wed, 4 Jun 2014 16:14:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48B7F20260 for ; Wed, 4 Jun 2014 16:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 683C020251 for ; Wed, 4 Jun 2014 16:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582AbaFDQOb (ORCPT ); Wed, 4 Jun 2014 12:14:31 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:56394 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751128AbaFDQOa (ORCPT ); Wed, 4 Jun 2014 12:14:30 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id D6DAF466F71; Wed, 4 Jun 2014 17:14:29 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jHBdWU3GmjOV; Wed, 4 Jun 2014 17:14:24 +0100 (BST) Received: from rainbowdash.ducie.codethink.co.uk (rainbowdash.dyn.ducie.codethink.co.uk [10.24.1.179]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPS id EE147466F7B; Wed, 4 Jun 2014 17:14:18 +0100 (BST) Received: from ben by rainbowdash.ducie.codethink.co.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1WsDpS-00086L-Mw; Wed, 04 Jun 2014 17:14:18 +0100 From: Ben Dooks To: linux-sh@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Ben Dooks Subject: [PATCH 2/8] shdma: fdt: allocate and use local hwid bitmap for shdma mux Date: Wed, 4 Jun 2014 17:14:09 +0100 Message-Id: <1401898455-31064-3-git-send-email-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <1401898455-31064-1-git-send-email-ben.dooks@codethink.co.uk> References: <1401898455-31064-1-git-send-email-ben.dooks@codethink.co.uk> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the shdma-of.c code to allocating and using a slave bitmap for tracking allocation of the slave channels used by the mid-rid stored in the phandle for the mux. This means that we can have multiple shdma muxes in the system without any issue of slave-ids clashing and all the child dma units will be able to properly protect against the re-use of a mid/rid pair. Signed-off-by: Ben Dooks --- drivers/dma/sh/shdma-base.c | 2 ++ drivers/dma/sh/shdma-of.c | 16 ++++++++++++++++ include/linux/shdma-base.h | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c index 5b18c88..861e1f5 100644 --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c @@ -986,6 +986,8 @@ int shdma_init(struct device *dev, struct shdma_dev *sdev, dma_dev->dev = dev; sdev->slave_used = shdma_global_slave_used; + shdma_of_setup(dev, sdev); + return 0; } EXPORT_SYMBOL(shdma_init); diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c index b4ff9d3..894c48e 100644 --- a/drivers/dma/sh/shdma-of.c +++ b/drivers/dma/sh/shdma-of.c @@ -17,6 +17,10 @@ #include #include +struct shdma_of_state { + unsigned long slave_used[256 / sizeof(unsigned long)]; +}; + #define to_shdma_chan(c) container_of(c, struct shdma_chan, dma_chan) static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec, @@ -41,11 +45,23 @@ static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec, return chan; } +void shdma_of_setup(struct device *dev, struct shdma_dev *shdev) +{ + struct shdma_of_state *ofs = dev_get_platdata(dev->parent); + + shdev->slave_used = ofs->slave_used; +} + static int shdma_of_probe(struct platform_device *pdev) { const struct of_dev_auxdata *lookup = dev_get_platdata(&pdev->dev); + struct shdma_of_state *ofs; int ret; + ofs = devm_kzalloc(&pdev->dev, sizeof(*ofs), GFP_KERNEL); + if (!ofs) + return -ENOMEM; + ret = of_dma_controller_register(pdev->dev.of_node, shdma_of_xlate, pdev); if (ret < 0) diff --git a/include/linux/shdma-base.h b/include/linux/shdma-base.h index 6966593..0a3e422 100644 --- a/include/linux/shdma-base.h +++ b/include/linux/shdma-base.h @@ -131,4 +131,10 @@ bool shdma_chan_filter(struct dma_chan *chan, void *arg); #define shdma_chan_filter NULL #endif +#ifdef CONFIG_OF +extern void shdma_of_setup(struct device *dev, struct shdma_dev *sdev); +#else +static inline void shdma_of_setup(struct device *dev, struct shdma_dev *sdev) { } +#endif + #endif