Skip to contentSkip to conversation

Management Complex restool driver

PATCH In review Lijun Pan 3 participants 11 messages Feb 9, 2016

Subsystems (2)
lore
Share & tools
lore

Lijun Pan

author
#0 lore raw

v3 cover Management Complex restool driver

This series of patches are rebased on
https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-next&id=c75955d1ee43b214c497cc297956866ca05ef22b

patch v1 1/5 "staging: fsl-mc: section mismatch bug fix" is already accepted.

Lijun Pan (8):
staging: fsl-mc: static inline function to differentiate root dprc
staging: fsl-mc: add sysfs rescan attribute in TODO
staging: fsl-mc: dprc device's sysfs rescan documentation
staging: fsl-mc: root dprc rescan attribute to sync kernel with MC
staging: fsl-mc: fsl-mc bus's sysfs rescan documentation
staging: fsl-mc: bus rescan attribute to sync kernel with MC
staging: fsl-mc: update TODO and README for restool driver
staging: fsl-mc: Management Complex restool driver

 Documentation/ABI/testing/sysfs-bus-fsl-mc   |   11 +
 Documentation/ABI/testing/sysfs-devices-dprc |   13 +
 Documentation/ioctl/ioctl-number.txt         |    1 +
 drivers/staging/fsl-mc/README.txt            |   11 +-
 drivers/staging/fsl-mc/TODO                  |   24 +-
 drivers/staging/fsl-mc/bus/Kconfig           |    7 +-
 drivers/staging/fsl-mc/bus/Makefile          |    3 +
 drivers/staging/fsl-mc/bus/mc-bus.c          |  113 ++++++--
 drivers/staging/fsl-mc/bus/mc-ioctl.h        |   22 ++
 drivers/staging/fsl-mc/bus/mc-restool.c      |  392 ++++++++++++++++++++++++++
 drivers/staging/fsl-mc/include/mc.h          |   14 +
 11 files changed, 588 insertions(+), 23 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsl-mc
 create mode 100644 Documentation/ABI/testing/sysfs-devices-dprc
 create mode 100644 drivers/staging/fsl-mc/bus/mc-ioctl.h
 create mode 100644 drivers/staging/fsl-mc/bus/mc-restool.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v3 1/8 staging: fsl-mc: static inline function to differentiate root dprc

Define a static inline function is_root_dprc(dev) to tell whether a device is root dprc or not via platform_bus_type. Remove fsl_mc_is_root_dprc() because is_root_dprc() is simpler and easier to understand.

---
v3: rebased on top of greg's staging-testing
v2: use static inline function instead of macro
replace the fsl_mc_is_root_dprc with is_root_dprc

 drivers/staging/fsl-mc/bus/mc-bus.c |   22 +++-------------------
 drivers/staging/fsl-mc/include/mc.h |   14 ++++++++++++++
 2 files changed, 17 insertions(+), 19 deletions(-)
drivers/staging/fsl-mc/bus/mc-bus.c +3 -19
index 9317561..b828985 100644
@@ -24,8 +24,6 @@
 
 static struct kmem_cache *mc_dev_cache;
 
-static bool fsl_mc_is_root_dprc(struct device *dev);
-
 /**
  * fsl_mc_bus_match - device to driver matching callback
  * @dev: the MC object device structure to match against
@@ -54,7 +52,7 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
 	 * Only exception is the root DPRC, which is a special case.
 	 */
 	if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0 &&
-	    !fsl_mc_is_root_dprc(&mc_dev->dev))
+	    !is_root_dprc(&mc_dev->dev))
 		goto out;
 
 	/*
@@ -238,20 +236,6 @@ static void fsl_mc_get_root_dprc(struct device *dev,
 	}
 }
 
-/**
- * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
- */
-static bool fsl_mc_is_root_dprc(struct device *dev)
-{
-	struct device *root_dprc_dev;
-
-	fsl_mc_get_root_dprc(dev, &root_dprc_dev);
-	if (!root_dprc_dev)
-		return false;
-	else
-		return dev == root_dprc_dev;
-}
-
 static int get_dprc_icid(struct fsl_mc_io *mc_io,
 			 int container_id, u16 *icid)
 {
@@ -545,7 +529,7 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
 			mc_dev->mc_io = NULL;
 		}
 
