Re: [PATCH] ibmvnic: remove excessive irqsave

2021-03-04 Thread Lijun Pan



> On Mar 4, 2021, at 11:49 PM, Christophe Leroy  
> wrote:
> 
> 
> 
> Le 05/03/2021 à 02:43, angkery a écrit :
>> From: Junlin Yang 
>> ibmvnic_remove locks multiple spinlocks while disabling interrupts:
>> spin_lock_irqsave(&adapter->state_lock, flags);
>> spin_lock_irqsave(&adapter->rwi_lock, flags);
>> there is no need for the second irqsave,since interrupts are disabled
>> at that point, so remove the second irqsave:
> 
> The problème is not that there is no need. The problem is a lot more serious:
> As reported by coccinella, the second _irqsave() overwrites the value saved 
> in 'flags' by the first _irqsave, therefore when the second _irqrestore 
> comes, the value in 'flags' is not valid, the value saved by the first 
> _irqsave has been lost. This likely leads to IRQs remaining disabled, which 
> is _THE_ problem really.

That does sounds like a more serious functional problem than coccinella check.
Thanks for your explanation.

> 
>> spin_lock_irqsave(&adapter->state_lock, flags);
>> spin_lock(&adapter->rwi_lock);
>> Generated by: ./scripts/coccinelle/locks/flags.cocci
>> ./drivers/net/ethernet/ibm/ibmvnic.c:5413:1-18:
>> ERROR: nested lock+irqsave that reuses flags from line 5404.
>> Signed-off-by: Junlin Yang 
>> ---
>>  drivers/net/ethernet/ibm/ibmvnic.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
>> b/drivers/net/ethernet/ibm/ibmvnic.c
>> index 2464c8a..a52668d 100644
>> --- a/drivers/net/ethernet/ibm/ibmvnic.c
>> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
>> @@ -5408,9 +5408,9 @@ static void ibmvnic_remove(struct vio_dev *dev)
>>   * after setting state, so __ibmvnic_reset() which is called
>>   * from the flush_work() below, can make progress.
>>   */
>> -spin_lock_irqsave(&adapter->rwi_lock, flags);
>> +spin_lock(&adapter->rwi_lock);
>>  adapter->state = VNIC_REMOVING;
>> -spin_unlock_irqrestore(&adapter->rwi_lock, flags);
>> +spin_unlock(&adapter->rwi_lock);
>>  spin_unlock_irqrestore(&adapter->state_lock, flags);
>>  



Re: [PATCH] vio: make remove callback return void

2021-01-29 Thread Lijun Pan
On Wed, Jan 27, 2021 at 6:41 PM Uwe Kleine-König  wrote:
>
> The driver core ignores the return value of struct bus_type::remove()
> because there is only little that can be done. To simplify the quest to
> make this function return void, let struct vio_driver::remove() return
> void, too. All users already unconditionally return 0, this commit makes
> it obvious that returning an error code is a bad idea and makes it
> obvious for future driver authors that returning an error code isn't
> intended.
>
> Note there are two nominally different implementations for a vio bus:
> one in arch/sparc/kernel/vio.c and the other in
> arch/powerpc/platforms/pseries/vio.c. I didn't care to check which
> driver is using which of these busses (or if even some of them can be
> used with both) and simply adapt all drivers and the two bus codes in
> one go.
>
> Note that for the powerpc implementation there is a semantical change:
> Before this patch for a device that was bound to a driver without a
> remove callback vio_cmo_bus_remove(viodev) wasn't called. As the device
> core still considers the device unbound after vio_bus_remove() returns
> calling this unconditionally is the consistent behaviour which is
> implemented here.
>
> Signed-off-by: Uwe Kleine-König 

Acked-by: Lijun Pan 


Re: [PATCH] ibmvnic: fix: NULL pointer dereference.

2020-12-30 Thread Lijun Pan
On Wed, Dec 30, 2020 at 1:25 AM YANG LI  wrote:
>
> The error is due to dereference a null pointer in function
> reset_one_sub_crq_queue():
>
> if (!scrq) {
> netdev_dbg(adapter->netdev,
>"Invalid scrq reset. irq (%d) or msgs(%p).\n",
> scrq->irq, scrq->msgs);
> return -EINVAL;
> }
>
> If the expression is true, scrq must be a null pointer and cannot
> dereference.
>
> Signed-off-by: YANG LI 
> Reported-by: Abaci 
> ---

Acked-by: Lijun Pan 


[PATCH] ARM: dts: ls2080a: Add quirk for Erratum A009116

2016-02-09 Thread Lijun Pan
Add "snps,quirk-frame-length-adjustment" property to
USB3 node for erratum A009116. This property provides
value of GFLADJ_30MHZ for post silicon frame length
adjustment.

Signed-off-by: Lijun Pan 
---
 arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi |2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
index 6e9e033..fa506f5 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
@@ -501,6 +501,7 @@
reg = <0x0 0x310 0x0 0x1>;
interrupts = <0 80 0x4>; /* Level high type */
dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
};
 
usb1: usb3@311 {
@@ -509,6 +510,7 @@
reg = <0x0 0x311 0x0 0x1>;
interrupts = <0 81 0x4>; /* Level high type */
dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
};
 
