ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0107-fsl_qbman-Adjust-platform-device-creation-for-QMan-p.patch
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
5
6 Fix the platform device creation in QMan portals such that
7 dma mappings are done properly.
8
9 Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
10 Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
11 ---
12  drivers/staging/fsl_qbman/qman_high.c | 47 +++++++++++++++++++----------------
13  1 file changed, 25 insertions(+), 22 deletions(-)
14
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(
18         char buf[16];
19         int ret;
20         u32 isdr;
21 +       struct platform_device_info pdev_info;
22  
23         if (!portal) {
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);
30 +
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);
35 +
36 +       portal->pdev = platform_device_register_full(&pdev_info);
37         if (!portal->pdev) {
38                 pr_err("qman_portal - platform_device_alloc() failed\n");
39 -               goto fail_devalloc;
40 -       }
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;
44 -#else
45 -       if (dma_set_mask(&portal->pdev->dev, DMA_BIT_MASK(40))) {
46 -               pr_err("qman_portal - dma_set_mask() failed\n");
47 -               goto fail_devadd;
48 +               goto fail_devregister;
49         }
50 -#endif
51 +
52 +       arch_setup_dma_ops(&portal->pdev->dev, 0, 0, NULL, true);
53 +
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);
57 -       if (ret) {
58 -               pr_err("qman_portal - platform_device_add() failed\n");
59 -               goto fail_devadd;
60 -       }
61         dpa_rbtree_init(&portal->retire_table);
62         isdr = 0xffffffff;
63         qm_isr_disable_write(__p, isdr);
64 @@ -751,10 +747,8 @@ fail_eqcr_empty:
65  fail_affinity:
66         free_irq(config->public_cfg.irq, portal);
67  fail_irq:
68 -       platform_device_del(portal->pdev);
69 -fail_devadd:
70 -       platform_device_put(portal->pdev);
71 -fail_devalloc:
72 +       platform_device_unregister(portal->pdev);
73 +fail_devregister:
74         if (num_ceetms)
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);
80  
81 -       platform_device_del(qm->pdev);
82 -       platform_device_put(qm->pdev);
83 +       platform_device_unregister(qm->pdev);
84  
85         qm->config = NULL;
86         if (qm->alloced)
87 @@ -1809,6 +1802,16 @@ int qman_init_fq(struct qman_fq *fq, u32
88                 } else {
89                         phys_fq = dma_map_single(&p->pdev->dev, fq, sizeof(*fq),
90                                                 DMA_TO_DEVICE);
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",
94 +                                       fq->fqid);
95 +                               FQUNLOCK(fq);
96 +                               PORTAL_IRQ_UNLOCK(p, irqflags);
97 +                               put_affine_portal();
98 +                               return -EIO;
99 +                       }
100 +
101                         qm_fqd_stashing_set64(&mcc->initfq.fqd, phys_fq);
102                 }
103         }