-		if (fsl_mc_is_root_dprc(&mc_dev->dev)) {
+		if (is_root_dprc(&mc_dev->dev)) {
 			if (atomic_read(&root_dprc_count) > 0)
 				atomic_dec(&root_dprc_count);
 			else
@@ -777,7 +761,7 @@ static int fsl_mc_bus_remove(struct platform_device *pdev)
 {
 	struct fsl_mc *mc = platform_get_drvdata(pdev);
 
-	if (WARN_ON(!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev)))
+	if (WARN_ON(!is_root_dprc(&mc->root_mc_bus_dev->dev)))
 		return -EINVAL;
 
 	fsl_mc_device_remove(mc->root_mc_bus_dev);
drivers/staging/fsl-mc/include/mc.h +14 -0
index ac7c1ce..6dffa29 100644
@@ -15,6 +15,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/list.h>
 #include <linux/interrupt.h>
+#include <linux/platform_device.h>
 #include "../include/dprc.h"
 
 #define FSL_MC_VENDOR_FREESCALE	0x1957
@@ -226,4 +227,17 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
 
 extern struct bus_type fsl_mc_bus_type;
 
+/**
+  * is_root_dprc - tell whether dev is root dprc or not.
+  * root dprc's parent is a platform device,
+  * that platform device's bus type is platform_bus_type.
+  * @dev: MC object device
+  * return 1 on root dprc, 0 otherwise
+  */
+static inline bool is_root_dprc(struct device *dev)
+{
+	return ((to_fsl_mc_device(dev)->flags & FSL_MC_IS_DPRC) &&
+		((dev)->bus == &fsl_mc_bus_type) &&
+		((dev)->parent->bus == &platform_bus_type));
+}
 #endif /* _FSL_MC_H_ */
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v3 2/8 staging: fsl-mc: add sysfs rescan attribute in TODO

In reply to Lijun Pan

Demonstrate why sysfs rescan attribute is helpful for moving fsl-mc bus out of staging.

---
 drivers/staging/fsl-mc/TODO |    6 ++++++
 1 file changed, 6 insertions(+)
drivers/staging/fsl-mc/TODO +6 -0
index 3894368..5065821 100644
@@ -1,3 +1,9 @@
+* Add sysfs rescan attribute for fsl-mc bus, and dprc device. The rescan will
+  trigger the fsl-mc bus, dprc driver to re-discover the objects under fsl-mc
+  bus and dprc.X container. Hence this feature actually verifies the
+  functionality of fsl-mc bus, and dprc driver, and it helps moving
+  fsl-mc bus out of staging.
+
 * Decide if multiple root fsl-mc buses will be supported per Linux instance,
   and if so add support for this.
 
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH v3 3/8 staging: fsl-mc: dprc device's sysfs rescan documentation

In reply to Lijun Pan

Add the sysfs documentation for the rescan attribute of dprc devices.

---
 Documentation/ABI/testing/sysfs-devices-dprc |   13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-dprc
Documentation/ABI/testing/sysfs-devices-dprc new file +13 -0
new file mode 100644
index 0000000..3c5d725
@@ -0,0 +1,13 @@
+What:		/sys/devices/.../dprc.X/rescan
+Date:		October 2015
+Contact:	Lijun Pan <[email protected]>
+Description:
+		Writing a non-zero value to this attribute will
+		force a rescan of dprc.X container in the system, and
+		add/remove previously added/removed objects in
+		Management Complex firmwarer, i.e., synchronize
+		the objects under dprc.X and Management Complex
+		firmware. For example:
+		# echo 1 > /sys/devices/platform/80c000000.fsl-mc/dprc.1/rescan
+
+
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH v3 4/8 staging: fsl-mc: root dprc rescan attribute to sync kernel with MC

In reply to Lijun Pan

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/rescan

---
v3: rebased on top of greg's staging-testing

 drivers/staging/fsl-mc/bus/mc-bus.c |   44 +++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/staging/fsl-mc/bus/mc-bus.c +44 -0
index b828985..b47c3ec 100644
@@ -102,10 +102,54 @@ static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
 	return 0;
 }
 
+static ssize_t rescan_store(struct device *dev,
+			    struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	unsigned long val;
+	unsigned int irq_count;
+	struct fsl_mc_device *root_mc_dev;
+	struct fsl_mc_bus *root_mc_bus;
+
+	if (!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, &irq_count);
+		mutex_unlock(&root_mc_bus->scan_mutex);
+	}
+
+	return count;
+}
+
+static DEVICE_ATTR_WO(rescan);
+
+static struct attribute *fsl_mc_dev_attrs[] = {
+	&dev_attr_rescan.attr,
+	NULL,
+};
+
+static const struct attribute_group fsl_mc_dev_group = {
+	.attrs = fsl_mc_dev_attrs,
+};
+
+static const struct attribute_group *fsl_mc_dev_groups[] = {
+	&fsl_mc_dev_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,
 };
 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
 
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH v3 5/8 staging: fsl-mc: fsl-mc bus's sysfs rescan documentation