ccn@400 {
-- 
1.7.9.5



[PATCH] usb: fsl: fix typo FLS_USB2_WORKAROUND_ENGCM09152

2016-02-09 Thread Lijun Pan
FLS_USB2_WORKAROUND_ENGCM09152 is a typo.
It should be FSL_USB2_WORKAROUND_ENGCM09152 since
FSL is the abbreviation of Freescale.

Signed-off-by: Lijun Pan 
---
 arch/arm/mach-imx/mach-mx35_3ds.c|2 +-
 arch/arm/mach-imx/mach-vpr200.c  |2 +-
 drivers/usb/gadget/udc/fsl_mxc_udc.c |2 +-
 include/linux/fsl_devices.h  |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-imx/mach-mx35_3ds.c 
b/arch/arm/mach-imx/mach-mx35_3ds.c
index 7e315f0..4d4403e 100644
--- a/arch/arm/mach-imx/mach-mx35_3ds.c
+++ b/arch/arm/mach-imx/mach-mx35_3ds.c
@@ -507,7 +507,7 @@ static int mx35_3ds_otg_init(struct platform_device *pdev)
 static const struct fsl_usb2_platform_data usb_otg_pdata __initconst = {
.operating_mode = FSL_USB2_DR_DEVICE,
.phy_mode   = FSL_USB2_PHY_UTMI_WIDE,
-   .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
+   .workaround = FSL_USB2_WORKAROUND_ENGCM09152,
 /*
  * ENGCM09152 also requires a hardware change.
  * Please check the MX35 Chip Errata document for details.
diff --git a/arch/arm/mach-imx/mach-vpr200.c b/arch/arm/mach-imx/mach-vpr200.c
index 27a8f7e..9104ebc 100644
--- a/arch/arm/mach-imx/mach-vpr200.c
+++ b/arch/arm/mach-imx/mach-vpr200.c
@@ -238,7 +238,7 @@ static const iomux_v3_cfg_t vpr200_pads[] __initconst = {
 static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
.operating_mode = FSL_USB2_DR_DEVICE,
.phy_mode   = FSL_USB2_PHY_UTMI,
-   .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
+   .workaround = FSL_USB2_WORKAROUND_ENGCM09152,
 };
 
 static int vpr200_usbh_init(struct platform_device *pdev)
diff --git a/drivers/usb/gadget/udc/fsl_mxc_udc.c 
b/drivers/usb/gadget/udc/fsl_mxc_udc.c
index f16e149..af502bd 100644
--- a/drivers/usb/gadget/udc/fsl_mxc_udc.c
+++ b/drivers/usb/gadget/udc/fsl_mxc_udc.c
@@ -86,7 +86,7 @@ int fsl_udc_clk_finalize(struct platform_device *pdev)
int ret = 0;
 
/* workaround ENGcm09152 for i.MX35 */
-   if (pdata->workaround & FLS_USB2_WORKAROUND_ENGCM09152) {
+   if (pdata->workaround & FSL_USB2_WORKAROUND_ENGCM09152) {
unsigned int v;
struct resource *res = platform_get_resource
(pdev, IORESOURCE_MEM, 0);
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index f291291..8e08089 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -119,7 +119,7 @@ struct fsl_usb2_platform_data {
 #define FSL_USB2_PORT0_ENABLED 0x0001
 #define FSL_USB2_PORT1_ENABLED 0x0002
 
-#define FLS_USB2_WORKAROUND_ENGCM09152 (1 << 0)
+#define FSL_USB2_WORKAROUND_ENGCM09152 (1 << 0)
 
 struct spi_device;
 
-- 
1.7.9.5



RE: [PATCH RESEND v2 1/8] staging: fsl-mc: static inline function to differentiate root dprc

2016-02-08 Thread Lijun Pan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Sunday, February 07, 2016 9:34 PM
> To: Lijun Pan 
> Cc: a...@arndb.de; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; bhamc...@freescale.com; lijun.pan2...@gmail.com;
> bhupesh.sha...@freescale.com; german.riv...@freescale.com;
> ag...@suse.de; stuart.yo...@freescale.com; nir.e...@freescale.com;
> itai.k...@freescale.com; scottw...@freescale.com; le...@freescale.com;
> r89...@freescale.com; dan.carpen...@oracle.com;
> richard.schm...@freescale.com
> Subject: Re: [PATCH RESEND v2 1/8] staging: fsl-mc: static inline function to
> differentiate root dprc
> 
> On Fri, Dec 11, 2015 at 01:25:47PM -0600, Lijun Pan wrote:
> > 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.
> >
> > Signed-off-by: Lijun Pan 
> > ---
> > v2: use static inline function instead of macro
> > replace the fsl_mc_is_root_dprc with is_root_dprc
> 
> 
> This series doesn't apply to my tree anymore, due to another big patcheset for
> this subsystem being applied.  Can you please rebase it against my staging-
> testing branch of staging.git and resend?
> 

Greg,

I have just rebased the patches and re-sended the v3.
Please check your emails.

Thanks
Lijun

> thanks,
> 
> greg k-h


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

2016-02-08 Thread 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.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/README.txt |   11 ++-
 drivers/staging/fsl-mc/TODO   |   18 --
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/README.txt
index 8214102..e9ec507 100644
--- a/drivers/staging/fsl-mc/README.txt
+++ b/drivers/staging/fsl-mc/README.txt
@@ -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
 
diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 5065821..4892eb6 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -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:
 
-- 
1.7.9.5



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

2016-02-08 Thread 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

Signed-off-by: Lijun Pan 
---
v3: rebased on top of greg's staging-testing

 drivers/staging/fsl-mc/bus/mc-bus.c |   47 +++
 1 file changed, 47 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index b47c3ec..713d441 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -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);
 
-- 
1.7.9.5



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

2016-02-08 Thread Lijun Pan
Add the sysfs documentation for the rescan attribute of
dprc devices.

Signed-off-by: Lijun Pan 
---
 Documentation/ABI/testing/sysfs-devices-dprc |   13 +
 1 file changed, 13 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-dprc

diff --git a/Documentation/ABI/testing/sysfs-devices-dprc 
b/Documentation/ABI/testing/sysfs-devices-dprc
new file mode 100644
index 000..3c5d725
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-dprc
@@ -0,0 +1,13 @@
+What:  /sys/devices/.../dprc.X/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+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/80c00.fsl-mc/dprc.1/rescan
+
+
-- 
1.7.9.5



[PATCH v3 0/8] Management Complex restool driver

2016-02-08 Thread Lijun Pan
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

-- 
1.7.9.5



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

2016-02-08 Thread Lijun Pan
Demonstrate why sysfs rescan attribute is helpful for
moving fsl-mc bus out of staging.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/TODO |6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 3894368..5065821 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -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.
 
-- 
1.7.9.5



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

2016-02-08 Thread Lijun Pan
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.

Signed-off-by: Lijun Pan 
---
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(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 9317561..b828985 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -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);
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index ac7c1ce..6dffa29 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "../include/dprc.h"
 
 #define FSL_MC_VENDOR_FREESCALE0x1957
@@ -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_ */
-- 
1.7.9.5



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

2016-02-08 Thread Lijun Pan
Add the sysfs documentation for the rescan attribute of
fsl-mc bus.

Signed-off-by: Lijun Pan 
---
 Documentation/ABI/testing/sysfs-bus-fsl-mc |   11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsl-mc

diff --git a/Documentation/ABI/testing/sysfs-bus-fsl-mc 
b/Documentation/ABI/testing/sysfs-bus-fsl-mc
new file mode 100644
index 000..3fa747c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-fsl-mc
@@ -0,0 +1,11 @@
+What:  /sys/bus/fsl-mc/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+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
-- 
1.7.9.5



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

2016-02-08 Thread 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.

Signed-off-by: Lijun Pan 
---
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

diff --git a/Documentation/ioctl/ioctl-number.txt 
b/Documentation/ioctl/ioctl-number.txt
index 91261a3..64cc31d 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -170,6 +170,7 @@ Code  Seq#(hex) Include FileComments
 '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!
diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index c498ac6..92aff45 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -22,4 +22,9 @@ config FSL_MC_BUS
  Only enable this option when building the kernel for
  Freescale QorQIQ LS2 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.
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index e731517..30a63a3 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -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
diff --git a/drivers/staging/fsl-mc/bus/mc-ioctl.h 
b/drivers/staging/fsl-mc/bus/mc-ioctl.h
new file mode 100644
index 000..8ac502a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-ioctl.h
@@ -0,0 +1,22 @@
+/*
+ * Freescale Management Complex (MC) ioclt interface
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 
+#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_ */
diff --git a/drivers/staging/fsl-mc/bus/mc-restool.c 
b/drivers/staging/fsl-mc/bus/mc-restool.c
new file mode 100644
index 000..57f059a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-restool.c
@@ -0,0 +1,392 @@
+/*
+ * Freescale Management Complex (MC) restool driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 "../include/mc-private.h&qu

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

2016-02-08 Thread 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

Signed-off-by: Lijun Pan 
---
v3: rebased on top of greg's staging-testing

 drivers/staging/fsl-mc/bus/mc-bus.c |   44 +++
 1 file changed, 44 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index b828985..b47c3ec 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -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);
 
-- 
1.7.9.5



[PATCH RESEND v2 8/8] staging: fsl-mc: Management Complex restool driver

2015-12-11 Thread 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.

Signed-off-by: Lijun Pan 
---
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

diff --git a/Documentation/ioctl/ioctl-number.txt 
b/Documentation/ioctl/ioctl-number.txt
index df1b25e..3e83fe9 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -166,6 +166,7 @@ Code  Seq#(hex) Include FileComments
 '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!
diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 0d779d9..39c6ef9 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -21,4 +21,9 @@ config FSL_MC_BUS
  Only enable this option when building the kernel for
  Freescale QorQIQ LS2 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.
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index 25433a9..28b5fc0 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -15,3 +15,6 @@ mc-bus-driver-objs := mc-bus.o \
  mc-allocator.o \
  dpmcp.o \
  dpbp.o
+
+# MC restool kernel support
+obj-$(CONFIG_FSL_MC_RESTOOL) += mc-restool.o
diff --git a/drivers/staging/fsl-mc/bus/mc-ioctl.h 
b/drivers/staging/fsl-mc/bus/mc-ioctl.h
new file mode 100644
index 000..8ac502a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-ioctl.h
@@ -0,0 +1,22 @@
+/*
+ * Freescale Management Complex (MC) ioclt interface
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 
+#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_ */
diff --git a/drivers/staging/fsl-mc/bus/mc-restool.c 
b/drivers/staging/fsl-mc/bus/mc-restool.c
new file mode 100644
index 000..57f059a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-restool.c
@@ -0,0 +1,392 @@
+/*
+ * Freescale Management Complex (MC) restool driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 "../include/mc-private.h"
+#include 
+#include 
+#include 
+#include 

[PATCH RESEND v3] fsl-ifc: add missing include on ARM64

2015-12-11 Thread Lijun Pan
Need to include sched.h to fix the following compilation error
if FSL_IFC is enabled on ARM64 machine.

In file included from include/linux/mmzone.h:9:0,
 from include/linux/gfp.h:5,
 from include/linux/kmod.h:22,
 from include/linux/module.h:13,
 from drivers/memory/fsl_ifc.c:22:
drivers/memory/fsl_ifc.c: In function ‘check_nand_stat’:
include/linux/wait.h:165:35: error: ‘TASK_NORMAL’ undeclared (first use in this 
function)
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^
include/linux/wait.h:165:35: note: each undeclared identifier is reported only 
once for each function it appears in
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^

Analysis is as follows:
I put some instrumental code and get the
following .h files inclusion sequence:

In file included from ./arch/arm64/include/asm/compat.h:25:0,
 from ./arch/arm64/include/asm/stat.h:23,
 from include/linux/stat.h:5,
 from include/linux/module.h:10,
 from drivers/memory/fsl_ifc.c:23:
include/linux/sched.h:113:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or 
‘__attribute__’ before ‘struct’
 struct sched_attr {
 ^

CONFIG_COMPAT=y is enabled while 39 and 48 bit VA is selected.
When 42 bit VA is selected, it does not enable CONFIG_COMPAT=y

In ./arch/arm64/include/asm/stat.h:23, it has
"#ifdef CONFIG_COMPAT"
"#include "
"..."
"#endif"

Since ./arch/arm64/include/asm/stat.h does not
include ./arch/arm64/include/asm/compat.h,
then it will not include include/linux/sched.h
Hence we have to manually add "#include "
in drivers/memory/fsl_ifc.c

Signed-off-by: Lijun Pan 
---
v3: change the subject title to better reflect the commit message
insert linux/sched.h in more appropriate place among all .h files
articulate CONFIG_COMPAT=y is set in 39/48 bit VA
v2: reordering the include .h files according to Arnd's suggestion
detailing why linux/sched.h is needed.

 drivers/memory/fsl_ifc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index e87459f..acd1460 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND v2 1/8] staging: fsl-mc: static inline function to differentiate root dprc

2015-12-11 Thread Lijun Pan
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.

Signed-off-by: Lijun Pan 
---
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(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 84db55b..25e205421 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -22,8 +22,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
@@ -52,7 +50,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;
 
/*
@@ -236,20 +234,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)
 {
@@ -541,7 +525,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
@@ -772,7 +756,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);
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index a933291..6051955 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "../include/dprc.h"
 
 #define FSL_MC_VENDOR_FREESCALE0x1957
@@ -200,4 +201,17 @@ void fsl_mc_object_free(struct fsl_mc_device *mc_adev);
 
 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_ */
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND v2 6/8] staging: fsl-mc: bus rescan attribute to sync kernel with MC

2015-12-11 Thread 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

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 46 +
 1 file changed, 46 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 61d44fd..f9ee5fe 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -142,11 +142,57 @@ static const struct attribute_group *fsl_mc_dev_groups[] 
= {
NULL,
 };
 
+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 (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);
+   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);
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND v2 2/8] staging: fsl-mc: add sysfs rescan attribute in TODO

2015-12-11 Thread Lijun Pan
Demonstrate why sysfs rescan attribute is helpful for
moving fsl-mc bus out of staging.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/TODO | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 3894368..5065821 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -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.
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-12-11 Thread Lijun Pan
Add the sysfs documentation for the rescan attribute of
dprc devices.

Signed-off-by: Lijun Pan 
---
 Documentation/ABI/testing/sysfs-devices-dprc | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-dprc

diff --git a/Documentation/ABI/testing/sysfs-devices-dprc 
b/Documentation/ABI/testing/sysfs-devices-dprc
new file mode 100644
index 000..3c5d725
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-dprc
@@ -0,0 +1,13 @@
+What:  /sys/devices/.../dprc.X/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+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/80c00.fsl-mc/dprc.1/rescan
+
+
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND v2 4/8] staging: fsl-mc: root dprc rescan attribute to sync kernel with MC

