aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0036-sdk-dpa-use-netdev-dev-for-DMA-mapping.patch
blob: 39631c32f06fc34a656f09acad52c7c66aa17b22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From e1ae30545347709590bab5f4a3c27e7f639c6ead Mon Sep 17 00:00:00 2001
From: Madalin Bucur <madalin.bucur@nxp.com>
Date: Wed, 18 Oct 2017 19:36:59 +0300
Subject: [PATCH] sdk: dpa: use netdev dev for DMA mapping

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c |  2 +-
 .../ethernet/freescale/sdk_dpaa/dpaa_eth_base.c    |  2 +-
 .../ethernet/freescale/sdk_dpaa/dpaa_eth_common.c  | 35 ++++------------------
 .../ethernet/freescale/sdk_dpaa/dpaa_eth_common.h  |  2 +-
 4 files changed, 9 insertions(+), 32 deletions(-)

--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
@@ -875,7 +875,7 @@ static int dpa_priv_bp_create(struct net
 
 	for (i = 0; i < count; i++) {
 		int err;
-		err = dpa_bp_alloc(&dpa_bp[i]);
+		err = dpa_bp_alloc(&dpa_bp[i], net_dev->dev.parent);
 		if (err < 0) {
 			dpa_bp_free(priv);
 			priv->dpa_bp = NULL;
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_base.c
@@ -176,7 +176,7 @@ int dpa_bp_create(struct net_device *net
 
 	for (i = 0; i < count; i++) {
 		int err;
-		err = dpa_bp_alloc(&dpa_bp[i]);
+		err = dpa_bp_alloc(&dpa_bp[i], net_dev->dev.parent);
 		if (err < 0) {
 			dpa_bp_free(priv);
 			priv->dpa_bp = NULL;
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c
@@ -686,11 +686,10 @@ void dpa_set_buffers_layout(struct mac_d
 EXPORT_SYMBOL(dpa_set_buffers_layout);
 
 int __attribute__((nonnull))
-dpa_bp_alloc(struct dpa_bp *dpa_bp)
+dpa_bp_alloc(struct dpa_bp *dpa_bp, struct device *dev)
 {
 	int err;
 	struct bman_pool_params	 bp_params;
-	struct platform_device *pdev;
 
 	if (dpa_bp->size == 0 || dpa_bp->config_count == 0) {
 		pr_err("Buffer pool is not properly initialized! Missing size or initial number of buffers");
@@ -723,44 +722,25 @@ dpa_bp_alloc(struct dpa_bp *dpa_bp)
 
 	dpa_bp->bpid = (uint8_t)bman_get_params(dpa_bp->pool)->bpid;
 
-	pdev = platform_device_register_simple("dpaa_eth_bpool",
-			dpa_bp->bpid, NULL, 0);
-	if (IS_ERR(pdev)) {
-		pr_err("platform_device_register_simple() failed\n");
-		err = PTR_ERR(pdev);
-		goto pdev_register_failed;
-	}
-	{
-		struct dma_map_ops *ops = get_dma_ops(&pdev->dev);
-		ops->dma_supported = NULL;
-	}
-	err = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
+	err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(40));
 	if (err) {
 		pr_err("dma_coerce_mask_and_coherent() failed\n");
-		goto pdev_mask_failed;
+		goto bman_free_pool;
 	}
-#ifdef CONFIG_FMAN_ARM
-	/* force coherency */
-	pdev->dev.archdata.dma_coherent = true;
-	arch_setup_dma_ops(&pdev->dev, 0, 0, NULL, true);
-#endif
 
-	dpa_bp->dev = &pdev->dev;
+	dpa_bp->dev = dev;
 
 	if (dpa_bp->seed_cb) {
 		err = dpa_bp->seed_cb(dpa_bp);
 		if (err)
-			goto pool_seed_failed;
+			goto bman_free_pool;
 	}
 
 	dpa_bpid2pool_map(dpa_bp->bpid, dpa_bp);
 
 	return 0;
 
-pool_seed_failed:
-pdev_mask_failed:
-	platform_device_unregister(pdev);
-pdev_register_failed:
+bman_free_pool:
 	bman_free_pool(dpa_bp->pool);
 
 	return err;
@@ -822,9 +802,6 @@ _dpa_bp_free(struct dpa_bp *dpa_bp)
 
 	dpa_bp_array[bp->bpid] = NULL;
 	bman_free_pool(bp->pool);
-
-	if (bp->dev)
-		platform_device_unregister(to_platform_device(bp->dev));
 }
 
 void __cold __attribute__((nonnull))
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.h
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.h
@@ -163,7 +163,7 @@ void dpa_set_rx_mode(struct net_device *
 void dpa_set_buffers_layout(struct mac_device *mac_dev,
 		struct dpa_buffer_layout_s *layout);
 int __attribute__((nonnull))
-dpa_bp_alloc(struct dpa_bp *dpa_bp);
+dpa_bp_alloc(struct dpa_bp *dpa_bp, struct device *dev);
 void __cold __attribute__((nonnull))
 dpa_bp_free(struct dpa_priv_s *priv);
 struct dpa_bp *dpa_bpid2pool(int bpid);