In reply to Lijun Pan

Add the sysfs documentation for the rescan attribute of fsl-mc bus.

---
 Documentation/ABI/testing/sysfs-bus-fsl-mc |   11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsl-mc
Documentation/ABI/testing/sysfs-bus-fsl-mc new file +11 -0
new file mode 100644
index 0000000..3fa747c
@@ -0,0 +1,11 @@
+What:		/sys/bus/fsl-mc/rescan
+Date:		October 2015
+Contact:	Lijun Pan <[email protected]>
+Description:
+		Writing a non-zero value to this attribute will
+		force a rescan of fsl-mc bus in the system, and
+		add/remove previously added/removed objects in
+		Management Complex firmwarer, i.e., synchronize
+		the objects under fsl-mc bus and Management Complex
+		firmware. For example:
+		# echo 1 > /sys/bus/fsl-mc/rescan
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH v3 6/8 staging: fsl-mc: bus rescan attribute to sync kernel with MC

In reply to Lijun Pan

Introduce 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

---
v3: rebased on top of greg's staging-testing

 drivers/staging/fsl-mc/bus/mc-bus.c |   47 +++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
drivers/staging/fsl-mc/bus/mc-bus.c +47 -0
index b47c3ec..713d441 100644
@@ -145,11 +145,58 @@ static const struct attribute_group *fsl_mc_dev_groups[] = {
 	NULL,
 };
 
+static int scan_fsl_mc_bus(struct device *dev, void *data)
+{
+	unsigned int irq_count;
+	struct fsl_mc_device *root_mc_dev;
+	struct fsl_mc_bus *root_mc_bus;
+
+	if (is_root_dprc(dev)) {
+		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, &irq_count);
+		mutex_unlock(&root_mc_bus->scan_mutex);
+	}
+
+	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, (S_IWUSR | S_IWGRP), 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.7.9.5
author
#7 lore raw

PATCH v3 7/8 staging: fsl-mc: update TODO and README for restool driver

In reply to Lijun Pan

Add more introduction of restool driver and state why restool driver is needed in helping moving fsl-mc bus out of staging tree.

---
 drivers/staging/fsl-mc/README.txt |   11 ++++++++++-
 drivers/staging/fsl-mc/TODO       |   18 ++++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/staging/fsl-mc/README.txt +10 -1
index 8214102..e9ec507 100644
@@ -130,7 +130,16 @@ the objects involved in creating a network interfaces.
     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.
+    dynamically. The kernel side restool driver communicates with
+    user space restool via ioctl. Restool relies on allocator driver
+    to allocate dpmcp resources, enumerates fsl-mc bus to find root dprc
+    objects of interest. When the user space restool program sends a request
+    to restool driver to create a dp* objects in MC firmware, an interrupt
+    will be triggered by MC firmware and the dprc driver's interrupt handler
+    shall process the interrupt (synchronizing the objects in MC firmware and
+    objects in Linux kernel). Though small, restool driver helps verify all
+    the functionality of fsl-mc bus, dprc driver, allocator driver,
+    and MC flib API.
 
 -DPAA2 Objects for an Ethernet Network Interface
 