2015-12-11 Thread 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

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 43 +
 1 file changed, 43 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 25e205421..61d44fd 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -100,10 +100,53 @@ 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;
+   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);
+   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);
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND v2 5/8] staging: fsl-mc: fsl-mc bus's sysfs rescan documentation

2015-12-11 Thread Lijun Pan
Add the sysfs documentation for the rescan attribute of
fsl-mc bus.

Signed-off-by: Lijun Pan 
---
 Documentation/ABI/testing/sysfs-bus-fsl-mc | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsl-mc

diff --git a/Documentation/ABI/testing/sysfs-bus-fsl-mc 
b/Documentation/ABI/testing/sysfs-bus-fsl-mc
new file mode 100644
index 000..3fa747c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-fsl-mc
@@ -0,0 +1,11 @@
+What:  /sys/bus/fsl-mc/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+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
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND v2 0/8] Management Complex restool driver

2015-12-11 Thread Lijun Pan
*** This is a resend of the last iteration of this patch series ***

This series of patches are based on
http://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-next&id=63f2be5c3b358db031f86eafa9cd450f6558a55b

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

This v2 series have,
patch 1/8 use inline function to differentiate root dprc
patch 2/8 add sysfs rescan attribute in TODO list
patch 3/8 add sysfs rescan documentation for dprc device
patch 4/8 introduce the sysfs rescan attribute for root dprc device
patch 5/8 add sysfs rescan documentation for fsl-mc bus
patch 6/8 introduce the sysfs rescan attribute for fsl-mc bus
patch 7/8 add restool driver introduction in TODO list and README
patch 8/8 introduction of restool driver, which sits on fsl-mc bus and
utilizes fsl-mc bus to communicate with MC firmware.
restool driver is the first driver to start using fsl-mc bus.
This restool driver is small and helps fsl-mc bus move out of staging.

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  | 112 ++--
 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, 587 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

-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-12-11 Thread 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.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/README.txt | 11 ++-
 drivers/staging/fsl-mc/TODO   | 18 --
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/README.txt
index 8214102..e9ec507 100644
--- a/drivers/staging/fsl-mc/README.txt
+++ b/drivers/staging/fsl-mc/README.txt
@@ -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
 
diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 5065821..4892eb6 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -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:
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-10-30 Thread 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

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 43 +
 1 file changed, 43 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 25e205421..61d44fd 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -100,10 +100,53 @@ 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;
+   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);
+   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);
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 5/8] staging: fsl-mc: fsl-mc bus's sysfs rescan documentation

2015-10-30 Thread Lijun Pan
Add the sysfs documentation for the rescan attribute of
fsl-mc bus.

Signed-off-by: Lijun Pan 
---
 Documentation/ABI/testing/sysfs-bus-fsl-mc | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsl-mc

