bus: fsl-mc: enhance Management Complex userspace support
Subsystems (5)
Ioana Ciornei
maintainerv2 cover bus: fsl-mc: enhance Management Complex userspace support
This patch set adds restool support in fsl-mc bus along with a rescan attribute to the root DPRC container.
Changes in v2:
- changed mc_command in fsl_mc_command structure
- updated fsl_mc_command to use the proper types and moved it in uapi
- added proper sysfs documentation
Ioana Ciornei (6):
bus: fsl-mc: change mc_command in fsl_mc_command
bus: fsl-mc: move fsl_mc_command struct in a uapi header
bus: fsl-mc: add fsl_mc_allocator cleanup function
bus: fsl-mc: add restool userspace support
bus: fsl-mc: add root dprc rescan attribute
bus: fsl-mc: add bus rescan attribute
Documentation/ABI/stable/sysfs-bus-fsl-mc | 13 ++ Documentation/ioctl/ioctl-number.txt | 1 + Documentation/networking/dpaa2/overview.rst | 4 + MAINTAINERS | 2 + drivers/bus/fsl-mc/Kconfig | 7 + drivers/bus/fsl-mc/Makefile | 3 + drivers/bus/fsl-mc/dpbp.c | 12 +- drivers/bus/fsl-mc/dpcon.c | 14 +- drivers/bus/fsl-mc/dpmcp.c | 6 +- drivers/bus/fsl-mc/dprc-driver.c | 4 +- drivers/bus/fsl-mc/dprc.c | 28 ++-- drivers/bus/fsl-mc/fsl-mc-allocator.c | 5 + drivers/bus/fsl-mc/fsl-mc-bus.c | 97 +++++++++++- drivers/bus/fsl-mc/fsl-mc-private.h | 53 +++++++ drivers/bus/fsl-mc/fsl-mc-restool.c | 219 ++++++++++++++++++++++++++++ drivers/bus/fsl-mc/mc-sys.c | 20 +-- drivers/staging/fsl-dpaa2/ethernet/dpni.c | 84 +++++------ drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 64 ++++---- drivers/staging/fsl-mc/bus/dpio/dpio.c | 12 +- include/linux/fsl/mc.h | 16 +- include/uapi/linux/fsl_mc.h | 31 ++++ 21 files changed, 561 insertions(+), 134 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-bus-fsl-mc create mode 100644 drivers/bus/fsl-mc/fsl-mc-restool.c create mode 100644 include/uapi/linux/fsl_mc.h
Signature · 1 line
1.9.1
Ioana Ciornei
maintainerPATCH v2 1/6 bus: fsl-mc: change mc_command in fsl_mc_command
The "struct mc_command" is a very generic name for a global kernel structure. Change its name in "struct fsl_mc_command".
---
Changes in v2:
- added the patch itself
drivers/bus/fsl-mc/dpbp.c | 12 ++--- drivers/bus/fsl-mc/dpcon.c | 14 +++--- drivers/bus/fsl-mc/dpmcp.c | 6 +-- drivers/bus/fsl-mc/dprc.c | 28 +++++------ drivers/bus/fsl-mc/fsl-mc-bus.c | 2 +- drivers/bus/fsl-mc/mc-sys.c | 20 ++++---- drivers/staging/fsl-dpaa2/ethernet/dpni.c | 84 +++++++++++++++---------------- drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 64 +++++++++++------------ drivers/staging/fsl-mc/bus/dpio/dpio.c | 12 ++--- include/linux/fsl/mc.h | 10 ++-- 10 files changed, 126 insertions(+), 126 deletions(-)
drivers/bus/fsl-mc/dpbp.c +6 -6
@@ -31,7 +31,7 @@ int dpbp_open(struct fsl_mc_io *mc_io,int dpbp_id, u16 *token) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpbp_cmd_open *cmd_params;int err;
@@ -68,7 +68,7 @@ int dpbp_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLOSE, cmd_flags,
@@ -91,7 +91,7 @@ int dpbp_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_ENABLE, cmd_flags,
@@ -114,7 +114,7 @@ int dpbp_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE,
@@ -137,7 +137,7 @@ int dpbp_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET,
@@ -163,7 +163,7 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io,u16 token, struct dpbp_attr *attr) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpbp_rsp_get_attributes *rsp_params;int err;
drivers/bus/fsl-mc/dpcon.c +7 -7
@@ -31,7 +31,7 @@ int dpcon_open(struct fsl_mc_io *mc_io,int dpcon_id, u16 *token) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpcon_cmd_open *dpcon_cmd;int err;
@@ -69,7 +69,7 @@ int dpcon_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE,
@@ -93,7 +93,7 @@ int dpcon_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_ENABLE,
@@ -117,7 +117,7 @@ int dpcon_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE,
@@ -141,7 +141,7 @@ int dpcon_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET,
@@ -166,7 +166,7 @@ int dpcon_get_attributes(struct fsl_mc_io *mc_io,u16 token, struct dpcon_attr *attr) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpcon_rsp_get_attr *dpcon_rsp;int err;
@@ -204,7 +204,7 @@ int dpcon_set_notification(struct fsl_mc_io *mc_io,u16 token, struct dpcon_notification_cfg *cfg) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpcon_cmd_set_notification *dpcon_cmd;/* prepare command */
drivers/bus/fsl-mc/dpmcp.c +3 -3
@@ -30,7 +30,7 @@ int dpmcp_open(struct fsl_mc_io *mc_io,int dpmcp_id, u16 *token) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpmcp_cmd_open *cmd_params;int err;
@@ -66,7 +66,7 @@ int dpmcp_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CLOSE,
@@ -88,7 +88,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_RESET,
drivers/bus/fsl-mc/dprc.c +14 -14
@@ -24,7 +24,7 @@ int dprc_open(struct fsl_mc_io *mc_io,int container_id, u16 *token) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_cmd_open *cmd_params;int err;
@@ -61,7 +61,7 @@ int dprc_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLOSE, cmd_flags,
@@ -88,7 +88,7 @@ int dprc_set_irq(struct fsl_mc_io *mc_io,u8 irq_index, struct dprc_irq_cfg *irq_cfg) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_cmd_set_irq *cmd_params;/* prepare command */
@@ -126,7 +126,7 @@ int dprc_set_irq_enable(struct fsl_mc_io *mc_io, u8 irq_index, u8 en) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };struct dprc_cmd_set_irq_enable *cmd_params;/* prepare command */
@@ -162,7 +162,7 @@ int dprc_set_irq_mask(struct fsl_mc_io *mc_io, u8 irq_index, u32 mask) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };struct dprc_cmd_set_irq_mask *cmd_params;/* prepare command */
@@ -194,7 +194,7 @@ int dprc_get_irq_status(struct fsl_mc_io *mc_io,u8 irq_index, u32 *status) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_cmd_get_irq_status *cmd_params;struct dprc_rsp_get_irq_status *rsp_params;int err;
@@ -236,7 +236,7 @@ int dprc_clear_irq_status(struct fsl_mc_io *mc_io, u8 irq_index, u32 status) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };struct dprc_cmd_clear_irq_status *cmd_params;/* prepare command */
@@ -264,7 +264,7 @@ int dprc_get_attributes(struct fsl_mc_io *mc_io,u16 token, struct dprc_attributes *attr) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_rsp_get_attributes *rsp_params;int err;
@@ -302,7 +302,7 @@ int dprc_get_obj_count(struct fsl_mc_io *mc_io,u16 token, int *obj_count) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_rsp_get_obj_count *rsp_params;int err;
@@ -344,7 +344,7 @@ int dprc_get_obj(struct fsl_mc_io *mc_io,int obj_index, struct fsl_mc_obj_desc *obj_desc) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_cmd_get_obj *cmd_params;struct dprc_rsp_get_obj *rsp_params;int err;
@@ -399,7 +399,7 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io,u8 irq_index, struct dprc_irq_cfg *irq_cfg) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_cmd_set_obj_irq *cmd_params;/* prepare command */
@@ -440,7 +440,7 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,u8 region_index, struct dprc_region_desc *region_desc) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dprc_cmd_get_obj_region *cmd_params;struct dprc_rsp_get_obj_region *rsp_params;int err;
@@ -482,7 +482,7 @@ int dprc_get_api_version(struct fsl_mc_io *mc_io, u16 *major_ver, u16 *minor_ver) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };int err;/* prepare command */
@@ -512,7 +512,7 @@ int dprc_get_container_id(struct fsl_mc_io *mc_io,u32 cmd_flags, int *container_id) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };int err;/* prepare command */
drivers/bus/fsl-mc/fsl-mc-bus.c +1 -1
@@ -314,7 +314,7 @@ static int mc_get_version(struct fsl_mc_io *mc_io,u32 cmd_flags, struct mc_version *mc_ver_info) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpmng_rsp_get_version *rsp_params;int err;
drivers/bus/fsl-mc/mc-sys.c +10 -10
@@ -28,14 +28,14 @@#define MC_CMD_COMPLETION_POLLING_MIN_SLEEP_USECS 10#define MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS 500 -static enum mc_cmd_status mc_cmd_hdr_read_status (struct mc_command *cmd) +static enum mc_cmd_status mc_cmd_hdr_read_status (struct fsl_mc_command *cmd) {struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;return (enum mc_cmd_status )hdr->status; } -static u16 mc_cmd_hdr_read_cmdid (struct mc_command *cmd) +static u16 mc_cmd_hdr_read_cmdid (struct fsl_mc_command *cmd) {struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;u16 cmd_id =le16_to_cpu (hdr->cmd_id);
@@ -94,8 +94,8 @@ static const char *mc_status_to_string(enum mc_cmd_status status)* @portal: pointer to an MC portal * @cmd: pointer to a filled command */ -static inline void mc_write_command (struct mc_command __iomem *portal, -struct mc_command *cmd) +static inline void mc_write_command (struct fsl_mc_command __iomem *portal, +struct fsl_mc_command *cmd) {int i;
@@ -121,9 +121,9 @@ static inline void mc_write_command(struct mc_command __iomem *portal,* * Returns MC_CMD_STATUS_OK on Success; Error code otherwise. */ -static inline enum mc_cmd_status mc_read_response (struct mc_command __iomem * - portal, -struct mc_command *resp) +static inline enum mc_cmd_status mc_read_response (struct fsl_mc_command __iomem + *portal, +struct fsl_mc_command *resp) {int i;enum mc_cmd_status status;
@@ -156,7 +156,7 @@ static inline enum mc_cmd_status mc_read_response(struct mc_command __iomem ** @mc_status: MC command completion status */ static int mc_polling_wait_preemptible (struct fsl_mc_io *mc_io, -struct mc_command *cmd, +struct fsl_mc_command *cmd,enum mc_cmd_status *mc_status) {enum mc_cmd_status status;
@@ -202,7 +202,7 @@ static int mc_polling_wait_preemptible(struct fsl_mc_io *mc_io,* @mc_status: MC command completion status */ static int mc_polling_wait_atomic (struct fsl_mc_io *mc_io, -struct mc_command *cmd, +struct fsl_mc_command *cmd,enum mc_cmd_status *mc_status) {enum mc_cmd_status status;
@@ -241,7 +241,7 @@ static int mc_polling_wait_atomic(struct fsl_mc_io *mc_io,* * Returns '0' on Success; Error code otherwise. */ -int mc_send_command (struct fsl_mc_io *mc_io,struct mc_command *cmd) +int mc_send_command (struct fsl_mc_io *mc_io,struct fsl_mc_command *cmd) {int error;enum mc_cmd_status status;
drivers/staging/fsl-dpaa2/ethernet/dpni.c +42 -42
336 lines not on this page · raw message
drivers/staging/fsl-dpaa2/ethsw/dpsw.c +32 -32
256 lines not on this page · raw message
drivers/staging/fsl-mc/bus/dpio/dpio.c +6 -6
@@ -37,7 +37,7 @@ int dpio_open(struct fsl_mc_io *mc_io,int dpio_id, u16 *token) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpio_cmd_open *dpio_cmd;int err;
@@ -70,7 +70,7 @@ int dpio_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE,
@@ -92,7 +92,7 @@ int dpio_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE,
@@ -114,7 +114,7 @@ int dpio_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };/* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE,
@@ -138,7 +138,7 @@ int dpio_get_attributes(struct fsl_mc_io *mc_io,u16 token, struct dpio_attr *attr) { - struct mc_command cmd = { 0 }; + struct fsl_mc_command cmd = { 0 };struct dpio_rsp_get_attr *dpio_rsp;int err;
@@ -180,7 +180,7 @@ int dpio_get_api_version(struct fsl_mc_io *mc_io, u16 *major_ver, u16 *minor_ver) { -struct mc_command cmd = {0 }; +struct fsl_mc_command cmd = {0 };int err;/* prepare command */
include/linux/fsl/mc.h +5 -5
@@ -209,7 +209,7 @@ struct mc_cmd_header {__le16 cmd_id; }; -struct mc_command { +struct fsl_mc_command {u64 header;u64 params[MC_CMD_NUM_OF_PARAMS ]; };
@@ -256,7 +256,7 @@ static inline u64 mc_encode_cmd_header(u16 cmd_id,return header; } -static inline u16 mc_cmd_hdr_read_token (struct mc_command *cmd) +static inline u16 mc_cmd_hdr_read_token (struct fsl_mc_command *cmd) {struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;u16 token =le16_to_cpu (hdr->token);
@@ -273,7 +273,7 @@ struct mc_rsp_api_ver {__le16 minor_ver; }; -static inline u32 mc_cmd_read_object_id (struct mc_command *cmd) +static inline u32 mc_cmd_read_object_id (struct fsl_mc_command *cmd) {struct mc_rsp_create *rsp_params;
@@ -281,7 +281,7 @@ static inline u32 mc_cmd_read_object_id(struct mc_command *cmd)return le32_to_cpu (rsp_params->object_id); } -static inline void mc_cmd_read_api_version (struct mc_command *cmd, +static inline void mc_cmd_read_api_version (struct fsl_mc_command *cmd,u16 *major_ver,u16 *minor_ver) {
@@ -342,7 +342,7 @@ struct fsl_mc_io { }; }; -int mc_send_command (struct fsl_mc_io *mc_io,struct mc_command *cmd); +int mc_send_command (struct fsl_mc_io *mc_io,struct fsl_mc_command *cmd);#ifdef CONFIG_FSL_MC_BUS #define dev_is_fsl_mc (_dev) ((_dev)->bus == &fsl_mc_bus_type)
Signature · 1 line
1.9.1
Ioana Ciornei
maintainerPATCH v2 2/6 bus: fsl-mc: move fsl_mc_command struct in a uapi header
In reply to Ioana CiorneiDefine "struct fsl_mc_command" as a structure that can cross the user/kernel boundary. Also change the variable types used with the proper ones.
---
Changes in v2:
- added the patch itself
MAINTAINERS | 1 + include/linux/fsl/mc.h | 8 +------- include/uapi/linux/fsl_mc.h | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 include/uapi/linux/fsl_mc.h
MAINTAINERS +1 -0
@@ -11463,6 +11463,7 @@ S: Maintained F: drivers/bus/fsl-mc/ F: Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt F: Documentation/networking/dpaa2/overview.rst +F: include/uapi/linux/fsl_mc.h QT1010 MEDIA DRIVER M: Antti Palosaari <[email protected]>
include/linux/fsl/mc.h +1 -7
@@ -12,6 +12,7 @@#include <linux/device.h> #include <linux/mod_devicetable.h> #include <linux/interrupt.h> +#include <uapi/linux/fsl_mc.h> #define FSL_MC_VENDOR_FREESCALE 0x1957
@@ -198,8 +199,6 @@ struct fsl_mc_device {#define to_fsl_mc_device (_dev) \ container_of(_dev, struct fsl_mc_device, dev) -#define MC_CMD_NUM_OF_PARAMS 7 -struct mc_cmd_header {u8 src_id;u8 flags_hw;
@@ -209,11 +208,6 @@ struct mc_cmd_header {__le16 cmd_id; }; -struct fsl_mc_command { -u64 header; -u64 params[MC_CMD_NUM_OF_PARAMS ]; -}; -enum mc_cmd_status {MC_CMD_STATUS_OK =0x0 ,/* Completed successfully */ MC_CMD_STATUS_READY =0x1 ,/* Ready to be processed */
include/uapi/linux/fsl_mc.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Management Complex (MC) userspace public interface +* +* Copyright 2018 NXP +* +*/ +#ifndef _UAPI_FSL_MC_H_ +#define _UAPI_FSL_MC_H_ + +#define MC_CMD_NUM_OF_PARAMS 7 + +/** +* struct fsl_mc_command - Management Complex (MC) command structure +* @header: MC command header +* @params: MC command parameters +*/ +struct fsl_mc_command { +__u64 header; +__u64 params[MC_CMD_NUM_OF_PARAMS ]; +}; + +#endif /* _UAPI_FSL_MC_H_ */
Signature · 1 line
1.9.1
Greg KH
maintainerRe: [PATCH v2 2/6] bus: fsl-mc: move fsl_mc_command struct in a uapi header
Quoted 66 lines · Ioana Ciornei
Define "struct
fsl_mc_command" as a structure that can cross the user/kernel boundary. Also change the variable types used with the proper ones.Signed-off-by Ioana Ciornei <[email protected]>---
Changes in v2:
- added the patch itselfMAINTAINERS | 1 + include/linux/fsl/mc.h | 8 +------- include/uapi/linux/fsl_mc.h | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 include/uapi/linux/fsl_mc.hMAINTAINERS +1
-0@@ -11463,6 +11463,7 @@ S: Maintained F: drivers/bus/fsl-mc/ F: Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt F: Documentation/networking/dpaa2/overview.rst +F: include/uapi/linux/fsl_mc.h QT1010 MEDIA DRIVER M: Antti Palosaari <[email protected]>include/linux/fsl/mc.h +1
-7@@ -12,6 +12,7 @@#include <linux/device.h> #include <linux/mod_devicetable.h> #include <linux/interrupt.h> +#include <uapi/linux/fsl_mc.h> #define FSL_MC_VENDOR_FREESCALE 0x1957@@ -198,8 +199,6 @@ struct fsl_mc_device {#define to_fsl_mc_device (_dev) \ container_of(_dev, struct fsl_mc_device, dev) -#define MC_CMD_NUM_OF_PARAMS 7 -struct mc_cmd_header {u8 src_id;u8 flags_hw;@@ -209,11 +208,6 @@ struct mc_cmd_header {__le16 cmd_id; }; -struct fsl_mc_command { -u64 header; -u64 params[MC_CMD_NUM_OF_PARAMS ]; -}; -enum mc_cmd_status {MC_CMD_STATUS_OK =0x0 ,/* Completed successfully */ MC_CMD_STATUS_READY =0x1 ,/* Ready to be processed */ include/uapi/linux/fsl_mc.h new file +0
-0
include/uapi/linux/fsl_mc.h line 1
Quoted 1 line
include/uapi/linux/fsl_mc.h new file +1
-0@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */
UAPI files should have the correct license on them:
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
thanks,
greg k-h
Ioana Ciornei
maintainerPATCH v2 3/6 bus: fsl-mc: add fsl_mc_allocator cleanup function
In reply to Ioana CiorneiThe userspace support for fsl-mc requires a fsl_mc_allocator cleanup function. Add the needed function.
---
Changes in v2:
- added the patch itself
drivers/bus/fsl-mc/fsl-mc-allocator.c | 5 +++++ drivers/bus/fsl-mc/fsl-mc-private.h | 2 ++ 2 files changed, 7 insertions(+)
drivers/bus/fsl-mc/fsl-mc-allocator.c +5 -0
@@ -646,3 +646,8 @@ int __init fsl_mc_allocator_driver_init(void) {return fsl_mc_driver_register (&fsl_mc_allocator_driver); } + +void fsl_mc_allocator_driver_exit (void ) +{ +fsl_mc_driver_unregister (&fsl_mc_allocator_driver); +}
drivers/bus/fsl-mc/fsl-mc-private.h +2 -0
@@ -525,6 +525,8 @@ int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,int __init fsl_mc_allocator_driver_init (void ); +void fsl_mc_allocator_driver_exit (void ); +void fsl_mc_init_all_resource_pools (struct fsl_mc_device *mc_bus_dev);void fsl_mc_cleanup_all_resource_pools (struct fsl_mc_device *mc_bus_dev);
Signature · 1 line
1.9.1
Ioana Ciornei
maintainerPATCH v2 4/6 bus: fsl-mc: add restool userspace support
In reply to Ioana CiorneiAdding kernel support for restool, a userspace tool for resource management, means exporting an ioctl capable device file representing the root resource container.
This new functionality in the fsl-mc bus driver intends to provide restool an interface to interact with the MC firmware. Commands that are composed in userspace are sent to the MC firmware through the RESTOOL_SEND_MC_COMMAND ioctl.
By default the implicit MC I/O portal is used for this operation, but if the implicit one is busy, a dynamic portal is allocated and then freed upon execution.
---
Changes in v2:
- split the bus/driver changes in a separate patch
- moved the ioctl in the uapi header file
Documentation/ioctl/ioctl-number.txt | 1 + Documentation/networking/dpaa2/overview.rst | 4 + drivers/bus/fsl-mc/Kconfig | 7 + drivers/bus/fsl-mc/Makefile | 3 + drivers/bus/fsl-mc/fsl-mc-bus.c | 19 +++ drivers/bus/fsl-mc/fsl-mc-private.h | 48 ++++++ drivers/bus/fsl-mc/fsl-mc-restool.c | 219 ++++++++++++++++++++++++++++ include/uapi/linux/fsl_mc.h | 8 + 8 files changed, 309 insertions(+) create mode 100644 drivers/bus/fsl-mc/fsl-mc-restool.c
Documentation/ioctl/ioctl-number.txt +1 -0
@@ -170,6 +170,7 @@ Code Seq#(hex) Include File Comments 'R' 00-1F linux/random.h conflict! 'R' 01 linux/rfkill.h conflict! 'R' C0-DF net/bluetooth/rfcomm.h +'R' E0 uapi/linux/fsl_mc.h 'S' all linux/cdrom.h conflict! 'S' 80-81 scsi/scsi_ioctl.h conflict! 'S' 82-FF scsi/scsi.h conflict!
Documentation/networking/dpaa2/overview.rst +4 -0
@@ -127,6 +127,10 @@ level. DPRCs can be defined statically and populated with objects via a config file passed to the MC when firmware starts it. +There is also a Linux user space tool called "restool" that can be +used to create/destroy containers and objects dynamically. The latest +version of restool can be found at: + https://github.com/qoriq-open-source/restool DPAA2 Objects for an Ethernet Network Interface -----------------------------------------------
drivers/bus/fsl-mc/Kconfig +7 -0
@@ -14,3 +14,10 @@ config FSL_MC_BUS architecture. The fsl-mc bus driver handles discovery of DPAA2 objects (which are represented as Linux devices) and binding objects to drivers. + +config FSL_MC_RESTOOL + bool "Management Complex (MC) restool support" + depends on FSL_MC_BUS + help + Provides kernel support for the Management Complex resource + manager user-space tool - restool.
drivers/bus/fsl-mc/Makefile +3 -0
@@ -16,3 +16,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \ fsl-mc-allocator.o \ fsl-mc-msi.o \ dpmcp.o + +# MC restool kernel support +obj-$(CONFIG_FSL_MC_RESTOOL) += fsl-mc-restool.o
drivers/bus/fsl-mc/fsl-mc-bus.c +19 -0
@@ -792,6 +792,7 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)struct fsl_mc *mc;struct fsl_mc_device *mc_bus_dev =NULL ;struct fsl_mc_io *mc_io =NULL ; +struct fsl_mc_bus *mc_bus =NULL ;int container_id;phys_addr_t mc_portal_phys_addr;u32 mc_portal_size;
@@ -863,9 +864,18 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)if (error <0 ) goto error_cleanup_mc_io; + mc_bus =to_fsl_mc_bus (mc_bus_dev); + error =fsl_mc_restool_create_device_file (mc_bus); +if (error <0 ) + goto error_cleanup_device; + mc->root_mc_bus_dev = mc_bus_dev; +return 0 ; +error_cleanup_device: +fsl_mc_device_remove (mc_bus_dev); + error_cleanup_mc_io:fsl_destroy_mc_io (mc_io);return error;
@@ -878,10 +888,12 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)static int fsl_mc_bus_remove (struct platform_device *pdev) {struct fsl_mc *mc =platform_get_drvdata (pdev); +struct fsl_mc_bus *mc_bus =to_fsl_mc_bus (mc->root_mc_bus_dev);if (!fsl_mc_is_root_dprc (&mc->root_mc_bus_dev->dev))return -EINVAL ; +fsl_mc_restool_remove_device_file (mc_bus);fsl_mc_device_remove (mc->root_mc_bus_dev);fsl_destroy_mc_io (mc->root_mc_bus_dev->mc_io);
@@ -931,8 +943,15 @@ static int __init fsl_mc_bus_driver_init(void)if (error <0 ) goto error_cleanup_dprc_driver; + error =fsl_mc_restool_init (); +if (error <0 ) + goto error_cleanup_mc_allocator; +return 0 ; +error_cleanup_mc_allocator: +fsl_mc_allocator_driver_exit (); + error_cleanup_dprc_driver:dprc_driver_exit ();
drivers/bus/fsl-mc/fsl-mc-private.h +48 -0
76 lines not on this page · raw message
drivers/bus/fsl-mc/fsl-mc-restool.c new file +219 -0
219 lines not on this page · raw message
include/uapi/linux/fsl_mc.h +8 -0
@@ -14,10 +14,18 @@* struct fsl_mc_command - Management Complex (MC) command structure * @header: MC command header * @params: MC command parameters +* +* Used by RESTOOL_SEND_MC_COMMAND */ struct fsl_mc_command {__u64 header;__u64 params[MC_CMD_NUM_OF_PARAMS ]; }; +#define RESTOOL_IOCTL_TYPE 'R' +#define RESTOOL_IOCTL_SEQ 0xE0 + +#define RESTOOL_SEND_MC_COMMAND \ + _IOWR(RESTOOL_IOCTL_TYPE, RESTOOL_IOCTL_SEQ, struct fsl_mc_command) +#endif /* _UAPI_FSL_MC_H_ */
Signature · 1 line
1.9.1
Ioana Ciornei
maintainerPATCH v2 5/6 bus: fsl-mc: add root dprc rescan attribute
In reply to Ioana CiorneiIntroduce the rescan attribute as a device attribute to synchronize the fsl-mc bus objects and the MC firmware.
To rescan the root dprc only, e.g.
echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan
---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Documentation/ABI/stable/sysfs-bus-fsl-mc | 6 ++++++ MAINTAINERS | 1 + drivers/bus/fsl-mc/dprc-driver.c | 4 ++-- drivers/bus/fsl-mc/fsl-mc-bus.c | 28 ++++++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl-mc-private.h | 3 +++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-bus-fsl-mc
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +6 -0
@@ -0,0 +1,6 @@ +What: /sys/bus/fsl-mc/devices/dprc.*/rescan +Date: March. 2018 +KernelVersion: 4.16 +Contact: Ioana Ciornei <[email protected]> +Description: Root dprc rescan attribute +Users: Userspace drivers and management tools
MAINTAINERS +1 -0
@@ -11464,6 +11464,7 @@ F: drivers/bus/fsl-mc/ F: Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt F: Documentation/networking/dpaa2/overview.rst F: include/uapi/linux/fsl_mc.h +F: Documentation/ABI/stable/sysfs-bus-fsl-mc QT1010 MEDIA DRIVER M: Antti Palosaari <[email protected]>
drivers/bus/fsl-mc/dprc-driver.c +2 -2
@@ -214,8 +214,8 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,* populated before they can get allocation requests from probe callbacks * of the device drivers for the non-allocatable devices. */ -static int dprc_scan_objects (struct fsl_mc_device *mc_bus_dev, -unsigned int *total_irq_count) +int dprc_scan_objects (struct fsl_mc_device *mc_bus_dev, +unsigned int *total_irq_count) {int num_child_objects;int dprc_get_obj_failures;
drivers/bus/fsl-mc/fsl-mc-bus.c +28 -0
@@ -137,8 +137,36 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (modalias); +static ssize_t rescan_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct fsl_mc_device *root_mc_dev; +struct fsl_mc_bus *root_mc_bus; +unsigned long val; + +if (!fsl_mc_is_root_dprc (dev)) +return -EINVAL ; + + root_mc_dev =to_fsl_mc_device (dev); + root_mc_bus =to_fsl_mc_bus (root_mc_dev); + +if (kstrtoul (buf,0 , &val) <0 ) +return -EINVAL ; + +if (val) { +mutex_lock (&root_mc_bus->scan_mutex); +dprc_scan_objects (root_mc_dev,NULL ); +mutex_unlock (&root_mc_bus->scan_mutex); + } + +return count; +} +static DEVICE_ATTR_WO (rescan); +static struct attribute *fsl_mc_dev_attrs[] = { &dev_attr_modalias.attr, + &dev_attr_rescan.attr,NULL , };
drivers/bus/fsl-mc/fsl-mc-private.h +3 -0
@@ -545,6 +545,9 @@ int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,void dprc_driver_exit (void ); +int dprc_scan_objects (struct fsl_mc_device *mc_bus_dev, +unsigned int *total_irq_count); +int __init fsl_mc_allocator_driver_init (void );void fsl_mc_allocator_driver_exit (void );
Signature · 1 line
1.9.1
Ioana Ciornei
maintainerPATCH v2 6/6 bus: fsl-mc: add bus rescan attribute
In reply to Ioana CiorneiIntroduce the rescan attribute as a bus attribute to synchronize the fsl-mc bus objects and the MC firmware.
To rescan the fsl-mc bus, e.g.,
echo 1 > /sys/bus/fsl-mc/rescan
---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Documentation/ABI/stable/sysfs-bus-fsl-mc | 7 +++++ drivers/bus/fsl-mc/fsl-mc-bus.c | 48 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
Documentation/ABI/stable/sysfs-bus-fsl-mc +7 -0
@@ -4,3 +4,10 @@ KernelVersion: 4.16 Contact: Ioana Ciornei <[email protected]> Description: Root dprc rescan attribute Users: Userspace drivers and management tools + +What: /sys/bus/fsl-mc/rescan +Date: March. 2018 +KernelVersion: 4.16 +Contact: Ioana Ciornei <[email protected]> +Description: Bus rescan attribute +Users: Userspace drivers and management tools
drivers/bus/fsl-mc/fsl-mc-bus.c +48 -0
59 lines not on this page · raw message
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 7 lines · Ioana Ciornei
This patch set adds restool support in fsl-mc bus along with a rescan attribute to the root DPRC container.
Changes in v2:
- changedmc_commandinfsl_mc_commandstructure
- updatedfsl_mc_commandto use the proper types and moved it in uapi
- added proper sysfs documentation
I've applied patches 1 and 3 here, can you redo patch 2 and resend them based on my tree?
thanks,
greg k-h
Ioana Ciornei
maintainerQuoted 10 lines
Quoted 7 lines
This patch set adds restool support in fsl-mc bus along with a rescan attribute to the root DPRC container.
Changes in v2:
- changedmc_commandinfsl_mc_commandstructure
- updatedfsl_mc_commandto use the proper types and moved it in uapi
- added proper sysfs documentationI've applied patches 1 and 3 here, can you redo patch 2 and resend them based on my tree?
Yes, sure. I will send the updated patch set right away.
Quoted 4 lines
thanks,
greg k-h