1 From fddd729bd2150e83365528cefb9f1fef581e04c5 Mon Sep 17 00:00:00 2001
2 From: Vakul Garg <vakul.garg@nxp.com>
3 Date: Sun, 6 Jan 2019 19:05:37 +0530
4 Subject: [PATCH] fsl_qbman: Adjust platform device creation for QMan portals
6 Fix the platform device creation in QMan portals such that
7 dma mappings are done properly.
9 Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
10 Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
12 drivers/staging/fsl_qbman/qman_high.c | 47 +++++++++++++++++++----------------
13 1 file changed, 25 insertions(+), 22 deletions(-)
15 --- a/drivers/staging/fsl_qbman/qman_high.c
16 +++ b/drivers/staging/fsl_qbman/qman_high.c
17 @@ -575,6 +575,7 @@ struct qman_portal *qman_create_portal(
21 + struct platform_device_info pdev_info;
24 portal = kmalloc(sizeof(*portal), GFP_KERNEL);
25 @@ -671,27 +672,22 @@ struct qman_portal *qman_create_portal(
26 portal->dqrr_disable_ref = 0;
27 portal->cb_dc_ern = NULL;
28 sprintf(buf, "qportal-%d", config->public_cfg.channel);
29 - portal->pdev = platform_device_alloc(buf, -1);
31 + memset(&pdev_info, 0, sizeof(pdev_info));
32 + pdev_info.name = buf;
33 + pdev_info.id = PLATFORM_DEVID_NONE;
34 + pdev_info.dma_mask = DMA_BIT_MASK(40);
36 + portal->pdev = platform_device_register_full(&pdev_info);
38 pr_err("qman_portal - platform_device_alloc() failed\n");
41 -#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
42 - portal->pdev->dev.coherent_dma_mask = DMA_BIT_MASK(40);
43 - portal->pdev->dev.dma_mask = &portal->pdev->dev.coherent_dma_mask;
45 - if (dma_set_mask(&portal->pdev->dev, DMA_BIT_MASK(40))) {
46 - pr_err("qman_portal - dma_set_mask() failed\n");
48 + goto fail_devregister;
52 + arch_setup_dma_ops(&portal->pdev->dev, 0, 0, NULL, true);
54 portal->pdev->dev.pm_domain = &qman_portal_device_pm_domain;
55 portal->pdev->dev.platform_data = portal;
56 - ret = platform_device_add(portal->pdev);
58 - pr_err("qman_portal - platform_device_add() failed\n");
61 dpa_rbtree_init(&portal->retire_table);
63 qm_isr_disable_write(__p, isdr);
64 @@ -751,10 +747,8 @@ fail_eqcr_empty:
66 free_irq(config->public_cfg.irq, portal);
68 - platform_device_del(portal->pdev);
70 - platform_device_put(portal->pdev);
72 + platform_device_unregister(portal->pdev);
75 for (ret = 0; ret < num_ceetms; ret++)
76 kfree(portal->ccgrs[ret]);
77 @@ -852,8 +846,7 @@ void qman_destroy_portal(struct qman_por
78 qm_dqrr_finish(&qm->p);
79 qm_eqcr_finish(&qm->p);
81 - platform_device_del(qm->pdev);
82 - platform_device_put(qm->pdev);
83 + platform_device_unregister(qm->pdev);
87 @@ -1809,6 +1802,16 @@ int qman_init_fq(struct qman_fq *fq, u32
89 phys_fq = dma_map_single(&p->pdev->dev, fq, sizeof(*fq),
91 + if (dma_mapping_error(&p->pdev->dev, phys_fq)) {
92 + dev_err(&p->pdev->dev,
93 + "dma_map_single failed for fqid: %u\n",
96 + PORTAL_IRQ_UNLOCK(p, irqflags);
97 + put_affine_portal();
101 qm_fqd_stashing_set64(&mcc->initfq.fqd, phys_fq);