diff --git a/Documentation/ABI/testing/sysfs-bus-fsl-mc 
b/Documentation/ABI/testing/sysfs-bus-fsl-mc
new file mode 100644
index 000..3fa747c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-fsl-mc
@@ -0,0 +1,11 @@
+What:  /sys/bus/fsl-mc/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+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
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-10-30 Thread Lijun Pan
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.

Signed-off-by: Lijun Pan 
---
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(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 84db55b..25e205421 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -22,8 +22,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
@@ -52,7 +50,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;
 
/*
@@ -236,20 +234,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)
 {
@@ -541,7 +525,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
@@ -772,7 +756,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);
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index a933291..6051955 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "../include/dprc.h"
 
 #define FSL_MC_VENDOR_FREESCALE0x1957
@@ -200,4 +201,17 @@ void fsl_mc_object_free(struct fsl_mc_device *mc_adev);
 
 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_ */
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/8] staging: fsl-mc: add sysfs rescan attribute in TODO

2015-10-30 Thread Lijun Pan
Demonstrate why sysfs rescan attribute is helpful for
moving fsl-mc bus out of staging.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/TODO | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 3894368..5065821 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -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.
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-10-30 Thread 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.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/README.txt | 11 ++-
 drivers/staging/fsl-mc/TODO   | 18 --
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/README.txt
index 8214102..e9ec507 100644
--- a/drivers/staging/fsl-mc/README.txt
+++ b/drivers/staging/fsl-mc/README.txt
@@ -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
 
diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 5065821..4892eb6 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -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:
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 8/8] staging: fsl-mc: Management Complex restool driver

2015-10-30 Thread 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.

Signed-off-by: Lijun Pan 
---
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

diff --git a/Documentation/ioctl/ioctl-number.txt 
b/Documentation/ioctl/ioctl-number.txt
index df1b25e..3e83fe9 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -166,6 +166,7 @@ Code  Seq#(hex) Include FileComments
 '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!
diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 0d779d9..39c6ef9 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -21,4 +21,9 @@ config FSL_MC_BUS
  Only enable this option when building the kernel for
  Freescale QorQIQ LS2 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.
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index 25433a9..28b5fc0 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -15,3 +15,6 @@ mc-bus-driver-objs := mc-bus.o \
  mc-allocator.o \
  dpmcp.o \
  dpbp.o
