bus: fsl-mc: enhance Management Complex userspace support
Subsystems (3)
Ioana Ciornei
maintainercover 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.
Ioana Ciornei (3):
bus: fsl-mc: add restool userspace support
bus: fsl-mc: add root dprc rescan attribute
bus: fsl-mc: add bus rescan attribute
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/dprc-driver.c | 4 +- drivers/bus/fsl-mc/fsl-mc-allocator.c | 5 + drivers/bus/fsl-mc/fsl-mc-bus.c | 95 ++++++++++++ drivers/bus/fsl-mc/fsl-mc-private.h | 59 ++++++++ drivers/bus/fsl-mc/fsl-mc-restool.c | 219 ++++++++++++++++++++++++++++ 9 files changed, 395 insertions(+), 2 deletions(-) create mode 100644 drivers/bus/fsl-mc/fsl-mc-restool.c
Signature · 1 line
1.9.1
Ioana Ciornei
maintainerPATCH 1/3 bus: fsl-mc: add restool userspace support
Adding 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.
--- 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-allocator.c | 5 + drivers/bus/fsl-mc/fsl-mc-bus.c | 19 +++ drivers/bus/fsl-mc/fsl-mc-private.h | 56 +++++++ drivers/bus/fsl-mc/fsl-mc-restool.c | 219 ++++++++++++++++++++++++++++ 8 files changed, 314 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 drivers/bus/fsl-mc/fsl-mc-private.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
@@ -14,3 +14,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-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-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 +56 -0
95 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
Signature · 1 line
1.9.1
Re: [PATCH 1/3] bus: fsl-mc: add restool userspace support
Quoted 12 lines · Ioana Ciornei
Adding 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 theRESTOOL_SEND_MC_COMMANDioctl.
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.Signed-off-by Ioana Ciornei <[email protected]>
Quoted 9 lines
--- 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-allocator.c | 5 + drivers/bus/fsl-mc/fsl-mc-bus.c | 19 +++ drivers/bus/fsl-mc/fsl-mc-private.h | 56 +++++++ drivers/bus/fsl-mc/fsl-mc-restool.c | 219 ++++++++++++++++++++++++++++
This is a "tiny" patch, yet I think it needs to be broken up more, as you are mixing a few different things in the same patch, and you forgot one big thing...
Quoted 35 lines
8 files changed, 314 insertions(+) create mode 100644 drivers/bus/fsl-mc/fsl-mc-restool.cDocumentation/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 drivers/bus/fsl-mc/fsl-mc-private.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 +0
-0
drivers/bus/fsl-mc/Kconfig config FSL_MC_BUS · line 23
Quoted 10 lines
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.
Why would you want to make this a build option? Why would you ever _not_ want this?
Quoted 16 lines
drivers/bus/fsl-mc/Makefile +3
-0@@ -14,3 +14,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.odrivers/bus/fsl-mc/fsl-mc-allocator.c +0
-0
drivers/bus/fsl-mc/fsl-mc-allocator.c int __init fsl_mc_allocator_driver_init(void) · line 653
Quoted 8 lines
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); +}
Why are you mixing the bus/driver changes in with the addition of the ioctl? That should be broken out into the "first" patch of this series, to make the addition of the ioctl easier to see and review.
drivers/bus/fsl-mc/fsl-mc-allocator.c
Quoted 5 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c +5
-0+#define RESTOOL_IOCTL_TYPE 'R' +#define RESTOOL_IOCTL_SEQ 0xE0 + +#define RESTOOL_SEND_MC_COMMAND \ + _IOWR(RESTOOL_IOCTL_TYPE, RESTOOL_IOCTL_SEQ, struct mc_command)
"struct mc_command" is not defined as a structure that can cross the user/kernel boundry at all. At the least it is not in a public uapi header file. It also does not use the correct variable types, and it is a very generic name for a global kernel structure that the whole world is now going to be able to see.
Please fix all of that up first, before adding the ioctl itself :)
drivers/bus/fsl-mc/fsl-mc-allocator.c
Quoted 11 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c +11
-0+static int fsl_mc_restool_send_command (unsigned long arg, +struct fsl_mc_io *mc_io) +{ +struct mc_command mc_cmd; +int error; + + error =copy_from_user (&mc_cmd, (void __user *)arg,sizeof (mc_cmd)); +if (error) +return -EFAULT ; + + error =mc_send_command (mc_io, &mc_cmd);
are you doing correct error and validation checking of this user-provided structure? Remember, you can not trust this data at all.
All input is evil.
thanks,
greg k-h
Ioana Ciornei
maintainerRE: [PATCH 1/3] bus: fsl-mc: add restool userspace support
Hi,
Comments inline.
Quoted 21 lines
Quoted 12 lines
Adding 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 theRESTOOL_SEND_MC_COMMANDioctl.
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.Signed-off-by Ioana Ciornei <[email protected]>Quoted 9 lines
--- 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-allocator.c | 5 + drivers/bus/fsl-mc/fsl-mc-bus.c | 19 +++ drivers/bus/fsl-mc/fsl-mc-private.h | 56 +++++++ drivers/bus/fsl-mc/fsl-mc-restool.c | 219
Quoted 4 lines
++++++++++++++++++++++++++++
This is a "tiny" patch, yet I think it needs to be broken up more, as you are mixing a few different things in the same patch, and you forgot one big thing...
I will break the patch into multiple ones in the next version.
Quoted 44 lines
Documentation/ioctl/ioctl-number.txt Code Seq#(hex) Include File
Quoted 10 lines
8 files changed, 314 insertions(+) create mode 100644 drivers/bus/fsl-mc/fsl-mc-restool.cDocumentation/ioctl/ioctl-number.txt +0
-0@@ -170,6 +170,7 @@ Code Seq#(hex) Include FileComments
Quoted 33 lines
Documentation/ioctl/ioctl-number.txt +1
-0'R' 00-1F linux/random.h conflict! 'R' 01 linux/rfkill.h conflict! 'R' C0-DF net/bluetooth/rfcomm.h +'R' E0 drivers/bus/fsl-mc/fsl-mc-private.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 +0
-0@@ -127,6 +127,10 @@ level. DPRCs can be defined statically and populated with objects via aconfig file passed to the MC when firmware starts it.
Documentation/networking/dpaa2/overview.rst +5
-0+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 +2
-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
Quoted 8 lines
drivers/bus/fsl-mc/Kconfig config FSL_MC_BUS · line 23
Quoted 5 lines
drivers/bus/fsl-mc/Kconfig +5
-0+ 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.Why would you want to make this a build option? Why would you ever _not_ want this?
Using the restool user-space tool for managing MC resources is not the only possibility for creating/destroying MC objects, changing their properties, etc. While restool's intended use is in a dynamic context, users also have the option to deploy a static configuration using a Data Path Layout file that describes the MC resource configuration. In this case, the restool support is no longer needed.
Quoted 23 lines
Quoted 23 lines
drivers/bus/fsl-mc/Makefile +3
-0@@ -14,3 +14,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.odrivers/bus/fsl-mc/fsl-mc-allocator.c +1
-0@@ -646,3 +646,8 @@ int __init fsl_mc_allocator_driver_init(void) {return fsl_mc_driver_register (&fsl_mc_allocator_driver); } +
Quoted 8 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c int __init fsl_mc_allocator_driver_init(void) · line 653
Quoted 4 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c +4
-0+void fsl_mc_allocator_driver_exit (void ) +{ +fsl_mc_driver_unregister (&fsl_mc_allocator_driver); +}Why are you mixing the bus/driver changes in with the addition of the ioctl? That should be broken out into the "first" patch of this series, to make the addition of the ioctl easier to see and review.
Will split the bus changes into a separate patch.
Quoted 8 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c
Quoted 6 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c +5
-0+#define RESTOOL_IOCTL_TYPE 'R' +#define RESTOOL_IOCTL_SEQ 0xE0 + +#define RESTOOL_SEND_MC_COMMAND \ + _IOWR(RESTOOL_IOCTL_TYPE, RESTOOL_IOCTL_SEQ, struct
mc_command)
Quoted 6 lines
"struct
mc_command" is not defined as a structure that can cross the user/kernel boundry at all. At the least it is not in a public uapi header file. It also does not use the correct variable types, and it is a very generic name for a global kernel structure that the whole world is now going to be able to see.Please fix all of that up first, before adding the ioctl itself :)
I will move the mc_command structure into a uapi header file for the fsl-mc bus in the next version of the patchset.
Quoted 9 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c
Quoted 8 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c +7
-0+static int fsl_mc_restool_send_command (unsigned long arg, +struct fsl_mc_io *mc_io) +{ +struct mc_command mc_cmd; +int error; + + error = copy_from_user(&mc_cmd, (void __user *)arg,
sizeof(mc_cmd));
Quoted 7 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c
Quoted 4 lines
drivers/bus/fsl-mc/fsl-mc-allocator.c +4
-0+if (error) +return -EFAULT ; + + error =mc_send_command (mc_io, &mc_cmd);are you doing correct error and validation checking of this user-provided structure? Remember, you can not trust this data at all.
The Management Complex is the one validating the commands received.
The restool support in the bus driver is just a passthrough for the commands passed from user-space and their associated responses from the MC firmware.
Quoted 6 lines
All input is evil.
thanks,
greg k-h
Ioana Ciornei
maintainerPATCH 2/3 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
--- 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 +++ 3 files changed, 33 insertions(+), 2 deletions(-)
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
@@ -464,6 +464,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
Re: [PATCH 2/3] bus: fsl-mc: add root dprc rescan attribute
Quoted 52 lines · Ioana Ciornei
Introduce 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/rescanSigned-off-by Ioana Ciornei <[email protected]>--- 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 +++ 3 files changed, 33 insertions(+), 2 deletions(-)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 +16
-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 ;
drivers/bus/fsl-mc/fsl-mc-bus.c static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, · line 165
Quoted 10 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +10
-0+ +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);
You did not add the correct new documentation in Documentation/ABI/ for the new sysfs attributes you are creating. Please do so as part of this patch series.
thanks,
greg k-h
Ioana Ciornei
maintainerRE: [PATCH 2/3] bus: fsl-mc: add root dprc rescan attribute
Quoted 59 lines
drivers/bus/fsl-mc/dprc-driver.c static void dprc_add_new_devices(struct
Quoted 20 lines
Introduce 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/rescanSigned-off-by Ioana Ciornei <[email protected]>--- 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 +++ 3 files changed, 33 insertions(+), 2 deletions(-)drivers/bus/fsl-mc/dprc-driver.c +0
-0@@ -214,8 +214,8 @@ static void dprc_add_new_devices(struct
fsl_mc_device*mc_bus_dev,Quoted 38 lines
drivers/bus/fsl-mc/dprc-driver.c +2
-2* 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;(quoted diff) +0
-0
b/drivers/bus/fsl-mc/fsl-mc-bus.cindex 240b99d..763cbeb 100644drivers/bus/fsl-mc/fsl-mc-bus.c +21
-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); + }
Quoted 8 lines
drivers/bus/fsl-mc/fsl-mc-bus.c static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, · line 165
Quoted 4 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +4
-0+ +return count; +} +static DEVICE_ATTR_WO (rescan);You did not add the correct new documentation in
Documentation/ABI/for the new sysfs attributes you are creating. Please do so as part of this patch series.
Sorry for that. Will add the proper Documentation in the next version.
Ioana
Quoted 4 lines
thanks,
greg k-h
Ioana Ciornei
maintainerPATCH 3/3 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
--- drivers/bus/fsl-mc/fsl-mc-bus.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
drivers/bus/fsl-mc/fsl-mc-bus.c +48 -0
@@ -172,11 +172,59 @@ static ssize_t rescan_store(struct device *dev,ATTRIBUTE_GROUPS (fsl_mc_dev); +static int scan_fsl_mc_bus (struct device *dev,void *data) +{ +struct fsl_mc_device *root_mc_dev; +struct fsl_mc_bus *root_mc_bus; + +if (!fsl_mc_is_root_dprc (dev)) + goto exit; + + root_mc_dev =to_fsl_mc_device (dev); + root_mc_bus =to_fsl_mc_bus (root_mc_dev); +mutex_lock (&root_mc_bus->scan_mutex); +dprc_scan_objects (root_mc_dev,NULL ); +mutex_unlock (&root_mc_bus->scan_mutex); + +exit: +return 0 ; +} + +static ssize_t bus_rescan_store (struct bus_type *bus, +const char *buf,size_t count) +{ +unsigned long val; + +if (kstrtoul (buf,0 , &val) <0 ) +return -EINVAL ; + +if (val) +bus_for_each_dev (bus,NULL ,NULL , scan_fsl_mc_bus); + +return count; +} +static BUS_ATTR(rescan, 0220, NULL, bus_rescan_store); + +static struct attribute *fsl_mc_bus_attrs[] = { + &bus_attr_rescan.attr, +NULL , +}; + +static const struct attribute_group fsl_mc_bus_group = { + .attrs = fsl_mc_bus_attrs, +}; + +static const struct attribute_group *fsl_mc_bus_groups[] = { + &fsl_mc_bus_group, +NULL , +}; +struct bus_type fsl_mc_bus_type = { .name ="fsl-mc" , .match = fsl_mc_bus_match, .uevent = fsl_mc_bus_uevent, .dev_groups = fsl_mc_dev_groups, + .bus_groups = fsl_mc_bus_groups, };EXPORT_SYMBOL_GPL (fsl_mc_bus_type);
Signature · 1 line
1.9.1