drivers/staging/fsl-mc/TODO +16 -2
index 5065821..4892eb6 100644
@@ -5,10 +5,24 @@
   fsl-mc bus out of staging.
 
 * Decide if multiple root fsl-mc buses will be supported per Linux instance,
-  and if so add support for this.
+  and if so add support for this. No matter fsl-mc bus support multiple root
+  dprc or not, restool driver is designed to support multiple root if fsl-mc
+  bus is ready some day later. If there is only one root dprc, restool driver
+  works fine.
+
+* Add at least one driver utilizing fsl-mc bus. Restool driver is a very
+  small and simple driver, which interacts with fsl-mc bus, dprc driver,
+  allocator driver. Restool relies on allocator driver to allocate
+  dpmcp resources, enumerates fsl-mc bus to find root dprc objects of interest.
+  When the user space restool program sends a request to restool driver to
+  create a dp* objects in MC firmware, an interrupt will be triggered by
+  MC firmware and the dprc driver's interrupt handler shall process the
+  interrupt. Though small, restool driver helps verify all the functionality
+  of fsl-mc bus, dprc driver, allocator driver, and MC flib API. Restool
+  driver helps in moving fsl-mc bus out of staging branch.
 
 * Add at least one device driver for a DPAA2 object (child device of the
-  fsl-mc bus).  Most likely candidate for this is adding DPAA2 Ethernet
+  fsl-mc bus). Most likely candidate for this is adding DPAA2 Ethernet
   driver support, which depends on drivers for several objects: DPNI,
   DPIO, DPMAC.  Other pre-requisites include:
 
Signature · 1 line
1.7.9.5
maintainer
#8 lore raw

Re: [PATCH v3 7/8] staging: fsl-mc: update TODO and README for restool driver

Quoted 37 lines · Lijun Pan

Add more introduction of restool driver and state why restool driver is needed in helping moving fsl-mc bus out of staging tree.

---
 drivers/staging/fsl-mc/README.txt |   11 ++++++++++-
 drivers/staging/fsl-mc/TODO       |   18 ++++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/staging/fsl-mc/README.txt +10 -1
index 8214102..e9ec507 100644
@@ -130,7 +130,16 @@ the objects involved in creating a network interfaces.
     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.
+    dynamically. The kernel side restool driver communicates with
+    user space restool via ioctl. Restool relies on allocator driver
+    to allocate dpmcp resources, enumerates fsl-mc bus to find root dprc
+    objects of interest. When the user space restool program sends a request
+    to restool driver to create a dp* objects in MC firmware, an interrupt
+    will be triggered by MC firmware and the dprc driver's interrupt handler
+    shall process the interrupt (synchronizing the objects in MC firmware and
+    objects in Linux kernel). Though small, restool driver helps verify all
+    the functionality of fsl-mc bus, dprc driver, allocator driver,
+    and MC flib API.
 
 -DPAA2 Objects for an Ethernet Network Interface
 
drivers/staging/fsl-mc/TODO +0 -0
index 5065821..4892eb6 100644

drivers/staging/fsl-mc/TODO line 11

Quoted 8 lines
drivers/staging/fsl-mc/TODO +4 -1
@@ -5,10 +5,24 @@
   fsl-mc bus out of staging.
 
 * Decide if multiple root fsl-mc buses will be supported per Linux instance,
-  and if so add support for this.
+  and if so add support for this. No matter fsl-mc bus support multiple root
+  dprc or not, restool driver is designed to support multiple root if fsl-mc
+  bus is ready some day later. If there is only one root dprc, restool driver
+  works fine.

The english here doesn't make much sense, and also, it seems that you all can't agree what should happen here.

Why are you adding new functionality to this driver instead of working to get it out of the staging tree properly? What is this patch series doing toward _REMOVING_ items from the TODO list? It seems like you are adding more stuff to sort out at some unknown later time.

drivers/staging/fsl-mc/TODO line 22

Quoted 10 lines
drivers/staging/fsl-mc/TODO +10 -0
+* Add at least one driver utilizing fsl-mc bus. Restool driver is a very
+  small and simple driver, which interacts with fsl-mc bus, dprc driver,
+  allocator driver. Restool relies on allocator driver to allocate
+  dpmcp resources, enumerates fsl-mc bus to find root dprc objects of interest.
+  When the user space restool program sends a request to restool driver to
+  create a dp* objects in MC firmware, an interrupt will be triggered by
+  MC firmware and the dprc driver's interrupt handler shall process the
+  interrupt. Though small, restool driver helps verify all the functionality
+  of fsl-mc bus, dprc driver, allocator driver, and MC flib API. Restool
+  driver helps in moving fsl-mc bus out of staging branch.