+
+# MC restool kernel support
+obj-$(CONFIG_FSL_MC_RESTOOL) += mc-restool.o
diff --git a/drivers/staging/fsl-mc/bus/mc-ioctl.h 
b/drivers/staging/fsl-mc/bus/mc-ioctl.h
new file mode 100644
index 000..8ac502a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-ioctl.h
@@ -0,0 +1,22 @@
+/*
+ * Freescale Management Complex (MC) ioclt interface
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 
+#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_ */
diff --git a/drivers/staging/fsl-mc/bus/mc-restool.c 
b/drivers/staging/fsl-mc/bus/mc-restool.c
new file mode 100644
index 000..57f059a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-restool.c
@@ -0,0 +1,392 @@
+/*
+ * Freescale Management Complex (MC) restool driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 "../include/mc-private.h"
+#include 
+#include 
+#include 
+#include 

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

2015-10-30 Thread 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

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 46 +
 1 file changed, 46 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 61d44fd..f9ee5fe 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -142,11 +142,57 @@ static const struct attribute_group *fsl_mc_dev_groups[] 
= {
NULL,
 };
 
+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 (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);
+   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);
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-10-30 Thread Lijun Pan
Add the sysfs documentation for the rescan attribute of
dprc devices.

Signed-off-by: Lijun Pan 
---
 Documentation/ABI/testing/sysfs-devices-dprc | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-dprc

diff --git a/Documentation/ABI/testing/sysfs-devices-dprc 
b/Documentation/ABI/testing/sysfs-devices-dprc
new file mode 100644
index 000..3c5d725
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-dprc
@@ -0,0 +1,13 @@
+What:  /sys/devices/.../dprc.X/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+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/80c00.fsl-mc/dprc.1/rescan
+
+
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 0/8] Management Complex restool driver

2015-10-30 Thread Lijun Pan
This series of patches are based on
http://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-next&id=63f2be5c3b358db031f86eafa9cd450f6558a55b

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

This v2 series have,
patch 1/8 use inline function to differentiate root dprc
patch 2/8 add sysfs rescan attribute in TODO list
patch 3/8 add sysfs rescan documentation for dprc device
patch 4/8 introduce the sysfs rescan attribute for root dprc device
patch 5/8 add sysfs rescan documentation for fsl-mc bus
patch 6/8 introduce the sysfs rescan attribute for fsl-mc bus
patch 7/8 add restool driver introduction in TODO list and README
patch 8/8 introduction of restool driver, which sits on fsl-mc bus and
utilizes fsl-mc bus to communicate with MC firmware.
restool driver is the first driver to start using fsl-mc bus.
This restool driver is small and helps fsl-mc bus move out of staging.

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  | 112 ++--
 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, 587 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

-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/5] staging: fsl-mc: Management Complex restool driver

2015-10-30 Thread Lijun Pan


> -Original Message-
> From: Pan Lijun-B44306
> Sent: Thursday, October 29, 2015 6:55 PM
> To: Wood Scott-B07421 
> Cc: gre...@linuxfoundation.org; a...@arndb.de; de...@driverdev.osuosl.org;
> linux-kernel@vger.kernel.org; Yoder Stuart-B08248
> ; katz Itai-RM05202 ;
> Rivera Jose-B46482 ; Li Yang-Leo-R58472
> ; ag...@suse.de; Hamciuc Bogdan-BHAMCIU1
> ; Marginean Alexandru-R89243
> ; Sharma Bhupesh-B45370
> ; Erez Nir-RM30794
> ; Schmitt Richard-B43082
> ; dan.carpen...@oracle.com
> Subject: RE: [PATCH 5/5] staging: fsl-mc: Management Complex restool driver
> 
> 
> 
> > -Original Message-
> > From: Wood Scott-B07421
> > Sent: Tuesday, October 27, 2015 12:17 AM
> > To: Pan Lijun-B44306 
> > Cc: gre...@linuxfoundation.org; a...@arndb.de;
> > de...@driverdev.osuosl.org; linux-kernel@vger.kernel.org; Yoder
> > Stuart-B08248 ; katz Itai-RM05202
> > ; Rivera Jose-B46482
> > ; Li Yang-Leo-R58472
> > ; ag...@suse.de; Hamciuc Bogdan-BHAMCIU1
> > ; Marginean Alexandru-R89243
> > ; Sharma Bhupesh-B45370
> > ; Erez Nir-RM30794
> > ; Schmitt Richard-B43082
> > ; dan.carpen...@oracle.com
> > Subject: Re: [PATCH 5/5] staging: fsl-mc: Management Complex restool
> > driver
> >
> > On Sun, 2015-10-25 at 17:41 -0500, Lijun Pan wrote:
> > > 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.
> > >
> > > Signed-off-by: Lijun Pan 
> > > ---
> > >  drivers/staging/fsl-mc/bus/Kconfig  |   7 +-
> > >  drivers/staging/fsl-mc/bus/Makefile |   3 +
> > >  drivers/staging/fsl-mc/bus/mc-ioctl.h   |  24 ++
> > >  drivers/staging/fsl-mc/bus/mc-restool.c | 488
> > > 
> > >  4 files changed, 521 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
> > >
> > > diff --git a/drivers/staging/fsl-mc/bus/Kconfig
> > > b/drivers/staging/fsl- mc/bus/Kconfig index 0d779d9..39c6ef9 100644
> > > --- a/drivers/staging/fsl-mc/bus/Kconfig
> > > +++ b/drivers/staging/fsl-mc/bus/Kconfig
> > > @@ -21,4 +21,9 @@ config FSL_MC_BUS
> > > Only enable this option when building the kernel for
> > > Freescale QorQIQ LS2 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.
> > > diff --git a/drivers/staging/fsl-mc/bus/Makefile
> > > b/drivers/staging/fsl- mc/bus/Makefile index 25433a9..28b5fc0 100644
> > > --- a/drivers/staging/fsl-mc/bus/Makefile
> > > +++ b/drivers/staging/fsl-mc/bus/Makefile
> > > @@ -15,3 +15,6 @@ mc-bus-driver-objs := mc-bus.o \
> > > mc-allocator.o \
> > > dpmcp.o \
> > > dpbp.o
> > > +
> > > +# MC restool kernel support
> > > +obj-$(CONFIG_FSL_MC_RESTOOL) += mc-restool.o
> > > diff --git a/drivers/staging/fsl-mc/bus/mc-ioctl.h
> > > b/drivers/staging/fsl- mc/bus/mc-ioctl.h new file mode 100644 index
> > > 000..e52f907
> > > --- /dev/null
> > > +++ b/drivers/staging/fsl-mc/bus/mc-ioctl.h
> > > @@ -0,0 +1,24 @@
> > > +/*
> > &g

RE: [PATCH 5/5] staging: fsl-mc: Management Complex restool driver

2015-10-29 Thread Lijun Pan


> -Original Message-
> From: Wood Scott-B07421
> Sent: Tuesday, October 27, 2015 12:17 AM
> To: Pan Lijun-B44306 
> Cc: gre...@linuxfoundation.org; a...@arndb.de; de...@driverdev.osuosl.org;
> linux-kernel@vger.kernel.org; Yoder Stuart-B08248
> ; katz Itai-RM05202 ;
> Rivera Jose-B46482 ; Li Yang-Leo-R58472
> ; ag...@suse.de; Hamciuc Bogdan-BHAMCIU1
> ; Marginean Alexandru-R89243
> ; Sharma Bhupesh-B45370
> ; Erez Nir-RM30794
> ; Schmitt Richard-B43082
> ; dan.carpen...@oracle.com
> Subject: Re: [PATCH 5/5] staging: fsl-mc: Management Complex restool driver
> 
> On Sun, 2015-10-25 at 17:41 -0500, Lijun Pan wrote:
> > 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.
> >
> > Signed-off-by: Lijun Pan 
> > ---
> >  drivers/staging/fsl-mc/bus/Kconfig  |   7 +-
> >  drivers/staging/fsl-mc/bus/Makefile |   3 +
> >  drivers/staging/fsl-mc/bus/mc-ioctl.h   |  24 ++
> >  drivers/staging/fsl-mc/bus/mc-restool.c | 488
> > 
> >  4 files changed, 521 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
> >
> > diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-
> > mc/bus/Kconfig index 0d779d9..39c6ef9 100644
> > --- a/drivers/staging/fsl-mc/bus/Kconfig
> > +++ b/drivers/staging/fsl-mc/bus/Kconfig
> > @@ -21,4 +21,9 @@ config FSL_MC_BUS
> > Only enable this option when building the kernel for
> > Freescale QorQIQ LS2 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.
> > diff --git a/drivers/staging/fsl-mc/bus/Makefile
> > b/drivers/staging/fsl- mc/bus/Makefile index 25433a9..28b5fc0 100644
> > --- a/drivers/staging/fsl-mc/bus/Makefile
> > +++ b/drivers/staging/fsl-mc/bus/Makefile
> > @@ -15,3 +15,6 @@ mc-bus-driver-objs := mc-bus.o \
> > mc-allocator.o \
> > dpmcp.o \
> > dpbp.o
> > +
> > +# MC restool kernel support
> > +obj-$(CONFIG_FSL_MC_RESTOOL) += mc-restool.o
> > diff --git a/drivers/staging/fsl-mc/bus/mc-ioctl.h
> > b/drivers/staging/fsl- mc/bus/mc-ioctl.h new file mode 100644 index
> > 000..e52f907
> > --- /dev/null
> > +++ b/drivers/staging/fsl-mc/bus/mc-ioctl.h
> > @@ -0,0 +1,24 @@
> > +/*
> > + * Freescale Management Complex (MC) ioclt interface
> 
> ioctl
> 
> > + *
> > + * Copyright (C) 2014 Freescale Semiconductor, Inc.
> > + * Author: Lijun Pan 
> > + *
> > + * 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 
> > +
> > +#define RESTOOL_IOCTL_TYPE   'R'
> > +
> > +#define RESTOOL_DPRC_SYNC \
> > + _IO(RESTOOL_IOCTL_TYPE, 0x2)
> > +
> > +#define RESTOOL_SEND_MC_COMMAND \
> > + _IOWR(RESTOOL_IOCTL_TYPE, 0x4, struct mc_command)
> 
> Look at Documentation/ioctl/ioctl-number.txt and reserve a range within 'R'
> that doesn't conflict.
> 
> Add thorough documentation of this API.

What path do you recommend me to put documentation of this 

RE: [PATCH 4/5] staging: fsl-mc: bus rescan attribute to sync kernel with MC

2015-10-29 Thread Lijun Pan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, October 27, 2015 12:40 AM
> To: Pan Lijun-B44306 
> Cc: a...@arndb.de; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; Hamciuc Bogdan-BHAMCIU1
> ; Sharma Bhupesh-B45370
> ; Rivera Jose-B46482
> ; ag...@suse.de; Yoder Stuart-B08248
> ; Erez Nir-RM30794 ;
> katz Itai-RM05202 ; Wood Scott-B07421
> ; Li Yang-Leo-R58472 ;
> Marginean Alexandru-R89243 ;
> dan.carpen...@oracle.com; Schmitt Richard-B43082
> 
> Subject: Re: [PATCH 4/5] staging: fsl-mc: bus rescan attribute to sync kernel
> with MC
> 
> On Sun, Oct 25, 2015 at 05:41:22PM -0500, Lijun Pan wrote:
> > 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
> >
> > Signed-off-by: Lijun Pan 
> > ---
> >  drivers/staging/fsl-mc/bus/mc-bus.c | 46
> > +
> >  1 file changed, 46 insertions(+)
> >
> > diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c
> > b/drivers/staging/fsl-mc/bus/mc-bus.c
> > index 33a56ad..f1baad7 100644
> > --- a/drivers/staging/fsl-mc/bus/mc-bus.c
> > +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
> > @@ -144,11 +144,57 @@ static const struct attribute_group
> *fsl_mc_dev_groups[] = {
> > NULL,
> >  };
> >
> > +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 (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);
> > +   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);
> 
> No documentation update as well?

Hi Greg,

Are you saying something like adding
Documentation/ABI/testing/sysfs-bus-fsl-mc? For the fsl-mc bus
Documentation/ABI/testing/sysfs-devices-dprc? For the dprc device?
Or 
drivers/staging/fsl-mc/[README.txt | TODO]?

Thanks
Lijun


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/5] staging: fsl-mc: Management Complex restool driver

2015-10-26 Thread Lijun Pan


> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Monday, October 26, 2015 1:20 AM
> To: Pan Lijun-B44306 
> Cc: gre...@linuxfoundation.org; a...@arndb.de; de...@driverdev.osuosl.org;
> linux-kernel@vger.kernel.org; Yoder Stuart-B08248
> ; katz Itai-RM05202 ;
> Rivera Jose-B46482 ; Li Yang-Leo-R58472
> ; Wood Scott-B07421 ;
> ag...@suse.de; Hamciuc Bogdan-BHAMCIU1 ;
> Marginean Alexandru-R89243 ; Sharma Bhupesh-
> B45370 ; Erez Nir-RM30794
> ; Schmitt Richard-B43082
> 
> Subject: Re: [PATCH 5/5] staging: fsl-mc: Management Complex restool driver
> 
> A few style issues and error handling bugs.  See below.
> 
> On Sun, Oct 25, 2015 at 05:41:23PM -0500, Lijun Pan wrote:
> > +static int fsl_mc_restool_dev_open(struct inode *inode, struct file
> > +*filep) {
> > +   struct fsl_mc_device *root_mc_dev;
> > +   int error = 0;
> > +   struct fsl_mc_io *dynamic_mc_io = NULL;
> > +   struct restool_misc *restool_misc;
> > +   struct restool_misc *restool_misc_cursor;
> > +
> > +   pr_debug("%s: inode's dev_t == %u\n", __func__, inode->i_rdev);
> > +
> > +   list_for_each_entry(restool_misc_cursor, &misc_list, list) {
> > +   if (restool_misc_cursor->miscdevt == inode->i_rdev) {
> > +   pr_debug("%s: Found the restool_misc\n", __func__);
> > +   restool_misc = restool_misc_cursor;
> > +   break;
> > +   }
> > +   }
> > +
> > +   if (!restool_misc)
> > +   return -EINVAL;
> > +
> > +   if (WARN_ON(restool_misc->dev == NULL))
> > +   return -EINVAL;
> > +
> > +   mutex_lock(&restool_misc->mutex);
> > +
> > +   if (!restool_misc->static_instance_in_use) {
> > +   restool_misc->static_instance_in_use = true;
> > +   filep->private_data = restool_misc->static_mc_io;
> > +   } else {
> > +   dynamic_mc_io = kzalloc(sizeof(struct fsl_mc_io),
> GFP_KERNEL);
> > +   if (dynamic_mc_io == NULL) {
> > +   error = -ENOMEM;
> > +   goto error;
> > +   }
> > +
> > +   root_mc_dev = to_fsl_mc_device(restool_misc->dev);
> > +   error = fsl_mc_portal_allocate(root_mc_dev, 0,
> &dynamic_mc_io);
> > +   if (error < 0) {
> > +   pr_err("Not able to allocate MC portal\n");
> > +   goto error;
> > +   }
> > +   ++restool_misc->dynamic_instance_count;
> > +   filep->private_data = dynamic_mc_io;
> > +   }
> > +
> > +   mutex_unlock(&restool_misc->mutex);
> > +
> > +   return 0;
> > +error:
> > +   if (dynamic_mc_io != NULL) {
> > +   fsl_mc_portal_free(dynamic_mc_io);
> > +   kfree(dynamic_mc_io);
> > +   }
> > +
> > +   mutex_unlock(&restool_misc->mutex);
> > +
> > +   return error;
> > +}
> 
> Don't do One Err style error handling where there is only one error label.  
> It is
> bug prone.  In this example if we call
> fsl_mc_portal_free() when fsl_mc_portal_allocate() failed then it can trigger 
> a
> WARN_ON().  The handling.fsl_mc_portal_allocate() function has some very
> complicated error handling so this probably causes a crash but I am too last 
> to
> untangle it...  Anyway do it like this:
> 
>   if (WARN_ON(restool_misc->dev == NULL))
>   return -EINVAL;
> 
>   mutex_lock(&restool_misc->mutex);
> 
>   if (!restool_misc->static_instance_in_use) {
>   restool_misc->static_instance_in_use = true;
>   filep->private_data = restool_misc->static_mc_io;
>   } else {
>   dynamic_mc_io = kzalloc(sizeof(struct fsl_mc_io),
> GFP_KERNEL);
>   if (dynamic_mc_io == NULL) {
>   error = -ENOMEM;
>   goto err_unlock;
>   }
> 
>   root_mc_dev = to_fsl_mc_device(restool_misc->dev);
>   error = fsl_mc_portal_allocate(root_mc_dev, 0,
> &dynamic_mc_io);
>   if (error < 0) {
>   pr_err("Not able to allocate MC portal\n");
>   goto free_dynamic_mc_io;
>   }
>   ++restool_misc->dynamic_instance_count;
>   filep->private_data = dynamic_mc_io;
>   }
> 
>   mutex_unlock(&restool_misc->mutex);
> 
>   return 0;
> 
> free_d

RE: [PATCH 2/5] staging: fsl-mc: define a macro to differentiate root dprc

2015-10-26 Thread Lijun Pan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Sunday, October 25, 2015 7:13 PM
> To: Pan Lijun-B44306 
> Cc: a...@arndb.de; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; Yoder Stuart-B08248 ;
> katz Itai-RM05202 ; Rivera Jose-B46482
> ; Li Yang-Leo-R58472 ;
> Wood Scott-B07421 ; ag...@suse.de; Hamciuc
> Bogdan-BHAMCIU1 ; Marginean Alexandru-R89243
> ; Sharma Bhupesh-B45370
> ; Erez Nir-RM30794
> ; Schmitt Richard-B43082
> ; dan.carpen...@oracle.com
> Subject: Re: [PATCH 2/5] staging: fsl-mc: define a macro to differentiate root
> dprc
> 
> On Sun, Oct 25, 2015 at 05:41:20PM -0500, Lijun Pan wrote:
> > Define is_root_dprc(dev) to tell whether a device is root dprc or not
> > via platform_bus_type.
> >
> > Signed-off-by: Lijun Pan 
> > ---
> >  drivers/staging/fsl-mc/include/mc.h | 10 ++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/staging/fsl-mc/include/mc.h
> > b/drivers/staging/fsl-mc/include/mc.h
> > index a933291..483763e 100644
> > --- a/drivers/staging/fsl-mc/include/mc.h
> > +++ b/drivers/staging/fsl-mc/include/mc.h
> > @@ -14,6 +14,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include "../include/dprc.h"
> >
> >  #define FSL_MC_VENDOR_FREESCALE0x1957
> > @@ -109,6 +110,15 @@ struct fsl_mc_resource {
> >  #define FSL_MC_IS_DPRC 0x0001
> >
> >  /**
> > +  * root dprc's parent is a platform device
> > +  * that platform device's bus type is platform_bus_type.
> > +  */
> > +#define is_root_dprc(dev) \
> > +   ((to_fsl_mc_device(dev)->flags & FSL_MC_IS_DPRC) && \
> > +   ((dev)->bus == &fsl_mc_bus_type) && \
> > +   ((dev)->parent->bus == &platform_bus_type))
> > +
> 
> It's best to make this type of thing a static inline function, to ensure you 
> get the
> correct typechecking.
> 

