1 From ede8d823f0e1b2c5e14cbac13839b818ed1c18cf Mon Sep 17 00:00:00 2001
2 From: Biwen Li <biwen.li@nxp.com>
3 Date: Tue, 30 Oct 2018 18:26:10 +0800
4 Subject: [PATCH 07/40] apaa2-dpio:support layerscape
5 This is an integrated patch of dpaa2-dpio for layerscape
7 Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
8 Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
9 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 Signed-off-by: Guanhua Gao <guanhua.gao@nxp.com>
11 Signed-off-by: Haiying Wang <Haiying.Wang@nxp.com>
12 Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
13 Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
14 Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
15 Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
16 Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
17 Signed-off-by: Biwen Li <biwen.li@nxp.com>
19 drivers/staging/fsl-mc/Kconfig | 1 +
20 drivers/staging/fsl-mc/Makefile | 1 +
21 drivers/staging/fsl-mc/bus/Kconfig | 5 +-
22 drivers/staging/fsl-mc/bus/Makefile | 3 +-
23 drivers/staging/fsl-mc/bus/dpbp-cmd.h | 28 +-
24 drivers/staging/fsl-mc/bus/dpbp.c | 28 +-
25 drivers/staging/fsl-mc/bus/dpcon-cmd.h | 28 +-
26 drivers/staging/fsl-mc/bus/dpcon.c | 32 +-
27 drivers/staging/fsl-mc/bus/dpio/Makefile | 3 +-
28 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h | 29 +-
29 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c | 53 ++--
30 .../staging/fsl-mc/bus/dpio/dpio-service.c | 258 +++++++++++++---
31 drivers/staging/fsl-mc/bus/dpio/dpio.c | 51 ++--
32 drivers/staging/fsl-mc/bus/dpio/dpio.h | 32 +-
33 .../staging/fsl-mc/bus/dpio/qbman-portal.c | 217 ++++++++++---
34 .../staging/fsl-mc/bus/dpio/qbman-portal.h | 112 ++++---
35 drivers/staging/fsl-mc/bus/dpmcp.c | 28 +-
36 drivers/staging/fsl-mc/bus/dprc-driver.c | 4 +-
37 drivers/staging/fsl-mc/bus/dprc.c | 28 +-
38 drivers/staging/fsl-mc/bus/fsl-mc-allocator.c | 4 +-
39 drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 4 +-
40 drivers/staging/fsl-mc/bus/fsl-mc-msi.c | 4 +-
41 drivers/staging/fsl-mc/bus/fsl-mc-private.h | 4 +-
42 .../fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c | 4 +-
43 drivers/staging/fsl-mc/bus/mc-io.c | 28 +-
44 drivers/staging/fsl-mc/bus/mc-sys.c | 28 +-
45 drivers/staging/fsl-mc/include/dpaa2-fd.h | 288 ++++++++++++++++--
46 drivers/staging/fsl-mc/include/dpaa2-global.h | 27 +-
47 drivers/staging/fsl-mc/include/dpaa2-io.h | 97 ++++--
48 drivers/staging/fsl-mc/include/dpbp.h | 29 +-
49 drivers/staging/fsl-mc/include/dpcon.h | 32 +-
50 drivers/staging/fsl-mc/include/dpopr.h | 110 +++++++
51 drivers/staging/fsl-mc/include/mc.h | 4 +-
52 33 files changed, 970 insertions(+), 634 deletions(-)
53 create mode 100644 drivers/staging/fsl-mc/include/dpopr.h
55 --- a/drivers/staging/fsl-mc/Kconfig
56 +++ b/drivers/staging/fsl-mc/Kconfig
58 +# SPDX-License-Identifier: GPL-2.0
59 source "drivers/staging/fsl-mc/bus/Kconfig"
60 --- a/drivers/staging/fsl-mc/Makefile
61 +++ b/drivers/staging/fsl-mc/Makefile
63 +# SPDX-License-Identifier: GPL-2.0
64 # Freescale Management Complex (MC) bus drivers
65 obj-$(CONFIG_FSL_MC_BUS) += bus/
66 --- a/drivers/staging/fsl-mc/bus/Kconfig
67 +++ b/drivers/staging/fsl-mc/bus/Kconfig
69 +# SPDX-License-Identifier: GPL-2.0
73 # Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
75 -# This file is released under the GPLv2
79 bool "QorIQ DPAA2 fsl-mc bus driver"
80 @@ -18,7 +17,7 @@ config FSL_MC_BUS
83 tristate "QorIQ DPAA2 DPIO driver"
84 - depends on FSL_MC_BUS && ARCH_LAYERSCAPE
85 + depends on FSL_MC_BUS
87 Driver for the DPAA2 DPIO object. A DPIO provides queue and
88 buffer management facilities for software to interact with
89 --- a/drivers/staging/fsl-mc/bus/Makefile
90 +++ b/drivers/staging/fsl-mc/bus/Makefile
92 +# SPDX-License-Identifier: GPL-2.0
94 # Freescale Management Complex (MC) bus drivers
96 # Copyright (C) 2014 Freescale Semiconductor, Inc.
98 -# This file is released under the GPLv2
100 obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o
102 mc-bus-driver-objs := fsl-mc-bus.o \
103 --- a/drivers/staging/fsl-mc/bus/dpbp-cmd.h
104 +++ b/drivers/staging/fsl-mc/bus/dpbp-cmd.h
106 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
108 * Copyright 2013-2016 Freescale Semiconductor Inc.
110 - * Redistribution and use in source and binary forms, with or without
111 - * modification, are permitted provided that the following conditions are met:
112 - * * Redistributions of source code must retain the above copyright
113 - * notice, this list of conditions and the following disclaimer.
114 - * * Redistributions in binary form must reproduce the above copyright
115 - * notice, this list of conditions and the following disclaimer in the
116 - * documentation and/or other materials provided with the distribution.
117 - * * Neither the name of the above-listed copyright holders nor the
118 - * names of any contributors may be used to endorse or promote products
119 - * derived from this software without specific prior written permission.
121 - * ALTERNATIVELY, this software may be distributed under the terms of the
122 - * GNU General Public License ("GPL") as published by the Free Software
123 - * Foundation, either version 2 of that License or (at your option) any
126 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
127 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
128 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
129 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
130 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
131 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
132 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
133 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
134 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
135 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
136 - * POSSIBILITY OF SUCH DAMAGE.
138 #ifndef _FSL_DPBP_CMD_H
139 #define _FSL_DPBP_CMD_H
140 --- a/drivers/staging/fsl-mc/bus/dpbp.c
141 +++ b/drivers/staging/fsl-mc/bus/dpbp.c
143 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
145 * Copyright 2013-2016 Freescale Semiconductor Inc.
147 - * Redistribution and use in source and binary forms, with or without
148 - * modification, are permitted provided that the following conditions are met:
149 - * * Redistributions of source code must retain the above copyright
150 - * notice, this list of conditions and the following disclaimer.
151 - * * Redistributions in binary form must reproduce the above copyright
152 - * notice, this list of conditions and the following disclaimer in the
153 - * documentation and/or other materials provided with the distribution.
154 - * * Neither the name of the above-listed copyright holders nor the
155 - * names of any contributors may be used to endorse or promote products
156 - * derived from this software without specific prior written permission.
158 - * ALTERNATIVELY, this software may be distributed under the terms of the
159 - * GNU General Public License ("GPL") as published by the Free Software
160 - * Foundation, either version 2 of that License or (at your option) any
163 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
164 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
165 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
166 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
167 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
168 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
169 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
170 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
171 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
172 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
173 - * POSSIBILITY OF SUCH DAMAGE.
175 #include <linux/kernel.h>
176 #include "../include/mc.h"
177 --- a/drivers/staging/fsl-mc/bus/dpcon-cmd.h
178 +++ b/drivers/staging/fsl-mc/bus/dpcon-cmd.h
180 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
182 * Copyright 2013-2016 Freescale Semiconductor Inc.
184 - * Redistribution and use in source and binary forms, with or without
185 - * modification, are permitted provided that the following conditions are met:
186 - * * Redistributions of source code must retain the above copyright
187 - * notice, this list of conditions and the following disclaimer.
188 - * * Redistributions in binary form must reproduce the above copyright
189 - * notice, this list of conditions and the following disclaimer in the
190 - * documentation and/or other materials provided with the distribution.
191 - * * Neither the name of the above-listed copyright holders nor the
192 - * names of any contributors may be used to endorse or promote products
193 - * derived from this software without specific prior written permission.
195 - * ALTERNATIVELY, this software may be distributed under the terms of the
196 - * GNU General Public License ("GPL") as published by the Free Software
197 - * Foundation, either version 2 of that License or (at your option) any
200 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
201 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
203 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
204 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
205 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
206 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
207 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
208 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
209 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
210 - * POSSIBILITY OF SUCH DAMAGE.
212 #ifndef _FSL_DPCON_CMD_H
213 #define _FSL_DPCON_CMD_H
214 --- a/drivers/staging/fsl-mc/bus/dpcon.c
215 +++ b/drivers/staging/fsl-mc/bus/dpcon.c
217 -/* Copyright 2013-2016 Freescale Semiconductor Inc.
218 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
220 + * Copyright 2013-2016 Freescale Semiconductor Inc.
222 - * Redistribution and use in source and binary forms, with or without
223 - * modification, are permitted provided that the following conditions are met:
224 - * * Redistributions of source code must retain the above copyright
225 - * notice, this list of conditions and the following disclaimer.
226 - * * Redistributions in binary form must reproduce the above copyright
227 - * notice, this list of conditions and the following disclaimer in the
228 - * documentation and/or other materials provided with the distribution.
229 - * * Neither the name of the above-listed copyright holders nor the
230 - * names of any contributors may be used to endorse or promote products
231 - * derived from this software without specific prior written permission.
234 - * ALTERNATIVELY, this software may be distributed under the terms of the
235 - * GNU General Public License ("GPL") as published by the Free Software
236 - * Foundation, either version 2 of that License or (at your option) any
239 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
240 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
243 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
244 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
245 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
246 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
247 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
248 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
249 - * POSSIBILITY OF SUCH DAMAGE.
251 #include <linux/kernel.h>
252 #include "../include/mc.h"
253 --- a/drivers/staging/fsl-mc/bus/dpio/Makefile
254 +++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
256 +# SPDX-License-Identifier: GPL-2.0
258 # QorIQ DPAA2 DPIO driver
261 -subdir-ccflags-y := -Werror
263 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
265 fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o dpio-driver.o
266 --- a/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
267 +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
269 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
271 * Copyright 2013-2016 Freescale Semiconductor Inc.
274 - * Redistribution and use in source and binary forms, with or without
275 - * modification, are permitted provided that the following conditions are met:
276 - * * Redistributions of source code must retain the above copyright
277 - * notice, this list of conditions and the following disclaimer.
278 - * * Redistributions in binary form must reproduce the above copyright
279 - * notice, this list of conditions and the following disclaimer in the
280 - * documentation and/or other materials provided with the distribution.
281 - * * Neither the name of the above-listed copyright holders nor the
282 - * names of any contributors may be used to endorse or promote products
283 - * derived from this software without specific prior written permission.
285 - * ALTERNATIVELY, this software may be distributed under the terms of the
286 - * GNU General Public License ("GPL") as published by the Free Software
287 - * Foundation, either version 2 of that License or (at your option) any
290 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
291 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
292 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
293 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
294 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
295 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
296 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
297 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
298 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
299 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
300 - * POSSIBILITY OF SUCH DAMAGE.
302 #ifndef _FSL_DPIO_CMD_H
303 #define _FSL_DPIO_CMD_H
305 #define DPIO_CMDID_ENABLE DPIO_CMD(0x002)
306 #define DPIO_CMDID_DISABLE DPIO_CMD(0x003)
307 #define DPIO_CMDID_GET_ATTR DPIO_CMD(0x004)
308 +#define DPIO_CMDID_RESET DPIO_CMD(0x005)
310 struct dpio_cmd_open {
312 --- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
313 +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
315 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
317 * Copyright 2014-2016 Freescale Semiconductor Inc.
318 - * Copyright NXP 2016
319 + * Copyright 2016 NXP
321 - * Redistribution and use in source and binary forms, with or without
322 - * modification, are permitted provided that the following conditions are met:
323 - * * Redistributions of source code must retain the above copyright
324 - * notice, this list of conditions and the following disclaimer.
325 - * * Redistributions in binary form must reproduce the above copyright
326 - * notice, this list of conditions and the following disclaimer in the
327 - * documentation and/or other materials provided with the distribution.
328 - * * Neither the name of Freescale Semiconductor nor the
329 - * names of its contributors may be used to endorse or promote products
330 - * derived from this software without specific prior written permission.
332 - * ALTERNATIVELY, this software may be distributed under the terms of the
333 - * GNU General Public License ("GPL") as published by the Free Software
334 - * Foundation, either version 2 of that License or (at your option) any
337 - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
338 - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
339 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
340 - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
341 - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
342 - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
343 - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
344 - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
345 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
346 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
349 #include <linux/types.h>
350 @@ -114,6 +89,7 @@ static int dpaa2_dpio_probe(struct fsl_m
352 struct device *dev = &dpio_dev->dev;
353 static int next_cpu = -1;
354 + int possible_next_cpu;
356 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
358 @@ -135,6 +111,12 @@ static int dpaa2_dpio_probe(struct fsl_m
362 + err = dpio_reset(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
364 + dev_err(dev, "dpio_reset() failed\n");
368 err = dpio_get_attributes(dpio_dev->mc_io, 0, dpio_dev->mc_handle,
371 @@ -156,23 +138,23 @@ static int dpaa2_dpio_probe(struct fsl_m
373 /* get the cpu to use for the affinity hint */
375 - next_cpu = cpumask_first(cpu_online_mask);
376 + possible_next_cpu = cpumask_first(cpu_online_mask);
378 - next_cpu = cpumask_next(next_cpu, cpu_online_mask);
379 + possible_next_cpu = cpumask_next(next_cpu, cpu_online_mask);
381 - if (!cpu_possible(next_cpu)) {
382 + if (possible_next_cpu >= nr_cpu_ids) {
383 dev_err(dev, "probe failed. Number of DPIOs exceeds NR_CPUS.\n");
385 goto err_allocate_irqs;
387 - desc.cpu = next_cpu;
388 + desc.cpu = next_cpu = possible_next_cpu;
391 - * Set the CENA regs to be the cache inhibited area of the portal to
392 - * avoid coherency issues if a user migrates to another core.
393 + * Set the CENA regs to be the cache enabled area of the portal to
394 + * achieve the best performance.
396 - desc.regs_cena = ioremap_wc(dpio_dev->regions[1].start,
397 - resource_size(&dpio_dev->regions[1]));
398 + desc.regs_cena = ioremap_cache_ns(dpio_dev->regions[0].start,
399 + resource_size(&dpio_dev->regions[0]));
400 desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
401 resource_size(&dpio_dev->regions[1]));
403 @@ -207,6 +189,7 @@ err_register_dpio_irq:
405 dpio_disable(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
408 dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
410 fsl_mc_portal_free(dpio_dev->mc_io);
411 --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
412 +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
414 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
416 * Copyright 2014-2016 Freescale Semiconductor Inc.
419 - * Redistribution and use in source and binary forms, with or without
420 - * modification, are permitted provided that the following conditions are met:
421 - * * Redistributions of source code must retain the above copyright
422 - * notice, this list of conditions and the following disclaimer.
423 - * * Redistributions in binary form must reproduce the above copyright
424 - * notice, this list of conditions and the following disclaimer in the
425 - * documentation and/or other materials provided with the distribution.
426 - * * Neither the name of Freescale Semiconductor nor the
427 - * names of its contributors may be used to endorse or promote products
428 - * derived from this software without specific prior written permission.
430 - * ALTERNATIVELY, this software may be distributed under the terms of the
431 - * GNU General Public License ("GPL") as published by the Free Software
432 - * Foundation, either version 2 of that License or (at your option) any
435 - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
436 - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
437 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
438 - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
439 - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
440 - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
441 - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
442 - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
443 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
444 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
446 #include <linux/types.h>
447 #include "../../include/mc.h"
449 #include "qbman-portal.h"
453 struct dpaa2_io_desc dpio_desc;
454 struct qbman_swp_desc swp_desc;
455 struct qbman_swp *swp;
456 @@ -83,7 +57,7 @@ static inline struct dpaa2_io *service_s
457 * If cpu == -1, choose the current cpu, with no guarantees about
458 * potentially being migrated away.
460 - if (unlikely(cpu < 0))
462 cpu = smp_processor_id();
464 /* If a specific cpu was requested, pick it up immediately */
465 @@ -95,6 +69,10 @@ static inline struct dpaa2_io *service_s
469 + d = service_select_by_cpu(d, -1);
473 spin_lock(&dpio_list_lock);
474 d = list_entry(dpio_list.next, struct dpaa2_io, node);
476 @@ -105,6 +83,23 @@ static inline struct dpaa2_io *service_s
480 + * dpaa2_io_service_select() - return a dpaa2_io service affined to this cpu
483 + * Return the affine dpaa2_io service, or NULL if there is no service affined
484 + * to the specified cpu. If DPAA2_IO_ANY_CPU is used, return the next available
487 +struct dpaa2_io *dpaa2_io_service_select(int cpu)
489 + if (cpu == DPAA2_IO_ANY_CPU)
490 + return service_select(NULL);
492 + return service_select_by_cpu(NULL, cpu);
494 +EXPORT_SYMBOL_GPL(dpaa2_io_service_select);
497 * dpaa2_io_create() - create a dpaa2_io object.
498 * @desc: the dpaa2_io descriptor
500 @@ -126,7 +121,6 @@ struct dpaa2_io *dpaa2_io_create(const s
504 - atomic_set(&obj->refs, 1);
505 obj->dpio_desc = *desc;
506 obj->swp_desc.cena_bar = obj->dpio_desc.regs_cena;
507 obj->swp_desc.cinh_bar = obj->dpio_desc.regs_cinh;
508 @@ -158,7 +152,6 @@ struct dpaa2_io *dpaa2_io_create(const s
512 -EXPORT_SYMBOL(dpaa2_io_create);
515 * dpaa2_io_down() - release the dpaa2_io object.
516 @@ -171,11 +164,8 @@ EXPORT_SYMBOL(dpaa2_io_create);
518 void dpaa2_io_down(struct dpaa2_io *d)
520 - if (!atomic_dec_and_test(&d->refs))
524 -EXPORT_SYMBOL(dpaa2_io_down);
526 #define DPAA_POLL_MAX 32
528 @@ -206,7 +196,7 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io
531 q64 = qbman_result_SCN_ctx(dq);
533 + ctx = (void *)(uintptr_t)q64;
536 pr_crit("fsl-mc-dpio: Unrecognised/ignored DQRR entry\n");
537 @@ -222,7 +212,6 @@ done:
538 qbman_swp_interrupt_set_inhibit(swp, 0);
541 -EXPORT_SYMBOL(dpaa2_io_irq);
544 * dpaa2_io_service_register() - Prepare for servicing of FQDAN or CDAN
545 @@ -252,7 +241,7 @@ int dpaa2_io_service_register(struct dpa
548 ctx->dpio_id = d->dpio_desc.dpio_id;
549 - ctx->qman64 = (u64)ctx;
550 + ctx->qman64 = (u64)(uintptr_t)ctx;
551 ctx->dpio_private = d;
552 spin_lock_irqsave(&d->lock_notifications, irqflags);
553 list_add(&ctx->node, &d->notifications);
554 @@ -265,7 +254,7 @@ int dpaa2_io_service_register(struct dpa
558 -EXPORT_SYMBOL(dpaa2_io_service_register);
559 +EXPORT_SYMBOL_GPL(dpaa2_io_service_register);
562 * dpaa2_io_service_deregister - The opposite of 'register'.
563 @@ -288,7 +277,7 @@ void dpaa2_io_service_deregister(struct
564 list_del(&ctx->node);
565 spin_unlock_irqrestore(&d->lock_notifications, irqflags);
567 -EXPORT_SYMBOL(dpaa2_io_service_deregister);
568 +EXPORT_SYMBOL_GPL(dpaa2_io_service_deregister);
571 * dpaa2_io_service_rearm() - Rearm the notification for the given DPIO service.
572 @@ -322,7 +311,7 @@ int dpaa2_io_service_rearm(struct dpaa2_
576 -EXPORT_SYMBOL(dpaa2_io_service_rearm);
577 +EXPORT_SYMBOL_GPL(dpaa2_io_service_rearm);
580 * dpaa2_io_service_pull_fq() - pull dequeue functions from a fq.
581 @@ -385,7 +374,7 @@ int dpaa2_io_service_pull_channel(struct
585 -EXPORT_SYMBOL(dpaa2_io_service_pull_channel);
586 +EXPORT_SYMBOL_GPL(dpaa2_io_service_pull_channel);
589 * dpaa2_io_service_enqueue_fq() - Enqueue a frame to a frame queue.
590 @@ -441,7 +430,7 @@ int dpaa2_io_service_enqueue_qd(struct d
592 return qbman_swp_enqueue(d->swp, &ed, fd);
594 -EXPORT_SYMBOL(dpaa2_io_service_enqueue_qd);
595 +EXPORT_SYMBOL_GPL(dpaa2_io_service_enqueue_qd);
598 * dpaa2_io_service_release() - Release buffers to a buffer pool.
599 @@ -453,7 +442,7 @@ EXPORT_SYMBOL(dpaa2_io_service_enqueue_q
600 * Return 0 for success, and negative error code for failure.
602 int dpaa2_io_service_release(struct dpaa2_io *d,
606 unsigned int num_buffers)
608 @@ -468,7 +457,7 @@ int dpaa2_io_service_release(struct dpaa
610 return qbman_swp_release(d->swp, &rd, buffers, num_buffers);
612 -EXPORT_SYMBOL(dpaa2_io_service_release);
613 +EXPORT_SYMBOL_GPL(dpaa2_io_service_release);
616 * dpaa2_io_service_acquire() - Acquire buffers from a buffer pool.
617 @@ -482,7 +471,7 @@ EXPORT_SYMBOL(dpaa2_io_service_release);
618 * Eg. if the buffer pool is empty, this will return zero.
620 int dpaa2_io_service_acquire(struct dpaa2_io *d,
624 unsigned int num_buffers)
626 @@ -499,7 +488,7 @@ int dpaa2_io_service_acquire(struct dpaa
630 -EXPORT_SYMBOL(dpaa2_io_service_acquire);
631 +EXPORT_SYMBOL_GPL(dpaa2_io_service_acquire);
634 * 'Stores' are reusable memory blocks for holding dequeue results, and to
635 @@ -553,7 +542,7 @@ struct dpaa2_io_store *dpaa2_io_store_cr
639 -EXPORT_SYMBOL(dpaa2_io_store_create);
640 +EXPORT_SYMBOL_GPL(dpaa2_io_store_create);
643 * dpaa2_io_store_destroy() - Frees the dma memory storage for dequeue
644 @@ -567,7 +556,7 @@ void dpaa2_io_store_destroy(struct dpaa2
645 kfree(s->alloced_addr);
648 -EXPORT_SYMBOL(dpaa2_io_store_destroy);
649 +EXPORT_SYMBOL_GPL(dpaa2_io_store_destroy);
652 * dpaa2_io_store_next() - Determine when the next dequeue result is available.
653 @@ -615,4 +604,177 @@ struct dpaa2_dq *dpaa2_io_store_next(str
657 -EXPORT_SYMBOL(dpaa2_io_store_next);
658 +EXPORT_SYMBOL_GPL(dpaa2_io_store_next);
661 + * dpaa2_io_query_fq_count() - Get the frame and byte count for a given fq.
662 + * @d: the given DPIO object.
663 + * @fqid: the id of frame queue to be queried.
664 + * @fcnt: the queried frame count.
665 + * @bcnt: the queried byte count.
667 + * Knowing the FQ count at run-time can be useful in debugging situations.
668 + * The instantaneous frame- and byte-count are hereby returned.
670 + * Return 0 for a successful query, and negative error code if query fails.
672 +int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid,
673 + u32 *fcnt, u32 *bcnt)
675 + struct qbman_fq_query_np_rslt state;
676 + struct qbman_swp *swp;
677 + unsigned long irqflags;
680 + d = service_select(d);
685 + spin_lock_irqsave(&d->lock_mgmt_cmd, irqflags);
686 + ret = qbman_fq_query_state(swp, fqid, &state);
687 + spin_unlock_irqrestore(&d->lock_mgmt_cmd, irqflags);
690 + *fcnt = qbman_fq_state_frame_count(&state);
691 + *bcnt = qbman_fq_state_byte_count(&state);
695 +EXPORT_SYMBOL_GPL(dpaa2_io_query_fq_count);
698 + * dpaa2_io_query_bp_count() - Query the number of buffers currently in a
700 + * @d: the given DPIO object.
701 + * @bpid: the index of buffer pool to be queried.
702 + * @num: the queried number of buffers in the buffer pool.
704 + * Return 0 for a successful query, and negative error code if query fails.
706 +int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, u32 *num)
708 + struct qbman_bp_query_rslt state;
709 + struct qbman_swp *swp;
710 + unsigned long irqflags;
713 + d = service_select(d);
718 + spin_lock_irqsave(&d->lock_mgmt_cmd, irqflags);
719 + ret = qbman_bp_query(swp, bpid, &state);
720 + spin_unlock_irqrestore(&d->lock_mgmt_cmd, irqflags);
723 + *num = qbman_bp_info_num_free_bufs(&state);
726 +EXPORT_SYMBOL_GPL(dpaa2_io_query_bp_count);
729 + * dpaa2_io_service_enqueue_orp_fq() - Enqueue a frame to a frame queue with
730 + * order restoration
731 + * @d: the given DPIO service.
732 + * @fqid: the given frame queue id.
733 + * @fd: the frame descriptor which is enqueued.
734 + * @orpid: the order restoration point ID
735 + * @seqnum: the order sequence number
736 + * @last: must be set for the final frame if seqnum is shared (spilt frame)
738 + * Performs an enqueue to a frame queue using the specified order restoration
739 + * point. The QMan device will ensure the order of frames placed on the
740 + * queue will be ordered as per the sequence number.
742 + * In the case a frame is split it is possible to enqueue using the same
743 + * sequence number more than once. The final frame in a shared sequence number
744 + * most be indicated by setting last = 1. For non shared sequence numbers
745 + * last = 1 must always be set.
747 + * Return 0 for successful enqueue, or -EBUSY if the enqueue ring is not ready,
748 + * or -ENODEV if there is no dpio service.
750 +int dpaa2_io_service_enqueue_orp_fq(struct dpaa2_io *d, u32 fqid,
751 + const struct dpaa2_fd *fd, u16 orpid,
752 + u16 seqnum, int last)
754 + struct qbman_eq_desc ed;
756 + d = service_select(d);
759 + qbman_eq_desc_clear(&ed);
760 + qbman_eq_desc_set_orp(&ed, 0, orpid, seqnum, !last);
761 + qbman_eq_desc_set_fq(&ed, fqid);
762 + return qbman_swp_enqueue(d->swp, &ed, fd);
764 +EXPORT_SYMBOL(dpaa2_io_service_enqueue_orp_fq);
767 + * dpaa2_io_service_enqueue_orp_qd() - Enqueue a frame to a queueing destination
768 + * with order restoration
769 + * @d: the given DPIO service.
770 + * @qdid: the given queuing destination id.
771 + * @fd: the frame descriptor which is enqueued.
772 + * @orpid: the order restoration point ID
773 + * @seqnum: the order sequence number
774 + * @last: must be set for the final frame if seqnum is shared (spilt frame)
776 + * Performs an enqueue to a frame queue using the specified order restoration
777 + * point. The QMan device will ensure the order of frames placed on the
778 + * queue will be ordered as per the sequence number.
780 + * In the case a frame is split it is possible to enqueue using the same
781 + * sequence number more than once. The final frame in a shared sequence number
782 + * most be indicated by setting last = 1. For non shared sequence numbers
783 + * last = 1 must always be set.
785 + * Return 0 for successful enqueue, or -EBUSY if the enqueue ring is not ready,
786 + * or -ENODEV if there is no dpio service.
788 +int dpaa2_io_service_enqueue_orp_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
789 + u16 qdbin, const struct dpaa2_fd *fd,
790 + u16 orpid, u16 seqnum, int last)
792 + struct qbman_eq_desc ed;
794 + d = service_select(d);
797 + qbman_eq_desc_clear(&ed);
798 + qbman_eq_desc_set_orp(&ed, 0, orpid, seqnum, !last);
799 + qbman_eq_desc_set_qd(&ed, qdid, qdbin, prio);
800 + return qbman_swp_enqueue(d->swp, &ed, fd);
802 +EXPORT_SYMBOL_GPL(dpaa2_io_service_enqueue_orp_qd);
805 + * dpaa2_io_service_orp_seqnum_drop() - Remove a sequence number from
806 + * an order restoration list
807 + * @d: the given DPIO service.
808 + * @orpid: Order restoration point to remove a sequence number from
809 + * @seqnum: Sequence number to remove
811 + * Removes a frames sequence number from an order restoration point without
812 + * enqueing the frame. Used to indicate that the order restoration hardware
813 + * should not expect to see this sequence number. Typically used to indicate
814 + * a frame was terminated or dropped from a flow.
816 + * Return 0 for successful enqueue, or -EBUSY if the enqueue ring is not ready,
817 + * or -ENODEV if there is no dpio service.
819 +int dpaa2_io_service_orp_seqnum_drop(struct dpaa2_io *d, u16 orpid, u16 seqnum)
821 + struct qbman_eq_desc ed;
822 + struct dpaa2_fd fd;
824 + d = service_select(d);
827 + qbman_eq_desc_clear(&ed);
828 + qbman_eq_desc_set_orp_hole(&ed, orpid, seqnum);
829 + return qbman_swp_enqueue(d->swp, &ed, &fd);
831 +EXPORT_SYMBOL_GPL(dpaa2_io_service_orp_seqnum_drop);
832 --- a/drivers/staging/fsl-mc/bus/dpio/dpio.c
833 +++ b/drivers/staging/fsl-mc/bus/dpio/dpio.c
835 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
837 * Copyright 2013-2016 Freescale Semiconductor Inc.
840 - * Redistribution and use in source and binary forms, with or without
841 - * modification, are permitted provided that the following conditions are met:
842 - * * Redistributions of source code must retain the above copyright
843 - * notice, this list of conditions and the following disclaimer.
844 - * * Redistributions in binary form must reproduce the above copyright
845 - * notice, this list of conditions and the following disclaimer in the
846 - * documentation and/or other materials provided with the distribution.
847 - * * Neither the name of the above-listed copyright holders nor the
848 - * names of any contributors may be used to endorse or promote products
849 - * derived from this software without specific prior written permission.
851 - * ALTERNATIVELY, this software may be distributed under the terms of the
852 - * GNU General Public License ("GPL") as published by the Free Software
853 - * Foundation, either version 2 of that License or (at your option) any
856 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
857 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
858 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
859 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
860 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
861 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
862 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
863 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
864 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
865 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
866 - * POSSIBILITY OF SUCH DAMAGE.
868 #include <linux/kernel.h>
869 #include "../../include/mc.h"
870 @@ -222,3 +196,26 @@ int dpio_get_api_version(struct fsl_mc_i
876 + * dpio_reset() - Reset the DPIO, returns the object to initial state.
877 + * @mc_io: Pointer to MC portal's I/O object
878 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
879 + * @token: Token of DPIO object
881 + * Return: '0' on Success; Error code otherwise.
883 +int dpio_reset(struct fsl_mc_io *mc_io,
887 + struct fsl_mc_command cmd = { 0 };
889 + /* prepare command */
890 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET,
894 + /* send command to mc*/
895 + return mc_send_command(mc_io, &cmd);
897 --- a/drivers/staging/fsl-mc/bus/dpio/dpio.h
898 +++ b/drivers/staging/fsl-mc/bus/dpio/dpio.h
900 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
902 * Copyright 2013-2016 Freescale Semiconductor Inc.
905 - * Redistribution and use in source and binary forms, with or without
906 - * modification, are permitted provided that the following conditions are met:
907 - * * Redistributions of source code must retain the above copyright
908 - * notice, this list of conditions and the following disclaimer.
909 - * * Redistributions in binary form must reproduce the above copyright
910 - * notice, this list of conditions and the following disclaimer in the
911 - * documentation and/or other materials provided with the distribution.
912 - * * Neither the name of the above-listed copyright holders nor the
913 - * names of any contributors may be used to endorse or promote products
914 - * derived from this software without specific prior written permission.
916 - * ALTERNATIVELY, this software may be distributed under the terms of the
917 - * GNU General Public License ("GPL") as published by the Free Software
918 - * Foundation, either version 2 of that License or (at your option) any
921 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
922 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
923 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
924 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
925 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
926 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
927 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
928 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
929 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
930 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
931 - * POSSIBILITY OF SUCH DAMAGE.
935 @@ -106,4 +80,8 @@ int dpio_get_api_version(struct fsl_mc_i
939 +int dpio_reset(struct fsl_mc_io *mc_io,
943 #endif /* __FSL_DPIO_H */
944 --- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
945 +++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
947 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
949 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
952 - * Redistribution and use in source and binary forms, with or without
953 - * modification, are permitted provided that the following conditions are met:
954 - * * Redistributions of source code must retain the above copyright
955 - * notice, this list of conditions and the following disclaimer.
956 - * * Redistributions in binary form must reproduce the above copyright
957 - * notice, this list of conditions and the following disclaimer in the
958 - * documentation and/or other materials provided with the distribution.
959 - * * Neither the name of Freescale Semiconductor nor the
960 - * names of its contributors may be used to endorse or promote products
961 - * derived from this software without specific prior written permission.
963 - * ALTERNATIVELY, this software may be distributed under the terms of the
964 - * GNU General Public License ("GPL") as published by the Free Software
965 - * Foundation, either version 2 of that License or (at your option) any
968 - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
969 - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
970 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
971 - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
972 - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
973 - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
974 - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
975 - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
976 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
977 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
980 #include <asm/cacheflush.h>
981 @@ -99,6 +74,14 @@ enum qbman_sdqcr_fc {
982 qbman_sdqcr_fc_up_to_3 = 1
985 +#define dccvac(p) { asm volatile("dc cvac, %0;" : : "r" (p) : "memory"); }
986 +#define dcivac(p) { asm volatile("dc ivac, %0" : : "r"(p) : "memory"); }
987 +static inline void qbman_inval_prefetch(struct qbman_swp *p, uint32_t offset)
989 + dcivac(p->addr_cena + offset);
990 + prefetch(p->addr_cena + offset);
995 static inline u32 qbman_read_register(struct qbman_swp *p, u32 offset)
996 @@ -189,7 +172,7 @@ struct qbman_swp *qbman_swp_init(const s
997 p->addr_cinh = d->cinh_bar;
999 reg = qbman_set_swp_cfg(p->dqrr.dqrr_size,
1000 - 1, /* Writes Non-cacheable */
1001 + 0, /* Writes cacheable */
1002 0, /* EQCR_CI stashing threshold */
1003 3, /* RPM: Valid bit mode, RCR in array mode */
1004 2, /* DCM: Discrete consumption ack mode */
1005 @@ -315,6 +298,7 @@ void qbman_swp_mc_submit(struct qbman_sw
1008 *v = cmd_verb | p->mc.valid_bit;
1013 @@ -325,6 +309,7 @@ void *qbman_swp_mc_result(struct qbman_s
1017 + qbman_inval_prefetch(p, QBMAN_CENA_SWP_RR(p->mc.valid_bit));
1018 ret = qbman_get_cmd(p, QBMAN_CENA_SWP_RR(p->mc.valid_bit));
1020 /* Remove the valid-bit - command completed if the rest is non-zero */
1021 @@ -370,6 +355,43 @@ void qbman_eq_desc_set_no_orp(struct qbm
1022 d->verb |= enqueue_rejects_to_fq;
1026 + * qbman_eq_desc_set_orp() - Set order-restoration in the enqueue descriptor
1027 + * @d: the enqueue descriptor.
1028 + * @response_success: 1 = enqueue with response always; 0 = enqueue with
1029 + * rejections returned on a FQ.
1030 + * @oprid: the order point record id.
1031 + * @seqnum: the order restoration sequence number.
1032 + * @incomplete: indicates whether this is the last fragments using the same
1033 + * sequence number.
1035 +void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success,
1036 + u16 oprid, u16 seqnum, int incomplete)
1038 + d->verb |= (1 << QB_ENQUEUE_CMD_ORP_ENABLE_SHIFT);
1039 + if (respond_success)
1040 + d->verb |= enqueue_response_always;
1042 + d->verb |= enqueue_rejects_to_fq;
1043 + d->orpid = cpu_to_le16(oprid);
1044 + d->seqnum = cpu_to_le16((!!incomplete << 14) | seqnum);
1048 + * qbman_eq_desc_set_orp_hole() - fill a hole in the order-restoration sequence
1049 + * without any enqueue
1050 + * @d: the enqueue descriptor.
1051 + * @oprid: the order point record id.
1052 + * @seqnum: the order restoration sequence number.
1054 +void qbman_eq_desc_set_orp_hole(struct qbman_eq_desc *d, u16 oprid,
1057 + d->verb |= (1 << QB_ENQUEUE_CMD_ORP_ENABLE_SHIFT) | enqueue_empty;
1058 + d->orpid = cpu_to_le16(oprid);
1059 + d->seqnum = cpu_to_le16(seqnum);
1063 * Exactly one of the following descriptor "targets" should be set. (Calling any
1064 * one of these will replace the effect of any prior call to one of these.)
1065 @@ -429,12 +451,23 @@ int qbman_swp_enqueue(struct qbman_swp *
1068 p = qbman_get_cmd(s, QBMAN_CENA_SWP_EQCR(EQAR_IDX(eqar)));
1069 - memcpy(&p->dca, &d->dca, 31);
1070 + /* This is mapped as DEVICE type memory, writes are
1071 + * with address alignment:
1072 + * desc.dca address alignment = 1
1073 + * desc.seqnum address alignment = 2
1074 + * desc.orpid address alignment = 4
1075 + * desc.tgtid address alignment = 8
1078 + p->seqnum = d->seqnum;
1079 + p->orpid = d->orpid;
1080 + memcpy(&p->tgtid, &d->tgtid, 24);
1081 memcpy(&p->fd, fd, sizeof(*fd));
1083 /* Set the verb byte, have to substitute in the valid-bit */
1085 p->verb = d->verb | EQAR_VB(eqar);
1090 @@ -522,7 +555,7 @@ void qbman_pull_desc_set_storage(struct
1093 /* save the virtual address */
1094 - d->rsp_addr_virt = (u64)storage;
1095 + d->rsp_addr_virt = (u64)(uintptr_t)storage;
1098 d->verb &= ~(1 << QB_VDQCR_VERB_RLS_SHIFT);
1099 @@ -615,7 +648,7 @@ int qbman_swp_pull(struct qbman_swp *s,
1100 atomic_inc(&s->vdq.available);
1103 - s->vdq.storage = (void *)d->rsp_addr_virt;
1104 + s->vdq.storage = (void *)(uintptr_t)d->rsp_addr_virt;
1105 p = qbman_get_cmd(s, QBMAN_CENA_SWP_VDQCR);
1107 p->tok = QMAN_DQ_TOKEN_VALID;
1108 @@ -627,6 +660,7 @@ int qbman_swp_pull(struct qbman_swp *s,
1109 /* Set the verb byte, have to substitute in the valid-bit */
1110 p->verb = d->verb | s->vdq.valid_bit;
1111 s->vdq.valid_bit ^= QB_VALID_BIT;
1116 @@ -680,8 +714,7 @@ const struct dpaa2_dq *qbman_swp_dqrr_ne
1117 s->dqrr.next_idx, pi);
1118 s->dqrr.reset_bug = 0;
1120 - prefetch(qbman_get_cmd(s,
1121 - QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx)));
1122 + qbman_inval_prefetch(s, QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx));
1125 p = qbman_get_cmd(s, QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx));
1126 @@ -696,8 +729,7 @@ const struct dpaa2_dq *qbman_swp_dqrr_ne
1127 * knew from reading PI.
1129 if ((verb & QB_VALID_BIT) != s->dqrr.valid_bit) {
1130 - prefetch(qbman_get_cmd(s,
1131 - QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx)));
1132 + qbman_inval_prefetch(s, QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx));
1136 @@ -720,7 +752,7 @@ const struct dpaa2_dq *qbman_swp_dqrr_ne
1137 (flags & DPAA2_DQ_STAT_EXPIRED))
1138 atomic_inc(&s->vdq.available);
1140 - prefetch(qbman_get_cmd(s, QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx)));
1141 + qbman_inval_prefetch(s, QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx));
1145 @@ -848,6 +880,7 @@ int qbman_swp_release(struct qbman_swp *
1148 p->verb = d->verb | RAR_VB(rar) | num_buffers;
1153 @@ -855,7 +888,7 @@ int qbman_swp_release(struct qbman_swp *
1154 struct qbman_acquire_desc {
1162 @@ -863,10 +896,10 @@ struct qbman_acquire_desc {
1163 struct qbman_acquire_rslt {
1175 @@ -929,7 +962,7 @@ int qbman_swp_acquire(struct qbman_swp *
1176 struct qbman_alt_fq_state_desc {
1184 @@ -952,7 +985,7 @@ int qbman_swp_alt_fq_state(struct qbman_
1188 - p->fqid = cpu_to_le32(fqid) & ALT_FQ_FQID_MASK;
1189 + p->fqid = cpu_to_le32(fqid & ALT_FQ_FQID_MASK);
1191 /* Complete the management command */
1192 r = qbman_swp_mc_complete(s, p, alt_fq_verb);
1193 @@ -978,11 +1011,11 @@ int qbman_swp_alt_fq_state(struct qbman_
1194 struct qbman_cdan_ctrl_desc {
1208 @@ -990,7 +1023,7 @@ struct qbman_cdan_ctrl_desc {
1209 struct qbman_cdan_ctrl_rslt {
1217 @@ -1033,3 +1066,99 @@ int qbman_swp_CDAN_set(struct qbman_swp
1222 +#define QBMAN_RESPONSE_VERB_MASK 0x7f
1223 +#define QBMAN_FQ_QUERY_NP 0x45
1224 +#define QBMAN_BP_QUERY 0x32
1226 +struct qbman_fq_query_desc {
1233 +int qbman_fq_query_state(struct qbman_swp *s, u32 fqid,
1234 + struct qbman_fq_query_np_rslt *r)
1236 + struct qbman_fq_query_desc *p;
1239 + p = (struct qbman_fq_query_desc *)qbman_swp_mc_start(s);
1243 + /* FQID is a 24 bit value */
1244 + p->fqid = cpu_to_le32(fqid & 0x00FFFFFF);
1245 + resp = qbman_swp_mc_complete(s, p, QBMAN_FQ_QUERY_NP);
1247 + pr_err("qbman: Query FQID %d NP fields failed, no response\n",
1251 + *r = *(struct qbman_fq_query_np_rslt *)resp;
1252 + /* Decode the outcome */
1253 + WARN_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_FQ_QUERY_NP);
1255 + /* Determine success or failure */
1256 + if (r->rslt != QBMAN_MC_RSLT_OK) {
1257 + pr_err("Query NP fields of FQID 0x%x failed, code=0x%02x\n",
1258 + p->fqid, r->rslt);
1265 +u32 qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r)
1267 + return (le32_to_cpu(r->frm_cnt) & 0x00FFFFFF);
1270 +u32 qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r)
1272 + return le32_to_cpu(r->byte_cnt);
1275 +struct qbman_bp_query_desc {
1282 +int qbman_bp_query(struct qbman_swp *s, u16 bpid,
1283 + struct qbman_bp_query_rslt *r)
1285 + struct qbman_bp_query_desc *p;
1288 + p = (struct qbman_bp_query_desc *)qbman_swp_mc_start(s);
1292 + p->bpid = cpu_to_le16(bpid);
1293 + resp = qbman_swp_mc_complete(s, p, QBMAN_BP_QUERY);
1295 + pr_err("qbman: Query BPID %d fields failed, no response\n",
1299 + *r = *(struct qbman_bp_query_rslt *)resp;
1300 + /* Decode the outcome */
1301 + WARN_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_BP_QUERY);
1303 + /* Determine success or failure */
1304 + if (r->rslt != QBMAN_MC_RSLT_OK) {
1305 + pr_err("Query fields of BPID 0x%x failed, code=0x%02x\n",
1313 +u32 qbman_bp_info_num_free_bufs(struct qbman_bp_query_rslt *a)
1315 + return le32_to_cpu(a->fill);
1317 --- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
1318 +++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
1320 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
1322 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
1323 * Copyright 2016 NXP
1325 - * Redistribution and use in source and binary forms, with or without
1326 - * modification, are permitted provided that the following conditions are met:
1327 - * * Redistributions of source code must retain the above copyright
1328 - * notice, this list of conditions and the following disclaimer.
1329 - * * Redistributions in binary form must reproduce the above copyright
1330 - * notice, this list of conditions and the following disclaimer in the
1331 - * documentation and/or other materials provided with the distribution.
1332 - * * Neither the name of Freescale Semiconductor nor the
1333 - * names of its contributors may be used to endorse or promote products
1334 - * derived from this software without specific prior written permission.
1336 - * ALTERNATIVELY, this software may be distributed under the terms of the
1337 - * GNU General Public License ("GPL") as published by the Free Software
1338 - * Foundation, either version 2 of that License or (at your option) any
1341 - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
1342 - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1343 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1344 - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
1345 - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1346 - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1347 - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1348 - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1349 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1350 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1352 #ifndef __FSL_QBMAN_PORTAL_H
1353 #define __FSL_QBMAN_PORTAL_H
1354 @@ -57,8 +32,8 @@ struct qbman_pull_desc {
1365 @@ -95,17 +70,17 @@ enum qbman_pull_type_e {
1366 struct qbman_eq_desc {
1390 @@ -113,9 +88,9 @@ struct qbman_eq_desc {
1391 struct qbman_release_desc {
1402 /* Management command result codes */
1403 @@ -187,6 +162,9 @@ int qbman_result_has_new_result(struct q
1405 void qbman_eq_desc_clear(struct qbman_eq_desc *d);
1406 void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success);
1407 +void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success,
1408 + u16 oprid, u16 seqnum, int incomplete);
1409 +void qbman_eq_desc_set_orp_hole(struct qbman_eq_desc *d, u16 oprid, u16 seqnum);
1410 void qbman_eq_desc_set_token(struct qbman_eq_desc *d, u8 token);
1411 void qbman_eq_desc_set_fq(struct qbman_eq_desc *d, u32 fqid);
1412 void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, u32 qdid,
1413 @@ -466,4 +444,62 @@ static inline void *qbman_swp_mc_complet
1418 +struct qbman_fq_query_np_rslt {
1438 +int qbman_fq_query_state(struct qbman_swp *s, u32 fqid,
1439 + struct qbman_fq_query_np_rslt *r);
1440 +u32 qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r);
1441 +u32 qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r);
1443 +struct qbman_bp_query_rslt {
1459 + __le64 bpscn_addr;
1470 +int qbman_bp_query(struct qbman_swp *s, u16 bpid,
1471 + struct qbman_bp_query_rslt *r);
1473 +u32 qbman_bp_info_num_free_bufs(struct qbman_bp_query_rslt *a);
1475 #endif /* __FSL_QBMAN_PORTAL_H */
1476 --- a/drivers/staging/fsl-mc/bus/dpmcp.c
1477 +++ b/drivers/staging/fsl-mc/bus/dpmcp.c
1479 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1481 * Copyright 2013-2016 Freescale Semiconductor Inc.
1483 - * Redistribution and use in source and binary forms, with or without
1484 - * modification, are permitted provided that the following conditions are met:
1485 - * * Redistributions of source code must retain the above copyright
1486 - * notice, this list of conditions and the following disclaimer.
1487 - * * Redistributions in binary form must reproduce the above copyright
1488 - * notice, this list of conditions and the following disclaimer in the
1489 - * documentation and/or other materials provided with the distribution.
1490 - * * Neither the name of the above-listed copyright holders nor the
1491 - * names of any contributors may be used to endorse or promote products
1492 - * derived from this software without specific prior written permission.
1494 - * ALTERNATIVELY, this software may be distributed under the terms of the
1495 - * GNU General Public License ("GPL") as published by the Free Software
1496 - * Foundation, either version 2 of that License or (at your option) any
1499 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1500 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1501 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1502 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
1503 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1504 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1505 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1506 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1507 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1508 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1509 - * POSSIBILITY OF SUCH DAMAGE.
1511 #include <linux/kernel.h>
1512 #include "../include/mc.h"
1513 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c
1514 +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
1516 +// SPDX-License-Identifier: GPL-2.0
1518 * Freescale data path resource container (DPRC) driver
1520 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
1521 * Author: German Rivera <German.Rivera@freescale.com>
1523 - * This file is licensed under the terms of the GNU General Public
1524 - * License version 2. This program is licensed "as is" without any
1525 - * warranty of any kind, whether express or implied.
1528 #include <linux/module.h>
1529 --- a/drivers/staging/fsl-mc/bus/dprc.c
1530 +++ b/drivers/staging/fsl-mc/bus/dprc.c
1532 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1534 * Copyright 2013-2016 Freescale Semiconductor Inc.
1536 - * Redistribution and use in source and binary forms, with or without
1537 - * modification, are permitted provided that the following conditions are met:
1538 - * * Redistributions of source code must retain the above copyright
1539 - * notice, this list of conditions and the following disclaimer.
1540 - * * Redistributions in binary form must reproduce the above copyright
1541 - * notice, this list of conditions and the following disclaimer in the
1542 - * documentation and/or other materials provided with the distribution.
1543 - * * Neither the name of the above-listed copyright holders nor the
1544 - * names of any contributors may be used to endorse or promote products
1545 - * derived from this software without specific prior written permission.
1547 - * ALTERNATIVELY, this software may be distributed under the terms of the
1548 - * GNU General Public License ("GPL") as published by the Free Software
1549 - * Foundation, either version 2 of that License or (at your option) any
1552 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1553 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1554 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1555 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
1556 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1557 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1558 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1559 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1560 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1561 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1562 - * POSSIBILITY OF SUCH DAMAGE.
1564 #include <linux/kernel.h>
1565 #include "../include/mc.h"
1566 --- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
1567 +++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
1569 +// SPDX-License-Identifier: GPL-2.0
1571 * fsl-mc object allocator driver
1573 * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
1575 - * This file is licensed under the terms of the GNU General Public
1576 - * License version 2. This program is licensed "as is" without any
1577 - * warranty of any kind, whether express or implied.
1580 #include <linux/module.h>
1581 --- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
1582 +++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
1584 +// SPDX-License-Identifier: GPL-2.0
1586 * Freescale Management Complex (MC) bus driver
1588 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
1589 * Author: German Rivera <German.Rivera@freescale.com>
1591 - * This file is licensed under the terms of the GNU General Public
1592 - * License version 2. This program is licensed "as is" without any
1593 - * warranty of any kind, whether express or implied.
1596 #define pr_fmt(fmt) "fsl-mc: " fmt
1597 --- a/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
1598 +++ b/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
1600 +// SPDX-License-Identifier: GPL-2.0
1602 * Freescale Management Complex (MC) bus driver MSI support
1604 * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
1605 * Author: German Rivera <German.Rivera@freescale.com>
1607 - * This file is licensed under the terms of the GNU General Public
1608 - * License version 2. This program is licensed "as is" without any
1609 - * warranty of any kind, whether express or implied.
1612 #include <linux/of_device.h>
1613 --- a/drivers/staging/fsl-mc/bus/fsl-mc-private.h
1614 +++ b/drivers/staging/fsl-mc/bus/fsl-mc-private.h
1616 +/* SPDX-License-Identifier: GPL-2.0 */
1618 * Freescale Management Complex (MC) bus private declarations
1620 * Copyright (C) 2016 Freescale Semiconductor, Inc.
1622 - * This file is licensed under the terms of the GNU General Public
1623 - * License version 2. This program is licensed "as is" without any
1624 - * warranty of any kind, whether express or implied.
1626 #ifndef _FSL_MC_PRIVATE_H_
1627 #define _FSL_MC_PRIVATE_H_
1628 --- a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
1629 +++ b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
1631 +// SPDX-License-Identifier: GPL-2.0
1633 * Freescale Management Complex (MC) bus driver MSI support
1635 * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
1636 * Author: German Rivera <German.Rivera@freescale.com>
1638 - * This file is licensed under the terms of the GNU General Public
1639 - * License version 2. This program is licensed "as is" without any
1640 - * warranty of any kind, whether express or implied.
1643 #include <linux/of_device.h>
1644 --- a/drivers/staging/fsl-mc/bus/mc-io.c
1645 +++ b/drivers/staging/fsl-mc/bus/mc-io.c
1647 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1649 * Copyright 2013-2016 Freescale Semiconductor Inc.
1651 - * Redistribution and use in source and binary forms, with or without
1652 - * modification, are permitted provided that the following conditions are met:
1653 - * * Redistributions of source code must retain the above copyright
1654 - * notice, this list of conditions and the following disclaimer.
1655 - * * Redistributions in binary form must reproduce the above copyright
1656 - * notice, this list of conditions and the following disclaimer in the
1657 - * documentation and/or other materials provided with the distribution.
1658 - * * Neither the name of the above-listed copyright holders nor the
1659 - * names of any contributors may be used to endorse or promote products
1660 - * derived from this software without specific prior written permission.
1662 - * ALTERNATIVELY, this software may be distributed under the terms of the
1663 - * GNU General Public License ("GPL") as published by the Free Software
1664 - * Foundation, either version 2 of that License or (at your option) any
1667 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1668 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1669 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1670 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
1671 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1672 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1673 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1674 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1675 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1676 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1677 - * POSSIBILITY OF SUCH DAMAGE.
1680 #include <linux/io.h>
1681 --- a/drivers/staging/fsl-mc/bus/mc-sys.c
1682 +++ b/drivers/staging/fsl-mc/bus/mc-sys.c
1684 +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
1686 * Copyright 2013-2016 Freescale Semiconductor Inc.
1688 * I/O services to send MC commands to the MC hardware
1690 - * Redistribution and use in source and binary forms, with or without
1691 - * modification, are permitted provided that the following conditions are met:
1692 - * * Redistributions of source code must retain the above copyright
1693 - * notice, this list of conditions and the following disclaimer.
1694 - * * Redistributions in binary form must reproduce the above copyright
1695 - * notice, this list of conditions and the following disclaimer in the
1696 - * documentation and/or other materials provided with the distribution.
1697 - * * Neither the name of the above-listed copyright holders nor the
1698 - * names of any contributors may be used to endorse or promote products
1699 - * derived from this software without specific prior written permission.
1701 - * ALTERNATIVELY, this software may be distributed under the terms of the
1702 - * GNU General Public License ("GPL") as published by the Free Software
1703 - * Foundation, either version 2 of that License or (at your option) any
1706 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1707 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1708 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1709 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
1710 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1711 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1712 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1713 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1714 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1715 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1716 - * POSSIBILITY OF SUCH DAMAGE.
1719 #include <linux/delay.h>
1720 --- a/drivers/staging/fsl-mc/include/dpaa2-fd.h
1721 +++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
1723 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
1725 * Copyright 2014-2016 Freescale Semiconductor Inc.
1726 * Copyright 2016 NXP
1728 - * Redistribution and use in source and binary forms, with or without
1729 - * modification, are permitted provided that the following conditions are met:
1730 - * * Redistributions of source code must retain the above copyright
1731 - * notice, this list of conditions and the following disclaimer.
1732 - * * Redistributions in binary form must reproduce the above copyright
1733 - * notice, this list of conditions and the following disclaimer in the
1734 - * documentation and/or other materials provided with the distribution.
1735 - * * Neither the name of Freescale Semiconductor nor the
1736 - * names of its contributors may be used to endorse or promote products
1737 - * derived from this software without specific prior written permission.
1739 - * ALTERNATIVELY, this software may be distributed under the terms of the
1740 - * GNU General Public License ("GPL") as published by the Free Software
1741 - * Foundation, either version 2 of that License or (at your option) any
1744 - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
1745 - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1746 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1747 - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
1748 - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1749 - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1750 - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1751 - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1752 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1753 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1755 #ifndef __FSL_DPAA2_FD_H
1756 #define __FSL_DPAA2_FD_H
1757 @@ -91,6 +66,27 @@ struct dpaa2_fd {
1758 #define SG_BPID_MASK 0x3FFF
1759 #define SG_FINAL_FLAG_MASK 0x1
1760 #define SG_FINAL_FLAG_SHIFT 15
1761 +#define FL_SHORT_LEN_FLAG_MASK 0x1
1762 +#define FL_SHORT_LEN_FLAG_SHIFT 14
1763 +#define FL_SHORT_LEN_MASK 0x3FFFF
1764 +#define FL_OFFSET_MASK 0x0FFF
1765 +#define FL_FORMAT_MASK 0x3
1766 +#define FL_FORMAT_SHIFT 12
1767 +#define FL_BPID_MASK 0x3FFF
1768 +#define FL_FINAL_FLAG_MASK 0x1
1769 +#define FL_FINAL_FLAG_SHIFT 15
1771 +/* Error bits in FD CTRL */
1772 +#define FD_CTRL_ERR_MASK 0x000000FF
1773 +#define FD_CTRL_UFD 0x00000004
1774 +#define FD_CTRL_SBE 0x00000008
1775 +#define FD_CTRL_FLC 0x00000010
1776 +#define FD_CTRL_FSE 0x00000020
1777 +#define FD_CTRL_FAERR 0x00000040
1779 +/* Annotation bits in FD CTRL */
1780 +#define FD_CTRL_PTA 0x00800000
1781 +#define FD_CTRL_PTV1 0x00400000
1783 enum dpaa2_fd_format {
1784 dpaa2_fd_single = 0,
1785 @@ -312,7 +308,7 @@ enum dpaa2_sg_format {
1787 static inline dma_addr_t dpaa2_sg_get_addr(const struct dpaa2_sg_entry *sg)
1789 - return le64_to_cpu((dma_addr_t)sg->addr);
1790 + return (dma_addr_t)le64_to_cpu(sg->addr);
1794 @@ -443,9 +439,243 @@ static inline bool dpaa2_sg_is_final(con
1796 static inline void dpaa2_sg_set_final(struct dpaa2_sg_entry *sg, bool final)
1798 - sg->format_offset &= cpu_to_le16(~(SG_FINAL_FLAG_MASK
1799 - << SG_FINAL_FLAG_SHIFT));
1800 + sg->format_offset &= cpu_to_le16((~(SG_FINAL_FLAG_MASK
1801 + << SG_FINAL_FLAG_SHIFT)) & 0xFFFF);
1802 sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT);
1806 + * struct dpaa2_fl_entry - structure for frame list entry.
1807 + * @addr: address in the FLE
1808 + * @len: length in the FLE
1809 + * @bpid: buffer pool ID
1810 + * @format_offset: format, offset, and short-length fields
1811 + * @frc: frame context
1812 + * @ctrl: control bits...including pta, pvt1, pvt2, err, etc
1813 + * @flc: flow context address
1815 +struct dpaa2_fl_entry {
1819 + __le16 format_offset;
1825 +enum dpaa2_fl_format {
1826 + dpaa2_fl_single = 0,
1832 + * dpaa2_fl_get_addr() - get the addr field of FLE
1833 + * @fle: the given frame list entry
1835 + * Return the address in the frame list entry.
1837 +static inline dma_addr_t dpaa2_fl_get_addr(const struct dpaa2_fl_entry *fle)
1839 + return (dma_addr_t)le64_to_cpu(fle->addr);
1843 + * dpaa2_fl_set_addr() - Set the addr field of FLE
1844 + * @fle: the given frame list entry
1845 + * @addr: the address needs to be set in frame list entry
1847 +static inline void dpaa2_fl_set_addr(struct dpaa2_fl_entry *fle,
1850 + fle->addr = cpu_to_le64(addr);
1854 + * dpaa2_fl_get_frc() - Get the frame context in the FLE
1855 + * @fle: the given frame list entry
1857 + * Return the frame context field in the frame lsit entry.
1859 +static inline u32 dpaa2_fl_get_frc(const struct dpaa2_fl_entry *fle)
1861 + return le32_to_cpu(fle->frc);
1865 + * dpaa2_fl_set_frc() - Set the frame context in the FLE
1866 + * @fle: the given frame list entry
1867 + * @frc: the frame context needs to be set in frame list entry
1869 +static inline void dpaa2_fl_set_frc(struct dpaa2_fl_entry *fle, u32 frc)
1871 + fle->frc = cpu_to_le32(frc);
1875 + * dpaa2_fl_get_ctrl() - Get the control bits in the FLE
1876 + * @fle: the given frame list entry
1878 + * Return the control bits field in the frame list entry.
1880 +static inline u32 dpaa2_fl_get_ctrl(const struct dpaa2_fl_entry *fle)
1882 + return le32_to_cpu(fle->ctrl);
1886 + * dpaa2_fl_set_ctrl() - Set the control bits in the FLE
1887 + * @fle: the given frame list entry
1888 + * @ctrl: the control bits to be set in the frame list entry
1890 +static inline void dpaa2_fl_set_ctrl(struct dpaa2_fl_entry *fle, u32 ctrl)
1892 + fle->ctrl = cpu_to_le32(ctrl);
1896 + * dpaa2_fl_get_flc() - Get the flow context in the FLE
1897 + * @fle: the given frame list entry
1899 + * Return the flow context in the frame list entry.
1901 +static inline dma_addr_t dpaa2_fl_get_flc(const struct dpaa2_fl_entry *fle)
1903 + return (dma_addr_t)le64_to_cpu(fle->flc);
1907 + * dpaa2_fl_set_flc() - Set the flow context field of FLE
1908 + * @fle: the given frame list entry
1909 + * @flc_addr: the flow context needs to be set in frame list entry
1911 +static inline void dpaa2_fl_set_flc(struct dpaa2_fl_entry *fle,
1912 + dma_addr_t flc_addr)
1914 + fle->flc = cpu_to_le64(flc_addr);
1917 +static inline bool dpaa2_fl_short_len(const struct dpaa2_fl_entry *fle)
1919 + return !!((le16_to_cpu(fle->format_offset) >>
1920 + FL_SHORT_LEN_FLAG_SHIFT) & FL_SHORT_LEN_FLAG_MASK);
1924 + * dpaa2_fl_get_len() - Get the length in the FLE
1925 + * @fle: the given frame list entry
1927 + * Return the length field in the frame list entry.
1929 +static inline u32 dpaa2_fl_get_len(const struct dpaa2_fl_entry *fle)
1931 + if (dpaa2_fl_short_len(fle))
1932 + return le32_to_cpu(fle->len) & FL_SHORT_LEN_MASK;
1934 + return le32_to_cpu(fle->len);
1938 + * dpaa2_fl_set_len() - Set the length field of FLE
1939 + * @fle: the given frame list entry
1940 + * @len: the length needs to be set in frame list entry
1942 +static inline void dpaa2_fl_set_len(struct dpaa2_fl_entry *fle, u32 len)
1944 + fle->len = cpu_to_le32(len);
1948 + * dpaa2_fl_get_offset() - Get the offset field in the frame list entry
1949 + * @fle: the given frame list entry
1951 + * Return the offset.
1953 +static inline u16 dpaa2_fl_get_offset(const struct dpaa2_fl_entry *fle)
1955 + return le16_to_cpu(fle->format_offset) & FL_OFFSET_MASK;
1959 + * dpaa2_fl_set_offset() - Set the offset field of FLE
1960 + * @fle: the given frame list entry
1961 + * @offset: the offset needs to be set in frame list entry
1963 +static inline void dpaa2_fl_set_offset(struct dpaa2_fl_entry *fle, u16 offset)
1965 + fle->format_offset &= cpu_to_le16(~FL_OFFSET_MASK);
1966 + fle->format_offset |= cpu_to_le16(offset);
1970 + * dpaa2_fl_get_format() - Get the format field in the FLE
1971 + * @fle: the given frame list entry
1973 + * Return the format.
1975 +static inline enum dpaa2_fl_format dpaa2_fl_get_format(
1976 + const struct dpaa2_fl_entry *fle)
1978 + return (enum dpaa2_fl_format)((le16_to_cpu(fle->format_offset) >>
1979 + FL_FORMAT_SHIFT) & FL_FORMAT_MASK);
1983 + * dpaa2_fl_set_format() - Set the format field of FLE
1984 + * @fle: the given frame list entry
1985 + * @format: the format needs to be set in frame list entry
1987 +static inline void dpaa2_fl_set_format(struct dpaa2_fl_entry *fle,
1988 + enum dpaa2_fl_format format)
1990 + fle->format_offset &= cpu_to_le16(~(FL_FORMAT_MASK << FL_FORMAT_SHIFT));
1991 + fle->format_offset |= cpu_to_le16(format << FL_FORMAT_SHIFT);
1995 + * dpaa2_fl_get_bpid() - Get the bpid field in the FLE
1996 + * @fle: the given frame list entry
1998 + * Return the buffer pool id.
2000 +static inline u16 dpaa2_fl_get_bpid(const struct dpaa2_fl_entry *fle)
2002 + return le16_to_cpu(fle->bpid) & FL_BPID_MASK;
2006 + * dpaa2_fl_set_bpid() - Set the bpid field of FLE
2007 + * @fle: the given frame list entry
2008 + * @bpid: buffer pool id to be set
2010 +static inline void dpaa2_fl_set_bpid(struct dpaa2_fl_entry *fle, u16 bpid)
2012 + fle->bpid &= cpu_to_le16(~(FL_BPID_MASK));
2013 + fle->bpid |= cpu_to_le16(bpid);
2017 + * dpaa2_fl_is_final() - Check final bit in FLE
2018 + * @fle: the given frame list entry
2022 +static inline bool dpaa2_fl_is_final(const struct dpaa2_fl_entry *fle)
2024 + return !!(le16_to_cpu(fle->format_offset) >> FL_FINAL_FLAG_SHIFT);
2028 + * dpaa2_fl_set_final() - Set the final bit in FLE
2029 + * @fle: the given frame list entry
2030 + * @final: the final boolean to be set
2032 +static inline void dpaa2_fl_set_final(struct dpaa2_fl_entry *fle, bool final)
2034 + fle->format_offset &= cpu_to_le16(~(FL_FINAL_FLAG_MASK <<
2035 + FL_FINAL_FLAG_SHIFT));
2036 + fle->format_offset |= cpu_to_le16(final << FL_FINAL_FLAG_SHIFT);
2039 #endif /* __FSL_DPAA2_FD_H */
2040 --- a/drivers/staging/fsl-mc/include/dpaa2-global.h
2041 +++ b/drivers/staging/fsl-mc/include/dpaa2-global.h
2043 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2045 * Copyright 2014-2016 Freescale Semiconductor Inc.
2046 * Copyright 2016 NXP
2048 - * Redistribution and use in source and binary forms, with or without
2049 - * modification, are permitted provided that the following conditions are met:
2050 - * * Redistributions of source code must retain the above copyright
2051 - * notice, this list of conditions and the following disclaimer.
2052 - * * Redistributions in binary form must reproduce the above copyright
2053 - * notice, this list of conditions and the following disclaimer in the
2054 - * documentation and/or other materials provided with the distribution.
2055 - * * Neither the name of Freescale Semiconductor nor the
2056 - * names of its contributors may be used to endorse or promote products
2057 - * derived from this software without specific prior written permission.
2059 - * ALTERNATIVELY, this software may be distributed under the terms of the
2060 - * GNU General Public License ("GPL") as published by the Free Software
2061 - * Foundation, either version 2 of that License or (at your option) any
2064 - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
2065 - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2066 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2067 - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
2068 - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2069 - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2070 - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2071 - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2072 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2073 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2075 #ifndef __FSL_DPAA2_GLOBAL_H
2076 #define __FSL_DPAA2_GLOBAL_H
2077 --- a/drivers/staging/fsl-mc/include/dpaa2-io.h
2078 +++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
2080 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2082 * Copyright 2014-2016 Freescale Semiconductor Inc.
2084 + * Copyright 2017 NXP
2086 - * Redistribution and use in source and binary forms, with or without
2087 - * modification, are permitted provided that the following conditions are met:
2088 - * * Redistributions of source code must retain the above copyright
2089 - * notice, this list of conditions and the following disclaimer.
2090 - * * Redistributions in binary form must reproduce the above copyright
2091 - * notice, this list of conditions and the following disclaimer in the
2092 - * documentation and/or other materials provided with the distribution.
2093 - * * Neither the name of Freescale Semiconductor nor the
2094 - * names of its contributors may be used to endorse or promote products
2095 - * derived from this software without specific prior written permission.
2097 - * ALTERNATIVELY, this software may be distributed under the terms of the
2098 - * GNU General Public License ("GPL") as published by the Free Software
2099 - * Foundation, either version 2 of that License or (at your option) any
2102 - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
2103 - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2104 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2105 - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
2106 - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2107 - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2108 - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2109 - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2110 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2111 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2113 #ifndef __FSL_DPAA2_IO_H
2114 #define __FSL_DPAA2_IO_H
2115 @@ -88,6 +63,8 @@ void dpaa2_io_down(struct dpaa2_io *d);
2117 irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
2119 +struct dpaa2_io *dpaa2_io_service_select(int cpu);
2122 * struct dpaa2_io_notification_ctx - The DPIO notification context structure
2123 * @cb: The callback to be invoked when the notification arrives
2124 @@ -103,7 +80,7 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io
2125 * Used when a FQDAN/CDAN registration is made by drivers.
2127 struct dpaa2_io_notification_ctx {
2128 - void (*cb)(struct dpaa2_io_notification_ctx *);
2129 + void (*cb)(struct dpaa2_io_notification_ctx *ctx);
2133 @@ -129,9 +106,9 @@ int dpaa2_io_service_enqueue_fq(struct d
2134 const struct dpaa2_fd *fd);
2135 int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
2136 u16 qdbin, const struct dpaa2_fd *fd);
2137 -int dpaa2_io_service_release(struct dpaa2_io *d, u32 bpid,
2138 +int dpaa2_io_service_release(struct dpaa2_io *d, u16 bpid,
2139 const u64 *buffers, unsigned int num_buffers);
2140 -int dpaa2_io_service_acquire(struct dpaa2_io *d, u32 bpid,
2141 +int dpaa2_io_service_acquire(struct dpaa2_io *d, u16 bpid,
2142 u64 *buffers, unsigned int num_buffers);
2144 struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
2145 @@ -139,4 +116,64 @@ struct dpaa2_io_store *dpaa2_io_store_cr
2146 void dpaa2_io_store_destroy(struct dpaa2_io_store *s);
2147 struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last);
2149 +/* Order Restoration Support */
2150 +int dpaa2_io_service_enqueue_orp_fq(struct dpaa2_io *d, u32 fqid,
2151 + const struct dpaa2_fd *fd, u16 orpid,
2152 + u16 seqnum, int last);
2154 +int dpaa2_io_service_enqueue_orp_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
2155 + u16 qdbin, const struct dpaa2_fd *fd,
2156 + u16 orpid, u16 seqnum, int last);
2158 +int dpaa2_io_service_orp_seqnum_drop(struct dpaa2_io *d, u16 orpid,
2166 + * struct dpaa2_cscn - The CSCN message format
2167 + * @verb: identifies the type of message (should be 0x27).
2168 + * @stat: status bits related to dequeuing response (not used)
2169 + * @state: bit 0 = 0/1 if CG is no/is congested
2170 + * @reserved: reserved byte
2171 + * @cgid: congest grp ID - the first 16 bits
2172 + * @ctx: context data
2174 + * Congestion management can be implemented in software through
2175 + * the use of Congestion State Change Notifications (CSCN). These
2176 + * are messages written by DPAA2 hardware to memory whenever the
2177 + * instantaneous count (I_CNT field in the CG) exceeds the
2178 + * Congestion State (CS) entrance threshold, signifying congestion
2179 + * entrance, or when the instantaneous count returns below exit
2180 + * threshold, signifying congestion exit. The format of the message
2181 + * is given by the dpaa2_cscn structure. Bit 0 of the state field
2182 + * represents congestion state written by the hardware.
2184 +struct dpaa2_cscn {
2193 +#define DPAA2_CSCN_SIZE 64
2194 +#define DPAA2_CSCN_ALIGN 16
2196 +#define DPAA2_CSCN_STATE_MASK 0x1
2197 +#define DPAA2_CSCN_CONGESTED 1
2199 +static inline bool dpaa2_cscn_state_congested(struct dpaa2_cscn *cscn)
2201 + return ((cscn->state & DPAA2_CSCN_STATE_MASK) == DPAA2_CSCN_CONGESTED);
2204 +int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid,
2205 + u32 *fcnt, u32 *bcnt);
2206 +int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid,
2209 #endif /* __FSL_DPAA2_IO_H */
2210 --- a/drivers/staging/fsl-mc/include/dpbp.h
2211 +++ b/drivers/staging/fsl-mc/include/dpbp.h
2213 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2215 * Copyright 2013-2016 Freescale Semiconductor Inc.
2217 - * Redistribution and use in source and binary forms, with or without
2218 - * modification, are permitted provided that the following conditions are met:
2219 - * * Redistributions of source code must retain the above copyright
2220 - * notice, this list of conditions and the following disclaimer.
2221 - * * Redistributions in binary form must reproduce the above copyright
2222 - * notice, this list of conditions and the following disclaimer in the
2223 - * documentation and/or other materials provided with the distribution.
2224 - * * Neither the name of the above-listed copyright holders nor the
2225 - * names of any contributors may be used to endorse or promote products
2226 - * derived from this software without specific prior written permission.
2229 - * ALTERNATIVELY, this software may be distributed under the terms of the
2230 - * GNU General Public License ("GPL") as published by the Free Software
2231 - * Foundation, either version 2 of that License or (at your option) any
2234 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2235 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2236 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2237 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
2238 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2239 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2240 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2241 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2242 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2243 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2244 - * POSSIBILITY OF SUCH DAMAGE.
2246 #ifndef __FSL_DPBP_H
2247 #define __FSL_DPBP_H
2248 --- a/drivers/staging/fsl-mc/include/dpcon.h
2249 +++ b/drivers/staging/fsl-mc/include/dpcon.h
2251 -/* Copyright 2013-2016 Freescale Semiconductor Inc.
2252 +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2254 + * Copyright 2013-2016 Freescale Semiconductor Inc.
2256 - * Redistribution and use in source and binary forms, with or without
2257 - * modification, are permitted provided that the following conditions are met:
2258 - * * Redistributions of source code must retain the above copyright
2259 - * notice, this list of conditions and the following disclaimer.
2260 - * * Redistributions in binary form must reproduce the above copyright
2261 - * notice, this list of conditions and the following disclaimer in the
2262 - * documentation and/or other materials provided with the distribution.
2263 - * * Neither the name of the above-listed copyright holders nor the
2264 - * names of any contributors may be used to endorse or promote products
2265 - * derived from this software without specific prior written permission.
2268 - * ALTERNATIVELY, this software may be distributed under the terms of the
2269 - * GNU General Public License ("GPL") as published by the Free Software
2270 - * Foundation, either version 2 of that License or (at your option) any
2273 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2274 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2275 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2276 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
2277 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2278 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2279 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2280 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2281 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2282 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2283 - * POSSIBILITY OF SUCH DAMAGE.
2285 #ifndef __FSL_DPCON_H
2286 #define __FSL_DPCON_H
2288 +++ b/drivers/staging/fsl-mc/include/dpopr.h
2291 + * Copyright 2017 NXP
2293 + * Redistribution and use in source and binary forms, with or without
2294 + * modification, are permitted provided that the following conditions are met:
2295 + * * Redistributions of source code must retain the above copyright
2296 + * notice, this list of conditions and the following disclaimer.
2297 + * * Redistributions in binary form must reproduce the above copyright
2298 + * notice, this list of conditions and the following disclaimer in the
2299 + * documentation and/or other materials provided with the distribution.
2300 + * * Neither the name of the above-listed copyright holders nor the
2301 + * names of any contributors may be used to endorse or promote products
2302 + * derived from this software without specific prior written permission.
2305 + * ALTERNATIVELY, this software may be distributed under the terms of the
2306 + * GNU General Public License ("GPL") as published by the Free Software
2307 + * Foundation, either version 2 of that License or (at your option) any
2310 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2311 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2312 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2313 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
2314 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2315 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2316 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2317 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2318 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2319 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2320 + * POSSIBILITY OF SUCH DAMAGE.
2322 +#ifndef __FSL_DPOPR_H_
2323 +#define __FSL_DPOPR_H_
2325 +/* Data Path Order Restoration API
2326 + * Contains initialization APIs and runtime APIs for the Order Restoration
2329 +/** Order Restoration properties */
2332 + * Create a new Order Point Record option
2334 +#define OPR_OPT_CREATE 0x1
2336 + * Retire an existing Order Point Record option
2338 +#define OPR_OPT_RETIRE 0x2
2341 + * struct opr_cfg - Structure representing OPR configuration
2342 + * @oprrws: Order point record (OPR) restoration window size (0 to 5)
2343 + * 0 - Window size is 32 frames.
2344 + * 1 - Window size is 64 frames.
2345 + * 2 - Window size is 128 frames.
2346 + * 3 - Window size is 256 frames.
2347 + * 4 - Window size is 512 frames.
2348 + * 5 - Window size is 1024 frames.
2349 + * @oa: OPR auto advance NESN window size (0 disabled, 1 enabled)
2350 + * @olws: OPR acceptable late arrival window size (0 to 3)
2351 + * 0 - Disabled. Late arrivals are always rejected.
2352 + * 1 - Window size is 32 frames.
2353 + * 2 - Window size is the same as the OPR restoration
2354 + * window size configured in the OPRRWS field.
2355 + * 3 - Window size is 8192 frames. Late arrivals are
2356 + * always accepted.
2357 + * @oeane: Order restoration list (ORL) resource exhaustion
2358 + * advance NESN enable (0 disabled, 1 enabled)
2359 + * @oloe: OPR loose ordering enable (0 disabled, 1 enabled)
2370 + * struct opr_qry - Structure representing OPR configuration
2371 + * @enable: Enabled state
2372 + * @rip: Retirement In Progress
2373 + * @ndsn: Next dispensed sequence number
2374 + * @nesn: Next expected sequence number
2375 + * @ea_hseq: Early arrival head sequence number
2376 + * @hseq_nlis: HSEQ not last in sequence
2377 + * @ea_tseq: Early arrival tail sequence number
2378 + * @tseq_nlis: TSEQ not last in sequence
2379 + * @ea_tptr: Early arrival tail pointer
2380 + * @ea_hptr: Early arrival head pointer
2381 + * @opr_id: Order Point Record ID
2382 + * @opr_vid: Order Point Record Virtual ID
2399 +#endif /* __FSL_DPOPR_H_ */
2400 --- a/drivers/staging/fsl-mc/include/mc.h
2401 +++ b/drivers/staging/fsl-mc/include/mc.h
2403 +/* SPDX-License-Identifier: GPL-2.0 */
2405 * Freescale Management Complex (MC) bus public interface
2407 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
2408 * Author: German Rivera <German.Rivera@freescale.com>
2410 - * This file is licensed under the terms of the GNU General Public
2411 - * License version 2. This program is licensed "as is" without any
2412 - * warranty of any kind, whether express or implied.