Freescale DPAA QBMan Drivers
Subsystems (5)
v2 cover Freescale DPAA QBMan Drivers
The Freescale Data Path Acceleration Architecture (DPAA) is a set of hardware components on specific QorIQ multicore processors. This architecture provides the infrastructure to support simplified sharing of networking interfaces and accelerators by multiple CPU cores and the accelerators.
The Queue Manager (QMan) is a hardware queue management block that allows software and accelerators on the datapath to enqueue and dequeue frames in order to communicate.
The Buffer Manager (BMan) is a hardware buffer pool management block that allows software and accelerators on the datapath to acquire and release buffers in order to build frames.
This patch set introduces the QBMan driver code that configures initializes the QBMan hardware and provides APIs for software to use the frame queues and buffer pools the blocks provide. These drivers provide the base fuctionality for software to communicate with the other DPAA accelerators on Freescale QorIQ processors.
Changes from v1:
- Cleanup Kconfig options
- Changed base QMan and BMan drivers to only be buit in.
Will add loadable support in future patch
- Replace panic() call with WARN_ON()
- Elimanated some unused APIs
- Replaced PowerPC specific IO accessors with platform independent versions
Emil Medve (1):
powerpc: re-add devm_ioremap_prot()
Geoff Thorpe (7):
soc/fsl: Introduce DPAA BMan device management driver soc/fsl: Introduce the DPAA BMan portal driver soc/fsl: Introduce drivers for the DPAA QMan soc/bman: Add self-tester for BMan driver soc/qman: Add self-tester for QMan driver soc/bman: Add debugfs support for the BMan driver soc/qman: Add debugfs support for the QMan driver
Hai-Ying Wang (2):
soc/bman: Add HOTPLUG_CPU support to the BMan driver soc/qman: Add HOTPLUG_CPU support to the QMan driver
Madalin Bucur (1):
soc/qman: add qman_delete_cgr_safe()
arch/powerpc/include/asm/io.h | 3 + arch/powerpc/lib/Makefile | 1 + arch/powerpc/lib/devres.c | 43 + arch/powerpc/platforms/85xx/corenet_generic.c | 16 + arch/powerpc/platforms/85xx/p1023_rdb.c | 14 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/fsl/Kconfig | 5 + drivers/soc/fsl/Makefile | 3 + drivers/soc/fsl/qbman/Kconfig | 120 + drivers/soc/fsl/qbman/Makefile | 20 + drivers/soc/fsl/qbman/bman-debugfs.c | 117 + drivers/soc/fsl/qbman/bman.c | 553 +++++ drivers/soc/fsl/qbman/bman.h | 542 +++++ drivers/soc/fsl/qbman/bman_api.c | 1072 +++++++++ drivers/soc/fsl/qbman/bman_portal.c | 391 ++++ drivers/soc/fsl/qbman/bman_priv.h | 134 ++ drivers/soc/fsl/qbman/bman_test.c | 56 + drivers/soc/fsl/qbman/bman_test.h | 34 + drivers/soc/fsl/qbman/bman_test_api.c | 184 ++ drivers/soc/fsl/qbman/bman_test_thresh.c | 198 ++ drivers/soc/fsl/qbman/bman_utils.c | 72 + drivers/soc/fsl/qbman/dpaa_resource.c | 359 +++ drivers/soc/fsl/qbman/dpaa_sys.h | 271 +++ drivers/soc/fsl/qbman/qman-debugfs.c | 1313 +++++++++++ drivers/soc/fsl/qbman/qman.c | 1026 +++++++++ drivers/soc/fsl/qbman/qman.h | 1128 ++++++++++ drivers/soc/fsl/qbman/qman_api.c | 2921 +++++++++++++++++++++++++ drivers/soc/fsl/qbman/qman_driver.c | 83 + drivers/soc/fsl/qbman/qman_portal.c | 672 ++++++ drivers/soc/fsl/qbman/qman_priv.h | 287 +++ drivers/soc/fsl/qbman/qman_test.c | 57 + drivers/soc/fsl/qbman/qman_test.h | 44 + drivers/soc/fsl/qbman/qman_test_api.c | 216 ++ drivers/soc/fsl/qbman/qman_test_stash.c | 502 +++++ drivers/soc/fsl/qbman/qman_utils.c | 305 +++ include/soc/fsl/bman.h | 518 +++++ include/soc/fsl/qman.h | 1977 +++++++++++++++++ 38 files changed, 15259 insertions(+) create mode 100644 arch/powerpc/lib/devres.c create mode 100644 drivers/soc/fsl/Kconfig create mode 100644 drivers/soc/fsl/Makefile create mode 100644 drivers/soc/fsl/qbman/Kconfig create mode 100644 drivers/soc/fsl/qbman/Makefile create mode 100644 drivers/soc/fsl/qbman/bman-debugfs.c create mode 100644 drivers/soc/fsl/qbman/bman.c create mode 100644 drivers/soc/fsl/qbman/bman.h create mode 100644 drivers/soc/fsl/qbman/bman_api.c create mode 100644 drivers/soc/fsl/qbman/bman_portal.c create mode 100644 drivers/soc/fsl/qbman/bman_priv.h create mode 100644 drivers/soc/fsl/qbman/bman_test.c create mode 100644 drivers/soc/fsl/qbman/bman_test.h create mode 100644 drivers/soc/fsl/qbman/bman_test_api.c create mode 100644 drivers/soc/fsl/qbman/bman_test_thresh.c create mode 100644 drivers/soc/fsl/qbman/bman_utils.c create mode 100644 drivers/soc/fsl/qbman/dpaa_resource.c create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.h create mode 100644 drivers/soc/fsl/qbman/qman-debugfs.c create mode 100644 drivers/soc/fsl/qbman/qman.c create mode 100644 drivers/soc/fsl/qbman/qman.h create mode 100644 drivers/soc/fsl/qbman/qman_api.c create mode 100644 drivers/soc/fsl/qbman/qman_driver.c create mode 100644 drivers/soc/fsl/qbman/qman_portal.c create mode 100644 drivers/soc/fsl/qbman/qman_priv.h create mode 100644 drivers/soc/fsl/qbman/qman_test.c create mode 100644 drivers/soc/fsl/qbman/qman_test.h create mode 100644 drivers/soc/fsl/qbman/qman_test_api.c create mode 100644 drivers/soc/fsl/qbman/qman_test_stash.c create mode 100644 drivers/soc/fsl/qbman/qman_utils.c create mode 100644 include/soc/fsl/bman.h create mode 100644 include/soc/fsl/qman.h
--
1.7.9.5
PATCH v2 1/11 powerpc: re-add devm_ioremap_prot()
From: Emil Medve <[email protected]>
devm_ioremap_prot() was removed in commit dedd24a12, and was introduced in commit b41e5fffe8.
This reverts commit dedd24a12fe6735898feeb06184ee346907abb5d.
--- arch/powerpc/include/asm/io.h | 3 +++ arch/powerpc/lib/Makefile | 1 + arch/powerpc/lib/devres.c | 43 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 arch/powerpc/lib/devres.c
arch/powerpc/include/asm/io.h +3 -0
@@ -855,6 +855,9 @@ static inline void * bus_to_virt(unsigned long address)#define clrsetbits_8 (addr, clear, set) clrsetbits(8, addr, clear, set) +void __iomem *devm_ioremap_prot (struct device *dev,resource_size_t offset, +size_t size,unsigned long flags); +#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_IO_H */
arch/powerpc/lib/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-y += string.o alloc.o crtsavres.o ppc_ksyms.o code-patching.o \ feature-fixups.o obj-$(CONFIG_PPC32) += div64.o copy_32.o +obj-$(CONFIG_HAS_IOMEM) += devres.o obj64-y += copypage_64.o copyuser_64.o usercopy_64.o mem_64.o hweight_64.o \ copyuser_power7.o string_64.o copypage_power7.o memcpy_power7.o \
arch/powerpc/lib/devres.c new file +43 -0
43 lines not on this page · raw message
Signature · 6 lines
1.7.9.5 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH v2 2/11 soc/fsl: Introduce DPAA BMan device management driver
In reply to Roy PledgeFrom: Geoff Thorpe <[email protected]>
This driver enables the Freescale DPAA 1.0 Buffer Manager block. BMan is a hardware buffer pool manager that allows accelerators connected to the SoC datapath to acquire and release buffers during data processing.
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/fsl/Kconfig | 5 + drivers/soc/fsl/Makefile | 3 + drivers/soc/fsl/qbman/Kconfig | 25 ++ drivers/soc/fsl/qbman/Makefile | 1 + drivers/soc/fsl/qbman/bman.c | 553 +++++++++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/bman_priv.h | 53 ++++ drivers/soc/fsl/qbman/dpaa_sys.h | 55 ++++ 9 files changed, 697 insertions(+) create mode 100644 drivers/soc/fsl/Kconfig create mode 100644 drivers/soc/fsl/Makefile create mode 100644 drivers/soc/fsl/qbman/Kconfig create mode 100644 drivers/soc/fsl/qbman/Makefile create mode 100644 drivers/soc/fsl/qbman/bman.c create mode 100644 drivers/soc/fsl/qbman/bman_priv.h create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.h
drivers/soc/Kconfig +1 -0
@@ -1,6 +1,7 @@ menu "SOC (System On Chip) specific Drivers" source "drivers/soc/mediatek/Kconfig" +source "drivers/soc/fsl/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/sunxi/Kconfig" source "drivers/soc/ti/Kconfig"
drivers/soc/Makefile +1 -0
@@ -3,6 +3,7 @@ # obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ +obj-$(CONFIG_FSL_SOC) += fsl/ obj-$(CONFIG_ARCH_QCOM) += qcom/ obj-$(CONFIG_ARCH_SUNXI) += sunxi/ obj-$(CONFIG_ARCH_TEGRA) += tegra/
drivers/soc/fsl/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +menu "Freescale SOC (System On Chip) specific Drivers" + +source "drivers/soc/fsl/qbman/Kconfig" + +endmenu
drivers/soc/fsl/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# Common +obj-$(CONFIG_FSL_DPA) += qbman/ +
drivers/soc/fsl/qbman/Kconfig new file +25 -0
@@ -0,0 +1,25 @@ +menuconfig FSL_DPA + bool "Freescale DPAA support" + depends on FSL_SOC || COMPILE_TEST + default n + help + FSL Data-Path Acceleration Architecture drivers + + These are not the actual Ethernet driver(s) + +if FSL_DPA + +config FSL_DPA_CHECKING + bool "additional driver checking" + default n + help + Compiles in additional checks to sanity-check the drivers and + any use of it by other code. Not recommended for performance + +config FSL_BMAN + tristate "BMan device management" + default n + help + FSL DPAA BMan driver + +endif # FSL_DPA
drivers/soc/fsl/qbman/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_FSL_BMAN) += bman.o
drivers/soc/fsl/qbman/bman.c new file +553 -0
553 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_priv.h new file +53 -0
53 lines not on this page · raw message
drivers/soc/fsl/qbman/dpaa_sys.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 3/11 soc/fsl: Introduce the DPAA BMan portal driver
In reply to Roy PledgeFrom: Geoff Thorpe <[email protected]>
Add support for Freescale DPAA 1.0 Buffer Manager portals. These portals allow software drivers for accelerators connected to the datapath to manage the hardware buffer pools.
--- drivers/soc/fsl/qbman/Kconfig | 6 + drivers/soc/fsl/qbman/Makefile | 6 + drivers/soc/fsl/qbman/bman.c | 5 +- drivers/soc/fsl/qbman/bman.h | 542 +++++++++++++++++ drivers/soc/fsl/qbman/bman_api.c | 1049 +++++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/bman_portal.c | 351 +++++++++++ drivers/soc/fsl/qbman/bman_priv.h | 81 +++ drivers/soc/fsl/qbman/bman_utils.c | 72 +++ drivers/soc/fsl/qbman/dpaa_resource.c | 356 +++++++++++ drivers/soc/fsl/qbman/dpaa_sys.h | 173 +++++- include/soc/fsl/bman.h | 518 ++++++++++++++++ 11 files changed, 3149 insertions(+), 10 deletions(-) create mode 100644 drivers/soc/fsl/qbman/bman.h create mode 100644 drivers/soc/fsl/qbman/bman_api.c create mode 100644 drivers/soc/fsl/qbman/bman_portal.c create mode 100644 drivers/soc/fsl/qbman/bman_utils.c create mode 100644 drivers/soc/fsl/qbman/dpaa_resource.c create mode 100644 include/soc/fsl/bman.h
drivers/soc/fsl/qbman/Kconfig +6 -0
@@ -22,4 +22,10 @@ config FSL_BMAN help FSL DPAA BMan driver +config FSL_BMAN_PORTAL + tristate "BMan portal(s)" + default n + help + FSL BMan portal driver + endif # FSL_DPA
drivers/soc/fsl/qbman/Makefile +6 -0
@@ -1 +1,7 @@ +# Common +obj-$(CONFIG_FSL_DPA) += dpaa_resource.o + obj-$(CONFIG_FSL_BMAN) += bman.o +obj-$(CONFIG_FSL_BMAN_PORTAL) += bman-portal.o +bman-portal-y = bman_portal.o bman_api.o \ + bman_utils.o
drivers/soc/fsl/qbman/bman.c +3 -2
@@ -165,11 +165,11 @@ static struct bman *bm_create(void *regs)static inline u32 __bm_in (struct bman *bm,u32 offset) { -return in_be32 ((void *)bm + offset); +return ioread32be ((void *)bm + offset); }static inline void __bm_out (struct bman *bm,u32 offset,u32 val) { -out_be32 ((void *)bm + offset, val); +iowrite32be (val, (void *) bm + offset); }#define bm_in (reg) __bm_in(bm, REG_##reg)#define bm_out (reg, val) __bm_out(bm, REG_##reg, val)
@@ -341,6 +341,7 @@ u32 bm_pool_free_buffers(u32 bpid) {return bm_in (POOL_CONTENT (bpid)); } +EXPORT_SYMBOL (bm_pool_free_buffers);static ssize_t show_fbpr_fpc (struct device *dev,struct device_attribute *dev_attr,char *buf)
drivers/soc/fsl/qbman/bman.h new file +542 -0
542 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_api.c new file +1049 -0
1,049 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_portal.c new file +351 -0
351 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_priv.h +81 -0
96 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_utils.c new file +72 -0
72 lines not on this page · raw message
drivers/soc/fsl/qbman/dpaa_resource.c new file +356 -0
356 lines not on this page · raw message
drivers/soc/fsl/qbman/dpaa_sys.h +165 -8
190 lines not on this page · raw message
include/soc/fsl/bman.h new file +518 -0
307 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.9.5
Part of the diff is not shown here. View the raw message.
PATCH v2 4/11 soc/fsl: Introduce drivers for the DPAA QMan
In reply to Roy PledgeFrom: Geoff Thorpe <[email protected]>
This driver enables the Freescale DPAA 1.0 Queue Manager block. QMan is hardware queue manager that allows accelerators connected to the SoC datapath to enqueue and dequeue frames to hardware queues, allowing data exchange between software and accelerators.
--- arch/powerpc/platforms/85xx/corenet_generic.c | 16 + arch/powerpc/platforms/85xx/p1023_rdb.c | 14 + drivers/soc/fsl/qbman/Kconfig | 60 +- drivers/soc/fsl/qbman/Makefile | 3 + drivers/soc/fsl/qbman/bman.c | 3 +- drivers/soc/fsl/qbman/bman_api.c | 6 +- drivers/soc/fsl/qbman/dpaa_resource.c | 7 +- drivers/soc/fsl/qbman/dpaa_sys.h | 60 +- drivers/soc/fsl/qbman/qman.c | 1026 +++++++++ drivers/soc/fsl/qbman/qman.h | 1128 ++++++++++ drivers/soc/fsl/qbman/qman_api.c | 2819 +++++++++++++++++++++++++ drivers/soc/fsl/qbman/qman_driver.c | 83 + drivers/soc/fsl/qbman/qman_portal.c | 629 ++++++ drivers/soc/fsl/qbman/qman_priv.h | 279 +++ drivers/soc/fsl/qbman/qman_utils.c | 305 +++ include/soc/fsl/qman.h | 1977 +++++++++++++++++ 16 files changed, 8407 insertions(+), 8 deletions(-) create mode 100644 drivers/soc/fsl/qbman/qman.c create mode 100644 drivers/soc/fsl/qbman/qman.h create mode 100644 drivers/soc/fsl/qbman/qman_api.c create mode 100644 drivers/soc/fsl/qbman/qman_driver.c create mode 100644 drivers/soc/fsl/qbman/qman_portal.c create mode 100644 drivers/soc/fsl/qbman/qman_priv.h create mode 100644 drivers/soc/fsl/qbman/qman_utils.c create mode 100644 include/soc/fsl/qman.h
arch/powerpc/platforms/85xx/corenet_generic.c +16 -0
@@ -203,6 +203,21 @@ static int __init corenet_generic_probe(void)return 0 ; } +/* Early setup is required for large chunks of contiguous (and coarsely-aligned) +* memory. The following shoe-horns QMan "init_early" calls into the +* platform setup to let them parse their CCSR nodes early on. +*/ +#ifdef CONFIG_FSL_QMAN_CONFIG +void __init qman_init_early (void ); +#endif + +__init void corenet_ds_init_early (void ) +{ +#ifdef CONFIG_FSL_QMAN_CONFIG +qman_init_early (); +#endif +} +define_machine (corenet_generic) { .name = "CoreNet Generic", .probe = corenet_generic_probe,
@@ -221,6 +236,7 @@ define_machine(corenet_generic) {#else .power_save = e500_idle, #endif + .init_early = corenet_ds_init_early, };machine_arch_initcall (corenet_generic, corenet_gen_publish_devices);
arch/powerpc/platforms/85xx/p1023_rdb.c +14 -0
@@ -103,7 +103,20 @@ static int __init p1023_rdb_probe(void)unsigned long root =of_get_flat_dt_root ();return of_flat_dt_is_compatible (root,"fsl,P1023RDB" ); +} + +/* Early setup is required for large chunks of contiguous (and coarsely-aligned) +* memory. The following shoe-horns QMan "init_early" calls into the +* platform setup to let them parse their CCSR nodes early on. */ +#ifdef CONFIG_FSL_QMAN_CONFIG +void __init qman_init_early (void ); +#endif +static __init void p1023_rdb_init_early (void ) +{ +#ifdef CONFIG_FSL_QMAN_CONFIG +qman_init_early (); +#endif }define_machine (p1023_rdb) {
@@ -119,4 +132,5 @@ define_machine(p1023_rdb) { .pcibios_fixup_bus = fsl_pcibios_fixup_bus, .pcibios_fixup_phb = fsl_pcibios_fixup_phb, #endif + .init_early = p1023_rdb_init_early, };
drivers/soc/fsl/qbman/Kconfig +58 -2
73 lines not on this page · raw message
drivers/soc/fsl/qbman/Makefile +3 -0
@@ -5,3 +5,6 @@ obj-$(CONFIG_FSL_BMAN) += bman.o obj-$(CONFIG_FSL_BMAN_PORTAL) += bman-portal.o bman-portal-y = bman_portal.o bman_api.o \ bman_utils.o + +obj-$(CONFIG_FSL_QMAN) += qman_api.o qman_utils.o qman_driver.o +obj-$(CONFIG_FSL_QMAN_CONFIG) += qman.o qman_portal.o
drivers/soc/fsl/qbman/bman.c +1 -2
@@ -540,7 +540,6 @@ static const struct of_device_id of_fsl_bman_ids[] = { }, {} }; -MODULE_DEVICE_TABLE (of, of_fsl_bman_ids);static struct platform_driver of_fsl_bman_driver = { .driver = {
@@ -551,4 +550,4 @@ static struct platform_driver of_fsl_bman_driver = { .remove = of_fsl_bman_remove, }; -module_platform_driver (of_fsl_bman_driver); +builtin_platform_driver (of_fsl_bman_driver);
drivers/soc/fsl/qbman/bman_api.c +5 -1
@@ -65,7 +65,11 @@ struct bman_portal {u8 alloced; }; +#ifdef FSL_DPA_PORTAL_SHARE +/* For an explanation of the locking, redirection, or affine-portal logic, +* please consult the QMan driver for details. This is the same, only simpler +* (no fiddly QMan-specific bits.) */ #define PORTAL_IRQ_LOCK (p, irqflags) \ do { \ if ((p)->is_shared) \
@@ -173,7 +177,7 @@ static void depletion_unlink(struct bman_pool *pool)PORTAL_IRQ_UNLOCK (pool->portal, irqflags); } -/* In the case that the application's core loop calls +/* In the case that the application's core loop calls qman_poll() and * bman_poll(), we ought to balance how often we incur the overheads of the * slow-path poll. We'll use two decrementer sources. The idle decrementer * constant is used when the last slow-poll detected no work to do, and the busy
drivers/soc/fsl/qbman/dpaa_resource.c +5 -2
@@ -28,7 +28,10 @@* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if defined(CONFIG_FSL_BMAN_PORTAL ) || defined(CONFIG_FSL_BMAN_PORTAL_MODULE ) +#if defined(CONFIG_FSL_BMAN_PORTAL ) || \ + defined(CONFIG_FSL_BMAN_PORTAL_MODULE ) || \ + defined(CONFIG_FSL_QMAN_PORTAL ) || \ + defined(CONFIG_FSL_QMAN_PORTAL_MODULE )#include "dpaa_sys.h" /* The allocator is a (possibly-empty) list of these */
@@ -353,4 +356,4 @@ u32 dpaa_resource_release(struct dpaa_resource *alloc, return total_invalid; }EXPORT_SYMBOL (dpaa_resource_release); -#endif /* CONFIG_FSL_BMAN_PORTAL* */ +#endif /* CONFIG_FSL_*MAN_PORTAL* */
drivers/soc/fsl/qbman/dpaa_sys.h +59 -1
69 lines not on this page · raw message
drivers/soc/fsl/qbman/qman.c new file +1026 -0
1,026 lines not on this page · raw message
drivers/soc/fsl/qbman/qman.h new file +1128 -0
1,128 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_api.c new file +2819 -0
598 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_driver.c new file +83 -0
83 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_portal.c new file +629 -0
629 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_priv.h new file +279 -0
279 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_utils.c new file +305 -0
305 lines not on this page · raw message
include/soc/fsl/qman.h new file +1977 -0
1,977 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.9.5
Part of the diff is not shown here. View the raw message.
PATCH v2 5/11 soc/bman: Add self-tester for BMan driver
In reply to Roy PledgeFrom: Geoff Thorpe <[email protected]>
Add a self test for the DPAA 1.0 Buffer Manager driver. This test ensures that the driver can properly acquire and release buffers using the BMan portal infrastructure.
--- drivers/soc/fsl/qbman/Kconfig | 26 ++++ drivers/soc/fsl/qbman/Makefile | 4 + drivers/soc/fsl/qbman/bman_test.c | 56 +++++++++ drivers/soc/fsl/qbman/bman_test.h | 34 +++++ drivers/soc/fsl/qbman/bman_test_api.c | 184 +++++++++++++++++++++++++++ drivers/soc/fsl/qbman/bman_test_thresh.c | 198 ++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/dpaa_sys.h | 1 + 7 files changed, 503 insertions(+) create mode 100644 drivers/soc/fsl/qbman/bman_test.c create mode 100644 drivers/soc/fsl/qbman/bman_test.h create mode 100644 drivers/soc/fsl/qbman/bman_test_api.c create mode 100644 drivers/soc/fsl/qbman/bman_test_thresh.c
drivers/soc/fsl/qbman/Kconfig +26 -0
@@ -28,6 +28,32 @@ config FSL_BMAN_PORTAL help FSL BMan portal driver +config FSL_BMAN_TEST + tristate "BMan self-tests" + default n + help + Compile self-test code + +config FSL_BMAN_TEST_API + bool "High-level API self-test" + depends on FSL_BMAN_TEST + default y + help + This requires the presence of cpu-affine portals, and performs + high-level API testing with them (whichever portal(s) are affine + to the cpu(s) the test executes on). + +config FSL_BMAN_TEST_THRESH + bool "Thresholds self-test" + depends on FSL_BMAN_TEST + default y + help + Multi-threaded (SMP) test of BMan pool depletion. A pool is seeded + before multiple threads (one per cpu) create pool objects to track + depletion state changes. The pool is then drained to empty by a + "drainer" thread, and the other threads that they observe exactly + the depletion state changes that are expected. + config FSL_QMAN bool "QMan device management" default n
drivers/soc/fsl/qbman/Makefile +4 -0
@@ -5,6 +5,10 @@ obj-$(CONFIG_FSL_BMAN) += bman.o obj-$(CONFIG_FSL_BMAN_PORTAL) += bman-portal.o bman-portal-y = bman_portal.o bman_api.o \ bman_utils.o +obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o +bman-test-y = bman_test.o +bman-test-$(CONFIG_FSL_BMAN_TEST_API) += bman_test_api.o +bman-test-$(CONFIG_FSL_BMAN_TEST_THRESH) += bman_test_thresh.o obj-$(CONFIG_FSL_QMAN) += qman_api.o qman_utils.o qman_driver.o obj-$(CONFIG_FSL_QMAN_CONFIG) += qman.o qman_portal.o
drivers/soc/fsl/qbman/bman_test.c new file +56 -0
56 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_test.h new file +34 -0
@@ -0,0 +1,34 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Freescale Semiconductor nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* ALTERNATIVELY, this software may be distributed under the terms of the +* GNU General Public License ("GPL") as published by the Free Software +* Foundation, either version 2 of that License or (at your option) any +* later version. +* +* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "bman_priv.h" + +void bman_test_api (void ); +void bman_test_thresh (void );
drivers/soc/fsl/qbman/bman_test_api.c new file +184 -0
184 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_test_thresh.c new file +198 -0
198 lines not on this page · raw message
drivers/soc/fsl/qbman/dpaa_sys.h +1 -0
@@ -37,6 +37,7 @@#include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/of_reserved_mem.h> +#include <linux/kthread.h> #include <linux/platform_device.h> #include <linux/ctype.h>
Signature · 1 line
1.7.9.5
PATCH v2 6/11 soc/qman: Add self-tester for QMan driver
In reply to Roy PledgeFrom: Geoff Thorpe <[email protected]>
Add a self test for the DPAA 1.0 Queue Manager driver. The tests ensure that the driver can properly enqueue and dequeue from frame queues using the QMan portal infrastructure.
--- drivers/soc/fsl/qbman/Makefile | 4 + drivers/soc/fsl/qbman/qman_test.c | 57 ++++ drivers/soc/fsl/qbman/qman_test.h | 44 +++ drivers/soc/fsl/qbman/qman_test_api.c | 216 +++++++++++++ drivers/soc/fsl/qbman/qman_test_stash.c | 502 +++++++++++++++++++++++++++++++ 5 files changed, 823 insertions(+) create mode 100644 drivers/soc/fsl/qbman/qman_test.c create mode 100644 drivers/soc/fsl/qbman/qman_test.h create mode 100644 drivers/soc/fsl/qbman/qman_test_api.c create mode 100644 drivers/soc/fsl/qbman/qman_test_stash.c
drivers/soc/fsl/qbman/Makefile +4 -0
@@ -12,3 +12,7 @@ bman-test-$(CONFIG_FSL_BMAN_TEST_THRESH) += bman_test_thresh.o obj-$(CONFIG_FSL_QMAN) += qman_api.o qman_utils.o qman_driver.o obj-$(CONFIG_FSL_QMAN_CONFIG) += qman.o qman_portal.o +obj-$(CONFIG_FSL_QMAN_TEST) += qman-test.o +qman-test-y = qman_test.o +qman-test-$(CONFIG_FSL_QMAN_TEST_API) += qman_test_api.o +qman-test-$(CONFIG_FSL_QMAN_TEST_STASH) += qman_test_stash.o
drivers/soc/fsl/qbman/qman_test.c new file +57 -0
57 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_test.h new file +44 -0
44 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_test_api.c new file +216 -0
216 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_test_stash.c new file +502 -0
502 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 8/11 soc/qman: Add debugfs support for the QMan driver
In reply to Roy PledgeFrom: Geoff Thorpe <[email protected]>
Add debugfs sypport for querying the state of hardware based queues managed by the DPAA 1.0 Queue Manager.
--- drivers/soc/fsl/qbman/Makefile | 1 + drivers/soc/fsl/qbman/dpaa_sys.h | 2 + drivers/soc/fsl/qbman/qman-debugfs.c | 1313 ++++++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/qman_api.c | 60 +- drivers/soc/fsl/qbman/qman_priv.h | 8 + 5 files changed, 1382 insertions(+), 2 deletions(-) create mode 100644 drivers/soc/fsl/qbman/qman-debugfs.c
drivers/soc/fsl/qbman/Makefile +1 -0
@@ -17,3 +17,4 @@ obj-$(CONFIG_FSL_QMAN_TEST) += qman-test.o qman-test-y = qman_test.o qman-test-$(CONFIG_FSL_QMAN_TEST_API) += qman_test_api.o qman-test-$(CONFIG_FSL_QMAN_TEST_STASH) += qman_test_stash.o +obj-$(CONFIG_FSL_QMAN_DEBUGFS) += qman-debugfs.o
drivers/soc/fsl/qbman/dpaa_sys.h +2 -0
@@ -38,7 +38,9 @@#include <linux/of_irq.h> #include <linux/of_reserved_mem.h> #include <linux/kthread.h> +#include <linux/uaccess.h> #include <linux/debugfs.h> +#include <linux/vmalloc.h> #include <linux/platform_device.h> #include <linux/ctype.h>
drivers/soc/fsl/qbman/qman-debugfs.c new file +1313 -0
1,313 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_api.c +58 -2
79 lines not on this page · raw message
drivers/soc/fsl/qbman/qman_priv.h +8 -0
@@ -156,6 +156,14 @@ struct qman_portal *qman_create_affine_slave(struct qman_portal *redirect,const struct qm_portal_config *qman_destroy_affine_portal (void );void qman_destroy_portal (struct qman_portal *qm); +/* This CGR feature is supported by h/w and required by unit-tests and the +* debugfs hooks, so is implemented in the driver. However it allows an explicit +* corruption of h/w fields by s/w that are usually incorruptible (because the +* counters are usually maintained entirely within h/w). As such, we declare +* this API internally. */ +int qman_testwrite_cgr (struct qman_cgr *cgr,u64 i_bcnt, +struct qm_mcr_cgrtestwrite *result); +#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP /* If the fq object pointer is greater than the size of context_b field, * than a lookup table is required. */
Signature · 1 line
1.7.9.5
PATCH v2 9/11 soc/bman: Add HOTPLUG_CPU support to the BMan driver
In reply to Roy PledgeFrom: Hai-Ying Wang <[email protected]>
Add support for CPU hotplug for the DPAA 1.0 Buffer Manager driver
--- drivers/soc/fsl/qbman/bman_portal.c | 40 +++++++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/dpaa_sys.h | 3 +++ 2 files changed, 43 insertions(+)
drivers/soc/fsl/qbman/bman_portal.c +40 -0
@@ -129,6 +129,42 @@ static void __cold bman_offline_cpu(unsigned int cpu) } } +#ifdef CONFIG_HOTPLUG_CPU +static void __cold bman_online_cpu (unsigned int cpu) +{ +struct bman_portal *p = (struct bman_portal *)affine_bportals[cpu]; +const struct bm_portal_config *pcfg; + +if (p) { + pcfg =bman_get_bm_portal_config (p); +if (pcfg) +irq_set_affinity (pcfg->public_cfg.irq,cpumask_of (cpu)); + } +} + +static int __cold bman_hotplug_cpu_callback (struct notifier_block *nfb, +unsigned long action,void *hcpu) +{ +unsigned int cpu = (unsigned long )hcpu; + +switch (action) { +case CPU_ONLINE : +case CPU_ONLINE_FROZEN : +bman_online_cpu (cpu); +break ; +case CPU_DOWN_PREPARE : +case CPU_DOWN_PREPARE_FROZEN : +bman_offline_cpu (cpu); + } + +return NOTIFY_OK ; +} + +static struct notifier_block bman_hotplug_cpu_notifier = { + .notifier_call = bman_hotplug_cpu_callback, +}; +#endif /* CONFIG_HOTPLUG_CPU */ +static int __cold bman_portal_probe (struct platform_device *of_dev) {struct device *dev = &of_dev->dev;
@@ -342,6 +378,10 @@ static int __init bman_portal_driver_register(struct platform_driver *drv)for_each_cpu (cpu, &offline_cpus)bman_offline_cpu (cpu); +#ifdef CONFIG_HOTPLUG_CPU +register_hotcpu_notifier (&bman_hotplug_cpu_notifier); +#endif +bman_seed_bpid_range (0 , bman_pool_max);return 0 ;
drivers/soc/fsl/qbman/dpaa_sys.h +3 -0
@@ -43,6 +43,9 @@#include <linux/vmalloc.h> #include <linux/platform_device.h> #include <linux/ctype.h> +#ifdef CONFIG_HOTPLUG_CPU +#include <linux/cpu.h> +#endif #include <asm/pgtable.h>
Signature · 1 line
1.7.9.5
PATCH v2 10/11 soc/qman: Add HOTPLUG_CPU support to the QMan driver
In reply to Roy PledgeFrom: Hai-Ying Wang <[email protected]>
Add support for CPU hotplug for the DPAA 1.0 Queue Manager driver.
--- drivers/soc/fsl/qbman/qman_portal.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/soc/fsl/qbman/qman_portal.c +43 -0
@@ -474,6 +474,46 @@ static void qman_offline_cpu(unsigned int cpu) } } +#ifdef CONFIG_HOTPLUG_CPU +static void qman_online_cpu (unsigned int cpu) +{ +struct qman_portal *p; +const struct qm_portal_config *pcfg; + + p = (struct qman_portal *)affine_portals[cpu]; +if (p) { + pcfg =qman_get_qm_portal_config (p); +if (pcfg) { +irq_set_affinity (pcfg->public_cfg.irq,cpumask_of (cpu)); +qman_portal_update_sdest (pcfg, cpu); + } + } +} + +static int qman_hotplug_cpu_callback (struct notifier_block *nfb, +unsigned long action,void *hcpu) +{ +unsigned int cpu = (unsigned long )hcpu; + +switch (action) { +case CPU_ONLINE : +case CPU_ONLINE_FROZEN : +qman_online_cpu (cpu); +break ; +case CPU_DOWN_PREPARE : +case CPU_DOWN_PREPARE_FROZEN : +qman_offline_cpu (cpu); +default : +break ; + } +return NOTIFY_OK ; +} + +static struct notifier_block qman_hotplug_cpu_notifier = { + .notifier_call = qman_hotplug_cpu_callback, +}; +#endif /* CONFIG_HOTPLUG_CPU */ +__init int qman_init (void ) {struct cpumask slave_cpus;
@@ -597,6 +637,9 @@ __init int qman_init(void)cpumask_andnot (&offline_cpus, cpu_possible_mask, cpu_online_mask);for_each_cpu (cpu, &offline_cpus)qman_offline_cpu (cpu); +#ifdef CONFIG_HOTPLUG_CPU +register_hotcpu_notifier (&qman_hotplug_cpu_notifier); +#endif return 0 ; }
Signature · 1 line
1.7.9.5
PATCH v2 11/11 soc/qman: add qman_delete_cgr_safe()
In reply to Roy PledgeFrom: Madalin Bucur <[email protected]>
Add qman_delete_cgr_safe() that can be called from any CPU. This in turn schedules qman_delete_cgr() on the proper CPU.
--- drivers/soc/fsl/qbman/qman_api.c | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
drivers/soc/fsl/qbman/qman_api.c +46 -0
@@ -2463,6 +2463,8 @@ EXPORT_SYMBOL(qman_modify_cgr); QM_CHANNEL_SWPORTAL0))#define PORTAL_IDX (n) (n->config->public_cfg.channel - QM_CHANNEL_SWPORTAL0) +static u8 qman_cgr_cpus[__CGR_NUM]; +int qman_create_cgr (struct qman_cgr *cgr,u32 flags,struct qm_mcc_initcgr *opts) {
@@ -2479,7 +2481,10 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,if (cgr->cgrid >= __CGR_NUM)return -EINVAL ; +preempt_disable (); p =get_affine_portal (); + qman_cgr_cpus[cgr->cgrid] =smp_processor_id (); +preempt_enable ();memset (&local_opts,0 ,sizeof (struct qm_mcc_initcgr )); cgr->chan = p->config->public_cfg.channel;
@@ -2621,6 +2626,47 @@ put_portal: }EXPORT_SYMBOL (qman_delete_cgr); +struct cgr_comp { +struct qman_cgr *cgr; +struct completion completion; +}; + +static int qman_delete_cgr_thread (void *p) +{ +struct cgr_comp *cgr_comp = (struct cgr_comp *)p; +int res; + + res =qman_delete_cgr ((struct qman_cgr *)cgr_comp->cgr); +complete (&cgr_comp->completion); + +return res; +} + +void qman_delete_cgr_safe (struct qman_cgr *cgr) +{ +struct task_struct *thread; +struct cgr_comp cgr_comp; + +preempt_disable (); +if (qman_cgr_cpus[cgr->cgrid] !=smp_processor_id ()) { +init_completion (&cgr_comp.completion); + cgr_comp.cgr = cgr; + thread =kthread_create (qman_delete_cgr_thread, &cgr_comp, +"cgr_del" ); + +if (likely (!IS_ERR (thread))) { +kthread_bind (thread, qman_cgr_cpus[cgr->cgrid]); +wake_up_process (thread); +wait_for_completion (&cgr_comp.completion); +preempt_enable (); +return ; + } + } +qman_delete_cgr (cgr); +preempt_enable (); +} +EXPORT_SYMBOL (qman_delete_cgr_safe); +int qman_set_wpm (int wpm_enable) {return qm_set_wpm (wpm_enable);
Signature · 1 line
1.7.9.5
PATCH v2 7/11 soc/bman: Add debugfs support for the BMan driver
In reply to Roy PledgeFrom: Geoff Thorpe <[email protected]>
Add debugfs support for querying the state of hardware based Buffer Manager pools used in DPAA 1.0.
--- drivers/soc/fsl/qbman/Kconfig | 7 ++ drivers/soc/fsl/qbman/Makefile | 1 + drivers/soc/fsl/qbman/bman-debugfs.c | 117 ++++++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/bman_api.c | 19 ++++++ drivers/soc/fsl/qbman/dpaa_sys.h | 7 +- 5 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 drivers/soc/fsl/qbman/bman-debugfs.c
drivers/soc/fsl/qbman/Kconfig +7 -0
@@ -54,6 +54,13 @@ config FSL_BMAN_TEST_THRESH "drainer" thread, and the other threads that they observe exactly the depletion state changes that are expected. +config FSL_BMAN_DEBUGFS + tristate "BMan debugfs support" + depends on DEBUG_FS + default n + help + BMan debugfs support + config FSL_QMAN bool "QMan device management" default n
drivers/soc/fsl/qbman/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o bman-test-y = bman_test.o bman-test-$(CONFIG_FSL_BMAN_TEST_API) += bman_test_api.o bman-test-$(CONFIG_FSL_BMAN_TEST_THRESH) += bman_test_thresh.o +obj-$(CONFIG_FSL_BMAN_DEBUGFS) += bman-debugfs.o obj-$(CONFIG_FSL_QMAN) += qman_api.o qman_utils.o qman_driver.o obj-$(CONFIG_FSL_QMAN_CONFIG) += qman.o qman_portal.o
drivers/soc/fsl/qbman/bman-debugfs.c new file +117 -0
117 lines not on this page · raw message
drivers/soc/fsl/qbman/bman_api.c +19 -0
@@ -1014,6 +1014,25 @@ int bman_flush_stockpile(struct bman_pool *pool, u32 flags) }EXPORT_SYMBOL (bman_flush_stockpile); +int bman_query_pools (struct bm_pool_state *state) +{ +struct bman_portal *p =get_affine_portal (); +struct bm_mc_result *mcr; +__maybe_unused unsigned long irqflags; + +PORTAL_IRQ_LOCK (p, irqflags); +bm_mc_start (&p->p); +bm_mc_commit (&p->p,BM_MCC_VERB_CMD_QUERY ); +while (!(mcr =bm_mc_result (&p->p))) +cpu_relax (); +DPA_ASSERT ((mcr->verb &BM_MCR_VERB_CMD_MASK ) ==BM_MCR_VERB_CMD_QUERY ); + *state = mcr->query; +PORTAL_IRQ_UNLOCK (p, irqflags); +put_affine_portal (); +return 0 ; +} +EXPORT_SYMBOL (bman_query_pools); +#ifdef CONFIG_FSL_BMAN u32 bman_query_free_buffers (struct bman_pool *pool) {
drivers/soc/fsl/qbman/dpaa_sys.h +1 -6
@@ -38,6 +38,7 @@#include <linux/of_irq.h> #include <linux/of_reserved_mem.h> #include <linux/kthread.h> +#include <linux/debugfs.h> #include <linux/platform_device.h> #include <linux/ctype.h>
@@ -76,9 +77,7 @@ int dpaa_resource_reserve(struct dpaa_resource *alloc, u32 base, u32 num);#define DPA_PORTAL_CE 0#define DPA_PORTAL_CI 1 -/***********************/ /* Misc inline assists */ -/***********************/ /* TODO: NB, we currently assume that hwsync() and lwsync() imply compiler * barriers and that dcb*() won't fall victim to compiler or execution
@@ -157,9 +156,7 @@ static inline void copy_words(void *dest, const void *src, size_t sz)#define copy_words memcpy#endif -/************/ /* RB-trees */ -/************/ /* We encapsulate RB-trees so that its easier to use non-linux forms in * non-linux systems. This also encapsulates the extra plumbing that linux code
@@ -215,9 +212,7 @@ static inline type *name##_find(struct dpa_rbtree *tree, u32 val) \return NULL ; \ } -/************/ /* Bootargs */ -/************/ /* QMan has "qportals=" and BMan has "bportals=", they use the same syntax * though; a comma-separated list of items, each item being a cpu index and/or a
Signature · 1 line
1.7.9.5
Quoted 20 lines · Roy Pledge
The Freescale Data Path Acceleration Architecture (DPAA) is a set of hardware components on specific QorIQ multicore processors. This architecture provides the infrastructure to support simplified sharing of networking interfaces and accelerators by multiple CPU cores and the accelerators.
The Queue Manager (QMan) is a hardware queue management block that allows software and accelerators on the datapath to enqueue and dequeue frames in order to communicate.
The Buffer Manager (BMan) is a hardware buffer pool management block that allows software and accelerators on the datapath to acquire and release buffers in order to build frames.
This patch set introduces the QBMan driver code that configures initializes the QBMan hardware and provides APIs for software to use the frame queues and buffer pools the blocks provide. These drivers provide the base fuctionality for software to communicate with the other DPAA accelerators on Freescale QorIQ processors.
Quoted 4 lines
Changes from v1:
- CleanupKconfigoptions
- Changed base QMan and BMan drivers to only be buit in. Will add loadable support in future patch
CONFIG_FSL_BMAN is tristate -- is it not expected to work if you select 'm'?
Quoted 1 line
- Replace
panic()call withWARN_ON()
panic() is still there.
Quoted 2 lines
Quoted 2 lines
- Replaced PowerPC specific IO accessors with platform independent versions
PowerPC accessors, and other PPC-specfic things like cache flushing and memory barriers, are still there.
-Scott
Scott Wood
NAKRe: [v2 02/11] soc/fsl: Introduce DPAA BMan device management driver
In reply to Roy PledgeQuoted 80 lines · Roy Pledge
From: Geoff Thorpe <[email protected]>
This driver enables the Freescale DPAA 1.0 Buffer Manager block. BMan is a hardware buffer pool manager that allows accelerators connected to the SoC datapath to acquire and release buffers during data processing.
Signed-off-by Geoff Thorpe <[email protected]>Signed-off-by Emil Medve <[email protected]>Signed-off-by Roy Pledge <[email protected]>--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/fsl/Kconfig | 5 + drivers/soc/fsl/Makefile | 3 + drivers/soc/fsl/qbman/Kconfig | 25 ++ drivers/soc/fsl/qbman/Makefile | 1 + drivers/soc/fsl/qbman/bman.c | 553 +++++++++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/bman_priv.h | 53 ++++ drivers/soc/fsl/qbman/dpaa_sys.h | 55 ++++ 9 files changed, 697 insertions(+) create mode 100644 drivers/soc/fsl/Kconfig create mode 100644 drivers/soc/fsl/Makefile create mode 100644 drivers/soc/fsl/qbman/Kconfig create mode 100644 drivers/soc/fsl/qbman/Makefile create mode 100644 drivers/soc/fsl/qbman/bman.c create mode 100644 drivers/soc/fsl/qbman/bman_priv.h create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.hdrivers/soc/Kconfig +1
-0@@ -1,6 +1,7 @@ menu "SOC (System On Chip) specific Drivers" source "drivers/soc/mediatek/Kconfig" +source "drivers/soc/fsl/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/sunxi/Kconfig" source "drivers/soc/ti/Kconfig"drivers/soc/Makefile +1
-0@@ -3,6 +3,7 @@ # obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ +obj-$(CONFIG_FSL_SOC) += fsl/ obj-$(CONFIG_ARCH_QCOM) += qcom/ obj-$(CONFIG_ARCH_SUNXI) += sunxi/ obj-$(CONFIG_ARCH_TEGRA) += tegra/drivers/soc/fsl/Kconfig new file +5
-0@@ -0,0 +1,5 @@ +menu "Freescale SOC (System On Chip) specific Drivers" + +source "drivers/soc/fsl/qbman/Kconfig" + +endmenudrivers/soc/fsl/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# Common +obj-$(CONFIG_FSL_DPA) += qbman/ +drivers/soc/fsl/qbman/Kconfig new file +0
-0
drivers/soc/fsl/qbman/Kconfig line 4
Quoted 4 lines
drivers/soc/fsl/qbman/Kconfig new file +4
-0@@ -0,0 +1,25 @@ +menuconfig FSL_DPA + bool "Freescale DPAA support" + depends on FSL_SOC || COMPILE_TEST + default n
Drop the COMPILE_TEST -- this driver still has PPCisms that will break the build elsewhere.
Quoted 9 lines
drivers/soc/fsl/qbman/Kconfig new file +9
-0+ help + FSL Data-Path Acceleration Architecture drivers + + These are not the actual Ethernet driver(s) + +if FSL_DPA + +config FSL_DPA_CHECKING + bool "additional driver checking"
drivers/soc/fsl/qbman/Kconfig line 23
Quoted 10 lines
drivers/soc/fsl/qbman/Kconfig new file +10
-0+ default n + help + Compiles in additional checks to sanity-check the drivers and + any use of it by other code. Not recommended for performance + +config FSL_BMAN + tristate "BMan device management" + default n + help + FSL DPAA BMan driver
Please describe here what BMan is and when it should be enabled. Why isn't it always enabled when DPA is enabled?
Quoted 50 lines
drivers/soc/fsl/qbman/Kconfig new file +1
-0+endif # FSL_DPAdrivers/soc/fsl/qbman/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_FSL_BMAN) += bman.odrivers/soc/fsl/qbman/bman.c new file +4
-0@@ -0,0 +1,553 @@ +/* Copyright (c) 2009 - 2015 Freescale Semiconductor, Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
drivers/soc/fsl/qbman/bman.c line 33
Quoted 4 lines
drivers/soc/fsl/qbman/bman.c new file +4
-0+ +#include "bman_priv.h" + +/* Last updated for v00.79 of the BG */
Don't make obscure references to ancient internal documents.
Quoted 35 lines
drivers/soc/fsl/qbman/bman.c new file +35
-0+ +struct bman ; + +/* Register offsets */ +#define REG_POOL_SWDET (n) (0x0000 + ((n) * 0x04)) +#define REG_POOL_HWDET (n) (0x0100 + ((n) * 0x04)) +#define REG_POOL_SWDXT (n) (0x0200 + ((n) * 0x04)) +#define REG_POOL_HWDXT (n) (0x0300 + ((n) * 0x04)) +#define REG_POOL_CONTENT (n) (0x0600 + ((n) * 0x04)) +#define REG_FBPR_FPC 0x0800 +#define REG_ECSR 0x0a00 +#define REG_ECIR 0x0a04 +#define REG_EADR 0x0a08 +#define REG_EDATA (n) (0x0a10 + ((n) * 0x04)) +#define REG_SBEC (n) (0x0a80 + ((n) * 0x04)) +#define REG_IP_REV_1 0x0bf8 +#define REG_IP_REV_2 0x0bfc +#define REG_FBPR_BARE 0x0c00 +#define REG_FBPR_BAR 0x0c04 +#define REG_FBPR_AR 0x0c10 +#define REG_SRCIDR 0x0d04 +#define REG_LIODNR 0x0d08 +#define REG_ERR_ISR 0x0e00/* + "enum bm_isr_reg" */ + +/* Used by all error interrupt registers except 'inhibit' */ +#define BM_EIRQ_IVCI 0x00000010/* Invalid Command Verb */ +#define BM_EIRQ_FLWI 0x00000008/* FBPR Low Watermark */ +#define BM_EIRQ_MBEI 0x00000004/* Multi-bit ECC Error */ +#define BM_EIRQ_SBEI 0x00000002/* Single-bit ECC Error */ +#define BM_EIRQ_BSCN 0x00000001/* pool State Change Notification */ + +/* BMAN_ECIR valid error bit */ +#define PORTAL_ECSR_ERR (BM_EIRQ_IVCI) + +union bman_ecir {
drivers/soc/fsl/qbman/bman.c line 78
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+u32 ecir_raw; +struct { +u32 __reserved1:4 ; +u32 portal_num:4 ; +u32 __reserved2:12 ; +u32 numb:4 ; +u32 __reserved3:2 ; +u32 pid:6 ; + } __packed info; +};
I've seen GCC generate some awful code when bitfields are combined with packed. Why are either necessary here?
Quoted 26 lines
drivers/soc/fsl/qbman/bman.c new file +26
-0+ +union bman_eadr { +u32 eadr_raw; +struct { +u32 __reserved1:5 ; +u32 memid:3 ; +u32 __reserved2:14 ; +u32 eadr:10 ; + } __packed info; +}; + +struct bman_hwerr_txt { +u32 mask; +const char *txt; +}; + +#define BMAN_HWE_TXT (a, b) { .mask = BM_EIRQ_##a, .txt = b } + +static const struct bman_hwerr_txt bman_hwerr_txts[] = { +BMAN_HWE_TXT (IVCI ,"Invalid Command Verb" ), +BMAN_HWE_TXT (FLWI ,"FBPR Low Watermark" ), +BMAN_HWE_TXT (MBEI ,"Multi-bit ECC Error" ), +BMAN_HWE_TXT (SBEI ,"Single-bit ECC Error" ), +BMAN_HWE_TXT (BSCN ,"Pool State Change Notification" ), +}; +#define BMAN_HWE_COUNT (sizeof(bman_hwerr_txts)/sizeof(struct
Quoted 1 line
bman_hwerr_txt))
Use ARRAY_SIZE().
drivers/soc/fsl/qbman/bman.c line 117
Quoted 12 lines
drivers/soc/fsl/qbman/bman.c new file +12
-0+struct bman_error_info_mdata { +u16 addr_mask; +u16 bits; +const char *txt; +}; + +#define BMAN_ERR_MDATA (a, b, c) { .addr_mask = a, .bits = b, .txt = c} +static const struct bman_error_info_mdata error_mdata[] = { +BMAN_ERR_MDATA (0x03FF ,192 ,"Stockpile memory" ), +BMAN_ERR_MDATA (0x00FF ,256 ,"SW portal ring memory port 1" ), +BMAN_ERR_MDATA (0x00FF ,256 ,"SW portal ring memory port 2" ), +};
Is all this detail necessary (and complete/up-to-date), versus printing raw
values and having the person investigating the issue look up the error values? Is there anything a normal user, who wouldn't be expected to look such things up, can do themselves in response to seeing the string output?
drivers/soc/fsl/qbman/bman.c line 122
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c new file +5
-0+#define BMAN_ERR_MDATA_COUNT \ + (sizeof(error_mdata)/sizeof(struct bman_error_info_mdata)) + +/* Add this in Kconfig */ +#define BMAN_ERRS_TO_UNENABLE (BM_EIRQ_FLWI)
"unenable"?
Why should it be added to Kconfig?
Quoted 17 lines
drivers/soc/fsl/qbman/bman.c new file +7
-0+ +/** +* bm_err_isr_<reg>_<verb> - Manipulate global interrupt registers +* @v: for accessors that write values, this is the 32-bit value +* +* Manipulates BMAN_ERR_ISR, BMAN_ERR_IER, BMAN_ERR_ISDR, BMAN_ERR_IIR. All +* manipulations except bm_err_isr_[un]inhibit() use 32-bit masks composed of
+ * the BM_EIRQ_*** definitions. Note that "bm_err_isr_enable_write" means
+ * "write the enable register" rather than "enable the write register"!
+ */drivers/soc/fsl/qbman/bman.c new file +6
-0+#define bm_err_isr_status_read (bm) \ + __bm_err_isr_read(bm, bm_isr_status) +#define bm_err_isr_status_clear (bm, m) \ + __bm_err_isr_write(bm, bm_isr_status, m) +#define bm_err_isr_enable_read (bm) \ + __bm_err_isr_read(bm, bm_isr_enable)
drivers/soc/fsl/qbman/bman.c line 148
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+#define bm_err_isr_enable_write (bm, v) \ + __bm_err_isr_write(bm, bm_isr_enable, v) +#define bm_err_isr_disable_read (bm) \ + __bm_err_isr_read(bm, bm_isr_disable) +#define bm_err_isr_disable_write (bm, v) \ + __bm_err_isr_write(bm, bm_isr_disable, v) +#define bm_err_isr_inhibit (bm) \ + __bm_err_isr_write(bm, bm_isr_inhibit, 1) +#define bm_err_isr_uninhibit (bm) \ + __bm_err_isr_write(bm, bm_isr_inhibit, 0)
Do these wrappers really contribute much to readability, especially given that you need a comment to disambiguate one of them?
drivers/soc/fsl/qbman/bman.c line 158
Quoted 7 lines
drivers/soc/fsl/qbman/bman.c new file +7
-0+/* +* TODO: unimplemented registers +* +* BMAN_POOLk_SDCNT, BMAN_POOLk_HDCNT, BMAN_FULT, +* BMAN_VLDPL, BMAN_EECC, BMAN_SBET, BMAN_EINJ +*/ +
Why are they TODO? What do you plan to do with them?
drivers/soc/fsl/qbman/bman.c line 164
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c new file +6
-0+/* Encapsulate "struct bman *" as a cast of the register space address. */ + +static struct bman *bm_create (void *regs) +{ +return (struct bman *)regs; +}
NACK
If you want the regs to be a struct, then actually define the members of the struct, use __iomem, don't hide the cast in a vaguely named function that isn't actually creating anything, and call it something like "struct bman_regs" so that it's clear that it's a register struct rather than a driver state struct.
Quoted 66 lines
drivers/soc/fsl/qbman/bman.c new file +66
-0+ +static inline u32 __bm_in (struct bman *bm,u32 offset) +{ +return in_be32 ((void *)bm + offset); +} +static inline void __bm_out (struct bman *bm,u32 offset,u32 val) +{ +out_be32 ((void *)bm + offset, val); +} +#define bm_in (reg) __bm_in(bm, REG_##reg) +#define bm_out (reg, val) __bm_out(bm, REG_##reg, val) + +static u32 __bm_err_isr_read (struct bman *bm,enum bm_isr_reg n) +{ +return __bm_in (bm,REG_ERR_ISR + (n <<2 )); +} + +static void __bm_err_isr_write (struct bman *bm,enum bm_isr_reg n,u32 val) +{ +__bm_out (bm,REG_ERR_ISR + (n <<2 ), val); +} + +static void bm_get_version (struct bman *bm,u16 *id,u8 *major,u8 *minor) +{ +u32 v =bm_in (IP_REV_1 ); + *id = (v >>16 ); + *major = (v >>8 ) &0xff ; + *minor = v &0xff ; +} + +static u32 __generate_thresh (u32 val,int roundup) +{ +u32 e =0 ;/* co-efficient, exponent */ +int oddbit =0 ; + +while (val >0xff ) { + oddbit = val &1 ; + val >>=1 ; + e++; +if (roundup && oddbit) + val++; + } +DPA_ASSERT (e <0x10 ); +return val | (e <<8 ); +} + +static void bm_set_pool (struct bman *bm,u8 pool,u32 swdet,u32 swdxt, +u32 hwdet,u32 hwdxt) +{ +DPA_ASSERT (pool < bman_pool_max); + +bm_out (POOL_SWDET (pool),__generate_thresh (swdet,0 )); +bm_out (POOL_SWDXT (pool),__generate_thresh (swdxt,1 )); +bm_out (POOL_HWDET (pool),__generate_thresh (hwdet,0 )); +bm_out (POOL_HWDXT (pool),__generate_thresh (hwdxt,1 )); +} + +static void bm_set_memory (struct bman *bm,u64 ba,int prio,u32 size) +{ +u32 exp =ilog2 (size); +/* choke if size isn't within range */ +DPA_ASSERT ((size >=4096 ) && (size <=1073741824 ) && +is_power_of_2 (size)); +/* choke if '[e]ba' has lower-alignment than 'size' */ +DPA_ASSERT (!(ba & (size -1 ))); +bm_out (FBPR_BARE ,upper_32_bits (ba));
drivers/soc/fsl/qbman/bman.c line 240
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+bm_out (FBPR_BAR ,lower_32_bits (ba)); +bm_out (FBPR_AR , (prio ?0x40000000 :0 ) | (exp -1 )); +} + +/*****************/ +/* Config driver */ +/*****************/ + +/* We support only one of these. */ +static struct bman *bm;
Please don't have both a file-scope "bm" and parameter "bm"s in the same file.
drivers/soc/fsl/qbman/bman.c line 244
Quoted 4 lines
drivers/soc/fsl/qbman/bman.c new file +4
-0+ +/* And this state belongs to 'bm' */ +static dma_addr_t fbpr_a; +static size_t fbpr_sz;
So why aren't they in "struct bman"?
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+static int bman_fbpr (struct reserved_mem *rmem) +{ + fbpr_a = rmem->base; + fbpr_sz = rmem->size; + +WARN_ON (!(fbpr_a && fbpr_sz)); + +return 0 ; +} +RESERVEDMEM_OF_DECLARE (bman_fbpr,"fsl,bman-fbpr" , bman_fbpr);
drivers/soc/fsl/qbman/bman.c line 265
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+ +int bm_pool_set (u32 bpid,const u32 *thresholds) +{ +if (!bm) +return -ENODEV ; +bm_set_pool (bm, bpid, thresholds[0 ], thresholds[1 ], + thresholds[2 ], thresholds[3 ]); +return 0 ; +} +EXPORT_SYMBOL (bm_pool_set);
Why does there need to be both bm_pool_set() and bm_set_pool() that do the some thing with a different calling convention?
Quoted 7 lines
drivers/soc/fsl/qbman/bman.c new file +7
-0+ +static void log_edata_bits (u32 bit_count) +{ +u32 i, j, mask =0xffffffff ; + +pr_warn ("ErrInt, EDATA:\n" ); + i = bit_count/32 ;
drivers/soc/fsl/qbman/bman.c line 282
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+if (bit_count%32 ) { + i++; + mask = ~(mask << bit_count%32 ); + } + j =16 -i; +pr_warn (" 0x%08x\n" ,bm_in (EDATA (j)) & mask); + j++; +for (; j <16 ; j++) +pr_warn (" 0x%08x\n" ,bm_in (EDATA (j))); +}
Put spaces around binary operators.
Where does the 16 come from? I see 8 EDATA registers, and no possibility for a non-multiple-of-32 number of bits. I also see the manual saying that "bit 0 from the memory is always in bit 0 of BMAN_EDATA0" so why is this code trying to right-justify it?
Why not just keep it simple and print all the EDATA registers?
Quoted 29 lines
drivers/soc/fsl/qbman/bman.c new file +29
-0+ +static void log_additional_error_info (u32 isr_val,u32 ecsr_val) +{ +union bman_ecir ecir_val; +union bman_eadr eadr_val; + + ecir_val.ecir_raw =bm_in (ECIR ); +/* Is portal info valid */ +if (ecsr_val &PORTAL_ECSR_ERR ) { +pr_warn ("ErrInt: SWP id %d, numb %d, pid %d\n" , + ecir_val.info.portal_num, ecir_val.info.numb, + ecir_val.info.pid); + } +if (ecsr_val & (BM_EIRQ_SBEI |BM_EIRQ_MBEI )) { + eadr_val.eadr_raw =bm_in (EADR ); +pr_warn ("ErrInt: EADR Memory: %s, 0x%x\n" , + error_mdata[eadr_val.info.memid].txt, + error_mdata[eadr_val.info.memid].addr_mask + & eadr_val.info.eadr); +log_edata_bits (error_mdata[eadr_val.info.memid].bits); + } +} + +/* BMan interrupt handler */ +static irqreturn_t bman_isr (int irq,void *ptr) +{ +u32 isr_val, ier_val, ecsr_val, isr_mask, i; + + ier_val =bm_err_isr_enable_read (bm);
drivers/soc/fsl/qbman/bman.c line 321
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+ isr_val =bm_err_isr_status_read (bm); + ecsr_val =bm_in (ECSR ); + isr_mask = isr_val & ier_val; + +if (!isr_mask) +return IRQ_NONE ; + +for (i =0 ; i <BMAN_HWE_COUNT ; i++) { +if (bman_hwerr_txts[i].mask & isr_mask) { +pr_warn ("ErrInt: %s\n" , bman_hwerr_txts[i].txt);
Use ptr to get to a struct device so you can use dev_err() here.
Quoted 84 lines
drivers/soc/fsl/qbman/bman.c new file +84
-0+if (bman_hwerr_txts[i].mask & ecsr_val) { +log_additional_error_info (isr_mask, ecsr_val); +/* Re-arm error capture registers */ +bm_out (ECSR , ecsr_val); + } +if (bman_hwerr_txts[i].mask &BMAN_ERRS_TO_UNENABLE ) { +pr_devel ("Un-enabling error 0x%x\n" , + bman_hwerr_txts[i].mask); + ier_val &= ~bman_hwerr_txts[i].mask; +bm_err_isr_enable_write (bm, ier_val); + } + } + } +bm_err_isr_status_clear (bm, isr_val); + +return IRQ_HANDLED ; +} + +u32 bm_pool_free_buffers (u32 bpid) +{ +return bm_in (POOL_CONTENT (bpid)); +} + +static ssize_t show_fbpr_fpc (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +return snprintf (buf,PAGE_SIZE ,"%u\n" ,bm_in (FBPR_FPC )); +}; + +static ssize_t show_pool_count (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +u32 data; +int i; + +if (kstrtoint (dev_attr->attr.name,10 , &i)) +return -EINVAL ; + data =bm_in (POOL_CONTENT (i)); +return snprintf (buf,PAGE_SIZE ,"%d\n" , data); +}; + +static ssize_t show_err_isr (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +return snprintf (buf,PAGE_SIZE ,"0x%08x\n" ,bm_in (ERR_ISR )); +}; + +static ssize_t show_sbec (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +int i; + +if (sscanf (dev_attr->attr.name,"sbec_%d" , &i) !=1 ) +return -EINVAL ; +return snprintf (buf,PAGE_SIZE ,"%u\n" ,bm_in (SBEC (i))); +}; + +static DEVICE_ATTR(err_isr, S_IRUSR, show_err_isr, NULL); +static DEVICE_ATTR(fbpr_fpc, S_IRUSR, show_fbpr_fpc, NULL); + +/* Didn't use DEVICE_ATTR as 64 of this would be required. +* Initialize them when needed. */ +static char *name_attrs_pool_count;/* "xx" + null-terminator */ +static struct device_attribute *dev_attr_buffer_pool_count; + +static DEVICE_ATTR(sbec_0, S_IRUSR, show_sbec, NULL); +static DEVICE_ATTR(sbec_1, S_IRUSR, show_sbec, NULL); + +static struct attribute *bman_dev_attributes[] = { + &dev_attr_fbpr_fpc.attr, + &dev_attr_err_isr.attr, +NULL +}; + +static struct attribute *bman_dev_ecr_attributes[] = { + &dev_attr_sbec_0.attr, + &dev_attr_sbec_1.attr, +NULL +}; + +static struct attribute **bman_dev_pool_count_attributes; + +/* root level */ +static const struct attribute_group bman_dev_attr_grp = {
drivers/soc/fsl/qbman/bman.c line 415
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+ .name = NULL, + .attrs = bman_dev_attributes +}; +static const struct attribute_group bman_dev_ecr_grp = { + .name ="error_capture" , + .attrs = bman_dev_ecr_attributes +}; +static struct attribute_group bman_dev_pool_countent_grp = { + .name ="pool_count" , +};
What do these sysfs attributes get used for, and where are they documented?
drivers/soc/fsl/qbman/bman.c line 421
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c new file +5
-0+static int of_fsl_bman_remove (struct platform_device *ofdev) +{ +sysfs_remove_group (&ofdev->dev.kobj, &bman_dev_attr_grp); +return 0 ; +};
This does not seem sufficient. At the least, you're creating more than one sysfs group in probe*(). How does this stop references to memory that was allocated using devm? Keep in mind that userspace can unbind a device from its driver, and there's nothing you can do to block it (unlike module removal). The remove() function has to be able to completely halt access to the device before returning, and any memory that needs to survive past remove() can't be allocated with devm.
If unbinding is not viable for this driver (which does not seem completely unreasonable given that it is subsystem infrastructure rather than a standalone device), then at least WARN in remove() (and no point doing anything else) to make it obvious that this is unsupported.
drivers/soc/fsl/qbman/bman.c line 434
Quoted 13 lines
drivers/soc/fsl/qbman/bman.c new file +13
-0+ +static int of_fsl_bman_probe (struct platform_device *ofdev) +{ +int ret, err_irq, i; +struct device *dev = &ofdev->dev; +struct device_node *node = dev->of_node; +struct resource res; +u32 __iomem *regs; +u16 id; +u8 major, minor; + +if (!of_device_is_available (node)) +return -ENODEV ;
The base OF platform code will check this for you.
Quoted 12 lines
drivers/soc/fsl/qbman/bman.c new file +12
-0+ + ret =of_address_to_resource (node,0 , &res); +if (ret) { +dev_err (dev,"Can't get %s property 'reg'\n" , node->full_name); +return ret; + } + regs =devm_ioremap (dev, res.start, res.end - res.start +1 ); +if (!regs) +return -ENXIO ; + + bm =bm_create (regs); +
drivers/soc/fsl/qbman/bman.c line 456
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c new file +10
-0+bm_get_version (bm, &id, &major, &minor); +dev_info (dev,"Bman ver:%04x,%02x,%02x\n" , id, major, minor); +if ((major ==1 ) && (minor ==0 )) + bman_pool_max =64 ; +else if ((major ==2 ) && (minor ==0 )) + bman_pool_max =8 ; +else if ((major ==2 ) && (minor ==1 )) + bman_pool_max =64 ; +else +dev_warn (dev,"unknown Bman version, default to rev1.0\n" );
Why is it safe to default to rev 1.0 rather than refusing to bind to an unknown version?
Also, unnecessary parentheses.
Quoted 142 lines
drivers/soc/fsl/qbman/bman.c new file +97
-0+ + +bm_set_memory (bm, fbpr_a,0 , fbpr_sz); + + err_irq =of_irq_to_resource (node,0 ,NULL ); +if (err_irq ==NO_IRQ ) { +dev_info (dev,"Can't get %s property 'interrupts'\n" , + node->full_name); +return -ENODEV ; + } + ret =devm_request_irq (dev, err_irq, bman_isr,IRQF_SHARED ,"bman-err" , + node); +if (ret) { +dev_err (dev,"devm_request_irq() failed %d for '%s'\n" , + ret, node->full_name); +return ret; + } +/* Disable Buffer Pool State Change */ +bm_err_isr_disable_write (bm,BM_EIRQ_BSCN ); +/* Write-to-clear any stale bits, (eg. starvation being asserted prior +* to resource allocation during driver init). */ +bm_err_isr_status_clear (bm,0xffffffff ); +/* Enable Error Interrupts */ +bm_err_isr_enable_write (bm,0xffffffff ); + + ret =sysfs_create_group (&dev->kobj, &bman_dev_attr_grp); +if (ret) + goto done; + ret =sysfs_create_group (&dev->kobj, &bman_dev_ecr_grp); +if (ret) + goto del_group_0; + + name_attrs_pool_count =devm_kmalloc (dev, +sizeof (char ) * bman_pool_max *3 ,GFP_KERNEL ); +if (!name_attrs_pool_count) + goto del_group_1; + + dev_attr_buffer_pool_count =devm_kmalloc (dev, +sizeof (struct device_attribute ) * bman_pool_max,GFP_KERNEL ); +if (!dev_attr_buffer_pool_count) + goto del_group_1; + + bman_dev_pool_count_attributes =devm_kmalloc (dev, +sizeof (struct attribute *) * (bman_pool_max +1 ),GFP_KERNEL ); +if (!bman_dev_pool_count_attributes) + goto del_group_1; + +for (i =0 ; i < bman_pool_max; i++) { + ret =scnprintf ((name_attrs_pool_count + i *3 ),3 ,"%d" , i); +if (!ret) + goto del_group_1; + dev_attr_buffer_pool_count[i].attr.name = + (name_attrs_pool_count + i *3 ); + dev_attr_buffer_pool_count[i].attr.mode =S_IRUSR ; + dev_attr_buffer_pool_count[i].show = show_pool_count; + bman_dev_pool_count_attributes[i] = + &dev_attr_buffer_pool_count[i].attr; + } + bman_dev_pool_count_attributes[bman_pool_max] =NULL ; + + bman_dev_pool_countent_grp.attrs = bman_dev_pool_count_attributes; + + ret =sysfs_create_group (&dev->kobj, &bman_dev_pool_countent_grp); +if (ret) + goto del_group_1; + + goto done; + +del_group_1: +sysfs_remove_group (&dev->kobj, &bman_dev_ecr_grp); +del_group_0: +sysfs_remove_group (&dev->kobj, &bman_dev_attr_grp); +done: +if (ret) +dev_err (dev,"Cannot create dev attributes ret=%d\n" , ret); + +return ret; +}; + +static const struct of_device_id of_fsl_bman_ids[] = { + { + .compatible ="fsl,bman" , + }, + {} +}; +MODULE_DEVICE_TABLE (of, of_fsl_bman_ids); + +static struct platform_driver of_fsl_bman_driver = { + .driver = { + .name =KBUILD_MODNAME , + .of_match_table = of_fsl_bman_ids, + }, + .probe = of_fsl_bman_probe, + .remove = of_fsl_bman_remove, +}; + +module_platform_driver (of_fsl_bman_driver);drivers/soc/fsl/qbman/bman_priv.h new file +4
-0@@ -0,0 +1,53 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */drivers/soc/fsl/qbman/bman_priv.h new file +2
-0+ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt
drivers/soc/fsl/qbman/bman_priv.h line 41
Quoted 10 lines
drivers/soc/fsl/qbman/bman_priv.h new file +10
-0+ +#include "dpaa_sys.h" + +/* used by CCSR and portal interrupt code */ +enum bm_isr_reg { + bm_isr_status =0 , + bm_isr_enable =1 , + bm_isr_disable =2 , + bm_isr_inhibit =3 +};
struct bm_isr_regs {
u32 status;
u32 enable;
u32 disable;
u32 inhibit;
};...and then you won't need __bm_err_isr_read/__bm_err_isr_write because it'll just be a straightforward in_be32/out_be32() (or an wrapper that handles endianness, if ls1043a ended up making this little-endian).
Or better, define all the registers in a struct rather than just these, and more of the I/O wrappers go away.
Quoted 5 lines
drivers/soc/fsl/qbman/bman_priv.h new file +2
-0+ +/* Set depletion thresholds associated with a buffer pool. Requires that the
+ * operating system have access to BMan CCSR (ie. compiled in support and
+ * run-time access courtesy of the device-tree). */
/*
* Please use standard
* Linux multi-line
* comment style,
* here and elsewhere.
*/
Quoted 61 lines
drivers/soc/fsl/qbman/bman_priv.h new file +8
-0+int bm_pool_set (u32 bpid,const u32 *thresholds); +#define BM_POOL_THRESH_SW_ENTER 0 +#define BM_POOL_THRESH_SW_EXIT 1 +#define BM_POOL_THRESH_HW_ENTER 2 +#define BM_POOL_THRESH_HW_EXIT 3 + +/* Read the free buffer count for a given buffer */ +u32 bm_pool_free_buffers (u32 bpid);drivers/soc/fsl/qbman/dpaa_sys.h new file +4
-0@@ -0,0 +1,55 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */drivers/soc/fsl/qbman/dpaa_sys.h new file +10
-0+ +#ifndef __DPAA_SYS_H +#define __DPAA_SYS_H + +#include <linux/module.h> +#include <linux/interrupt.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/of_reserved_mem.h> +#include <linux/platform_device.h>
drivers/soc/fsl/qbman/dpaa_sys.h line 49
Quoted 10 lines
drivers/soc/fsl/qbman/dpaa_sys.h new file +10
-0+ +#ifdef CONFIG_FSL_DPA_CHECKING +#define DPA_ASSERT (x) \ + do { \ + if (!(x)) { \ + pr_crit("ASSERT: (%s:%d) %s\n", __FILE__, __LINE__, \ + __stringify_1(x)); \ + dump_stack(); \ + panic("assertion failure"); \ + } \
Again, do not panic here. Use one of the WARN macros.
-Scott
Re: [v2 03/11] soc/fsl: Introduce the DPAA BMan portal driver
In reply to Roy PledgeQuoted 6 lines · Roy Pledge
drivers/soc/fsl/qbman/bman.c +0
-0@@ -165,11 +165,11 @@ static struct bman *bm_create(void *regs)
drivers/soc/fsl/qbman/bman.c static struct bman *bm_create(void *regs) · line 173
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +2
-2static inline u32 __bm_in (struct bman *bm,u32 offset) { -return in_be32 ((void *)bm + offset); +return ioread32be ((void *)bm + offset); }static inline void __bm_out (struct bman *bm,u32 offset,u32 val) { -out_be32 ((void *)bm + offset, val); +iowrite32be (val, (void *) bm + offset); }
Don't introduce a problem in one patch and then fix it in another. What does this change have to do with introducing the portal driver?
drivers/soc/fsl/qbman/bman.c u32 bm_pool_free_buffers(u32 bpid) · line 344
Quoted 7 lines
drivers/soc/fsl/qbman/bman.c +1
-0#define bm_in (reg) __bm_in(bm, REG_##reg)#define bm_out (reg, val) __bm_out(bm, REG_##reg, val)@@ -341,6 +341,7 @@ u32 bm_pool_free_buffers(u32 bpid) {return bm_in (POOL_CONTENT (bpid)); } +EXPORT_SYMBOL (bm_pool_free_buffers);
If you're exporting this (or even making it global), where's the documentation?
drivers/soc/fsl/qbman/bman.c u32 bm_pool_free_buffers(u32 bpid)
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c +6
-0+/* BTW, the drivers (and h/w programming model) already obtain the required +* synchronisation for portal accesses via lwsync(), hwsync(), and +* data-dependencies. Use of barrier()s or other order-preserving primitives +* simply degrade performance. Hence the use of the __raw_*() interfaces, which +* simply ensure that the compiler treats the portal registers as volatile (ie. +* non-coherent). */
volatile does not mean "non-coherent".
Be careful with this regarding endian, e.g. on ARM we can run the CPU in big or little endian on the same chip, and the raw accessors also unfortunately bypass endian conversion.
drivers/soc/fsl/qbman/bman.c
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c +6
-0+ +/* Cache-inhibited register access. */ +#define __bm_in (bm, o) __raw_readl((bm)->addr_ci + (o)) +#define __bm_out (bm, o, val) __raw_writel((val), (bm)->addr_ci + (o)) +#define bm_in (reg) __bm_in(&portal->addr, BM_REG_##reg) +#define bm_out (reg, val) __bm_out(&portal->addr, BM_REG_##reg, val)
Don't have multiple implementations of bm_in/out, with the same name, where bm in both refers to "bman", but which have different functions.
Quoted 7 lines
drivers/soc/fsl/qbman/bman.c +7
-0+/* Cache-enabled (index) register access */ +#define __bm_cl_touch_ro (bm, o) dcbt_ro((bm)->addr_ce + (o)) +#define __bm_cl_touch_rw (bm, o) dcbt_rw((bm)->addr_ce + (o)) +#define __bm_cl_in (bm, o) __raw_readl((bm)->addr_ce + (o)) +#define __bm_cl_out (bm, o, val) \ + do { \ + u32 *__tmpclout = (bm)->addr_ce + (o); \
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+__raw_writel ((val), __tmpclout); \ +dcbf (__tmpclout); \ + } while (0) +#define __bm_cl_invalidate (bm, o) dcbi((bm)->addr_ce + (o)) +#define bm_cl_touch_ro (reg) __bm_cl_touch_ro(&portal->addr, BM_CL_##reg##_CENA) +#define bm_cl_touch_rw (reg) __bm_cl_touch_rw(&portal->addr, BM_CL_##reg##_CENA) +#define bm_cl_in (reg) __bm_cl_in(&portal->addr, BM_CL_##reg##_CENA) +#define bm_cl_out (reg, val) __bm_cl_out(&portal->addr, BM_CL_##reg##_CENA, val) +#define bm_cl_invalidate (reg)\ + __bm_cl_invalidate(&portal->addr, BM_CL_##reg##_CENA)
Define these using functions to operate on pointers, and pass the pointer in without all the token-pasting. Some extra explanation of the cache manipulation would also be helpful.
drivers/soc/fsl/qbman/bman.c
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c +5
-0+/* --- RCR API --- */ + +/* Bit-wise logic to wrap a ring pointer by clearing the "carry bit" */ +#define RCR_CARRYCLEAR (p) \ + (void *)((unsigned long)(p) & (~(unsigned long)(BM_RCR_SIZE << 6)))
This could be a function.
Where does 6 come from? You use it again in the next function. Please define it symbolically.
drivers/soc/fsl/qbman/bman.c
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c +6
-0+ +/* Bit-wise logic to convert a ring pointer to a ring index */ +static inline u8 RCR_PTR2IDX (struct bm_rcr_entry *e) +{ +return ((uintptr_t )e >>6 ) & (BM_RCR_SIZE -1 ); +}
This is a function, so don't use ALLCAPS.
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+/* Increment the 'cursor' ring pointer, taking 'vbit' into account */ +static inline void RCR_INC (struct bm_rcr *rcr) +{ +/* NB: this is odd-looking, but experiments show that it generates +* fast code with essentially no branching overheads. We increment to +* the next RCR pointer and handle overflow and 'vbit'. */ +struct bm_rcr_entry *partial = rcr->cursor +1 ; + + rcr->cursor =RCR_CARRYCLEAR (partial); +if (partial != rcr->cursor)
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+ rcr->vbit ^=BM_RCR_VERB_VBIT ; +} + +static inline int bm_rcr_init (struct bm_portal *portal,enum bm_rcr_pmode pmode, +__maybe_unused enum bm_rcr_cmode cmode) +{ +/* This use of 'register', as well as all other occurrences, is because +* it has been observed to generate much faster code with gcc than is +* otherwise the case. */ + registerstruct bm_rcr *rcr = &portal->rcr;
What version of GCC? Normal optimization settings?
Has the seemingly excessive use of inline also been benchmarked against not doing so?
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c +5
-0+/* Buffer Pool Cleanup */ +static inline int bm_shutdown_pool (struct bm_portal *p,u32 bpid) +{ +struct bm_mc_command *bm_cmd; +struct bm_mc_result *bm_res;
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+int aq_count =0 ; +bool stop = false; + +while (!stop) { +/* Acquire buffers until empty */ + bm_cmd =bm_mc_start (p); + bm_cmd->acquire.bpid = bpid; +bm_mc_commit (p,BM_MCC_VERB_CMD_ACQUIRE |1 ); +while (!(bm_res =bm_mc_result (p))) +cpu_relax ();
How long can this take? How about a timeout?
And it looks like this happens with interrupts disabled. :-(
drivers/soc/fsl/qbman/bman.c
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c +5
-0+/* Compilation constants */ +#define RCR_THRESH 2/* reread h/w CI when running out of space */ +#define IRQNAME "BMan portal %d" +#define MAX_IRQNAME 16/* big enough for "BMan portal %d" */ +#define FSL_DPA_PORTAL_SHARE 1/* Allow portals to be shared */
If (some of) these are meant to be tunable they need to go in Kconfig.
drivers/soc/fsl/qbman/bman.c
Quoted 2 lines
drivers/soc/fsl/qbman/bman.c +2
-0+struct bman_portal { +struct bm_portal p;
What is the conceptual difference between 'bman_portal' and 'bm_portal'?
Quoted 16 lines
drivers/soc/fsl/qbman/bman.c +16
-0+/* 2-element array. pools[0] is mask, pools[1] is snapshot. */ +struct bman_depletion *pools; +int thresh_set; +unsigned long irq_sources; +u32 slowpoll;/* only used when interrupts are off */ +#ifdef FSL_DPA_CAN_WAIT_SYNC +struct bman_pool *rcri_owned;/* only 1 release WAIT_SYNC at a time */ +#endif +#ifdef FSL_DPA_PORTAL_SHARE +raw_spinlock_t sharing_lock;/* only used if is_shared */ +int is_shared; +struct bman_portal *sharing_redirect; +#endif +/* When the cpu-affine portal is activated, this is non-NULL */ +const struct bm_portal_config *config; +/* 64-entry hash-table of pool objects that are tracking depletion
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+* entry/exit (ie. BMAN_POOL_FLAG_DEPLETION). This isn't fast-path, so +* we're not fussy about cache-misses and so forth - whereas the above +* members should all fit in one cacheline. +* BTW, with 64 entries in the hash table and 64 buffer pools to track, +* you'll never guess the hash-function ... */ +struct bman_pool *cb[64 ]; +char irqname[MAX_IRQNAME ]; +/* Track if the portal was alloced by the driver */ +u8 alloced; +};
Consider sorting this to minimize padding, and keeping cache-hot members together (e.g. I see "slowpoll" which is "only used when interrupts are off" between presumably-cache-hot things like bm_portal and the lock).
s/u8 alloced/bool alloced/
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+#ifdef FSL_DPA_PORTAL_SHARE +#define PORTAL_IRQ_LOCK (p, irqflags) \ + do { \ + if ((p)->is_shared) \ + raw_spin_lock_irqsave(&(p)->sharing_lock, irqflags); \ + else \ + local_irq_save(irqflags); \ + } while (0) +#define PORTAL_IRQ_UNLOCK (p, irqflags) \ + do { \
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+if ((p)->is_shared) \ +raw_spin_unlock_irqrestore (&(p)->sharing_lock, \ + irqflags); \ +else \ +local_irq_restore (irqflags); \ + } while (0) +#else +#define PORTAL_IRQ_LOCK (p, irqflags) local_irq_save(irqflags) +#define PORTAL_IRQ_UNLOCK (p, irqflags) local_irq_restore(irqflags) +#endif
Don't use macros or allcaps.
If you're using raw locks and/or local_irq_save, the time of the critical section must be bounded. How long can this be held for?
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c +6
-0+static cpumask_t affine_mask; +static DEFINE_SPINLOCK (affine_mask_lock); +static DEFINE_PER_CPU(struct bman_portal, bman_affine_portal); +static inline struct bman_portal *get_raw_affine_portal (void ) +{ +return &get_cpu_var (bman_affine_portal);
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+} +#ifdef FSL_DPA_PORTAL_SHARE +static inline struct bman_portal *get_affine_portal (void ) +{ +struct bman_portal *p =get_raw_affine_portal (); + +if (p->sharing_redirect) +return p->sharing_redirect; +return p; +}
Where can I find documentation of the sharing_redirect mechanism? What is it needed for in the context of getting basic datapath support working?
drivers/soc/fsl/qbman/bman.c
Quoted 4 lines
drivers/soc/fsl/qbman/bman.c +4
-0+/* GOTCHA: this object type refers to a pool, it isn't *the* pool. There may be +* more than one such object per BMan buffer pool, eg. if different users of the +* pool are operating via different portals. */ +struct bman_pool {
So maybe call it struct bman_pool_user or similar?
Quoted 2 lines
+/* In the case that the application's core loop calls
+ *bman_poll(),
application?
Quoted 4 lines
we ought to balance how often we incur the overheads of the
+ * slow-path poll. We'll use two decrementer sources. The idle decrementer
+ * constant is used when the last slow-poll detected no work to do, and the busy
+ * decrementer constant when the last slow-poll had work to do. */
Why does this driver care whether the timer is implemented with a decrementer? What is a "decrementer source"?
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c +5
-0+#define SLOW_POLL_IDLE 1000 +#define SLOW_POLL_BUSY 10 +static u32 __poll_portal_slow (struct bman_portal *p,u32 is); + +/* Portal interrupt handler */
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+static irqreturn_t portal_isr (__always_unused int irq,void *ptr) +{ +struct bman_portal *p = ptr; +u32 clear = p->irq_sources; +u32 is =bm_isr_status_read (&p->p) & p->irq_sources; + + clear |=__poll_portal_slow (p, is); +bm_isr_status_clear (&p->p, clear); +return IRQ_HANDLED ; +}
No IRQ_NONE check, even behind the debug check ifdef?
drivers/soc/fsl/qbman/bman.c
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c +5
-0+struct bman_portal *bman_create_portal ( +struct bman_portal *portal, +const struct bm_portal_config *config) +{ +struct bm_portal *__p;
Please don't use gratuitous underscores.
drivers/soc/fsl/qbman/bman.c
Quoted 9 lines
drivers/soc/fsl/qbman/bman.c +9
-0+struct bman_portal *bman_create_affine_slave (struct bman_portal *redirect, +int cpu) +{ +#ifdef FSL_DPA_PORTAL_SHARE +struct bman_portal *p = &per_cpu (bman_affine_portal, cpu); + +BUG_ON (p->config); +BUG_ON (p->is_shared); +BUG_ON (!redirect->config->public_cfg.is_shared);
More BUG_ON()s...
Quoted 21 lines
drivers/soc/fsl/qbman/bman.c +21
-0+static u32 __poll_portal_slow (struct bman_portal *p,u32 is) +{ +struct bman_depletion tmp; +u32 ret = is; + +/* There is a gotcha to be aware of. If we do the query before clearing +* the status register, we may miss state changes that occur between the +* two. If we write to clear the status register before the query, the +* cache-enabled query command may overtake the status register write +* unless we use a heavyweight sync (which we don't want). Instead, we +* write-to-clear the status register then *read it back* before doing +* the query, hence the odd while loop with the 'is' accumulation. */ +if (is &BM_PIRQ_BSCN ) { +struct bm_mc_result *mcr; +__maybe_unused unsigned long irqflags; +unsigned int i, j; +u32 __is; + +bm_isr_status_clear (&p->p,BM_PIRQ_BSCN ); +while ((__is =bm_isr_status_read (&p->p)) &BM_PIRQ_BSCN ) { + is |= __is;
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+bm_isr_status_clear (&p->p,BM_PIRQ_BSCN ); + } + is &= ~BM_PIRQ_BSCN ; +PORTAL_IRQ_LOCK (p, irqflags); +bm_mc_start (&p->p); +bm_mc_commit (&p->p,BM_MCC_VERB_CMD_QUERY ); +while (!(mcr =bm_mc_result (&p->p))) +cpu_relax (); + tmp = mcr->query.ds.state; +PORTAL_IRQ_UNLOCK (p, irqflags);
Another apparently unbounded loop inside the lock.
drivers/soc/fsl/qbman/bman.c
Quoted 4 lines
drivers/soc/fsl/qbman/bman.c +4
-0+ ier =bm_isr_enable_read (&p->p); +/* Using "~ier" (rather than "bits" or "~p->irq_sources") creates a +* data-dependency, ie. to protect against re-ordering. */ +bm_isr_status_clear (&p->p, ~ier);
Aren't bm_isr_enable_read/bm_isr_status_clear() implemented with I/O accessors that ensure ordering anyway?
Quoted 25 lines
drivers/soc/fsl/qbman/bman.c +25
-0+PORTAL_IRQ_UNLOCK (p, irqflags); +put_affine_portal (); +return 0 ; +} +EXPORT_SYMBOL (bman_irqsource_remove); + +const cpumask_t *bman_affine_cpus (void ) +{ +return &affine_mask; +} +EXPORT_SYMBOL (bman_affine_cpus); + +u32 bman_poll_slow (void ) +{ +struct bman_portal *p =get_poll_portal (); +u32 ret; + +#ifdef FSL_DPA_PORTAL_SHARE +if (unlikely (p->sharing_redirect)) + ret = (u32)-1 ; + else +#endif + { +u32 is =bm_isr_status_read (&p->p) & ~p->irq_sources; +
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+ ret =__poll_portal_slow (p, is); +bm_isr_status_clear (&p->p, ret); + } +put_poll_portal (); +return ret; +} +EXPORT_SYMBOL (bman_poll_slow); + +/* Legacy wrapper */ +void bman_poll (void )
What legacy? This is a brand new driver, as far as mainline is concerned. What is this retaining compatibility with?
drivers/soc/fsl/qbman/bman.c
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c +6
-0+static inline struct bm_rcr_entry *try_rel_start (struct bman_portal **p, +#ifdef FSL_DPA_CAN_WAIT + __maybe_unused struct bman_pool *pool, +#endif +__maybe_unused unsigned long *irqflags, +__maybe_unused u32 flags)
Please don't vary the arguments of a function based on an ifdef.
drivers/soc/fsl/qbman/bman.c
Quoted 5 lines
drivers/soc/fsl/qbman/bman.c +5
-0+#ifdef CONFIG_FSL_DPA_CHECKING +if (!atomic_dec_and_test (&pool->in_use)) { +pr_crit ("Parallel attempts to enter bman_released() detected." ); +panic ("only one instance of bman_released/acquired allowed" ); + }
No panics.
drivers/soc/fsl/qbman/bman.c
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c +6
-0+#ifndef __FSL_BMAN_H +#define __FSL_BMAN_H + +#ifdef __cplusplus +extern "C" { +#endif
This is not needed.
drivers/soc/fsl/qbman/bman.c
Quoted 3 lines
drivers/soc/fsl/qbman/bman.c +3
-0+/* Enable blocking waits */ +#define FSL_DPA_CAN_WAIT 1 +#define FSL_DPA_CAN_WAIT_SYNC 1
Again, put them in Kconfig if it's really needed to keep both code paths.
drivers/soc/fsl/qbman/bman.c
Quoted 2 lines
drivers/soc/fsl/qbman/bman.c +2
-0+ +/* Last updated for v00.79 of the BG */
Same comment as previous patch.
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+ +/* Portal processing (interrupt) sources */ +#define BM_PIRQ_RCRI 0x00000002/* RCR Ring (below threshold) */ +#define BM_PIRQ_BSCN 0x00000001/* Buffer depletion State Change */ + +/* This wrapper represents a bit-array for the depletion state of the 64 BMan +* buffer pools. */ +struct bman_depletion { +u32 __state[2 ]; +};
Why underscores?
Quoted 15 lines
drivers/soc/fsl/qbman/bman.c +15
-0+#define BMAN_DEPLETION_EMPTY { { 0x00000000, 0x00000000 } } +#define BMAN_DEPLETION_FULL { { 0xffffffff, 0xffffffff } } +#define __bmdep_word (x) ((x) >> 5) +#define __bmdep_shift (x) ((x) & 0x1f) +#define __bmdep_bit (x) (0x80000000 >> __bmdep_shift(x)) +static inline void bman_depletion_init (struct bman_depletion *c) +{ + c->__state[0 ] = c->__state[1 ] =0 ; +} +static inline void bman_depletion_fill (struct bman_depletion *c) +{ + c->__state[0 ] = c->__state[1 ] = ~0 ; +} +static inline int bman_depletion_get (const struct bman_depletion *c,u8 bpid) +{
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+return c->__state[__bmdep_word (bpid)] &__bmdep_bit (bpid); +} +static inline void bman_depletion_set (struct bman_depletion *c,u8 bpid) +{ + c->__state[__bmdep_word (bpid)] |=__bmdep_bit (bpid); +} +static inline void bman_depletion_unset (struct bman_depletion *c,u8 bpid) +{ + c->__state[__bmdep_word (bpid)] &= ~__bmdep_bit (bpid); +}
You appear to be reimplementing __set_bit()/__clear_bit/test_bit().
drivers/soc/fsl/qbman/bman.c
Quoted 4 lines
drivers/soc/fsl/qbman/bman.c +4
-0+static inline dma_addr_t bm_buf_addr (const struct bm_buffer *buf) +{ +return (dma_addr_t )buf->addr; +}
You cannot convert a virtual address to a DMA address by casting.
Quoted 1 line
+/* Macro, so we compile better if 'v' isn't always 64-bit */
Have you actually seen a difference if the function is inlined?
drivers/soc/fsl/qbman/bman.c
Quoted 6 lines
drivers/soc/fsl/qbman/bman.c +6
-0+#define bm_buffer_set64 (buf, v) \ + do { \ + struct bm_buffer *__buf931 = (buf); \ + __buf931->hi = upper_32_bits(v); \ + __buf931->lo = lower_32_bits(v); \ + } while (0)
931?
What type is "buf" supposed to be?
Quoted 9 lines
drivers/soc/fsl/qbman/bman.c +9
-0+/* See 1.5.3.5.4: "Release Command" */ +struct bm_rcr_entry { +union { +struct { +u8 __dont_write_directly__verb; +u8 bpid;/* used with BM_RCR_VERB_CMD_BPID_SINGLE */ +u8 __reserved1[62 ]; + }; +struct bm_buffer bufs[8 ];
drivers/soc/fsl/qbman/bman.c
Quoted 10 lines
drivers/soc/fsl/qbman/bman.c +10
-0+ }; +} __packed; +#define BM_RCR_VERB_VBIT 0x80 +#define BM_RCR_VERB_CMD_MASK 0x70/* one of two values; */ +#define BM_RCR_VERB_CMD_BPID_SINGLE 0x20 +#define BM_RCR_VERB_CMD_BPID_MULTI 0x30 +#define BM_RCR_VERB_BUFCOUNT_MASK 0x0f/* values 1..8 */ + +/* See 1.5.3.1: "Acquire Command" */ +/* See 1.5.3.2: "Query Command" */
1.5.3.1 of what document? In DPAARM that's "FMan Network Interfaces".
-Scott
Re: [v2 04/11] soc/fsl: Introduce drivers for the DPAA QMan
In reply to Roy PledgeQuoted 8 lines · Roy Pledge
drivers/soc/fsl/qbman/qman_api.c new file +8
-0+/* Lock/unlock frame queues, subject to the "LOCKED" flag. This is about +* inter-processor locking only. Note, FQLOCK() is always called either under a +* local_irq_save() or from interrupt context - hence there's no need for irq +* protection (and indeed, attempting to nest irq-protection doesn't work, as +* the "irq en/disable" machinery isn't recursive...). */ +#define FQLOCK (fq) \ + do { \ + struct qman_fq *__fq478 = (fq); \
drivers/soc/fsl/qbman/qman_api.c line 71
Quoted 10 lines
drivers/soc/fsl/qbman/qman_api.c new file +10
-0+if (fq_isset (__fq478,QMAN_FQ_FLAG_LOCKED )) \ +spin_lock (&__fq478->fqlock); \ + } while (0) +#define FQUNLOCK (fq) \ + do { \ + struct qman_fq *__fq478 = (fq); \ + if (fq_isset(__fq478, QMAN_FQ_FLAG_LOCKED)) \ + spin_unlock(&__fq478->fqlock); \ + } while (0) +
I don't see QMAN_FQ_FLAG_LOCKED set anywhere. What is the use case?
-Scott
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [v2 04/11] soc/fsl: Introduce drivers for the DPAA QMan
Quoted 27 lines
-----Original Message-----
From: Wood Scott-B07421
Sent: Friday, September 11, 2015 9:10 PM
To: Pledge Roy-R01356 <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [v2 04/11] soc/fsl: Introduce drivers for the DPAA QManQuoted 16 lines · Roy Pledge
(quoted diff) +16
-0+/* Lock/unlock frame queues, subject to the "LOCKED" flag. This is +about + * inter-processor locking only. Note, FQLOCK() is always called +either under a + * local_irq_save() or from interrupt context - hence there's no need +for irq + * protection (and indeed, attempting to nest irq-protection doesn't +work, as + * the "irq en/disable" machinery isn't recursive...). */ #define +FQLOCK(fq) \ + do { \ + struct qman_fq *__fq478 = (fq); \ + if (fq_isset(__fq478, QMAN_FQ_FLAG_LOCKED)) \ + spin_lock(&__fq478->fqlock); \ + } while (0) +#define FQUNLOCK(fq) \
Quoted 8 lines
drivers/soc/fsl/qbman/qman_api.c line 71
Quoted 6 lines
drivers/soc/fsl/qbman/qman_api.c new file +6
-0+do { \ +struct qman_fq *__fq478 = (fq); \ +if (fq_isset (__fq478,QMAN_FQ_FLAG_LOCKED )) \ +spin_unlock (&__fq478->fqlock); \ + }while (0 ) +I don't see
QMAN_FQ_FLAG_LOCKEDset anywhere. What is the use case?
The idea was to allow multiple threads to manipulate the state of a frame queue at the same time without clobbering each others changes since the operation is a read/modify/write. I see two users of this flag in code that hasn't been submitted upstream yet, but I'm not sure if the use is required in those two instances either. At a glance it doesn't seem like it is needed but I would need to follow up with the users to make sure they aren't performing FQ management commands in multiple threads.
Quoted 2 lines
-Scott
Re: [v2 03/11] soc/fsl: Introduce the DPAA BMan portal driver
In reply to Roy PledgeHello,
sorry for the message format, but I don't have the original e-mail.
[...]
drivers/soc/fsl/qbman/bman.h new file +4 -0
@@ -0,0 +1,542 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions ar=
e met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyrig=
ht
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission=
.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of th= e
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND AN= Y
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMP= LIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AR= E
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR A= NY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DA= MAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SE= RVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUS= ED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR= TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE= OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bman_priv.h"
+
+extern u16 bman_pool_max;
[...]
drivers/soc/fsl/qbman/= renamed from drivers/soc/fsl/qbman/bman_portal.c +0 -0
bman_portal.c
new file mode 100644
index 0000000..62d8f64
drivers/soc/fsl/qbman/bman_portal.c new file +4 -0
@@ -0,0 +1,351 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions ar=
e met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyrig=
ht
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission=
.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of th= e
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND AN= Y
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMP= LIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AR= E
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR A= NY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DA= MAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SE= RVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUS= ED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR= TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE= OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bman_priv.h"
+
+/*
+ * Global variables of the max portal/pool number this BMan version supp= orted
+ */
+u16 bman_ip_rev;
+EXPORT_SYMBOL(bman_ip_rev);
+
+u16 bman_pool_max;
+EXPORT_SYMBOL(bman_pool_max);
[...]
Why are there two bman_pool_max variables, one global and one module spec= ific (drivers/soc/fsl/qbman/bman.c) which are similarly initialized. One = via the BMan register, the other via the FDT?
--=20
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : [email protected]
PGP : Public key available on request.
Diese Nachricht ist keine gesch=C3=A4ftliche Mitteilung im Sinne des EHUG= .