I will take your suggestion and make changes in patch v2.
Lijun


> thanks,
> 
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] staging: fsl-mc: Management Complex restool driver

2015-10-25 Thread 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.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/Kconfig  |   7 +-
 drivers/staging/fsl-mc/bus/Makefile |   3 +
 drivers/staging/fsl-mc/bus/mc-ioctl.h   |  24 ++
 drivers/staging/fsl-mc/bus/mc-restool.c | 488 
 4 files changed, 521 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

diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 0d779d9..39c6ef9 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -21,4 +21,9 @@ config FSL_MC_BUS
  Only enable this option when building the kernel for
  Freescale QorQIQ LS2 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.
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index 25433a9..28b5fc0 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -15,3 +15,6 @@ mc-bus-driver-objs := mc-bus.o \
  mc-allocator.o \
  dpmcp.o \
  dpbp.o
+
+# MC restool kernel support
+obj-$(CONFIG_FSL_MC_RESTOOL) += mc-restool.o
diff --git a/drivers/staging/fsl-mc/bus/mc-ioctl.h 
b/drivers/staging/fsl-mc/bus/mc-ioctl.h
new file mode 100644
index 000..e52f907
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-ioctl.h
@@ -0,0 +1,24 @@
+/*
+ * Freescale Management Complex (MC) ioclt interface
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 
+
+#define RESTOOL_IOCTL_TYPE   'R'
+
+#define RESTOOL_DPRC_SYNC \
+   _IO(RESTOOL_IOCTL_TYPE, 0x2)
+
+#define RESTOOL_SEND_MC_COMMAND \
+   _IOWR(RESTOOL_IOCTL_TYPE, 0x4, struct mc_command)
+
+#endif /* _FSL_MC_IOCTL_H_ */
diff --git a/drivers/staging/fsl-mc/bus/mc-restool.c 
b/drivers/staging/fsl-mc/bus/mc-restool.c
new file mode 100644
index 000..a219172
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-restool.c
@@ -0,0 +1,488 @@
+/*
+ * Freescale Management Complex (MC) restool driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * 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 "../include/mc-private.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mc-ioctl.h"
+#include "../include/mc-sys.h"
+#include "../include/mc-cmd.h"
+#include "../include/dpmng.h"
+
+/**
+ * Maximum number of DPRCs that can be opened at the same time
+ */
+#define MAX_DPRC_HANDLES   64
+
+/**
+ * restool_misc - information associated with the newly added miscdevice
+ * @misc: newly created miscdevice associated with root dprc
+ * @miscdevt: device id of this miscdevice
+ * @list: a linked list node representing this miscdevcie
+ * @static_mc_io: pointer to the static MC I/O object used by the restool
+ * @dynamic_instance_count: number of dynamically created instances
+ * @static_instance_in_use: static instance is in use or not
+ * @mutex: mutex lock to serialze the operations
+ * @dev: root dprc associated with this miscdevice
+ */
+struct restool_misc {
+   struct miscdevice misc;
+   dev_t miscdevt;
+   struct list_head list;
+   struct fsl_mc_io *static_mc_io;
+   uint32_t dynamic_instance_count;
+

[PATCH 1/5] staging: fsl-mc: section mismatch bug fix

2015-10-25 Thread Lijun Pan
WARNING: drivers/staging/built-in.o(.init.text+0xdc): Section mismatch in 
reference from the function fsl_mc_bus_driver_init() to the function 
.exit.text:dprc_driver_exit()
The function __init fsl_mc_bus_driver_init() references
a function __exit dprc_driver_exit().
This is often seen when error handling in the init function
uses functionality in the exit path.
The fix is often to remove the __exit annotation of
dprc_driver_exit() so it may be used outside an exit section.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c| 2 +-
 drivers/staging/fsl-mc/include/mc-private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index a9ead0d..2c4cd70 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -482,7 +482,7 @@ int __init dprc_driver_init(void)
return fsl_mc_driver_register(&dprc_driver);
 }
 
