linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Roy Pledge <roy.pledge@nxp.com>
To: <robin.murphy@arm.com>, <oss@buserror.net>,
	<linuxppc-dev@lists.ozlabs.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>
Cc: <madalin.bucur@nxp.com>, Roy Pledge <roy.pledge@nxp.com>
Subject: [RFC PATCH 1/5] soc/fsl/qbman: Use shared-dma-pool for BMan private memory allocations
Date: Wed, 29 Mar 2017 17:13:53 -0400	[thread overview]
Message-ID: <1490822037-6752-2-git-send-email-roy.pledge@nxp.com> (raw)
In-Reply-To: <1490822037-6752-1-git-send-email-roy.pledge@nxp.com>

Use the shared-memory-pool mechanism for free buffer proxy record
area allocation.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
---
 drivers/soc/fsl/qbman/bman_ccsr.c | 27 ++++++++++++++++++++++++++-
 drivers/soc/fsl/qbman/bman_priv.h |  3 +++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c
index a8e8389..5485c3c 100644
--- a/drivers/soc/fsl/qbman/bman_ccsr.c
+++ b/drivers/soc/fsl/qbman/bman_ccsr.c
@@ -170,10 +170,11 @@ static int fsl_bman_probe(struct platform_device *pdev)
 {
 	int ret, err_irq;
 	struct device *dev = &pdev->dev;
-	struct device_node *node = dev->of_node;
+	struct device_node *mem_node, *node = dev->of_node;
 	struct resource *res;
 	u16 id, bm_pool_cnt;
 	u8 major, minor;
+	u64 size;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -201,6 +202,30 @@ static int fsl_bman_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	ret = of_reserved_mem_device_init(dev);
+	if (ret) {
+		dev_err(dev, "of_reserved_mem_device_init() failed 0x%x\n", ret);
+		return -ENODEV;
+	}
+	mem_node = of_parse_phandle(dev->of_node, "memory-region", 0);
+	if (mem_node) {
+		ret = of_property_read_u64(mem_node, "size", &size);
+		if (ret) {
+			dev_err(dev, "FBPR: of_address_to_resource fails 0x%x\n", ret);
+			return -ENODEV;
+		}
+		fbpr_sz = size;
+	} else {
+		dev_err(dev, "No memory-region found for FBPR\n");
+		return -ENODEV;
+	}
+	if (!dma_zalloc_coherent(dev, fbpr_sz, &fbpr_a, 0)) {
+		dev_err(dev, "Alloc FBPR memory failed\n");
+		return -ENODEV;
+	}
+
+	dev_info(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz);
+
 	bm_set_memory(fbpr_a, fbpr_sz);
 
 	err_irq = platform_get_irq(pdev, 0);
diff --git a/drivers/soc/fsl/qbman/bman_priv.h b/drivers/soc/fsl/qbman/bman_priv.h
index f6896a2..765a4bf 100644
--- a/drivers/soc/fsl/qbman/bman_priv.h
+++ b/drivers/soc/fsl/qbman/bman_priv.h
@@ -33,6 +33,9 @@
 #include "dpaa_sys.h"
 
 #include <soc/fsl/bman.h>
+#include <linux/dma-contiguous.h>
+#include <linux/of_address.h>
+#include <linux/dma-mapping.h>
 
 /* Portal processing (interrupt) sources */
 #define BM_PIRQ_RCRI	0x00000002	/* RCR Ring (below threshold) */
-- 
2.9.3

  reply	other threads:[~2017-03-29 21:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 21:13 [RFC PATCH 0/5] soc/fsl/qbman: Rework private memory allocations Roy Pledge
2017-03-29 21:13 ` Roy Pledge [this message]
2017-03-29 21:13 ` [RFC PATCH 2/5] soc/fsl/qbman: Use shared-dma-pool for QMan " Roy Pledge
2017-03-30 14:09   ` Robin Murphy
2017-03-31  3:27     ` Michael Ellerman
2017-03-31 17:55       ` Robin Murphy
2017-04-01  7:25         ` Scott Wood
2017-04-03 14:52           ` Robin Murphy
2017-04-04  0:24             ` Scott Wood
2017-03-29 21:13 ` [RFC PATCH 3/5] dts: arch/powerpc: Update Freescale DTS for QBMan " Roy Pledge
2017-03-29 21:13 ` [RFC PATCH 4/5] dt-bindings: soc/fsl: Update reserved memory binding for QBMan Roy Pledge
2017-04-03 15:42   ` Rob Herring
2017-04-03 19:49     ` Roy Pledge
2017-04-04  0:32       ` Scott Wood
2017-03-29 21:13 ` [RFC PATCH 5/5] powerpc: Add HAVE_GENERIC_DMA_COHERENT options to Kconfig Roy Pledge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490822037-6752-2-git-send-email-roy.pledge@nxp.com \
    --to=roy.pledge@nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=madalin.bucur@nxp.com \
    --cc=oss@buserror.net \
    --cc=robin.murphy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).