From patchwork Wed Jun 4 16:14:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 4295431 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 4785A9F54F for ; Wed, 4 Jun 2014 16:14:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6880120260 for ; Wed, 4 Jun 2014 16:14:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E60F8202E9 for ; Wed, 4 Jun 2014 16:14:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750944AbaFDQO3 (ORCPT ); Wed, 4 Jun 2014 12:14:29 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:56384 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751209AbaFDQO0 (ORCPT ); Wed, 4 Jun 2014 12:14:26 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 3C68A464742; Wed, 4 Jun 2014 17:14:25 +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 LcoPwKJPIowd; Wed, 4 Jun 2014 17:14:19 +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 D93CD466F71; 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-00086G-JN; 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 1/8] shdma: fdt: allow moving of the shdma_slave_used fields Date: Wed, 4 Jun 2014 17:14:08 +0100 Message-Id: <1401898455-31064-2-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 The shdma_slave_used is used to track the DMA hardware channels that are claimed by clients. This works when the system has a global number space as used by the platform clients, however when we are using fdt possible space is much bigger (if we used phandle+hwid). It is much easier for the OF case to change to using the hwid of the channel and make the allocation bitmap part of the mux device that holds all the dma controllers that can access the set of hwids that need protecting. So change the code to make it that each sdev points to an bitmap that can be allocated via the shdma-of.c when needed. Signed-off-by: Ben Dooks --- drivers/dma/sh/shdma-base.c | 17 +++++++++-------- include/linux/shdma-base.h | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c index b35007e..5b18c88 100644 --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c @@ -49,7 +49,7 @@ static unsigned int slave_num = 256; module_param(slave_num, uint, 0444); /* A bitmask with slave_num bits */ -static unsigned long *shdma_slave_used; +static unsigned long *shdma_global_slave_used; /* Called under spin_lock_irq(&schan->chan_lock") */ static void shdma_chan_xfer_ld_queue(struct shdma_chan *schan) @@ -192,12 +192,12 @@ static int shdma_setup_slave(struct shdma_chan *schan, int slave_id, if (slave_id < 0 || slave_id >= slave_num) return -EINVAL; - if (test_and_set_bit(slave_id, shdma_slave_used)) + if (test_and_set_bit(slave_id, sdev->slave_used)) return -EBUSY; ret = ops->set_slave(schan, match, slave_addr, false); if (ret < 0) { - clear_bit(slave_id, shdma_slave_used); + clear_bit(slave_id, sdev->slave_used); return ret; } @@ -290,7 +290,7 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan) edescalloc: if (slave) esetslave: - clear_bit(slave->slave_id, shdma_slave_used); + clear_bit(slave->slave_id, sdev->slave_used); chan->private = NULL; return ret; } @@ -440,7 +440,7 @@ static void shdma_free_chan_resources(struct dma_chan *chan) if (schan->slave_id >= 0) { /* The caller is holding dma_list_mutex */ - clear_bit(schan->slave_id, shdma_slave_used); + clear_bit(schan->slave_id, sdev->slave_used); chan->private = NULL; } @@ -984,6 +984,7 @@ int shdma_init(struct device *dev, struct shdma_dev *sdev, dma_dev->device_control = shdma_control; dma_dev->dev = dev; + sdev->slave_used = shdma_global_slave_used; return 0; } @@ -997,9 +998,9 @@ EXPORT_SYMBOL(shdma_cleanup); static int __init shdma_enter(void) { - shdma_slave_used = kzalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG) * + shdma_global_slave_used = kzalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG) * sizeof(long), GFP_KERNEL); - if (!shdma_slave_used) + if (!shdma_global_slave_used) return -ENOMEM; return 0; } @@ -1007,7 +1008,7 @@ module_init(shdma_enter); static void __exit shdma_exit(void) { - kfree(shdma_slave_used); + kfree(shdma_global_slave_used); } module_exit(shdma_exit); diff --git a/include/linux/shdma-base.h b/include/linux/shdma-base.h index abdf1f2..6966593 100644 --- a/include/linux/shdma-base.h +++ b/include/linux/shdma-base.h @@ -106,6 +106,7 @@ struct shdma_ops { }; struct shdma_dev { + unsigned long *slave_used; /* bitmap of slave ids used */ struct dma_device dma_dev; struct shdma_chan **schan; const struct shdma_ops *ops;