-void __exit dprc_driver_exit(void)
+void dprc_driver_exit(void)
 {
fsl_mc_driver_unregister(&dprc_driver);
 }
diff --git a/drivers/staging/fsl-mc/include/mc-private.h 
b/drivers/staging/fsl-mc/include/mc-private.h
index 2c4cc79..c706f77 100644
--- a/drivers/staging/fsl-mc/include/mc-private.h
+++ b/drivers/staging/fsl-mc/include/mc-private.h
@@ -103,7 +103,7 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev);
 
 int __init dprc_driver_init(void);
 
-void __exit dprc_driver_exit(void);
+void dprc_driver_exit(void);
 
 int __init fsl_mc_allocator_driver_init(void);
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] staging: fsl-mc: root dprc rescan attribute to sync kernel with MC

2015-10-25 Thread 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

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 44 +
 1 file changed, 44 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 84db55b..33a56ad 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -102,13 +102,57 @@ 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;
+   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);
+   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);
 
+
 static atomic_t root_dprc_count = ATOMIC_INIT(0);
 
 static int fsl_mc_driver_probe(struct device *dev)
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] Management Complex restool driver

2015-10-25 Thread Lijun Pan
This series of patches are based on
http://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-next&id=63f2be5c3b358db031f86eafa9cd450f6558a55b
patch 1/5 solves the section mismatch bug in fsl-mc bus
patches 2/5 - 4/5 add sysfs rescan atrributes, which is used in the
user space for synchronization of MC firmware and MC bus purpose.
patch 5/5 is the introduction of restool driver, which sits on fsl-mc bus and
utilizes fsl-mc bus to communicate with MC firmware.
restool driver is the first driver to start using fsl-mc bus.
This restool driver is small and helps fsl-mc bus move out of staging.

Lijun Pan (5):
  staging: fsl-mc: section mismatch bug fix
  staging: fsl-mc: define a macro to differentiate root dprc
  staging: fsl-mc: root dprc rescan attribute to sync kernel with MC
  staging: fsl-mc: bus rescan attribute to sync kernel with MC
  staging: fsl-mc: Management Complex restool driver

 drivers/staging/fsl-mc/bus/Kconfig  |   7 +-
 drivers/staging/fsl-mc/bus/Makefile |   3 +
 drivers/staging/fsl-mc/bus/dprc-driver.c|   2 +-
 drivers/staging/fsl-mc/bus/mc-bus.c |  90 +
 drivers/staging/fsl-mc/bus/mc-ioctl.h   |  24 ++
 drivers/staging/fsl-mc/bus/mc-restool.c | 488 
 drivers/staging/fsl-mc/include/mc-private.h |   2 +-
 drivers/staging/fsl-mc/include/mc.h |  10 +
 8 files changed, 623 insertions(+), 3 deletions(-)
 create mode 100644 drivers/staging/fsl-mc/bus/mc-ioctl.h
 create mode 100644 drivers/staging/fsl-mc/bus/mc-restool.c

-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] staging: fsl-mc: bus rescan attribute to sync kernel with MC

2015-10-25 Thread 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

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 46 +
 1 file changed, 46 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 33a56ad..f1baad7 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -144,11 +144,57 @@ static const struct attribute_group *fsl_mc_dev_groups[] 
= {
NULL,
 };
 
+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 (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);
+   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);
 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] staging: fsl-mc: define a macro to differentiate root dprc

2015-10-25 Thread Lijun Pan
Define is_root_dprc(dev) to tell whether a device is
root dprc or not via platform_bus_type.

Signed-off-by: Lijun Pan 
---
 drivers/staging/fsl-mc/include/mc.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index a933291..483763e 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "../include/dprc.h"
 
 #define FSL_MC_VENDOR_FREESCALE0x1957
@@ -109,6 +110,15 @@ struct fsl_mc_resource {
 #define FSL_MC_IS_DPRC 0x0001
 
 /**
+  * root dprc's parent is a platform device
+  * that platform device's bus type is platform_bus_type.
+  */
+#define is_root_dprc(dev) \
+   ((to_fsl_mc_device(dev)->flags & FSL_MC_IS_DPRC) && \
+   ((dev)->bus == &fsl_mc_bus_type) && \
+   ((dev)->parent->bus == &platform_bus_type))
+
+/**
  * Default DMA mask for devices on a fsl-mc bus
  */
 #define FSL_MC_DEFAULT_DMA_MASK(~0ULL)
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] fsl-ifc: add missing include on ARM64

2015-10-12 Thread Lijun Pan
Dear Arnd,

I would like to have your feedback on this patch.
If it is good now, can you accept it?  
Lijun




On 10/1/15, 4:14 PM, "Lijun Pan"  wrote:

