drivers/bus: Freescale Management Complex bus driver patch series
Subsystems (2)
v7 cover drivers/bus: Freescale Management Complex bus driver patch series
This patch series introduces Linux support for the Freescale Management Complex (fsl-mc) hardware. This patch series is dependent on the patch series "ARM64: Add support for FSL's LS2085A SoC"
(http://thread.gmane.org/gmane.linux.ports.arm.kernel/351829)
The fsl-mc is a hardware resource manager that manages specialized hardware objects used in network-oriented packet processing applications. After the fsl-mc block is enabled, pools of hardware resources are available, such as queues, buffer pools, I/O interfaces. These resources are building blocks that can be used to create functional hardware objects such as network interfaces, crypto accelerator instances, or L2 switches.
All the fsl-mc managed hardware resources/objects are represented in a physical grouping mechanism called a 'container' or DPRC (data path resource container).
Quoted 1 line
From the point of view of an OS, a DPRC functions similar to a plug
and play bus. Using fsl-mc commands software can enumerate the contents of the DPRC discovering the hardware objects present and binding them to drivers. Hardware objects can be created and removed dynamically, providing hot pluggability of the hardware objects.
Software contexts interact with the fsl-mc by sending commands through a memory mapped hardware interface called an "MC portal". Every fsl-mc object type has a command set to manage the objects. Key DPRC commands include:
-create/destroy a DPRC
-enumerate objects and resource pools in the DPRC, including
identifying mappable regions and the number of IRQs an object may have
-IRQ configuration
-move objects/resources between DPRCs
-connecting objects (e.g. connecting a network interface to
an L2 switch port)
-reset
Patch 1 contains a minimal set of low level functions to send an d receive commands to the fsl-mc. It includes support for basic management commands and commands to manipulate DPRC objects.
Patch 2 contains a platform device driver that sets up and registers the basic bus infrastructure including support for adding/removing devices, register/unregister of drivers, and bus match support to bind devices to drivers.
Patch 3 contains an driver that manages DPRC objects (the container that holds the hardware resources). This driver functions as a bus controller and handles enumeration of the objects in the container and hotplug events.
CHANGE HISTORY
Changes in v7:
- Refactored MC bus data structures.
- Moved creation of fsl_mc_io object from fsl_mc_add_device() to dprc_probe().
- Addressed comments from Alex Graf. Details in each patch.
Changes in v6:
- Upgraded MC flibs to version 0.5
- Fixed warnings from latest checkpatch
Changes in v5:
- Addressed comments from Alex Graf. Details in each patch.
Changes in v4:
- Addressed changes from ALex Graf. Details in each patch.
- Upgraded MC flibs to version 0.5
- Fixed bug related to setting fsl_mc_bus_type.dev_root too late
Changes in v3:
- Addressed pending issues not resolved in v2:
* Removed Doxygen comments as requested by Greg Kroah-Hartman
* Moved newly added FSL-specific header files from include/linux to include/linux/fsl
* Changed wording of licenses in MC flib source files
* Fixed sparse warning about context imbalance in 'mc_send_command'
- Addressed additional comments from Kim Phillips, Scott Wood and Timur Tabi. Details in each patch.
Issues pending resolution not addressed by v3:
- Checkpatch warnings:
* WARNING: DT compatible string "fsl,qoriq-mc" appears un-documented This warning will go away once the prerequisite patch series is accepted upstream.
* WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? This warning still happens even after adding MAINTAINERS file entries in the same patch where new files were added
Changes in v2:
- Added reference to the patch series this patch is dependent on for device tree and device tree bindings changes. (See above).
- Removed patch 4 (update to the MAINTAINERS file), as this is done now in patch 1
- Addressed comments from Joe Perches, Kim Phillips, Alex Graf and Scott Wood. Details in each patch.
Issues pending resolution not addressed by v2:
- What to do with Doxygen comments in patch 1
- Whether to move or not FSL-specific header files added in include/linux,
by this patch series, to another location
- Whether to change or not the wording of the licenses used in some
source files
- Checkpatch warnings:
* WARNING: DT compatible string "fsl,qoriq-mc" appears un-documented
This warning will go away once the prerequisite patch series is
accepted upstream.
* WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
This warning still happens even after adding MAINTAINERS file entries in
the same patch where new files were added
- Sparse warning:
* drivers/bus/fsl-mc/fsl_mc_sys.c:193:9: warning: context imbalance in 'mc_send_command' - different lock contexts for basic block This warning is caused by conditionally acquiring/releasing a lock in function mc_send_command().
Not clear how to solve this warning, as we need to be able to decide at
run time based on a flag whether to acquire the lock or not.
Changes in v1:
- No changes since RFC v4
Changes in RFC v4:
- Fixed parameter mismatch for device_find_child() call in fsl_mc_dprc.c
- Added back the dma_mask field to struct fsl_mc_device as it is needed by some MC child device drivers. However, the default DMA mask now does not have the 32-bit limitation of the original patch series (v1).
Changes in RFC v3:
Rework to address comments from Arnd Bergmann:
- Removed per-bus list of children, and instead use device_for_each_child()
- Use the same structure (struct fsl_mc_device) to represent both bus devices and their children.
http://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg711301.html
Changes in RFC v2:
Rework to address comments from Arnd Bergmann:
- Removed fsl_mc_bus structure and global variable
- Removed the 'magic' fields from all structs
- Removed NULL initializers
- Replaced all occurrences of EXPORT_SYMBOL() with EXPORT_SYMBOL_GPL()
- Removed function dprc_parse_dt_node(), and replaced its call by a direct call to of_address_to_resource()
- Removed struct fsl_mc_device_region and use standard 'struct resource' instead.
- Removed dma_mask field from 'struct fsl_mc_device' as it is not currently being used.
- Removed redundant 'driver' field from struct fsl_mc_device
- Removed the container field. We can get the parent DPRC of a given dev, from its dev.parent field.
http://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg708858.html
PATCH v7 1/3 drivers/bus: Added Freescale Management Complex APIs
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
---
Changes in v7:
None
Changes in v6:
- Upgraded MC flibs for MC firmware 0.5.3
- Fixed new checkpatch warnings
Changes in v5:
- Addressed comments from Alex Graf:
* Removed unused variable in mc_send_command()
* Renamed dprc_get_container_id() as dpmng_get_container_id() and moved corresponding code from dprc.[hc] to dpmng.[hc], as "get_container_id" is not really an operation on a DPRC object, but it is a general MC management operation.
* Ensure that strings sent/received to/from the MC fw for DPRC commands are null-terminated.
Changes in v4:
- Addressed comments from Alex Graf:
* Added file description for files that did not have one
* Removed Marshalling/unmarshalling macros invoked in MC command wrapper functions, and instead do the marshalling/ unmarshalling directly in these functions.
* Added type cast u32 in status range-check in mc_status_to_error()
* Moved mc_write_command() and mc_read_response() inline function to mc_sys.c as they are only used in that file
* Renamed u64_enc() as mc_enc() and u64_dec() as mc_dec()
- Upgraded MC flibs for MC firmware 0.5
Changes in v3:
- Addressed comment from Greg Kroah-Hartman:
* Removed doxygen comments
- Addressed comment from Scott Wood:
* Replaced udelay() call with usleep_range() call in polling loop
- Addressed comments from Kim Phillips:
* Fixed license text in all files
* Renamed files:
drivers/bus/fsl-mc/fsl_dpmng_cmd.h -> drivers/bus/fsl-mc/dpmng-cmd.h drivers/bus/fsl-mc/fsl_dprc_cmd.h -> drivers/bus/fsl-mc/dprc-cmd.h drivers/bus/fsl-mc/fsl_mc_sys.c -> drivers/bus/fsl-mc/mc-sys.c include/linux/fsl_dpmng.h -> include/linux/fsl/dpmng.h include/linux/fsl_dprc.h -> include/linux/fsl/dprc.h include/linux/fsl_mc_cmd.h -> include/linux/fsl/mc-cmd.h include/linux/fsl_mc_sys.h -> include/linux/fsl/mc-sys.h
* Changed dpmng_load_iop() to take the DMA address directly, instead of the image virtual address.
* Removed if and WARN_ON that checks for NULL fsl_destroy_mc_io()
* Removed locking from mc_send_command(). Now the caller of MC flib APIs is responsible for protecting concurrent accesses to the same MC portal.
Changes in v2:
- Addressed comment from Joe Perches:
* Refactored logic to actively fail on err and proceed at the same indent level on success, for all functions in dprc.c and dpmng.c.
- Addressed comments from Kim Phillips:
* Fixed warning in mc_send_command
* Changed serialization logic in mc_send_command() to only use spinlock_irqsave() when both threads and interrupt handlers concurrently access the same portal.
* Changed switch to lookup table in mc_status_to_error()
* Removed macros iowrite64(), ioread64(), ENOTSUP from fsl_mc_sys.h
* Removed #ifdef side for FSL_MC_FIRMWARE in fsl_mc_cmd.h
* Changed non-devm_ API calls to devm_ API calls and refactored fsl_create_mc_io()/fsl_destroy_mc_io() to simplify cleanup logic.
- Addressed comments from Scott Wood:
* Return -ENXIO instead of -EFAULT when ioremap_nocache() fails
- Addressed comments from Alex Graf:
* Added MAINTAINERS file entries for new files
* Added dev param to fsl_create_mc_io(), to enable the use of devm_ APIs in this function and fsl_destroy_mc_io().
* Changed the value of the timeout for MC command completion to be a function of HZ instead of a hard-coded jiffies value.
MAINTAINERS | 8 + drivers/bus/fsl-mc/dpmng-cmd.h | 47 +++ drivers/bus/fsl-mc/dpmng.c | 78 ++++ drivers/bus/fsl-mc/dprc-cmd.h | 84 ++++ drivers/bus/fsl-mc/dprc.c | 913 +++++++++++++++++++++++++++++++++++++++++ drivers/bus/fsl-mc/mc-sys.c | 283 +++++++++++++ include/linux/fsl/dpmng.h | 80 ++++ include/linux/fsl/dprc.h | 801 ++++++++++++++++++++++++++++++++++++ include/linux/fsl/mc-cmd.h | 113 +++++ include/linux/fsl/mc-sys.h | 70 ++++ 10 files changed, 2477 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng-cmd.h create mode 100644 drivers/bus/fsl-mc/dpmng.c create mode 100644 drivers/bus/fsl-mc/dprc-cmd.h create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/mc-sys.c create mode 100644 include/linux/fsl/dpmng.h create mode 100644 include/linux/fsl/dprc.h create mode 100644 include/linux/fsl/mc-cmd.h create mode 100644 include/linux/fsl/mc-sys.h
MAINTAINERS +8 -0
@@ -4075,6 +4075,14 @@ F: sound/soc/fsl/fsl* F: sound/soc/fsl/imx* F: sound/soc/fsl/mpc8610_hpcd.c +FREESCALE QORIQ MANAGEMENT COMPLEX DRIVER +M: J. German Rivera <[email protected]> +L: [email protected] +S: Maintained +F: include/linux/fsl_mc* +F: include/linux/fsl_dp* +F: drivers/bus/fsl-mc/* + FREEVXFS FILESYSTEM M: Christoph Hellwig <[email protected]> W: ftp://ftp.openlinux.org/pub/people/hch/vxfs
drivers/bus/fsl-mc/dpmng-cmd.h new file +47 -0
47 lines not on this page · raw message
drivers/bus/fsl-mc/dpmng.c new file +78 -0
78 lines not on this page · raw message
drivers/bus/fsl-mc/dprc-cmd.h new file +84 -0
84 lines not on this page · raw message
drivers/bus/fsl-mc/dprc.c new file +913 -0
913 lines not on this page · raw message
drivers/bus/fsl-mc/mc-sys.c new file +283 -0
283 lines not on this page · raw message
include/linux/fsl/dpmng.h new file +80 -0
80 lines not on this page · raw message
include/linux/fsl/dprc.h new file +801 -0
801 lines not on this page · raw message
include/linux/fsl/mc-cmd.h new file +113 -0
113 lines not on this page · raw message
include/linux/fsl/mc-sys.h new file +70 -0
70 lines not on this page · raw message
--
2.3.0
Re: [PATCH v7 1/3] drivers/bus: Added Freescale Management Complex APIs
Quoted 7 lines · J. German Rivera
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>
Only 2 minor nits.
[...]
drivers/bus/fsl-mc/dpmng.c line 46
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 }; +int err; + +/* prepare command */ + cmd.header =mc_encode_cmd_header (DPMNG_CMDID_GET_VERSION , +MC_CMD_PRI_LOW ,0 ); + +/* send command to mc*/
Either my mail client is broken or this is a copy&paste error throughout the file :).
Quoted 11 lines
drivers/bus/fsl-mc/dpmng.c new file +11
-0+ err =mc_send_command (mc_io, &cmd); +if (err) +return err; + +/* retrieve response parameters */ + mc_ver_info->revision =mc_dec (cmd.params[0 ],0 ,32 ); + mc_ver_info->major =mc_dec (cmd.params[0 ],32 ,32 ); + mc_ver_info->minor =mc_dec (cmd.params[1 ],0 ,32 ); + +return 0 ; +}
[...]
include/linux/fsl/mc-cmd.h line 56
Quoted 8 lines
include/linux/fsl/mc-cmd.h new file +8
-0+ +struct mc_command { +uint64_t header; +uint64_t params[MC_CMD_NUM_OF_PARAMS ]; +}; + +enum mc_cmd_status { +MC_CMD_STATUS_OK =0x0 ,/*!< Completed successfully */
What is /*!< supposed to be? Can't this just be /*?
include/linux/fsl/mc-cmd.h line 68
Quoted 12 lines
include/linux/fsl/mc-cmd.h new file +12
-0+MC_CMD_STATUS_READY =0x1 ,/*!< Ready to be processed */ +MC_CMD_STATUS_AUTH_ERR =0x3 ,/*!< Authentication error */ +MC_CMD_STATUS_NO_PRIVILEGE =0x4 ,/*!< No privilege */ +MC_CMD_STATUS_DMA_ERR =0x5 ,/*!< DMA or I/O error */ +MC_CMD_STATUS_CONFIG_ERR =0x6 ,/*!< Configuration error */ +MC_CMD_STATUS_TIMEOUT =0x7 ,/*!< Operation timed out */ +MC_CMD_STATUS_NO_RESOURCE =0x8 ,/*!< No resources */ +MC_CMD_STATUS_NO_MEMORY =0x9 ,/*!< No memory available */ +MC_CMD_STATUS_BUSY =0xA ,/*!< Device is busy */ +MC_CMD_STATUS_UNSUPPORTED_OP =0xB ,/*!< Unsupported operation */ +MC_CMD_STATUS_INVALID_STATE =0xC /*!< Invalid state */ +};
Alex
PATCH v7 2/3 drivers/bus: Freescale Management Complex (fsl-mc) bus driver
In reply to J. German RiveraPlatform device driver that sets up the basic bus infrastructure for the fsl-mc bus type, including support for adding/removing fsl-mc devices, register/unregister of fsl-mc drivers, and bus match support to bind devices to drivers.
---
Changes in v7:
- Refactored MC bus data structures
- Removed creation of fsl_mc_io object from fsl_mc_add_device()
- Addressed comments from Alex Graf:
* Use the 'ranges' property for the 'fsl,qoriq-mc' node as a way to translate MC-returned addresses (bus relative addresses) to system physical addresses.
Changes addressed in v6:
- Fixed new checkpatch warnings
Changes addressed in v5:
- Addressed comments from Alex Graf:
* Renamed dprc_get_container_id() call as dpmng_get_container_id().
* Added TODO comment to use the 'ranges' property of the fsl-mc DT node.
Changes addressed in v4:
- Addressed comments from Alex Graf:
* Added missing scope limitations and more descriptive help text for the FSL_MC_BUS config option.
- Fixed bug related to setting fsl_mc_bus_type.dev_root too late.
Changes in v3:
- Addressed changes from Kim Phillips:
* Renamed files:
drivers/bus/fsl-mc/fsl_mc_bus.c -> drivers/bus/fsl-mc/mc-bus.c include/linux/fsl_mc.h -> include/linux/fsl/mc.h include/linux/fsl_mc_private.h -> include/linux/fsl/mc-private.h
- Addressed comments from Timur Tabi:
* Changed all functions that had goto out/error when no common cleanup was done, to just have multiple return points.
* Replaced error cleanup boolean flags with multiple exit points.
Changes in v2:
- Addressed comment from Joe Perches:
* Changed pr_debug to dev_dbg in fsl_mc_bus_match
- Addressed comments from Kim Phillips and Alex Graf:
* Changed version check to allow the driver to run with MC firmware that has major version number greater than or equal to the driver's major version number.
* Removed minor version check
- Removed unused variable parent_dev in fsl_mc_device_remove
drivers/bus/Kconfig | 3 + drivers/bus/Makefile | 3 + drivers/bus/fsl-mc/Kconfig | 24 ++ drivers/bus/fsl-mc/Makefile | 14 + drivers/bus/fsl-mc/mc-bus.c | 758 +++++++++++++++++++++++++++++++++++++++++ include/linux/fsl/mc-private.h | 67 ++++ include/linux/fsl/mc.h | 136 ++++++++ 7 files changed, 1005 insertions(+) create mode 100644 drivers/bus/fsl-mc/Kconfig create mode 100644 drivers/bus/fsl-mc/Makefile create mode 100644 drivers/bus/fsl-mc/mc-bus.c create mode 100644 include/linux/fsl/mc-private.h create mode 100644 include/linux/fsl/mc.h
drivers/bus/Kconfig +3 -0
@@ -67,4 +67,7 @@ config VEXPRESS_CONFIG help Platform configuration infrastructure for the ARM Ltd. Versatile Express. + +source "drivers/bus/fsl-mc/Kconfig" + endmenu
drivers/bus/Makefile +3 -0
@@ -15,3 +15,6 @@ obj-$(CONFIG_ARM_CCI) += arm-cci.o obj-$(CONFIG_ARM_CCN) += arm-ccn.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o + +# Freescale Management Complex (MC) bus drivers +obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
drivers/bus/fsl-mc/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +# +# Freescale Management Complex (MC) bus drivers +# +# Copyright (C) 2014 Freescale Semiconductor, Inc. +# +# This file is released under the GPLv2 +# + +config FSL_MC_BUS + tristate "Freescale Management Complex (MC) bus driver" + depends on OF && ARM64 + help + Driver to enable the bus infrastructure for the Freescale + QorIQ Management Complex (fsl-mc). The fsl-mc is a hardware + module of the QorIQ LS2 SoCs, that does resource management + for hardware building-blocks in the SoC that can be used + to dynamically create networking hardware objects such as + network interfaces (NICs), crypto accelerator instances, + or L2 switches. + + Only enable this option when building the kernel for + Freescale QorQIQ LS2xxxx SoCs. + +
drivers/bus/fsl-mc/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# Freescale Management Complex (MC) bus drivers +# +# Copyright (C) 2014 Freescale Semiconductor, Inc. +# +# This file is released under the GPLv2 +# +obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o + +mc-bus-driver-objs := mc-bus.o \ + mc-sys.o \ + dprc.o \ + dpmng.o +
drivers/bus/fsl-mc/mc-bus.c new file +758 -0
758 lines not on this page · raw message
include/linux/fsl/mc-private.h new file +67 -0
67 lines not on this page · raw message
include/linux/fsl/mc.h new file +136 -0
136 lines not on this page · raw message
--
2.3.0
Re: [PATCH v7 2/3] drivers/bus: Freescale Management Complex (fsl-mc) bus driver
Quoted 190 lines · J. German Rivera
Platform device driver that sets up the basic bus infrastructure for the fsl-mc bus type, including support for adding/removing fsl-mc devices, register/unregister of fsl-mc drivers, and bus match support to bind devices to drivers.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>---
Changes in v7:
- Refactored MC bus data structures
- Removed creation offsl_mc_ioobject fromfsl_mc_add_device()
- Addressed comments from Alex Graf:
* Use the 'ranges' property for the 'fsl,qoriq-mc' node as a way to translate MC-returned addresses (bus relative addresses) to system physical addresses.Changes addressed in v6:
- Fixed new checkpatch warningsChanges addressed in v5:
- Addressed comments from Alex Graf:
* Renameddprc_get_container_id()call asdpmng_get_container_id().
* Added TODO comment to use the 'ranges' property of the fsl-mc DT node.Changes addressed in v4:
- Addressed comments from Alex Graf:
* Added missing scope limitations and more descriptive help text for theFSL_MC_BUSconfig option.
- Fixed bug related to setting fsl_mc_bus_type.dev_root too late.Changes in v3:
- Addressed changes from Kim Phillips:
* Renamed files:drivers/bus/fsl-mc/fsl_mc_bus.c -> drivers/bus/fsl-mc/mc-bus.c include/linux/fsl_mc.h -> include/linux/fsl/mc.h include/linux/fsl_mc_private.h -> include/linux/fsl/mc-private.h- Addressed comments from Timur Tabi:
* Changed all functions that had goto out/error when no common cleanup was done, to just have multiple return points.
* Replaced error cleanup boolean flags with multiple exit points.Changes in v2:
- Addressed comment from Joe Perches:
* Changedpr_debugtodev_dbginfsl_mc_bus_match- Addressed comments from Kim Phillips and Alex Graf:
* Changed version check to allow the driver to run with MC firmware that has major version number greater than or equal to the driver's major version number.
* Removed minor version check- Removed unused variable
parent_devinfsl_mc_device_removedrivers/bus/Kconfig | 3 + drivers/bus/Makefile | 3 + drivers/bus/fsl-mc/Kconfig | 24 ++ drivers/bus/fsl-mc/Makefile | 14 + drivers/bus/fsl-mc/mc-bus.c | 758 +++++++++++++++++++++++++++++++++++++++++ include/linux/fsl/mc-private.h | 67 ++++ include/linux/fsl/mc.h | 136 ++++++++ 7 files changed, 1005 insertions(+) create mode 100644 drivers/bus/fsl-mc/Kconfig create mode 100644 drivers/bus/fsl-mc/Makefile create mode 100644 drivers/bus/fsl-mc/mc-bus.c create mode 100644 include/linux/fsl/mc-private.h create mode 100644 include/linux/fsl/mc.hdrivers/bus/Kconfig +3
-0@@ -67,4 +67,7 @@ config VEXPRESS_CONFIG help Platform configuration infrastructure for the ARM Ltd. Versatile Express. + +source "drivers/bus/fsl-mc/Kconfig" + endmenudrivers/bus/Makefile +3
-0@@ -15,3 +15,6 @@ obj-$(CONFIG_ARM_CCI) += arm-cci.o obj-$(CONFIG_ARM_CCN) += arm-ccn.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o + +# Freescale Management Complex (MC) bus drivers +obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/drivers/bus/fsl-mc/Kconfig new file +24
-0@@ -0,0 +1,24 @@ +# +# Freescale Management Complex (MC) bus drivers +# +# Copyright (C) 2014 Freescale Semiconductor, Inc. +# +# This file is released under the GPLv2 +# + +config FSL_MC_BUS + tristate "Freescale Management Complex (MC) bus driver" + depends on OF && ARM64 + help + Driver to enable the bus infrastructure for the Freescale + QorIQ Management Complex (fsl-mc). The fsl-mc is a hardware + module of the QorIQ LS2 SoCs, that does resource management + for hardware building-blocks in the SoC that can be used + to dynamically create networking hardware objects such as + network interfaces (NICs), crypto accelerator instances, + or L2 switches. + + Only enable this option when building the kernel for + Freescale QorQIQ LS2xxxx SoCs. + +drivers/bus/fsl-mc/Makefile new file +14
-0@@ -0,0 +1,14 @@ +# +# Freescale Management Complex (MC) bus drivers +# +# Copyright (C) 2014 Freescale Semiconductor, Inc. +# +# This file is released under the GPLv2 +# +obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o + +mc-bus-driver-objs := mc-bus.o \ + mc-sys.o \ + dprc.o \ + dpmng.o +drivers/bus/fsl-mc/mc-bus.c new file +41
-0@@ -0,0 +1,758 @@ +/* +* Freescale Management Complex (MC) bus driver +* +* Copyright (C) 2014 Freescale Semiconductor, Inc. +* Author: German Rivera <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/fsl/mc-private.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/of_address.h> +#include <linux/ioport.h> +#include <linux/slab.h> +#include <linux/limits.h> +#include <linux/fsl/dpmng.h> +#include <linux/fsl/mc-sys.h> +#include "dprc-cmd.h" + +static struct kmem_cache *mc_dev_cache; + +/** +* fsl_mc_bus_match - device to driver matching callback +* @dev: the MC object device structure to match against +* @drv: the device driver to search for matching MC object device id +* structures +* +* Returns 1 on success, 0 otherwise. +*/ +static int fsl_mc_bus_match (struct device *dev,struct device_driver *drv) +{ +const struct fsl_mc_device_match_id *id; +struct fsl_mc_device *mc_dev =to_fsl_mc_device (dev); +struct fsl_mc_driver *mc_drv =to_fsl_mc_driver (drv); +bool found = false; + +if (WARN_ON (!fsl_mc_bus_type.dev_root)) + goto out;
drivers/bus/fsl-mc/mc-bus.c line 51
Quoted 10 lines
drivers/bus/fsl-mc/mc-bus.c new file +10
-0+ +if (!mc_drv->match_id_table) + goto out; + +/* +* If the object is not 'plugged' don't match. +* Only exception is the root DPRC, which is a special case. +*/ +if ((mc_dev->obj_desc.state &DPRC_OBJ_STATE_PLUGGED ) ==0 && + &mc_dev->dev != fsl_mc_bus_type.dev_root)
Does this mean there can only be one fsl-mc per machine? Is this a reasonable limitation?
Wouldn't it be a lot cleaner to have individual buses for each fsl-mc dt node? If hardware only implements one today that's fine, but it means we don't have to completely reengineer everything tomorrow then.
Quoted 26 lines
drivers/bus/fsl-mc/mc-bus.c new file +26
-0+ goto out; + +/* +* Traverse the match_id table of the given driver, trying to find +* a matching for the given MC object device. +*/ +for (id = mc_drv->match_id_table; id->vendor !=0x0 ; id++) { +if (id->vendor == mc_dev->obj_desc.vendor && +strcmp (id->obj_type, mc_dev->obj_desc.type) ==0 && + id->ver_major == mc_dev->obj_desc.ver_major && + id->ver_minor == mc_dev->obj_desc.ver_minor) { + found = true; +break ; + } + } + +out: +dev_dbg (dev,"%smatched\n" , found ?"" :"not " ); +return found; +} + +/** +* fsl_mc_bus_uevent - callback invoked when a device is added +*/ +static int fsl_mc_bus_uevent (struct device *dev,struct kobj_uevent_env *env) +{
drivers/bus/fsl-mc/mc-bus.c line 87
Quoted 10 lines
drivers/bus/fsl-mc/mc-bus.c new file +10
-0+pr_debug ("%s invoked\n" , __func__); +return 0 ; +} + +struct bus_type fsl_mc_bus_type = { + .name ="fsl-mc" , + .match = fsl_mc_bus_match, + .uevent = fsl_mc_bus_uevent, +}; +EXPORT_SYMBOL_GPL (fsl_mc_bus_type);
Why does this have to get exported?
Quoted 63 lines
drivers/bus/fsl-mc/mc-bus.c new file +63
-0+ +static int fsl_mc_driver_probe (struct device *dev) +{ +struct fsl_mc_driver *mc_drv; +struct fsl_mc_device *mc_dev =to_fsl_mc_device (dev); +int error; + +if (WARN_ON (!dev->driver)) +return -EINVAL ; + + mc_drv =to_fsl_mc_driver (dev->driver); +if (WARN_ON (!mc_drv->probe)) +return -EINVAL ; + + error = mc_drv->probe (mc_dev); +if (error <0 ) { +dev_err (dev,"MC object device probe callback failed: %d\n" , + error); +return error; + } + +return 0 ; +} + +static int fsl_mc_driver_remove (struct device *dev) +{ +struct fsl_mc_driver *mc_drv =to_fsl_mc_driver (dev->driver); +struct fsl_mc_device *mc_dev =to_fsl_mc_device (dev); +int error; + +if (WARN_ON (!dev->driver)) +return -EINVAL ; + + error = mc_drv->remove (mc_dev); +if (error <0 ) { +dev_err (dev, +"MC object device remove callback failed: %d\n" , + error); +return error; + } + +return 0 ; +} + +static void fsl_mc_driver_shutdown (struct device *dev) +{ +struct fsl_mc_driver *mc_drv =to_fsl_mc_driver (dev->driver); +struct fsl_mc_device *mc_dev =to_fsl_mc_device (dev); + + mc_drv->shutdown (mc_dev); +} + +/** +* __fsl_mc_driver_register - registers a child device driver with the +* MC bus +* +* This function is implicitly invoked from the registration function of +* fsl_mc device drivers, which is generated by the +* module_fsl_mc_driver() macro. +*/ +int __fsl_mc_driver_register (struct fsl_mc_driver *mc_driver, +struct module *owner) +{
drivers/bus/fsl-mc/mc-bus.c line 160
Quoted 10 lines
drivers/bus/fsl-mc/mc-bus.c new file +10
-0+int error; + + mc_driver->driver.owner = owner; + mc_driver->driver.bus = &fsl_mc_bus_type; + +/* +* Set default driver callbacks, if not set by the child driver: +*/ +if (mc_driver->probe) + mc_driver->driver.probe = fsl_mc_driver_probe;
I don't understand this. I thought you want to put them as default in case they're *not* set?
Quoted 49 lines
drivers/bus/fsl-mc/mc-bus.c new file +49
-0+ +if (mc_driver->remove) + mc_driver->driver.remove = fsl_mc_driver_remove; + +if (mc_driver->shutdown) + mc_driver->driver.shutdown = fsl_mc_driver_shutdown; + + error =driver_register (&mc_driver->driver); +if (error <0 ) { +pr_err ("driver_register() failed for %s: %d\n" , + mc_driver->driver.name, error); +return error; + } + +pr_info ("MC object device driver %s registered\n" , + mc_driver->driver.name); +return 0 ; +} +EXPORT_SYMBOL_GPL (__fsl_mc_driver_register); + +/** +* fsl_mc_driver_unregister - unregisters a device driver from the +* MC bus +*/ +void fsl_mc_driver_unregister (struct fsl_mc_driver *mc_driver) +{ +driver_unregister (&mc_driver->driver); +} +EXPORT_SYMBOL_GPL (fsl_mc_driver_unregister); + +static int get_dprc_icid (struct fsl_mc_io *mc_io, +int container_id,uint16_t *icid) +{ +uint16_t dprc_handle; +struct dprc_attributes attr; +int error; + + error =dprc_open (mc_io, container_id, &dprc_handle); +if (error <0 ) { +pr_err ("dprc_open() failed: %d\n" , error); +return error; + } + +memset (&attr,0 ,sizeof (attr)); + error =dprc_get_attributes (mc_io, dprc_handle, &attr); +if (error <0 ) { +pr_err ("dprc_get_attributes() failed: %d\n" , error); + goto common_cleanup; + }
drivers/bus/fsl-mc/mc-bus.c line 219
Quoted 10 lines
drivers/bus/fsl-mc/mc-bus.c new file +10
-0+ + *icid = attr.icid; + error =0 ; + +common_cleanup: + (void )dprc_close (mc_io, dprc_handle); +return error; +} + +static int translate_mc_addr (uint64_t mc_addr,phys_addr_t *phys_addr)
This should probably check that both start and end are within range.
Quoted 12 lines
drivers/bus/fsl-mc/mc-bus.c new file +12
-0+{ +int i; +struct fsl_mc *mc =dev_get_drvdata (fsl_mc_bus_type.dev_root->parent); + +if (mc->num_translation_ranges ==0 ) { +/* +* Do identity mapping: +*/ + *phys_addr = mc_addr; +return 0 ; + } +
[...]
Quoted 9 lines
drivers/bus/fsl-mc/mc-bus.c new file +9
-0+/** +* fsl_mc_device_remove - Remove a MC object device from being visible to +* Linux +* +* @mc_dev: Pointer to a MC object device object +*/ +void fsl_mc_device_remove (struct fsl_mc_device *mc_dev) +{ +struct fsl_mc_bus *mc_bus =NULL ;
drivers/bus/fsl-mc/mc-bus.c line 449
Quoted 10 lines
drivers/bus/fsl-mc/mc-bus.c new file +10
-0+ +kfree (mc_dev->regions); + +/* +* The device-specific remove callback will get invoked by device_del() +*/ +device_del (&mc_dev->dev); +put_device (&mc_dev->dev); + +if (strcmp (mc_dev->obj_desc.type,"dprc" ) ==0 ) {
I think it'll make the code easier to understand if you extract the strcmp into a helper function that actually explains what it does. Something like fsl_mc_dev_is_container().
Quoted 15 lines
drivers/bus/fsl-mc/mc-bus.c new file +15
-0+struct fsl_mc_io *mc_io = mc_dev->mc_io; + + mc_bus =to_fsl_mc_bus (mc_dev); +fsl_destroy_mc_io (mc_io); +if (&mc_dev->dev == fsl_mc_bus_type.dev_root) + fsl_mc_bus_type.dev_root =NULL ; + } + + mc_dev->mc_io =NULL ; +if (mc_bus) +devm_kfree (mc_dev->dev.parent, mc_bus); +else +kmem_cache_free (mc_dev_cache, mc_dev); +} +EXPORT_SYMBOL_GPL (fsl_mc_device_remove);
[...]
drivers/bus/fsl-mc/mc-bus.c line 633
Quoted 13 lines
drivers/bus/fsl-mc/mc-bus.c new file +13
-0+dev_info (&pdev->dev, +"Freescale Management Complex Firmware version: %u.%u.%u\n" , + mc_version.major, mc_version.minor, mc_version.revision); + +if (mc_version.major <MC_VER_MAJOR ) { +dev_err (&pdev->dev, +"ERROR: MC firmware version not supported by driver (driver version: %u.%u)\n" , +MC_VER_MAJOR ,MC_VER_MINOR ); + error = -ENOTSUPP ; + goto error_cleanup_mc_io; + } + +if (mc_version.major >MC_VER_MAJOR ) {
How about we introduce 2 defines for MIN/MAX from the beginning? Then we can adjust the range by only touching the defines later :).
Quoted 4 lines
drivers/bus/fsl-mc/mc-bus.c new file +4
-0+dev_warn (&pdev->dev, +"WARNING: driver may not support newer MC firmware features (driver version: %u.%u)\n" , +MC_VER_MAJOR ,MC_VER_MINOR ); + }
[...]
Quoted 27 lines
drivers/bus/fsl-mc/mc-bus.c new file +27
-0+static int __init fsl_mc_bus_driver_init (void ) +{ +int error; + + mc_dev_cache =kmem_cache_create ("fsl_mc_device" , +sizeof (struct fsl_mc_device ),0 ,0 , +NULL ); +if (!mc_dev_cache) { +pr_err ("Could not create fsl_mc_device cache\n" ); +return -ENOMEM ; + } + + error =bus_register (&fsl_mc_bus_type); +if (error <0 ) { +pr_err ("fsl-mc bus type registration failed: %d\n" , error); + goto error_cleanup_cache; + } + +pr_info ("fsl-mc bus type registered\n" ); + + error =platform_driver_register (&fsl_mc_bus_driver); +if (error <0 ) { +pr_err ("platform_driver_register() failed: %d\n" , error); + goto error_cleanup_bus; + } + +return 0 ;
drivers/bus/fsl-mc/mc-bus.c line 741
Quoted 10 lines
drivers/bus/fsl-mc/mc-bus.c new file +10
-0+ +error_cleanup_bus: +bus_unregister (&fsl_mc_bus_type); + +error_cleanup_cache: +kmem_cache_destroy (mc_dev_cache); +return error; +} + +postcore_initcall (fsl_mc_bus_driver_init);
How does this get hooked up when compiled as a module?
Alex
PATCH v7 3/3 drivers/bus: Device driver for FSL-MC DPRC devices
In reply to J. German RiveraA DPRC (Data Path Resource Container) is an isolation device that contains a set of DPAA networking devices to be assigned to an isolation domain (e.g., a virtual machine).
---
Changes in v7:
- Create fsl_mc_io object in dprc_probe()
Changes in v6:
- Fixed new checkpatch warnings
Changes in v5:
None
Changes in v4:
- Addressed comments from Alex Graf:
* Fixed typo in comment
Changes in v3:
- Addressed comments from Kim Phillips:
* Renamed files:
drivers/bus/fsl-mc/fsl_mc_dprc.c -> drivers/bus/fsl-mc/dprc-driver.c
- Addressed comments from Timur Tabi:
* Changed dprc_scan_container() to just return dprc_scan_objects()
* Changed all functions that had goto out/error when no common cleanup was done, to just have multiple return points.
* Replaced error cleanup boolean flags with multiple exit points.
* REmoved __must_chewck from dprc_scan_*() functions
Changes in v2:
- Addressed comments from Kim Phillips:
* Fix warning in drivers/bus/fsl-mc/fsl_mc_dprc.c:173
* Fixed linker errors when MC bus driver built as module
drivers/bus/fsl-mc/Makefile | 3 +- drivers/bus/fsl-mc/dprc-driver.c | 384 +++++++++++++++++++++++++++++++++++++++ drivers/bus/fsl-mc/mc-bus.c | 8 + include/linux/fsl/mc-private.h | 10 + 4 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/fsl-mc/dprc-driver.c
drivers/bus/fsl-mc/Makefile +2 -1
@@ -10,5 +10,6 @@ obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o mc-bus-driver-objs := mc-bus.o \ mc-sys.o \ dprc.o \ - dpmng.o + dpmng.o \ + dprc-driver.o
drivers/bus/fsl-mc/dprc-driver.c new file +384 -0
384 lines not on this page · raw message
drivers/bus/fsl-mc/mc-bus.c +8 -0
@@ -728,8 +728,15 @@ static int __init fsl_mc_bus_driver_init(void) goto error_cleanup_bus; } + error =dprc_driver_init (); +if (error <0 ) + goto error_cleanup_driver; +return 0 ; +error_cleanup_driver: +platform_driver_unregister (&fsl_mc_bus_driver); + error_cleanup_bus:bus_unregister (&fsl_mc_bus_type);
@@ -745,6 +752,7 @@ static void __exit fsl_mc_bus_driver_exit(void)if (WARN_ON (!mc_dev_cache))return ; +dprc_driver_exit ();platform_driver_unregister (&fsl_mc_bus_driver);bus_unregister (&fsl_mc_bus_type);kmem_cache_destroy (mc_dev_cache);
include/linux/fsl/mc-private.h +10 -0
@@ -15,6 +15,8 @@#include <linux/mutex.h> #include <linux/stringify.h> +#define FSL_MC_DPRC_DRIVER_NAME "fsl_mc_dprc" +#define FSL_MC_DEVICE_MATCH (_mc_dev, _obj_desc) \ (strcmp((_mc_dev)->obj_desc.type, (_obj_desc)->type) == 0 && \ (_mc_dev)->obj_desc.id == (_obj_desc)->id)
@@ -64,4 +66,12 @@ int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc,void fsl_mc_device_remove (struct fsl_mc_device *mc_dev); +int dprc_scan_container (struct fsl_mc_device *mc_bus_dev); + +int dprc_scan_objects (struct fsl_mc_device *mc_bus_dev); + +int __init dprc_driver_init (void ); + +void __exit dprc_driver_exit(void); +#endif /* _FSL_MC_PRIVATE_H_ */
--
2.3.0
Re: [PATCH v7 3/3] drivers/bus: Device driver for FSL-MC DPRC devices
Quoted 294 lines · J. German Rivera
A DPRC (Data Path Resource Container) is an isolation device that contains a set of DPAA networking devices to be assigned to an isolation domain (e.g., a virtual machine).
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>---
Changes in v7:
- Createfsl_mc_ioobject indprc_probe()Changes in v6:
- Fixed new checkpatch warningsChanges in v5:
NoneChanges in v4:
- Addressed comments from Alex Graf:
* Fixed typo in commentChanges in v3:
- Addressed comments from Kim Phillips:
* Renamed files:drivers/bus/fsl-mc/fsl_mc_dprc.c -> drivers/bus/fsl-mc/dprc-driver.c- Addressed comments from Timur Tabi:
* Changeddprc_scan_container()to just returndprc_scan_objects()
* Changed all functions that had goto out/error when no common cleanup was done, to just have multiple return points.
* Replaced error cleanup boolean flags with multiple exit points.
* REmoved__must_chewckfrom dprc_scan_*() functionsChanges in v2:
- Addressed comments from Kim Phillips:
* Fix warning indrivers/bus/fsl-mc/fsl_mc_dprc.c:173
* Fixed linker errors when MC bus driver built as moduledrivers/bus/fsl-mc/Makefile | 3 +- drivers/bus/fsl-mc/dprc-driver.c | 384 +++++++++++++++++++++++++++++++++++++++ drivers/bus/fsl-mc/mc-bus.c | 8 + include/linux/fsl/mc-private.h | 10 + 4 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/fsl-mc/dprc-driver.cdrivers/bus/fsl-mc/Makefile +2
-1@@ -10,5 +10,6 @@ obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o mc-bus-driver-objs := mc-bus.o \ mc-sys.o \ dprc.o \ - dpmng.o + dpmng.o \ + dprc-driver.odrivers/bus/fsl-mc/dprc-driver.c new file +232
-0@@ -0,0 +1,384 @@ +/* +* Freescale data path resource container (DPRC) driver +* +* Copyright (C) 2014 Freescale Semiconductor, Inc. +* Author: German Rivera <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/fsl/mc-private.h> +#include <linux/fsl/mc-sys.h> +#include <linux/module.h> +#include <linux/slab.h> +#include "dprc-cmd.h" + +struct dprc_child_objs { +int child_count; +struct dprc_obj_desc *child_array; +}; + +static int __fsl_mc_device_remove_if_not_in_mc (struct device *dev,void *data) +{ +int i; +struct dprc_child_objs *objs; +struct fsl_mc_device *mc_dev; + +WARN_ON (!dev); +WARN_ON (!data); + mc_dev =to_fsl_mc_device (dev); + objs = data; + +for (i =0 ; i < objs->child_count; i++) { +struct dprc_obj_desc *obj_desc = &objs->child_array[i]; + +if (strlen (obj_desc->type) !=0 && +FSL_MC_DEVICE_MATCH (mc_dev, obj_desc)) +break ; + } + +if (i == objs->child_count) +fsl_mc_device_remove (mc_dev); + +return 0 ; +} + +static int __fsl_mc_device_remove (struct device *dev,void *data) +{ +WARN_ON (!dev); +WARN_ON (data); +fsl_mc_device_remove (to_fsl_mc_device (dev)); +return 0 ; +} + +/** +* dprc_remove_devices - Removes devices for objects removed from a DPRC +* +* @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object +* @obj_desc_array: array of object descriptors for child objects currently +* present in the DPRC in the MC. +* @num_child_objects_in_mc: number of entries in obj_desc_array +* +* Synchronizes the state of the Linux bus driver with the actual state of +* the MC by removing devices that represent MC objects that have +* been dynamically removed in the physical DPRC. +*/ +static void dprc_remove_devices (struct fsl_mc_device *mc_bus_dev, +struct dprc_obj_desc *obj_desc_array, +int num_child_objects_in_mc) +{ +if (num_child_objects_in_mc !=0 ) { +/* +* Remove child objects that are in the DPRC in Linux, +* but not in the MC: +*/ +struct dprc_child_objs objs; + + objs.child_count = num_child_objects_in_mc; + objs.child_array = obj_desc_array; +device_for_each_child (&mc_bus_dev->dev, &objs, + __fsl_mc_device_remove_if_not_in_mc); + }else { +/* +* There are no child objects for this DPRC in the MC. +* So, remove all the child devices from Linux: +*/ +device_for_each_child (&mc_bus_dev->dev,NULL , + __fsl_mc_device_remove); + } +} + +static int __fsl_mc_device_match (struct device *dev,void *data) +{ +struct dprc_obj_desc *obj_desc = data; +struct fsl_mc_device *mc_dev =to_fsl_mc_device (dev); + +return FSL_MC_DEVICE_MATCH (mc_dev, obj_desc); +} + +static struct fsl_mc_device *fsl_mc_device_lookup (struct dprc_obj_desc + *obj_desc, +struct fsl_mc_device + *mc_bus_dev) +{ +struct device *dev; + + dev =device_find_child (&mc_bus_dev->dev, obj_desc, + __fsl_mc_device_match); + +return dev ?to_fsl_mc_device (dev) :NULL ; +} + +/** +* dprc_add_new_devices - Adds devices to the logical bus for a DPRC +* +* @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object +* @obj_desc_array: array of device descriptors for child devices currently +* present in the physical DPRC. +* @num_child_objects_in_mc: number of entries in obj_desc_array +* +* Synchronizes the state of the Linux bus driver with the actual +* state of the MC by adding objects that have been newly discovered +* in the physical DPRC. +*/ +static void dprc_add_new_devices (struct fsl_mc_device *mc_bus_dev, +struct dprc_obj_desc *obj_desc_array, +int num_child_objects_in_mc) +{ +int error; +int i; + +for (i =0 ; i < num_child_objects_in_mc; i++) { +struct fsl_mc_device *child_dev; +struct fsl_mc_io *mc_io =NULL ; +struct dprc_obj_desc *obj_desc = &obj_desc_array[i]; + +if (strlen (obj_desc->type) ==0 ) +continue ; + +/* +* Check if device is already known to Linux: +*/ + child_dev =fsl_mc_device_lookup (obj_desc, mc_bus_dev); +if (child_dev) +continue ; + + error =fsl_mc_device_add (obj_desc, mc_io, &mc_bus_dev->dev, + &child_dev); +if (error <0 ) { +if (mc_io) +fsl_destroy_mc_io (mc_io); + +continue ; + } + } +} + +/** +* dprc_scan_objects - Discover objects in a DPRC +* +* @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object +* +* Detects objects added and removed from a DPRC and synchronizes the +* state of the Linux bus driver, MC by adding and removing +* devices accordingly. +*/ +int dprc_scan_objects (struct fsl_mc_device *mc_bus_dev) +{ +int num_child_objects; +int dprc_get_obj_failures; +int error; +struct dprc_obj_desc *child_obj_desc_array =NULL ; + + error =dprc_get_obj_count (mc_bus_dev->mc_io, + mc_bus_dev->mc_handle, + &num_child_objects); +if (error <0 ) { +dev_err (&mc_bus_dev->dev,"dprc_get_obj_count() failed: %d\n" , + error); +return error; + } + +if (num_child_objects !=0 ) { +int i; + + child_obj_desc_array = +devm_kmalloc_array (&mc_bus_dev->dev, num_child_objects, +sizeof (*child_obj_desc_array), +GFP_KERNEL ); +if (!child_obj_desc_array) +return -ENOMEM ; + +/* +* Discover objects currently present in the physical DPRC: +*/ + dprc_get_obj_failures =0 ; +for (i =0 ; i < num_child_objects; i++) { +struct dprc_obj_desc *obj_desc = + &child_obj_desc_array[i]; + + error =dprc_get_obj (mc_bus_dev->mc_io, + mc_bus_dev->mc_handle, + i, obj_desc); +if (error <0 ) { +dev_err (&mc_bus_dev->dev, +"dprc_get_obj(i=%d) failed: %d\n" , + i, error); +/* +* Mark the obj entry as "invalid", by using the +* empty string as obj type: +*/ + obj_desc->type[0 ] ='\0' ; + obj_desc->id = error; + dprc_get_obj_failures++; +continue ; + } + +dev_dbg (&mc_bus_dev->dev, +"Discovered object: type %s, id %d\n" , + obj_desc->type, obj_desc->id); + } + +if (dprc_get_obj_failures !=0 ) { +dev_err (&mc_bus_dev->dev, +"%d out of %d devices could not be retrieved\n" , + dprc_get_obj_failures, num_child_objects); + } + } + +dprc_remove_devices (mc_bus_dev, child_obj_desc_array, + num_child_objects);
drivers/bus/fsl-mc/dprc-driver.c line 242
Quoted 10 lines
drivers/bus/fsl-mc/dprc-driver.c new file +10
-0+ +dprc_add_new_devices (mc_bus_dev, child_obj_desc_array, + num_child_objects); + +if (child_obj_desc_array) +devm_kfree (&mc_bus_dev->dev, child_obj_desc_array); + +return 0 ; +} +EXPORT_SYMBOL_GPL (dprc_scan_objects);
Why is this exported?
Quoted 13 lines
drivers/bus/fsl-mc/dprc-driver.c new file +13
-0+ +/** +* dprc_scan_container - Scans a physical DPRC and synchronizes Linux bus state +* +* @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object +* +* Scans the physical DPRC and synchronizes the state of the Linux +* bus driver with the actual state of the MC by adding and removing +* devices as appropriate. +*/ +int dprc_scan_container (struct fsl_mc_device *mc_bus_dev) +{ +int error;
drivers/bus/fsl-mc/dprc-driver.c line 265
Quoted 10 lines
drivers/bus/fsl-mc/dprc-driver.c new file +10
-0+struct fsl_mc_bus *mc_bus =to_fsl_mc_bus (mc_bus_dev); + +/* +* Discover objects in the DPRC: +*/ +mutex_lock (&mc_bus->scan_mutex); + error =dprc_scan_objects (mc_bus_dev); +mutex_unlock (&mc_bus->scan_mutex); +return error; +}
Or rather why does the split exist at all? Can't you just fold the locking into the scan function?
Alex