From: Claudiu Manoil <claudiu.manoil@nxp.com>
To: <linuxppc-dev@lists.ozlabs.org>
Cc: Scott Wood <oss@buserror.net>, <roy.pledge@nxp.com>
Subject: [PATCH 09/17] soc/qman: test: Don't use dummy platform device for dma mapping
Date: Wed, 16 Nov 2016 16:40:22 +0200 [thread overview]
Message-ID: <1479307230-16650-10-git-send-email-claudiu.manoil@nxp.com> (raw)
In-Reply-To: <1479307230-16650-1-git-send-email-claudiu.manoil@nxp.com>
Replace dummy platform device hack with a reference to a portal's
platform device, in order to dma map the test frame for this
small unit test. The 2 qman symbols need to be exported because
this self test is a kernel module.
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
---
drivers/soc/fsl/qbman/qman.c | 1 +
drivers/soc/fsl/qbman/qman_portal.c | 1 +
drivers/soc/fsl/qbman/qman_test_stash.c | 31 ++++++++++++++++++++-----------
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index a0020d2..283c2d3 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2711,6 +2711,7 @@ const struct qm_portal_config *qman_get_qm_portal_config(
{
return portal->config;
}
+EXPORT_SYMBOL(qman_get_qm_portal_config);
struct gen_pool *qm_fqalloc; /* FQID allocator */
struct gen_pool *qm_qpalloc; /* pool-channel allocator */
diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c
index e6da2ea..c9a9bcb 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -31,6 +31,7 @@
#include "qman_priv.h"
struct qman_portal *qman_dma_portal;
+EXPORT_SYMBOL(qman_dma_portal);
/* Enable portal interupts (as opposed to polling mode) */
#define CONFIG_FSL_DPA_PIRQ_SLOW 1
diff --git a/drivers/soc/fsl/qbman/qman_test_stash.c b/drivers/soc/fsl/qbman/qman_test_stash.c
index 43cf66b..f8d25fa 100644
--- a/drivers/soc/fsl/qbman/qman_test_stash.c
+++ b/drivers/soc/fsl/qbman/qman_test_stash.c
@@ -191,6 +191,9 @@ struct hp_cpu {
static u32 *frame_ptr;
static dma_addr_t frame_dma;
+/* needed for dma_map*() */
+static const struct qm_portal_config *pcfg;
+
/* the main function waits on this */
static DECLARE_WAIT_QUEUE_HEAD(queue);
@@ -210,16 +213,14 @@ static int allocate_frame_data(void)
{
u32 lfsr = HP_FIRST_WORD;
int loop;
- struct platform_device *pdev = platform_device_alloc("foobar", -1);
- if (!pdev) {
- pr_crit("platform_device_alloc() failed");
- return -EIO;
- }
- if (platform_device_add(pdev)) {
- pr_crit("platform_device_add() failed");
+ if (!qman_dma_portal) {
+ pr_crit("portal not available\n");
return -EIO;
}
+
+ pcfg = qman_get_qm_portal_config(qman_dma_portal);
+
__frame_ptr = kmalloc(4 * HP_NUM_WORDS, GFP_KERNEL);
if (!__frame_ptr)
return -ENOMEM;
@@ -229,15 +230,22 @@ static int allocate_frame_data(void)
frame_ptr[loop] = lfsr;
lfsr = do_lfsr(lfsr);
}
- frame_dma = dma_map_single(&pdev->dev, frame_ptr, 4 * HP_NUM_WORDS,
+
+ frame_dma = dma_map_single(pcfg->dev, frame_ptr, 4 * HP_NUM_WORDS,
DMA_BIDIRECTIONAL);
- platform_device_del(pdev);
- platform_device_put(pdev);
+ if (dma_mapping_error(pcfg->dev, frame_dma)) {
+ pr_crit("dma mapping failure\n");
+ kfree(__frame_ptr);
+ return -EIO;
+ }
+
return 0;
}
static void deallocate_frame_data(void)
{
+ dma_unmap_single(pcfg->dev, frame_dma, 4 * HP_NUM_WORDS,
+ DMA_BIDIRECTIONAL);
kfree(__frame_ptr);
}
@@ -249,7 +257,8 @@ static inline int process_frame_data(struct hp_handler *handler,
int loop;
if (qm_fd_addr_get64(fd) != handler->addr) {
- pr_crit("bad frame address");
+ pr_crit("bad frame address, [%llX != %llX]\n",
+ qm_fd_addr_get64(fd), handler->addr);
return -EIO;
}
for (loop = 0; loop < HP_NUM_WORDS; loop++, p++) {
--
1.7.11.7
next prev parent reply other threads:[~2016-11-16 14:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 14:40 [PATCH 00/17] soc/qman: Fixes, endianness handling and related cleanup Claudiu Manoil
2016-11-16 14:40 ` [PATCH 01/17] soc/qman: Check ioremap return value Claudiu Manoil
2016-11-16 14:40 ` [PATCH 02/17] soc/qman: Replace of_get_property() with portable equivalent Claudiu Manoil
2016-11-16 14:40 ` [PATCH 03/17] soc/qman: Fix h/w resource cleanup error path handling Claudiu Manoil
2016-11-16 14:40 ` [PATCH 04/17] soc/qbman: Fix resource leak on portal probing error path Claudiu Manoil
2016-11-16 14:40 ` [PATCH 05/17] soc/qman: Fix struct qm_fqd set accessor for context_a Claudiu Manoil
2016-11-16 14:40 ` [PATCH 06/17] soc/qman: Fix direct access to fd's addr_lo, use proper accesor Claudiu Manoil
2016-11-16 14:40 ` [PATCH 07/17] soc/qman: test: Fix implementation of fd_cmp() Claudiu Manoil
2016-11-16 14:40 ` [PATCH 08/17] soc/qman: Don't add a new platform device for dma mapping Claudiu Manoil
2016-11-16 14:40 ` Claudiu Manoil [this message]
2016-11-16 14:40 ` [PATCH 10/17] soc/qman: Remove redundant checks from qman_create_cgr() Claudiu Manoil
2016-11-16 14:40 ` [PATCH 11/17] soc/qman: Remove unused struct qm_mcc* layouts Claudiu Manoil
2016-11-16 14:40 ` [PATCH 12/17] soc/qman: Fix accesses to fqid, cleanup Claudiu Manoil
2016-11-16 14:40 ` [PATCH 13/17] soc/qman: Drop unused field from eqcr/dqrr descriptors Claudiu Manoil
2016-11-16 14:40 ` [PATCH 14/17] soc/qbman: Handle endianness of qm/bm_in/out() Claudiu Manoil
2016-11-16 14:40 ` [PATCH 15/17] soc/qman: Change remaining contextB into context_b Claudiu Manoil
2016-11-16 14:40 ` [PATCH 16/17] soc/qman: Clean up CGR CSCN target update operations Claudiu Manoil
2016-11-16 14:40 ` [PATCH 17/17] soc/qman: Handle endianness of h/w descriptors Claudiu Manoil
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=1479307230-16650-10-git-send-email-claudiu.manoil@nxp.com \
--to=claudiu.manoil@nxp.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=oss@buserror.net \
--cc=roy.pledge@nxp.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).