>Need to include sched.h to fix the following compilation error
>if FSL_IFC is enabled on ARM64 machine.
>
>In file included from include/linux/mmzone.h:9:0,
> from include/linux/gfp.h:5,
> from include/linux/kmod.h:22,
> from include/linux/module.h:13,
> from drivers/memory/fsl_ifc.c:22:
>drivers/memory/fsl_ifc.c: In function ‘check_nand_stat’:
>include/linux/wait.h:165:35: error: ‘TASK_NORMAL’ undeclared (first use in 
>this function)
> #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
>   ^
>drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
>   wake_up(&ctrl->nand_wait);
>   ^
>include/linux/wait.h:165:35: note: each undeclared identifier is reported only 
>once for each function it appears in
> #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
>   ^
>drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
>   wake_up(&ctrl->nand_wait);
>   ^
>
>Analysis is as follows:
>I put some instrumental code and get the
>following .h files inclusion sequence:
>
>In file included from ./arch/arm64/include/asm/compat.h:25:0,
> from ./arch/arm64/include/asm/stat.h:23,
> from include/linux/stat.h:5,
> from include/linux/module.h:10,
> from drivers/memory/fsl_ifc.c:23:
>include/linux/sched.h:113:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or 
>‘__attribute__’ before ‘struct’
> struct sched_attr {
> ^
>
>CONFIG_COMPAT=y is enabled while 39 and 48 bit VA is selected.
>When 42 bit VA is selected, it does not enable CONFIG_COMPAT=y
>
>In ./arch/arm64/include/asm/stat.h:23, it has
>"#ifdef CONFIG_COMPAT"
>"#include "
>"..."
>"#endif"
>
>Since ./arch/arm64/include/asm/stat.h does not
>include ./arch/arm64/include/asm/compat.h,
>then it will not include include/linux/sched.h
>Hence we have to manually add "#include "
>in drivers/memory/fsl_ifc.c
>
>Signed-off-by: Lijun Pan 
>---
>v3: change the subject title to better reflect the commit message
>insert linux/sched.h in more appropriate place among all .h files
>articulate CONFIG_COMPAT=y is set in 39/48 bit VA
>v2: reordering the include .h files according to Arnd's suggestion
>detailing why linux/sched.h is needed.
>
> drivers/memory/fsl_ifc.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
>index e87459f..acd1460 100644
>--- a/drivers/memory/fsl_ifc.c
>+++ b/drivers/memory/fsl_ifc.c
>@@ -22,6 +22,7 @@
> #include 
> #include 
> #include 
>+#include 
> #include 
> #include 
> #include 
>-- 
>2.3.3
>
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�&j:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

[PATCH v3] fsl-ifc: add missing include on ARM64

2015-10-01 Thread Lijun Pan
Need to include sched.h to fix the following compilation error
if FSL_IFC is enabled on ARM64 machine.

In file included from include/linux/mmzone.h:9:0,
 from include/linux/gfp.h:5,
 from include/linux/kmod.h:22,
 from include/linux/module.h:13,
 from drivers/memory/fsl_ifc.c:22:
drivers/memory/fsl_ifc.c: In function ‘check_nand_stat’:
include/linux/wait.h:165:35: error: ‘TASK_NORMAL’ undeclared (first use in this 
function)
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^
include/linux/wait.h:165:35: note: each undeclared identifier is reported only 
once for each function it appears in
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^

Analysis is as follows:
I put some instrumental code and get the
following .h files inclusion sequence:

In file included from ./arch/arm64/include/asm/compat.h:25:0,
 from ./arch/arm64/include/asm/stat.h:23,
 from include/linux/stat.h:5,
 from include/linux/module.h:10,
 from drivers/memory/fsl_ifc.c:23:
include/linux/sched.h:113:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or 
‘__attribute__’ before ‘struct’
 struct sched_attr {
 ^

CONFIG_COMPAT=y is enabled while 39 and 48 bit VA is selected.
When 42 bit VA is selected, it does not enable CONFIG_COMPAT=y

In ./arch/arm64/include/asm/stat.h:23, it has
"#ifdef CONFIG_COMPAT"
"#include "
"..."
"#endif"

Since ./arch/arm64/include/asm/stat.h does not
include ./arch/arm64/include/asm/compat.h,
then it will not include include/linux/sched.h
Hence we have to manually add "#include "
in drivers/memory/fsl_ifc.c

Signed-off-by: Lijun Pan 
---
v3: change the subject title to better reflect the commit message
insert linux/sched.h in more appropriate place among all .h files
articulate CONFIG_COMPAT=y is set in 39/48 bit VA
v2: reordering the include .h files according to Arnd's suggestion
detailing why linux/sched.h is needed.

 drivers/memory/fsl_ifc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index e87459f..acd1460 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] fsl-ifc: fix compilation error on ARM's 42 bit VA

2015-09-30 Thread Lijun Pan
Need to include sched.h to fix the following compilation error
if FSL_IFC is enabled on ARM64 machine.
Also, sort the include files by alphabetical order.

In file included from include/linux/mmzone.h:9:0,
 from include/linux/gfp.h:5,
 from include/linux/kmod.h:22,
 from include/linux/module.h:13,
 from drivers/memory/fsl_ifc.c:22:
drivers/memory/fsl_ifc.c: In function ‘check_nand_stat’:
include/linux/wait.h:165:35: error: ‘TASK_NORMAL’ undeclared (first use in this 
function)
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^
include/linux/wait.h:165:35: note: each undeclared identifier is reported only 
once for each function it appears in
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^

Analysis is as follows:
I put some instrumental code and get the
following .h files inclusion sequence:

In file included from ./arch/arm64/include/asm/compat.h:25:0,
 from ./arch/arm64/include/asm/stat.h:23,
 from include/linux/stat.h:5,
 from include/linux/module.h:10,
 from drivers/memory/fsl_ifc.c:23:
include/linux/sched.h:113:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or 
‘__attribute__’ before ‘struct’
 struct sched_attr {
 ^

When 42 bit VA is selected, it does not enable CONFIG_COMPAT=y

In ./arch/arm64/include/asm/stat.h:23, it has
"#ifdef CONFIG_COMPAT"
"#include "
"..."
"#endif"

Since ./arch/arm64/include/asm/stat.h does not
include ./arch/arm64/include/asm/compat.h,
it will not include include/linux/sched.h
Hence we have to manually add "#include "
in drivers/memory/fsl_ifc.c

Signed-off-by: Lijun Pan 
---
v2: reordering the include .h files according to Arnd's suggestion
detailing why linux/sched.h is needed.
 
 drivers/memory/fsl_ifc.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index e87459f..defd62e 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -19,17 +19,18 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#include 
-#include 
 #include 
-#include 
-#include 
-#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
 struct fsl_ifc_ctrl *fsl_ifc_ctrl_dev;
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] fsl-ifc: fix compilation error on 42 bit VA

2015-09-23 Thread Lijun Pan
Need to include sched.h to fix the following compilation error
if FSL_IFC is enabled on ARM64 machine.

In file included from include/linux/mmzone.h:9:0,
 from include/linux/gfp.h:5,
 from include/linux/kmod.h:22,
 from include/linux/module.h:13,
 from drivers/memory/fsl_ifc.c:22:
drivers/memory/fsl_ifc.c: In function ‘check_nand_stat’:
include/linux/wait.h:165:35: error: ‘TASK_NORMAL’ undeclared (first use in this 
function)
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^
include/linux/wait.h:165:35: note: each undeclared identifier is reported only 
once for each function it appears in
 #define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
   ^
drivers/memory/fsl_ifc.c:136:3: note: in expansion of macro ‘wake_up’
   wake_up(&ctrl->nand_wait);
   ^
make[2]: *** [drivers/memory/fsl_ifc.o] Error 1
make[1]: *** [drivers/memory] Error 2
make[1]: *** Waiting for unfinished jobs

Signed-off-by: Lijun Pan 
---
 drivers/memory/fsl_ifc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index e87459f..8d90de6 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct fsl_ifc_ctrl *fsl_ifc_ctrl_dev;
 EXPORT_SYMBOL(fsl_ifc_ctrl_dev);
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/