Again, this doesn't make much sense. Why is this a TODO item?

drivers/staging/fsl-mc/TODO line 25

Quoted 3 lines
drivers/staging/fsl-mc/TODO +1 -1
 * Add at least one device driver for a DPAA2 object (child device of the
-  fsl-mc bus).  Most likely candidate for this is adding DPAA2 Ethernet
+  fsl-mc bus). Most likely candidate for this is adding DPAA2 Ethernet

Unneeded changed.

Why has the maintainers for this code not signed-off on these changes?

thanks,

greg k-h

#9 lore raw

RE: [PATCH v3 7/8] staging: fsl-mc: update TODO and README for restool driver

In reply to Lijun Pan
Quoted 60 lines

-----Original Message-----
From: Lijun Pan [mailto:[email protected]]
Sent: Monday, February 08, 2016 5:40 PM
To: [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lijun Pan <[email protected]>
Subject: [PATCH v3 7/8] staging: fsl-mc: update TODO and README for restool driver

Add more introduction of restool driver and state why restool driver is needed in helping moving fsl-mc bus out of staging tree.

---
 drivers/staging/fsl-mc/README.txt |   11 ++++++++++-
 drivers/staging/fsl-mc/TODO       |   18 ++++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/staging/fsl-mc/README.txt +10 -1
index 8214102..e9ec507 100644
@@ -130,7 +130,16 @@ the objects involved in creating a network interfaces.
     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.
+    dynamically. The kernel side restool driver communicates with
+    user space restool via ioctl. Restool relies on allocator driver
+    to allocate dpmcp resources, enumerates fsl-mc bus to find root dprc
+    objects of interest. When the user space restool program sends a request
+    to restool driver to create a dp* objects in MC firmware, an interrupt
+    will be triggered by MC firmware and the dprc driver's interrupt handler
+    shall process the interrupt (synchronizing the objects in MC firmware and
+    objects in Linux kernel). Though small, restool driver helps verify all
+    the functionality of fsl-mc bus, dprc driver, allocator driver,
+    and MC flib API.
 
 -DPAA2 Objects for an Ethernet Network Interface
 
drivers/staging/fsl-mc/TODO +5 -1
index 5065821..4892eb6 100644
@@ -5,10 +5,24 @@
   fsl-mc bus out of staging.
 
 * Decide if multiple root fsl-mc buses will be supported per Linux instance,
-  and if so add support for this.
+  and if so add support for this. No matter fsl-mc bus support multiple root
+  dprc or not, restool driver is designed to support multiple root if fsl-mc
+  bus is ready some day later. If there is only one root dprc, restool driver
+  works fine.
+

drivers/staging/fsl-mc/TODO line 22

Quoted 10 lines
drivers/staging/fsl-mc/TODO +10 -0
+* Add at least one driver utilizing fsl-mc bus. Restool driver is a very
+  small and simple driver, which interacts with fsl-mc bus, dprc driver,
+  allocator driver. Restool relies on allocator driver to allocate
+  dpmcp resources, enumerates fsl-mc bus to find root dprc objects of interest.
+  When the user space restool program sends a request to restool driver to
+  create a dp* objects in MC firmware, an interrupt will be triggered by
+  MC firmware and the dprc driver's interrupt handler shall process the
+  interrupt. Though small, restool driver helps verify all the functionality
+  of fsl-mc bus, dprc driver, allocator driver, and MC flib API. Restool
+  driver helps in moving fsl-mc bus out of staging branch.

I don't agree with expanding the TODO list. The discussion with Alex Graf and Greg last year left us with the target of getting a object driver into staging that uses the fsl-mc bus in a normal way, which is what the current TODO list reflects. Now that MSI support is in we are closer to being able to do that.

The restool driver is a special case that I think can wait.

Stuart

author
#10 lore raw

PATCH v3 8/8 staging: fsl-mc: Management Complex restool driver

In reply to Lijun Pan

The kernel support for the restool (a user space resource management tool) is a driver for the /dev/dprc.N device file.
Its purpose is to provide an ioctl interface,
which the restool uses to interact with the MC bus driver and with the MC firmware.
We allocate a dpmcp at driver initialization,
and keep that dpmcp until driver exit.
We use that dpmcp by default.
If that dpmcp is in use, we create another portal at run time and destroy the newly created portal after use.
The ioctl RESTOOL_SEND_MC_COMMAND sends user space command to fsl-mc bus and utilizes the fsl-mc bus to communicate with MC firmware. The ioctl RESTOOL_DPRC_SYNC request the mc-bus launch objects scan under root dprc.
In order to support multiple root dprc, we utilize the bus notify mechanism to scan fsl_mc_bus_type for the newly added root dprc. After discovering the root dprc, it creates a miscdevice /dev/dprc.N to associate with this root dprc.

---
v3: rebased on top of greg's staging-testing
v2:
remove verbose printk
improve error handling
synchronize misc_list access
reserve ioctl range in Documentation/ioctl/ioctl-number.txt remove ioctl sync command
flip if(!...) to make them fit in 80 columns change if(x==NULL) to if(!x)
change ("int error = 0;" initialization) to (int error;)

 Documentation/ioctl/ioctl-number.txt    |    1 +
 drivers/staging/fsl-mc/bus/Kconfig      |    7 +-
 drivers/staging/fsl-mc/bus/Makefile     |    3 +
 drivers/staging/fsl-mc/bus/mc-ioctl.h   |   22 ++
 drivers/staging/fsl-mc/bus/mc-restool.c |  392 +++++++++++++++++++++++++++++++
 5 files changed, 424 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/mc-ioctl.h
 create mode 100644 drivers/staging/fsl-mc/bus/mc-restool.c
Documentation/ioctl/ioctl-number.txt +1 -0
index 91261a3..64cc31d 100644
@@ -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-EF	drivers/staging/fsl-mc/bus/mc-ioctl.h
 'S'	all	linux/cdrom.h		conflict!
 'S'	80-81	scsi/scsi_ioctl.h	conflict!
 'S'	82-FF	scsi/scsi.h		conflict!
drivers/staging/fsl-mc/bus/Kconfig +6 -1
index c498ac6..92aff45 100644
@@ -22,4 +22,9 @@ config FSL_MC_BUS
 	  Only enable this option when building the kernel for
 	  Freescale QorQIQ LS2xxxx SoCs.
 
-
+config FSL_MC_RESTOOL
+        tristate "Freescale Management Complex (MC) restool driver"
+        depends on FSL_MC_BUS
+        help
+          Driver that provides kernel support for the Freescale Management
+	  Complex resource manager user-space tool.
drivers/staging/fsl-mc/bus/Makefile +3 -0
index e731517..30a63a3 100644
@@ -17,3 +17,6 @@ mc-bus-driver-objs := mc-bus.o \
 		      irq-gic-v3-its-fsl-mc-msi.o \
 		      dpmcp.o \
 		      dpbp.o
+
+# MC restool kernel support
+obj-$(CONFIG_FSL_MC_RESTOOL) += mc-restool.o
drivers/staging/fsl-mc/bus/mc-ioctl.h new file +22 -0
new file mode 100644
index 0000000..8ac502a
@@ -0,0 +1,22 @@
+/*
+ * Freescale Management Complex (MC) ioclt interface
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan <[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.
+ */
+#ifndef _FSL_MC_IOCTL_H_
+#define _FSL_MC_IOCTL_H_
+
+#include <linux/ioctl.h>
+#include "../include/mc-sys.h"
+
+#define RESTOOL_IOCTL_TYPE   'R'
+
+#define RESTOOL_SEND_MC_COMMAND \
+	_IOWR(RESTOOL_IOCTL_TYPE, 0xE0, struct mc_command)
+
+#endif /* _FSL_MC_IOCTL_H_ */
drivers/staging/fsl-mc/bus/mc-restool.c new file +392 -0

392 lines not on this page · raw message

Signature · 1 line
1.7.9.5