From patchwork Fri Jul 6 03:55:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 10510561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 18719601C0 for ; Fri, 6 Jul 2018 03:56:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 075BE27E5A for ; Fri, 6 Jul 2018 03:56:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEEB827F85; Fri, 6 Jul 2018 03:56:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 82F5A27E5A for ; Fri, 6 Jul 2018 03:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=22w6qGb1yrAxvWFC6sZI5km9g9BBcmHJVStZX1r+ru0=; b=n8/vls4naIt9z/PG7xDImixFn9 HYFplnslyhSn/TlAd3Knpemi4GsVYSiAxmMSZgGKiyJOIgDgoghaaSLMzdzvWvcQa0uY9vsQhYWzy 1Bdm35phU4gz/anseJ7gAL3s+FrT2UJlngAjdzvT0R9/Yaf0SA8Ju6RC7DfS5ZmZCSwl8oW5KIjfI eqLztag+nAq+vunQxEUznLQVIeDydMlXzNjxNkfy2nPTs471Xgh5YTVfDwLH+ILEW9zFZwvlUVFsG INGadCfMRtlDw/9FGHoaUv+CrMXzByvEwi1kvwoZl61KCPXQBD0KVnNmvjwK/NybvrMc+NKOLZGaK wPIag3sQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbHrF-0001Dm-FB; Fri, 06 Jul 2018 03:56:33 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbHr4-0000f5-JW for linux-arm-kernel@lists.infradead.org; Fri, 06 Jul 2018 03:56:28 +0000 Received: by mail-pf0-x244.google.com with SMTP id y24-v6so7200534pfe.12 for ; Thu, 05 Jul 2018 20:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GeiCyeTYAnNlTAnZk8bbwnhnfWJCW6BUDmOpTlPEQKk=; b=UeCCy/knUULgWF+J4DSAqihvfMaKzsAGxTljMybYmfjV9wxFjxOj/Zue5EAI+Wr0Uq NksK/mG80BcDR3I8+rmH8VUtQlxwNCUjvX27t8bQAS4OIDaFX85e02VPgB3M5ajaPRcB g44fz8W4WQr5oCgIYkeWX/Ywv5y7tSZ9EJJV0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GeiCyeTYAnNlTAnZk8bbwnhnfWJCW6BUDmOpTlPEQKk=; b=dXYUxdBY2a/tXLXv1Q/MbEVxl/xIybIAmmCHS3iHD/+IW6FgnhaBsuN3A8dxUoDr1b GfPV5NISz8b2GlHlJvR2bHioq6pk8CtIyPlFJak2zLYoUSXRR9HsUSAge7zPA8tInsRX 2zFlwQTYkbvSFu0ru2h86eIivKd1DgM4k1NaSq2U6neAr1Lj2mT5KsQAZSQbE+nX1eJP Ah7ijcRgUD5MHQz4G/SosROF0js+7bWt3Yd/rsqO3eOKKmpwqq/awLcp24e1LENrngga wQuydISAUF4cHgptzx6bmoWgBWlVJtFPBiobZuLWWNOx9zY9LfRkc5hIWYkoDmz5ZY/e rp8Q== X-Gm-Message-State: APt69E3iTRqLrNjo/MOTP51dHcikHRO1xSLunk6bvRhwOtrNvsSssiRS wvmJRfszmBDZgtzSUrsAe5gfOQ== X-Google-Smtp-Source: AAOMgpe50CBTkH7THvKowgg/nEk5I7e5REODVXbM6EoyZm8c+BW5SHFyZhRHZRsSn+p6dyu+9soRJA== X-Received: by 2002:a62:3e1a:: with SMTP id l26-v6mr9019822pfa.214.1530849371845; Thu, 05 Jul 2018 20:56:11 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.33]) by smtp.gmail.com with ESMTPSA id y14-v6sm12568403pgo.22.2018.07.05.20.56.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 20:56:11 -0700 (PDT) From: Guodong Xu To: vkoul@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, dan.j.williams@intel.com, xuwei5@hisilicon.com, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v2 2/4] k3dma: add support to reserved minimum channels Date: Fri, 6 Jul 2018 11:55:19 +0800 Message-Id: <20180706035521.13736-3-guodong.xu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180706035521.13736-1-guodong.xu@linaro.org> References: <20180706035521.13736-1-guodong.xu@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180705_205622_932667_40B9836C X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xuezhiliang@hisilicon.com, devicetree@vger.kernel.org, xupeng7@huawei.com, sunliang10@huawei.com, Guodong Xu , suzhuangluan@hisilicon.com, linux-kernel@vger.kernel.org, fengbaopeng@hisilicon.com, liyu65@hisilicon.com, zhongkaihua@huawei.com, xuhongtao8@hisilicon.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Li Yu On k3 series of SoC, DMA controller reserves some channels for other on-chip coprocessors. By reading property "hisilicon,dma-min-chan" from dts node, kernel will not use these reserved channels. As an example, on Hi3660, channel 0 is reserved for lpm3. Refer to Documentation/devicetree/bindings/dma/k3dma.txt for more information. Signed-off-by: Li Yu Signed-off-by: Guodong Xu --- drivers/dma/k3dma.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index fa31cccbe04f..33efb541acb2 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c @@ -113,6 +113,7 @@ struct k3_dma_dev { struct dma_pool *pool; u32 dma_channels; u32 dma_requests; + u32 dma_min_chan; unsigned int irq; }; @@ -309,7 +310,7 @@ static void k3_dma_tasklet(unsigned long arg) /* check new channel request in d->chan_pending */ spin_lock_irq(&d->lock); - for (pch = 0; pch < d->dma_channels; pch++) { + for (pch = d->dma_min_chan; pch < d->dma_channels; pch++) { p = &d->phy[pch]; if (p->vchan == NULL && !list_empty(&d->chan_pending)) { @@ -326,7 +327,7 @@ static void k3_dma_tasklet(unsigned long arg) } spin_unlock_irq(&d->lock); - for (pch = 0; pch < d->dma_channels; pch++) { + for (pch = d->dma_min_chan; pch < d->dma_channels; pch++) { if (pch_alloc & (1 << pch)) { p = &d->phy[pch]; c = p->vchan; @@ -825,6 +826,8 @@ static int k3_dma_probe(struct platform_device *op) "dma-channels", &d->dma_channels); of_property_read_u32((&op->dev)->of_node, "dma-requests", &d->dma_requests); + of_property_read_u32((&op->dev)->of_node, + "hisilicon,dma-min-chan", &d->dma_min_chan); } d->clk = devm_clk_get(&op->dev, NULL); @@ -848,12 +851,12 @@ static int k3_dma_probe(struct platform_device *op) return -ENOMEM; /* init phy channel */ - d->phy = devm_kcalloc(&op->dev, - d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL); + d->phy = devm_kcalloc(&op->dev, (d->dma_channels - d->dma_min_chan), + sizeof(struct k3_dma_phy), GFP_KERNEL); if (d->phy == NULL) return -ENOMEM; - for (i = 0; i < d->dma_channels; i++) { + for (i = d->dma_min_chan; i < d->dma_channels; i++) { struct k3_dma_phy *p = &d->phy[i]; p->idx = i;