Re: [v6 0/8] staging: fsl-mc: add dpio driver

2017-03-13 Thread Stuart Yoder
>
> This patch series adds the driver for the DPIO object which is a step
> to addressing the final item in the staging TODO list-- adding a
> functional driver on top of the bus driver.  The DPIO driver is a
> dependency for other functional drivers such as Ethernet.
>
> An overview of the DPIO object and driver components are in patch 1.
> Patches 2-6 are internal components of the DPIO driver-- bit twiddling
> of hardware registers, DPAA2 data structures, and the queuing APIs
> exposed to other drivers.
>
> Patch 7 adds the fsl-mc driver for the DPIO object.  It provides the
> probe/remove functions, demonstrating a working example of how fsl-mc
> drivers initialize, interact with the management complex hardware, map
> their mappable MMIO regions, initialize interrupts, register an ISR,
> etc.  All other DPAA2 drivers will follow a similar initialization
> pattern.
>
> version 6 changes
>-fixed error in size of SG_SHORT_LEN_MASK
>-removed improper padding in DPIO command responses
>-fixed some minor checkpatch warnings

Roy, when you re-spin this series please add information below the "---"
on each patch that changed identifying what changed in the patch.   For
example, be specific about which patches were affected by checkpatch and
what fixes you made.  Right now I can't tell.
For an example, of what I'm talking about look at previous versions of
this patch series.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 8/9] staging: fsl-dpaa2/eth: Add TODO file

2017-04-18 Thread Stuart Yoder
On Wed, Apr 12, 2017 at 11:25 AM, Ioana Radulescu
 wrote:
> Add a list of TODO items for the Ethernet driver
>
> Signed-off-by: Ioana Radulescu 
> ---
> v2: Add note
>
>  drivers/staging/fsl-dpaa2/ethernet/TODO | 14 ++
>  1 file changed, 14 insertions(+)
>  create mode 100644 drivers/staging/fsl-dpaa2/ethernet/TODO
>
> diff --git a/drivers/staging/fsl-dpaa2/ethernet/TODO 
> b/drivers/staging/fsl-dpaa2/ethernet/TODO
> new file mode 100644
> index ..110e66d44b42
> --- /dev/null
> +++ b/drivers/staging/fsl-dpaa2/ethernet/TODO
> @@ -0,0 +1,14 @@
> +* Add a DPAA2 MAC kernel driver in order to allow PHY management; currently
> +  the DPMAC objects and their link to DPNIs are handled by MC internally
> +  and all PHYs are seen as fixed-link
> +* add more debug support: decide how to expose detailed debug statistics,
> +  add ingress error queue support
> +* MC firmware uprev; the DPAA2 objects used by the Ethernet driver need to
> +  be kept in sync with binary interface changes in MC
> +* refine README file
> +* cleanup
> +
> +NOTE: None of the above is must-have before getting the DPAA2 Ethernet driver
> +out of staging. The main requirement for that is to have the drivers it
> +depends on, fsl-mc bus and DPIO driver, moved to drivers/bus and drivers/soc
> +respectively.

The TODO file should have contact info (I think)...look at other
drivers/staging TODO
for examples.

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] bus: fsl-mc: dpio: fix alter FQ state command

2017-04-21 Thread Stuart Yoder
On Fri, Apr 21, 2017 at 7:00 AM, Horia Geantă  wrote:
>
> When checking the response verb, the valid bit should be masked out,
> since its value flips depending on what Response Register
> (RR0 /RR1) it's been read from.
>
> Fixes: 321eecb06bfb ("bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2")
> Signed-off-by: Horia Geantă 
> ---
>  drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c 
> b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
> index 2a3ea29d9b43..5d020fb98c66 100644
> --- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
> +++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
> @@ -963,7 +963,7 @@ int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid,
> }
>
> /* Decode the outcome */
> -   WARN_ON(r->verb != alt_fq_verb);
> +   WARN_ON((r->verb & 0x7f) != alt_fq_verb);

Don't use magic constants like that.  Create a #define for the valid bit.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd

2017-04-29 Thread Stuart Yoder
On Fri, Apr 28, 2017 at 9:38 AM, Horia Geantă  wrote:
>
> While dpaa2_fd.simple structure fields are marked __leXX,
> corresponding cpu_to_leXX / leXX_to_cpu conversions are missing.
>
> While here, fix dpaa2_fd_{get,set}_bpid such that BMT, IVP bits
> sharing the 16-bit field with BPID are not affected.

Please split this into 2 separate patches.  Don't fix other misc things "while
you are at it" in the same patch.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3][v4] staging: fsl-mc: move bus driver out of staging

2017-05-19 Thread Stuart Yoder
On Fri, May 19, 2017 at 8:41 AM, Matthias Brugger
 wrote:
>
>
> On 19/05/17 15:13, laurentiu.tu...@nxp.com wrote:
>>
>> From: Stuart Yoder 
>>
>> Move the source files out of staging into their final locations:
>>-include files in drivers/staging/fsl-mc/include go to
>> include/linux/fsl
>>-irq-gic-v3-its-fsl-mc-msi.c goes to drivers/irqchip
>
>
> This driver has as compatible "arm,gic-v3-its". I wonder if this is correct
> and if it should be moved like this out of staging.

Matthias, can you be more specific as to what your concern is?

The fsl-mc bus needs to implement bus specific gic-v3 MSI support just
like the other
bus types.  See:
   drivers/irqchip/irq-gic-v3-its-pci-msi.c
   drivers/irqchip/irq-gic-v3-its-platform-msi.c

You will see that the PCI and platform bus types also find the gic-v3 node by
compatible string.

The bus specific gic-v3 support for fsl-mc is implemented in a
completely standard way.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/14] staging: fsl-mc: add dpmcp version check

2016-04-11 Thread Stuart Yoder
From: Itai Katz 

The dpmcp driver supports dpmcp version 3.0 and above.
This patch adds the code to check the version.

Signed-off-by: Itai Katz 
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dpmcp-cmd.h|6 +++---
 drivers/staging/fsl-mc/bus/mc-allocator.c |   11 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h 
b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h
index c6f4ec0..c9b52dd 100644
--- a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h
+++ b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h
@@ -32,9 +32,9 @@
 #ifndef _FSL_DPMCP_CMD_H
 #define _FSL_DPMCP_CMD_H
 
-/* DPMCP Version */
-#define DPMCP_VER_MAJOR3
-#define DPMCP_VER_MINOR0
+/* Minimal supported DPMCP Version */
+#define DPMCP_MIN_VER_MAJOR3
+#define DPMCP_MIN_VER_MINOR0
 
 /* Command IDs */
 #define DPMCP_CMDID_CLOSE  0x800
diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c 
b/drivers/staging/fsl-mc/bus/mc-allocator.c
index 52b16f7..4676ba1 100644
--- a/drivers/staging/fsl-mc/bus/mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
@@ -310,6 +310,17 @@ int __must_check fsl_mc_portal_allocate(struct 
fsl_mc_device *mc_dev,
if (WARN_ON(!dpmcp_dev))
goto error_cleanup_resource;
 
+   if (dpmcp_dev->obj_desc.ver_major < DPMCP_MIN_VER_MAJOR ||
+   (dpmcp_dev->obj_desc.ver_major == DPMCP_MIN_VER_MAJOR &&
+dpmcp_dev->obj_desc.ver_minor < DPMCP_MIN_VER_MINOR)) {
+   dev_err(&dpmcp_dev->dev,
+   "ERROR: Version %d.%d of DPMCP not supported.\n",
+   dpmcp_dev->obj_desc.ver_major,
+   dpmcp_dev->obj_desc.ver_minor);
+   error = -ENOTSUPP;
+   goto error_cleanup_resource;
+   }
+
if (WARN_ON(dpmcp_dev->obj_desc.region_count == 0))
goto error_cleanup_resource;
 
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/14] staging: fsl-mc: return -EINVAL for all fsl_mc_portal_allocate() failures

2016-04-11 Thread Stuart Yoder
From: Horia Geantă 

There are some error paths that allow for a NULL new_mc_io and err = 0
return code. Return -EINVAL instead.

Signed-off-by: Horia Geantă 
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-allocator.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c 
b/drivers/staging/fsl-mc/bus/mc-allocator.c
index 4676ba1..7ee71e7 100644
--- a/drivers/staging/fsl-mc/bus/mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
@@ -306,6 +306,7 @@ int __must_check fsl_mc_portal_allocate(struct 
fsl_mc_device *mc_dev,
if (error < 0)
return error;
 
+   error = -EINVAL;
dpmcp_dev = resource->data;
if (WARN_ON(!dpmcp_dev))
goto error_cleanup_resource;
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/14] staging: fsl-mc: don't use object versions to make binding decisions

2016-04-11 Thread Stuart Yoder
From: Itai Katz 

Up until now if the object version expected by a driver (in the API header
file) did not match the actual object version in the MC hardware the bus
driver refused to bind the object to the driver or printed out WARN_ON
dumps.

This patch removes those checks, and the responsibility of object version
checking should now be done in the object drivers themselves.  If the actual
version discovered is not supported, the driver's probe function should fail.
Drivers should use version checks to support new features and provide
backwards compatibility if at all possible.

This patch also removes the checks that caused bus driver probing to fail
if the overall MC version discovered did not match the firmware version
from the API header...this was too strict.  The overall MC version is
informational like a release number, and continues to be printed in the
boot log.

Signed-off-by: Itai Katz 
(Stuart: reworded commit log)
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c  |4 +--
 drivers/staging/fsl-mc/bus/mc-allocator.c |6 -
 drivers/staging/fsl-mc/bus/mc-bus.c   |   38 +
 3 files changed, 2 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 4334f3c..2d88c10 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -780,9 +780,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
 static const struct fsl_mc_device_match_id match_id_table[] = {
{
 .vendor = FSL_MC_VENDOR_FREESCALE,
-.obj_type = "dprc",
-.ver_major = DPRC_VER_MAJOR,
-.ver_minor = DPRC_VER_MINOR},
+.obj_type = "dprc"},
{.vendor = 0x0},
 };
 
diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c 
b/drivers/staging/fsl-mc/bus/mc-allocator.c
index 86f8543..52b16f7 100644
--- a/drivers/staging/fsl-mc/bus/mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
@@ -722,20 +722,14 @@ static const struct fsl_mc_device_match_id 
match_id_table[] = {
{
 .vendor = FSL_MC_VENDOR_FREESCALE,
 .obj_type = "dpbp",
-.ver_major = DPBP_VER_MAJOR,
-.ver_minor = DPBP_VER_MINOR
},
{
 .vendor = FSL_MC_VENDOR_FREESCALE,
 .obj_type = "dpmcp",
-.ver_major = DPMCP_VER_MAJOR,
-.ver_minor = DPMCP_VER_MINOR
},
{
 .vendor = FSL_MC_VENDOR_FREESCALE,
 .obj_type = "dpcon",
-.ver_major = DPCON_VER_MAJOR,
-.ver_minor = DPCON_VER_MINOR
},
{.vendor = 0x0},
 };
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index b594556..981e4c2 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -40,8 +40,6 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
bool found = false;
-   bool major_version_mismatch = false;
-   bool minor_version_mismatch = false;
 
if (WARN_ON(!fsl_mc_bus_exists()))
goto out;
@@ -64,32 +62,12 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
for (id = mc_drv->match_id_table; id->vendor != 0x0; id++) {
if (id->vendor == mc_dev->obj_desc.vendor &&
strcmp(id->obj_type, mc_dev->obj_desc.type) == 0) {
-   if (id->ver_major == mc_dev->obj_desc.ver_major) {
-   found = true;
-   if (id->ver_minor != mc_dev->obj_desc.ver_minor)
-   minor_version_mismatch = true;
-   } else {
-   major_version_mismatch = true;
-   }
+   found = true;
 
break;
}
}
 
-   if (major_version_mismatch) {
-   dev_warn(dev,
-"Major version mismatch: driver version %u.%u, MC 
object version %u.%u\n",
-id->ver_major, id->ver_minor,
-mc_dev->obj_desc.ver_major,
-mc_dev->obj_desc.ver_minor);
-   } else if (minor_version_mismatch) {
-   dev_warn(dev,
-"Minor version mismatch: driver version %u.%u, MC 
object version %u.%u\n",
-id->ver_major, id->ver_minor,
-mc_dev->obj_desc.ver_major,
-mc_dev->obj_desc.ver_minor);
-   }
-
 out:
dev_dbg(dev, "%smatched\n", found ? "" : "not ");
r

[PATCH 09/14] staging: fsl-mc: get version of root dprc from MC hardware

2016-04-11 Thread Stuart Yoder
From: Itai Katz 

The root dprc is discovered as a platform device in the device tree.  The
version of that dprc was previously set using hardcoded values from the API
header in the kernel).  This patch removes the use of the hardcoded version
numbers and instead reads the actual dprc version from the hardware.

Signed-off-by: Itai Katz 
(Stuart: resolved merge conflict, updated commit subject/log)
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-bus.c |   45 ---
 1 file changed, 37 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 2075597..b4c3c5e 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -229,11 +229,10 @@ static bool fsl_mc_is_root_dprc(struct device *dev)
return dev == root_dprc_dev;
 }
 
-static int get_dprc_icid(struct fsl_mc_io *mc_io,
-int container_id, u16 *icid)
+static int get_dprc_attr(struct fsl_mc_io *mc_io,
+int container_id, struct dprc_attributes *attr)
 {
u16 dprc_handle;
-   struct dprc_attributes attr;
int error;
 
error = dprc_open(mc_io, 0, container_id, &dprc_handle);
@@ -242,15 +241,14 @@ static int get_dprc_icid(struct fsl_mc_io *mc_io,
return error;
}
 
-   memset(&attr, 0, sizeof(attr));
-   error = dprc_get_attributes(mc_io, 0, dprc_handle, &attr);
+   memset(attr, 0, sizeof(struct dprc_attributes));
+   error = dprc_get_attributes(mc_io, 0, dprc_handle, attr);
if (error < 0) {
dev_err(mc_io->dev, "dprc_get_attributes() failed: %d\n",
error);
goto common_cleanup;
}
 
-   *icid = attr.icid;
error = 0;
 
 common_cleanup:
@@ -258,6 +256,34 @@ common_cleanup:
return error;
 }
 
+static int get_dprc_icid(struct fsl_mc_io *mc_io,
+int container_id, u16 *icid)
+{
+   struct dprc_attributes attr;
+   int error;
+
+   error = get_dprc_attr(mc_io, container_id, &attr);
+   if (error == 0)
+   *icid = attr.icid;
+
+   return error;
+}
+
+static int get_dprc_version(struct fsl_mc_io *mc_io,
+   int container_id, u16 *major, u16 *minor)
+{
+   struct dprc_attributes attr;
+   int error;
+
+   error = get_dprc_attr(mc_io, container_id, &attr);
+   if (error == 0) {
+   *major = attr.version.major;
+   *minor = attr.version.minor;
+   }
+
+   return error;
+}
+
 static int translate_mc_addr(struct fsl_mc_device *mc_dev,
 enum dprc_region_type mc_region_type,
 u64 mc_offset, phys_addr_t *phys_addr)
@@ -719,11 +745,14 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
goto error_cleanup_mc_io;
}
 
+   error = get_dprc_version(mc_io, container_id,
+&obj_desc.ver_major, &obj_desc.ver_minor);
+   if (error < 0)
+   goto error_cleanup_mc_io;
+
obj_desc.vendor = FSL_MC_VENDOR_FREESCALE;
strcpy(obj_desc.type, "dprc");
obj_desc.id = container_id;
-   obj_desc.ver_major = DPRC_VER_MAJOR;
-   obj_desc.ver_minor = DPRC_VER_MINOR;
obj_desc.irq_count = 1;
obj_desc.region_count = 0;
 
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/14] staging: fsl-mc: add dprc version check

2016-04-11 Thread Stuart Yoder
From: Itai Katz 

The dprc driver supports dprc version 5.0 and above.
This patch adds the code to check the version.

Signed-off-by: Itai Katz 
(Stuart: resolved merge conflicts, split dpseci quirk into separate patch)
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-cmd.h   |6 +++---
 drivers/staging/fsl-mc/bus/dprc-driver.c|   19 +++
 drivers/staging/fsl-mc/bus/mc-bus.c |1 +
 drivers/staging/fsl-mc/include/mc-private.h |2 ++
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-cmd.h 
b/drivers/staging/fsl-mc/bus/dprc-cmd.h
index d0198f5..9b854fa 100644
--- a/drivers/staging/fsl-mc/bus/dprc-cmd.h
+++ b/drivers/staging/fsl-mc/bus/dprc-cmd.h
@@ -40,9 +40,9 @@
 #ifndef _FSL_DPRC_CMD_H
 #define _FSL_DPRC_CMD_H
 
-/* DPRC Version */
-#define DPRC_VER_MAJOR 5
-#define DPRC_VER_MINOR 1
+/* Minimal supported DPRC Version */
+#define DPRC_MIN_VER_MAJOR 5
+#define DPRC_MIN_VER_MINOR 0
 
 /* Command IDs */
 #define DPRC_CMDID_CLOSE   0x800
diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 2d88c10..53c6e98 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -693,6 +693,25 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
goto error_cleanup_msi_domain;
}
 
+   error = dprc_get_attributes(mc_dev->mc_io, 0, mc_dev->mc_handle,
+   &mc_bus->dprc_attr);
+   if (error < 0) {
+   dev_err(&mc_dev->dev, "dprc_get_attributes() failed: %d\n",
+   error);
+   goto error_cleanup_open;
+   }
+
+   if (mc_bus->dprc_attr.version.major < DPRC_MIN_VER_MAJOR ||
+  (mc_bus->dprc_attr.version.major == DPRC_MIN_VER_MAJOR &&
+   mc_bus->dprc_attr.version.minor < DPRC_MIN_VER_MINOR)) {
+   dev_err(&mc_dev->dev,
+   "ERROR: DPRC version %d.%d not supported\n",
+   mc_bus->dprc_attr.version.major,
+   mc_bus->dprc_attr.version.minor);
+   error = -ENOTSUPP;
+   goto error_cleanup_open;
+   }
+
mutex_init(&mc_bus->scan_mutex);
 
/*
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index b4c3c5e..4053643 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -745,6 +745,7 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
goto error_cleanup_mc_io;
}
 
+   memset(&obj_desc, 0, sizeof(struct dprc_obj_desc));
error = get_dprc_version(mc_io, container_id,
 &obj_desc.ver_major, &obj_desc.ver_minor);
if (error < 0)
diff --git a/drivers/staging/fsl-mc/include/mc-private.h 
b/drivers/staging/fsl-mc/include/mc-private.h
index ee5f1d2..cab1ae9 100644
--- a/drivers/staging/fsl-mc/include/mc-private.h
+++ b/drivers/staging/fsl-mc/include/mc-private.h
@@ -94,12 +94,14 @@ struct fsl_mc_resource_pool {
  * from the physical DPRC.
  * @irq_resources: Pointer to array of IRQ objects for the IRQ pool
  * @scan_mutex: Serializes bus scanning
+ * @dprc_attr: DPRC attributes
  */
 struct fsl_mc_bus {
struct fsl_mc_device mc_dev;
struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
struct fsl_mc_device_irq *irq_resources;
struct mutex scan_mutex;/* serializes bus scanning */
+   struct dprc_attributes dprc_attr;
 };
 
 #define to_fsl_mc_bus(_mc_dev) \
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/14] staging: fsl-mc: set cacheable flag for added devices if applicable

2016-04-11 Thread Stuart Yoder
From: Itai Katz 

Some DPAA2 devices have mmio regions that should be mapped as
cacheable by drivers.  Set IORESOURCE_CACHEABLE in the region's
flags if applicable.

Signed-off-by: Itai Katz 
[Stuart: update subject and commit message]
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-bus.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 8bf76d7..2075597 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -354,6 +354,8 @@ static int fsl_mc_device_get_mmio_regions(struct 
fsl_mc_device *mc_dev,
regions[i].end = regions[i].start + region_desc.size - 1;
regions[i].name = "fsl-mc object MMIO region";
regions[i].flags = IORESOURCE_IO;
+   if (region_desc.flags & DPRC_REGION_CACHEABLE)
+   regions[i].flags |= IORESOURCE_CACHEABLE;
}
 
mc_dev->regions = regions;
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/14] staging: fsl-mc: DPAA2 overview readme update

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

incorporated feedback from review comments, other misc cleanup/tweaks

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/README.txt |  138 +
 1 file changed, 80 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/README.txt
index 8214102..179536a 100644
--- a/drivers/staging/fsl-mc/README.txt
+++ b/drivers/staging/fsl-mc/README.txt
@@ -11,11 +11,11 @@ Contents summary
-Overview of DPAA2 objects
-DPAA2 Linux driver architecture overview
 -bus driver
--dprc driver
+-DPRC driver
 -allocator
--dpio driver
+-DPIO driver
 -Ethernet
--mac
+-MAC
 
 DPAA2 Overview
 --
@@ -37,6 +37,9 @@ interfaces, an L2 switch, or accelerator instances.
 The MC provides memory-mapped I/O command interfaces (MC portals)
 which DPAA2 software drivers use to operate on DPAA2 objects:
 
+The diagram below shows an overview of the DPAA2 resource management
+architecture:
+
  +--+
  |  OS  |
  |DPAA2 drivers |
@@ -77,13 +80,13 @@ DPIO objects.
 
 Overview of DPAA2 Objects
 -
-The section provides a brief overview of some key objects
-in the DPAA2 hardware.  A simple scenario is described illustrating
-the objects involved in creating a network interfaces.
+The section provides a brief overview of some key DPAA2 objects.
+A simple scenario is described illustrating the objects involved
+in creating a network interfaces.
 
 -DPRC (Datapath Resource Container)
 
-A DPRC is an container object that holds all the other
+A DPRC is a container object that holds all the other
 types of DPAA2 objects.  In the example diagram below there
 are 8 objects of 5 types (DPMCP, DPIO, DPBP, DPNI, and DPMAC)
 in the container.
@@ -101,23 +104,23 @@ the objects involved in creating a network interfaces.
 | |
 +-+
 
-From the point of view of an OS, a DPRC is bus-like.  Like
-a plug-and-play bus, such as PCI, DPRC commands can be used to
-enumerate the contents of the DPRC, discover the hardware
-objects present (including mappable regions and interrupts).
+From the point of view of an OS, a DPRC behaves similar to a plug and
+play bus, like PCI.  DPRC commands can be used to enumerate the contents
+of the DPRC, discover the hardware objects present (including mappable
+regions and interrupts).
 
- dprc.1 (bus)
+ DPRC.1 (bus)
|
+--++---+---+---+
   ||   |   |   |
-dpmcp.1  dpio.1  dpbp.1  dpni.1  dpmac.1
-dpmcp.2  dpio.2
-dpmcp.3
+DPMCP.1  DPIO.1  DPBP.1  DPNI.1  DPMAC.1
+DPMCP.2  DPIO.2
+DPMCP.3
 
 Hardware objects can be created and destroyed dynamically, providing
 the ability to hot plug/unplug objects in and out of the DPRC.
 
-A DPRC has a mappable mmio region (an MC portal) that can be used
+A DPRC has a mappable MMIO region (an MC portal) that can be used
 to send MC commands.  It has an interrupt for status events (like
 hotplug).
 
@@ -137,10 +140,11 @@ the objects involved in creating a network interfaces.
 A typical Ethernet NIC is monolithic-- the NIC device contains TX/RX
 queuing mechanisms, configuration mechanisms, buffer management,
 physical ports, and interrupts.  DPAA2 uses a more granular approach
-utilizing multiple hardware objects.  Each object has specialized
-functions, and are used together by software to provide Ethernet network
-interface functionality.  This approach provides efficient use of finite
-hardware resources, flexibility, and performance advantages.
+utilizing multiple hardware objects.  Each object provides specialized
+functions. Groups of these objects are used by software to provide
+Ethernet network interface functionality.  This approach provides
+efficient use of finite hardware resources, flexibility, and
+performance advantages.
 
 The diagram below shows the objects needed for a simple
 network interface configuration on a system with 2 CPUs.
@@ -168,46 +172,52 @@ the objects involved in creating a network interfaces.
 
 Below the objects are described.  For each object a brief description
 is provided along with a summary of the kinds of operations the object
-supports and a summary of key resources of the object (mmio regions
-and irqs).
+supports and a summary of key resources of the object (MMIO regions
+and IRQs).
 
-DPMAC (Datapath Ethernet MAC): represents an Ethernet MAC, a
 hardware device that connects to an Ethernet PHY and allows
 physical

[PATCH 04/14] staging: fsl-mc: update dpbp binary interface to v2.2

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dpbp.c |   77 -
 drivers/staging/fsl-mc/include/dpbp-cmd.h |4 +-
 drivers/staging/fsl-mc/include/dpbp.h |   51 ++-
 3 files changed, 127 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpbp.c 
b/drivers/staging/fsl-mc/bus/dpbp.c
index 2d97173..c31fe1b 100644
--- a/drivers/staging/fsl-mc/bus/dpbp.c
+++ b/drivers/staging/fsl-mc/bus/dpbp.c
@@ -293,7 +293,7 @@ int dpbp_set_irq(struct fsl_mc_io *mc_io,
cmd.params[0] |= mc_enc(0, 8, irq_index);
cmd.params[0] |= mc_enc(32, 32, irq_cfg->val);
cmd.params[1] |= mc_enc(0, 64, irq_cfg->addr);
-   cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id);
+   cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
 
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
@@ -334,7 +334,7 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io,
/* retrieve response parameters */
irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32);
irq_cfg->addr = (u64)mc_dec(cmd.params[1], 0, 64);
-   irq_cfg->user_irq_id = (int)mc_dec(cmd.params[2], 0, 32);
+   irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32);
*type = (int)mc_dec(cmd.params[2], 32, 32);
return 0;
 }
@@ -502,6 +502,7 @@ int dpbp_get_irq_status(struct fsl_mc_io *mc_io,
/* prepare command */
cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS,
  cmd_flags, token);
+   cmd.params[0] |= mc_enc(0, 32, *status);
cmd.params[0] |= mc_enc(32, 8, irq_index);
 
/* send command to mc*/
@@ -580,3 +581,75 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io,
return 0;
 }
 EXPORT_SYMBOL(dpbp_get_attributes);
+
+/**
+ * dpbp_set_notifications() - Set notifications towards software
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPBP object
+ * @cfg:   notifications configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpbp_set_notifications(struct fsl_mc_io *mc_io,
+  u32 cmd_flags,
+  u16 token,
+  struct dpbp_notification_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_NOTIFICATIONS,
+ cmd_flags,
+ token);
+
+   cmd.params[0] |= mc_enc(0, 32, cfg->depletion_entry);
+   cmd.params[0] |= mc_enc(32, 32, cfg->depletion_exit);
+   cmd.params[1] |= mc_enc(0, 32, cfg->surplus_entry);
+   cmd.params[1] |= mc_enc(32, 32, cfg->surplus_exit);
+   cmd.params[2] |= mc_enc(0, 16, cfg->options);
+   cmd.params[3] |= mc_enc(0, 64, cfg->message_ctx);
+   cmd.params[4] |= mc_enc(0, 64, cfg->message_iova);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpbp_get_notifications() - Get the notifications configuration
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPBP object
+ * @cfg:   notifications configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpbp_get_notifications(struct fsl_mc_io *mc_io,
+  u32 cmd_flags,
+  u16 token,
+  struct dpbp_notification_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   int err;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_NOTIFICATIONS,
+ cmd_flags,
+ token);
+
+   /* send command to mc*/
+   err = mc_send_command(mc_io, &cmd);
+   if (err)
+   return err;
+
+   /* retrieve response parameters */
+   cfg->depletion_entry = (u32)mc_dec(cmd.params[0], 0, 32);
+   cfg->depletion_exit = (u32)mc_dec(cmd.params[0], 32, 32);
+   cfg->surplus_entry = (u32)mc_dec(cmd.params[1], 0, 32);
+   cfg->surplus_exit = (u32)mc_dec(cmd.params[1], 32, 32);
+   cfg->options = (u16)mc_dec(cmd.params[2], 0, 16);
+   cfg->message_ctx = (u64)mc_dec(cmd.params[3], 0, 64);
+   cfg->message_iova = (u64)mc_dec(cmd.params[4], 0, 64);
+
+   return 0;
+}
diff --git a/drivers/staging/fsl-mc/include/dpbp-cmd.h 
b/drivers/staging/fsl-mc/include/dpbp-cmd.h
index efa9bf3..c57b454 100644
--- a/drivers/staging/fsl-mc/include/dpbp-cmd.h
+++ b/drivers/staging/fsl-mc/include/dpbp-cmd.h
@@ -34,7 +34,7 @@
 
 /* DPBP Version */
 #define DPBP_VER_MAJOR 2
-#define DPBP_VER_

[PATCH 03/14] staging: fsl-mc: update dpmcp binary interface to v3.0

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dpmcp-cmd.h |5 ++---
 drivers/staging/fsl-mc/bus/dpmcp.c |   35 ++--
 drivers/staging/fsl-mc/bus/dpmcp.h |   10 ++---
 3 files changed, 6 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h 
b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h
index a87e9f8..c6f4ec0 100644
--- a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h
+++ b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h
@@ -33,8 +33,8 @@
 #define _FSL_DPMCP_CMD_H
 
 /* DPMCP Version */
-#define DPMCP_VER_MAJOR2
-#define DPMCP_VER_MINOR1
+#define DPMCP_VER_MAJOR3
+#define DPMCP_VER_MINOR0
 
 /* Command IDs */
 #define DPMCP_CMDID_CLOSE  0x800
@@ -52,6 +52,5 @@
 #define DPMCP_CMDID_SET_IRQ_MASK   0x014
 #define DPMCP_CMDID_GET_IRQ_MASK   0x015
 #define DPMCP_CMDID_GET_IRQ_STATUS 0x016
-#define DPMCP_CMDID_CLEAR_IRQ_STATUS   0x017
 
 #endif /* _FSL_DPMCP_CMD_H */
diff --git a/drivers/staging/fsl-mc/bus/dpmcp.c 
b/drivers/staging/fsl-mc/bus/dpmcp.c
index b0248f5..fd6dd4e 100644
--- a/drivers/staging/fsl-mc/bus/dpmcp.c
+++ b/drivers/staging/fsl-mc/bus/dpmcp.c
@@ -213,7 +213,7 @@ int dpmcp_set_irq(struct fsl_mc_io *mc_io,
cmd.params[0] |= mc_enc(0, 8, irq_index);
cmd.params[0] |= mc_enc(32, 32, irq_cfg->val);
cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr);
-   cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id);
+   cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
 
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
@@ -254,7 +254,7 @@ int dpmcp_get_irq(struct fsl_mc_io *mc_io,
/* retrieve response parameters */
irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32);
irq_cfg->paddr = (u64)mc_dec(cmd.params[1], 0, 64);
-   irq_cfg->user_irq_id = (int)mc_dec(cmd.params[2], 0, 32);
+   irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32);
*type = (int)mc_dec(cmd.params[2], 32, 32);
return 0;
 }
@@ -435,37 +435,6 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
 }
 
 /**
- * dpmcp_clear_irq_status() - Clear a pending interrupt's status
- *
- * @mc_io: Pointer to MC portal's I/O object
- * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
- * @token: Token of DPMCP object
- * @irq_index: The interrupt index to configure
- * @status:Bits to clear (W1C) - one bit per cause:
- * 0 = don't change
- * 1 = clear status bit
- *
- * Return: '0' on Success; Error code otherwise.
- */
-int dpmcp_clear_irq_status(struct fsl_mc_io *mc_io,
-  u32 cmd_flags,
-  u16 token,
-  u8 irq_index,
-  u32 status)
-{
-   struct mc_command cmd = { 0 };
-
-   /* prepare command */
-   cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CLEAR_IRQ_STATUS,
- cmd_flags, token);
-   cmd.params[0] |= mc_enc(0, 32, status);
-   cmd.params[0] |= mc_enc(32, 8, irq_index);
-
-   /* send command to mc*/
-   return mc_send_command(mc_io, &cmd);
-}
-
-/**
  * dpmcp_get_attributes - Retrieve DPMCP attributes.
  *
  * @mc_io: Pointer to MC portal's I/O object
diff --git a/drivers/staging/fsl-mc/bus/dpmcp.h 
b/drivers/staging/fsl-mc/bus/dpmcp.h
index 6df351f..fe79d4d 100644
--- a/drivers/staging/fsl-mc/bus/dpmcp.h
+++ b/drivers/staging/fsl-mc/bus/dpmcp.h
@@ -82,12 +82,12 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,
  * struct dpmcp_irq_cfg - IRQ configuration
  * @paddr: Address that must be written to signal a message-based interrupt
  * @val:   Value to write into irq_addr address
- * @user_irq_id: A user defined number associated with this IRQ
+ * @irq_num: A user defined number associated with this IRQ
  */
 struct dpmcp_irq_cfg {
 uint64_t   paddr;
 uint32_t   val;
-intuser_irq_id;
+intirq_num;
 };
 
 int dpmcp_set_irq(struct fsl_mc_io *mc_io,
@@ -133,12 +133,6 @@ int dpmcp_get_irq_status(struct fsl_mc_io  *mc_io,
uint8_t irq_index,
uint32_t*status);
 
-int dpmcp_clear_irq_status(struct fsl_mc_io*mc_io,
-  uint32_t cmd_flags,
-  uint16_t token,
- uint8_t   irq_index,
- uint32_t  status);
-
 /**
  * struct dpmcp_attr - Structure represent

[PATCH 07/14] staging: fsl-mc: set up coherent dma ops for added devices

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

Unless discovered devices have the no shareability flag set,
set up coherent dma ops for them.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-bus.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 981e4c2..8bf76d7 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -469,6 +469,10 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
goto error_cleanup_dev;
}
 
+   /* Objects are coherent, unless 'no shareability' flag set. */
+   if (!(obj_desc->flags & DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY))
+   arch_setup_dma_ops(&mc_dev->dev, 0, 0, NULL, true);
+
/*
 * The device-specific probe callback will get invoked by device_add()
 */
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/14] staging: fsl-mc: misc updates

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

This patch series makes further progress towards completing the fsl-mc
TODO list.

-patch 1 removes three items from the TODO file that were previously 
 completed-- multiple root dprc support, MSI support, and command
 serialization

-patch 2 makes some way overdue updates to README.txt from review
 comments on the mailing list last fall

-patches 3-5 update the binary interface for several objects to
 sync with latest MC firmware (todo item: "MC firmware uprev")

-patches 6-13 are cleanup items
   -change in how object versions are used in binding decisions
   -setting coherent dma_ops for devices if necessary
   -setting cacheable flag for object regions if applicable
   -getting the version of the root dprc from hardware, not based
on what was in the .h file
   -dprc driver now refuses to probe if dprc version is not minimum
expected
   -added quirk for bug in coherency flag for dpseci objects
   -allocator driver refuses to bind to dpmcp objects if version
is not minimum expected

-patch 14 adds a second maintainer for the driver
 
Horia Geanta (1):
  staging: fsl-mc: add quirk handling for dpseci objects < 4.0

Horia Geantă (1):
  staging: fsl-mc: return -EINVAL for all fsl_mc_portal_allocate()
failures

Itai Katz (5):
  staging: fsl-mc: don't use object versions to make binding decisions
  staging: fsl-mc: set cacheable flag for added devices if applicable
  staging: fsl-mc: get version of root dprc from MC hardware
  staging: fsl-mc: add dprc version check
  staging: fsl-mc: add dpmcp version check

Stuart Yoder (7):
  staging: fsl-mc: TODO updates
  staging: fsl-mc: DPAA2 overview readme update
  staging: fsl-mc: update dpmcp binary interface to v3.0
  staging: fsl-mc: update dpbp binary interface to v2.2
  staging: fsl-mc: update dprc binary interface to v5.1
  staging: fsl-mc: set up coherent dma ops for added devices
  MAINTAINERS: fsl-mc: Add second maintainer

 MAINTAINERS |1 +
 drivers/staging/fsl-mc/README.txt   |  138 ---
 drivers/staging/fsl-mc/TODO |   13 ---
 drivers/staging/fsl-mc/bus/dpbp.c   |   77 ++-
 drivers/staging/fsl-mc/bus/dpmcp-cmd.h  |7 +-
 drivers/staging/fsl-mc/bus/dpmcp.c  |   35 +--
 drivers/staging/fsl-mc/bus/dpmcp.h  |   10 +-
 drivers/staging/fsl-mc/bus/dprc-cmd.h   |6 +-
 drivers/staging/fsl-mc/bus/dprc-driver.c|   33 ++-
 drivers/staging/fsl-mc/bus/dprc.c   |   26 ++---
 drivers/staging/fsl-mc/bus/mc-allocator.c   |   18 ++--
 drivers/staging/fsl-mc/bus/mc-bus.c |   93 +-
 drivers/staging/fsl-mc/bus/mc-msi.c |2 +-
 drivers/staging/fsl-mc/include/dpbp-cmd.h   |4 +-
 drivers/staging/fsl-mc/include/dpbp.h   |   51 +-
 drivers/staging/fsl-mc/include/dprc.h   |   19 ++--
 drivers/staging/fsl-mc/include/mc-private.h |2 +
 17 files changed, 335 insertions(+), 200 deletions(-)

-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/14] staging: fsl-mc: update dprc binary interface to v5.1

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

The meaning of the "status" parameter in dprc_get_irq_status
has changed, and this patch updates the flib and caller
of the API.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-cmd.h|4 ++--
 drivers/staging/fsl-mc/bus/dprc-driver.c |1 +
 drivers/staging/fsl-mc/bus/dprc.c|   26 +-
 drivers/staging/fsl-mc/bus/mc-msi.c  |2 +-
 drivers/staging/fsl-mc/include/dprc.h|   19 ---
 5 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-cmd.h 
b/drivers/staging/fsl-mc/bus/dprc-cmd.h
index 6552c20..d0198f5 100644
--- a/drivers/staging/fsl-mc/bus/dprc-cmd.h
+++ b/drivers/staging/fsl-mc/bus/dprc-cmd.h
@@ -41,8 +41,8 @@
 #define _FSL_DPRC_CMD_H
 
 /* DPRC Version */
-#define DPRC_VER_MAJOR 4
-#define DPRC_VER_MINOR 0
+#define DPRC_VER_MAJOR 5
+#define DPRC_VER_MINOR 1
 
 /* Command IDs */
 #define DPRC_CMDID_CLOSE   0x800
diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 31488a7..4334f3c 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -423,6 +423,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, 
void *arg)
if (WARN_ON(!msi_desc || msi_desc->irq != (u32)irq_num))
goto out;
 
+   status = 0;
error = dprc_get_irq_status(mc_io, 0, mc_dev->mc_handle, 0,
&status);
if (error < 0) {
diff --git a/drivers/staging/fsl-mc/bus/dprc.c 
b/drivers/staging/fsl-mc/bus/dprc.c
index 381b9a9..a2c4737 100644
--- a/drivers/staging/fsl-mc/bus/dprc.c
+++ b/drivers/staging/fsl-mc/bus/dprc.c
@@ -265,7 +265,7 @@ int dprc_get_irq(struct fsl_mc_io *mc_io,
/* retrieve response parameters */
irq_cfg->val = mc_dec(cmd.params[0], 0, 32);
irq_cfg->paddr = mc_dec(cmd.params[1], 0, 64);
-   irq_cfg->user_irq_id = mc_dec(cmd.params[2], 0, 32);
+   irq_cfg->irq_num = mc_dec(cmd.params[2], 0, 32);
*type = mc_dec(cmd.params[2], 32, 32);
 
return 0;
@@ -296,7 +296,7 @@ int dprc_set_irq(struct fsl_mc_io *mc_io,
cmd.params[0] |= mc_enc(32, 8, irq_index);
cmd.params[0] |= mc_enc(0, 32, irq_cfg->val);
cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr);
-   cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id);
+   cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
 
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
@@ -466,6 +466,7 @@ int dprc_get_irq_status(struct fsl_mc_io *mc_io,
/* prepare command */
cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_STATUS,
  cmd_flags, token);
+   cmd.params[0] |= mc_enc(0, 32, *status);
cmd.params[0] |= mc_enc(32, 8, irq_index);
 
/* send command to mc*/
@@ -948,6 +949,7 @@ int dprc_get_obj(struct fsl_mc_io *mc_io,
obj_desc->state = mc_dec(cmd.params[1], 32, 32);
obj_desc->ver_major = mc_dec(cmd.params[2], 0, 16);
obj_desc->ver_minor = mc_dec(cmd.params[2], 16, 16);
+   obj_desc->flags = mc_dec(cmd.params[2], 32, 16);
obj_desc->type[0] = mc_dec(cmd.params[3], 0, 8);
obj_desc->type[1] = mc_dec(cmd.params[3], 8, 8);
obj_desc->type[2] = mc_dec(cmd.params[3], 16, 8);
@@ -1042,6 +1044,7 @@ int dprc_get_obj_desc(struct fsl_mc_io *mc_io,
obj_desc->state = (u32)mc_dec(cmd.params[1], 32, 32);
obj_desc->ver_major = (u16)mc_dec(cmd.params[2], 0, 16);
obj_desc->ver_minor = (u16)mc_dec(cmd.params[2], 16, 16);
+   obj_desc->flags = mc_dec(cmd.params[2], 32, 16);
obj_desc->type[0] = (char)mc_dec(cmd.params[3], 0, 8);
obj_desc->type[1] = (char)mc_dec(cmd.params[3], 8, 8);
obj_desc->type[2] = (char)mc_dec(cmd.params[3], 16, 8);
@@ -1108,7 +,7 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
cmd.params[0] |= mc_enc(32, 8, irq_index);
cmd.params[0] |= mc_enc(0, 32, irq_cfg->val);
cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr);
-   cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id);
+   cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
cmd.params[2] |= mc_enc(32, 32, obj_id);
cmd.params[3] |= mc_enc(0, 8, obj_type[0]);
cmd.params[3] |= mc_enc(8, 8, obj_type[1]);
@@ -1189,7 +1192,7 @@ int dprc_get_obj_irq(struct fsl_mc_io *mc_io,
/* retrieve response parameters */
irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32);
irq_cfg->paddr = (u64)mc_dec(cmd.params[1], 0, 64);
-   irq_cfg->user_irq_id = (int)mc_dec(cmd.params[2], 0, 32);
+   irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32);
*t

[PATCH 01/14] staging: fsl-mc: TODO updates

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

remove 3 of the remaining TODO items:

   -multiple root fsl-mc buses-- done in patch series starting with
commit 14f928054a05 ("staging: fsl-mc: abstract test for existence
of fsl-mc bus")

   -interrupt support-- done in patch series starting with
commit 9b1b282ccd81 ("irqdomain: Added domain bus token
DOMAIN_BUS_FSL_MC_MSI")

   -MC command serialization-- done in commit 63f2be5c3b358 ("staging:
fsl-mc: Added serialization to mc_send_command()")

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/TODO |   13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 3894368..54a8bc6 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -1,21 +1,8 @@
-* Decide if multiple root fsl-mc buses will be supported per Linux instance,
-  and if so add support for this.
-
 * 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
   driver support, which depends on drivers for several objects: DPNI,
   DPIO, DPMAC.  Other pre-requisites include:
 
- * interrupt support. for meaningful driver support we need
-   interrupts, and thus need message interrupt support by the bus
-   driver.
-  -Note: this has dependencies on generic MSI support work
-   in process upstream, see [1] and [2].
-
- * Management Complex (MC) command serialization. locking mechanisms
-   are needed by drivers to serialize commands sent to the MC, including
-   from atomic context.
-
  * MC firmware uprev.  The MC firmware upon which the fsl-mc
bus driver and DPAA2 object drivers are based is continuing
to evolve, so minor updates are needed to keep in sync with binary
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/14] MAINTAINERS: fsl-mc: Add second maintainer

2016-04-11 Thread Stuart Yoder
From: Stuart Yoder 

Add Stuart Yoder as additional maintainer of fsl-mc bus driver.

Signed-off-by: Stuart Yoder 
---
 MAINTAINERS |1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 03e00c7..62db04e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4670,6 +4670,7 @@ F:sound/soc/fsl/mpc8610_hpcd.c
 
 FREESCALE QORIQ MANAGEMENT COMPLEX DRIVER
 M: "J. German Rivera" 
+M:     Stuart Yoder 
 L: linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-mc/
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/14] staging: fsl-mc: add quirk handling for dpseci objects < 4.0

2016-04-11 Thread Stuart Yoder
From: Horia Geanta 

dpseci objects < 4.0 are not coherent-- in spite of the fact
that the MC reports them to be coherent in certain versions.
Add a special case to set the no shareability flag for dpseci
objects < 4.0.

Signed-off-by: Horia Geanta 
(Stuart: reworded commit message, updated comment in patch)
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 53c6e98..7fc4717 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -312,6 +312,15 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
continue;
}
 
+   /*
+* add a quirk for all versions of dpsec < 4.0...none
+* are coherent regardless of what the MC reports.
+*/
+   if ((strcmp(obj_desc->type, "dpseci") == 0) &&
+   (obj_desc->ver_major < 4))
+   obj_desc->flags |=
+   DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY;
+
irq_count += obj_desc->irq_count;
dev_dbg(&mc_bus_dev->dev,
"Discovered object: type %s, id %d\n",
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/14] staging: fsl-mc: return -EINVAL for all fsl_mc_portal_allocate() failures

2016-04-11 Thread Stuart Yoder
From: Horia Geantă 

There are some error paths that allow for a NULL new_mc_io and err = 0
return code. Return -EINVAL instead.

Signed-off-by: Horia Geantă 
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-allocator.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c 
b/drivers/staging/fsl-mc/bus/mc-allocator.c
index 4676ba1..7ee71e7 100644
--- a/drivers/staging/fsl-mc/bus/mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
@@ -306,6 +306,7 @@ int __must_check fsl_mc_portal_allocate(struct 
fsl_mc_device *mc_dev,
if (error < 0)
return error;
 
+   error = -EINVAL;
dpmcp_dev = resource->data;
if (WARN_ON(!dpmcp_dev))
goto error_cleanup_resource;
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 13/14] staging: fsl-mc: return -EINVAL for all fsl_mc_portal_allocate() failures

2016-04-11 Thread Stuart Yoder

> -Original Message-
> From: Stuart Yoder 
> Date: Mon, Apr 11, 2016 at 11:56 AM
> Subject: [PATCH 13/14] staging: fsl-mc: return -EINVAL for all
> fsl_mc_portal_allocate() failures
> To: gre...@linuxfoundation.org, german.riv...@nxp.com
> Cc: de...@driverdev.osuosl.org, linux-ker...@vger.kernel.org,
> ag...@suse.de, a...@arndb.de, leoyang...@nxp.com, Horia Geantă
> , Stuart Yoder 
> 
> 
> From: Horia Geantă 
> 
> There are some error paths that allow for a NULL new_mc_io and err = 0
> return code. Return -EINVAL instead.
> 
> Signed-off-by: Horia Geantă 
> Signed-off-by: Stuart Yoder 
> ---
>  drivers/staging/fsl-mc/bus/mc-allocator.c |1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c
> b/drivers/staging/fsl-mc/bus/mc-allocator.c
> index 4676ba1..7ee71e7 100644
> --- a/drivers/staging/fsl-mc/bus/mc-allocator.c
> +++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
> @@ -306,6 +306,7 @@ int __must_check fsl_mc_portal_allocate(struct
> fsl_mc_device *mc_dev,
> if (error < 0)
> return error;
> 
> +   error = -EINVAL;
> dpmcp_dev = resource->data;
> if (WARN_ON(!dpmcp_dev))
> goto error_cleanup_resource;
> --
> 1.7.9.5

I had smtp mail server weirdness that led me to belive that the freescale.com
email addresses in this patch were causing the patch to not show up on the
mailing list, so I resent [PATCH 13/14] with the email address changed to
nxp.com.  Then both copies of [PATCH 13/14] showed up.  So please ignore
the duplicated email for this patch.  Both copies are identical and either
either freescale.com or nxp.com are ok for the email address.  nxp.com
version would be preferred I guess.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 4/6] staging: fsl-mc: Use platform_msi_* infrastructure

2016-04-13 Thread Stuart Yoder


> -Original Message-
> From: Matthias Brugger [mailto:mbrug...@suse.com]
> Sent: Wednesday, April 13, 2016 6:23 AM
> To: Marc Zyngier ; gre...@linuxfoundation.org; 
> robh...@kernel.org;
> frowand.l...@gmail.com; grant.lik...@linaro.org; german.riv...@freescale.com;
> jiang@linux.intel.com; t...@linutronix.de
> Cc: tred...@nvidia.com; Stuart Yoder ; jroe...@suse.de; 
> ag...@suse.de;
> b...@suse.de; matthias@gmail.com; bhaktipriy...@gmail.com; 
> linux-ker...@vger.kernel.org;
> devicet...@vger.kernel.org; de...@driverdev.osuosl.org; 
> linux-arm-ker...@lists.infradead.org
> Subject: Re: [PATCH 4/6] staging: fsl-mc: Use platform_msi_* infrastructure
> 
> 
> 
> On 13/04/16 12:56, Marc Zyngier wrote:
> > On 13/04/16 11:30, Matthias Brugger wrote:
> >> From: Matthias Brugger 
> >>
> >> The fsl-mc driver can't be build as a module because it uses msi_*
> >> functions directly. Port the driver to use the platform_msi_*
> >> infrastructure instead, to allow it to be build as a module.
> >>
> >> Signed-off-by: Matthias Brugger 
> >> ---
> >>   .../staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c |   5 +-
> >>   drivers/staging/fsl-mc/bus/mc-allocator.c  |   9 +-
> >>   drivers/staging/fsl-mc/bus/mc-msi.c| 169 
> >> +
> >>   drivers/staging/fsl-mc/include/mc-sys.h|   3 +
> >>   4 files changed, 14 insertions(+), 172 deletions(-)
> >>
> >> diff --git a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c 
> >> b/drivers/staging/fsl-
> mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> >> index 720e2b0..0eecb7e 100644
> >> --- a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> >> +++ b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> >> @@ -25,7 +25,6 @@ static struct irq_chip its_msi_irq_chip = {
> >>.irq_mask = irq_chip_mask_parent,
> >>.irq_unmask = irq_chip_unmask_parent,
> >>.irq_eoi = irq_chip_eoi_parent,
> >> -  .irq_set_affinity = msi_domain_set_affinity
> >>   };
> >>
> >>   static int its_fsl_mc_msi_prepare(struct irq_domain *msi_domain,
> >> @@ -86,7 +85,7 @@ int __init its_fsl_mc_msi_init(void)
> >>continue;
> >>}
> >>
> >> -  mc_msi_domain = fsl_mc_msi_create_irq_domain(
> >> +  mc_msi_domain = platform_msi_create_irq_domain(
> >> of_node_to_fwnode(np),
> >> &its_fsl_mc_msi_domain_info,
> >> parent);
> >
> > What? We are already creating a platform MSI domain for the ITS. How is
> > that going to work? If you want to convert this set of drivers to
> > platform ITS, fine. But you can't randomly hack in the ITS code and pray
> > for things not to fall apart.
> >
> 
>  From what I see, the difference between irq-gic-v3-its-fsl-mc-msi and
> the irq-gic-v3-its-platform-msi is the way ITS specific DeviceID is
> created in msi_prepare.
> 
> German, is there a reason why you use the ICID read from the DPRC as dev_id?

Because it _is_ the dev_id at the hardware level.  There is an fsl-mc bus
specific mechanism to get that id...it's not in the device tree.

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] staging: fsl-mc: bus: Drop warning

2016-04-14 Thread Stuart Yoder


> -Original Message-
> From: Matthias Brugger [mailto:mbrug...@suse.com]
> Sent: Thursday, April 14, 2016 4:24 PM
> To: german.riv...@freescale.com; gre...@linuxfoundation.org
> Cc: Stuart Yoder ; Scott Wood ; 
> ag...@suse.de; linux-
> ker...@vger.kernel.org; de...@driverdev.osuosl.org; mbrug...@suse.com
> Subject: [PATCH] staging: fsl-mc: bus: Drop warning
> 
> When updating the irq_chip and msi_domain_ops, the code checkes for
> already present functions.
> When more then one ITS controller are present in the system,
> irq_chip and msi_domain_ops got already set and a warning is invoked.

How can this situation happen?  And what do you mean by
multiple ITS controllers? ...multiple instances of the GIC ITS
on an SoC?

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 11/14] staging: fsl-mc: add quirk handling for dpseci objects < 4.0

2016-04-20 Thread Stuart Yoder


> -Original Message-
> From: Horia Ioan Geanta Neag
> Sent: Wednesday, April 20, 2016 6:42 AM
> To: Stuart Yoder ; Jose Rivera 
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; 
> linux-ker...@vger.kernel.org;
> ag...@suse.de; a...@arndb.de; Yang-Leo Li 
> Subject: Re: [PATCH 11/14] staging: fsl-mc: add quirk handling for dpseci 
> objects < 4.0
> 
> On 4/11/2016 7:50 PM, Stuart Yoder wrote:
> > From: Horia Geanta 
> >
> > dpseci objects < 4.0 are not coherent-- in spite of the fact
> > that the MC reports them to be coherent in certain versions.
> > Add a special case to set the no shareability flag for dpseci
> > objects < 4.0.
> >
> > Signed-off-by: Horia Geanta 
> > (Stuart: reworded commit message, updated comment in patch)
> > Signed-off-by: Stuart Yoder 
> 
> Do we really need this?
> First upstream dpsec driver will be for dpsec >= v4.0.

This has nothing to do with the dpsec driver, it's just trying
to be complete with potential MC firmware versions that
might be encountered.  There is supported MC firmware
(and example non-upstream Linux drivers) in customer hands
with dpsec < 4.0, and we are handling that case even if
encountering it is not likely (e.g. what if someone develops
their own driver?).

So let's keep this quirk for now.

Stuart


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/14 RESEND] MAINTAINERS: fsl-mc: Add second maintainer

2016-05-02 Thread Stuart Yoder
Add Stuart Yoder as additional maintainer of fsl-mc bus driver.

Signed-off-by: Stuart Yoder 
---
 MAINTAINERS |1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 03e00c7..62db04e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4670,6 +4670,7 @@ F:sound/soc/fsl/mpc8610_hpcd.c
 
 FREESCALE QORIQ MANAGEMENT COMPLEX DRIVER
 M: "J. German Rivera" 
+M:     Stuart Yoder 
 L: linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-mc/
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 00/14] staging: fsl-mc: misc updates

2016-05-02 Thread Stuart Yoder

> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Friday, April 29, 2016 8:01 PM
> To: Stuart Yoder 
> Cc: Jose Rivera ; de...@driverdev.osuosl.org; 
> ag...@suse.de; a...@arndb.de;
> linux-ker...@vger.kernel.org; Yang-Leo Li 
> Subject: Re: [PATCH 00/14] staging: fsl-mc: misc updates
> 
> On Mon, Apr 11, 2016 at 11:48:25AM -0500, Stuart Yoder wrote:
> > From: Stuart Yoder 
> >
> > This patch series makes further progress towards completing the fsl-mc
> > TODO list.
> 
> I don't seem to have gotten patch 14/14, can you resend just that one?

Done.  This was the patch where a 2nd maintainer was added for the fsl-mc
bus driver.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2016-02-09 Thread Stuart Yoder


> -Original Message-
> From: Lijun Pan [mailto:lijun@freescale.com]
> Sent: Monday, February 08, 2016 5:40 PM
> To: gre...@linuxfoundation.org; a...@arndb.de; de...@driverdev.osuosl.org; 
> linux-
> ker...@vger.kernel.org
> Cc: stuart.yo...@freescale.com; itai.k...@freescale.com; 
> german.riv...@freescale.com;
> le...@freescale.com; scottw...@freescale.com; ag...@suse.de; 
> bhamc...@freescale.com;
> r89...@freescale.com; bhupesh.sha...@freescale.com; nir.e...@freescale.com;
> richard.schm...@freescale.com; dan.carpen...@oracle.com; 
> lijun.pan2...@gmail.com; Lijun
> Pan 
> Subject: [PATCH v3 7/8] staging: fsl-mc: update TODO and README for restool 
> driver
> 
> Add more introduction of restool driver and state why
> restool driver is needed in helping moving fsl-mc bus
> out of staging tree.
> 
> 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.

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

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

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-mc: update TODO list

2015-07-16 Thread Stuart Yoder
update TODO list to provide more detail on remaining work

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/TODO | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index d78288b..c29516b 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -6,8 +6,30 @@
   and if so add support for this.
 
 * Add at least one device driver for a DPAA2 object (child device of the
-  fsl-mc bus).
+  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:
+
+ * interrupt support. for meaningful driver support we need
+   interrupts, and thus need message interrupt support by the bus
+   driver.
+  -Note: this has dependencies on generic MSI support work
+   in process upstream, see [1] and [2].
+
+ * Management Complex (MC) command serialization. locking mechanisms
+   are needed by drivers to serialize commands sent to the MC, including
+   from atomic context.
+
+ * MC firmware uprev.  The MC firmware upon which the fsl-mc
+   bus driver and DPAA2 object drivers are based is continuing
+   to evolve, so minor updates are needed to keep in sync with binary
+   interface changes to the MC.
+
+* Cleanup
 
 Please send any patches to Greg Kroah-Hartman ,
 german.riv...@freescale.com, de...@driverdev.osuosl.org,
 linux-ker...@vger.kernel.org
+
+[1] https://lkml.org/lkml/2015/7/9/93
+[2] https://lkml.org/lkml/2015/7/7/712
-- 
2.3.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-mc: add DPAA2 overview readme

2015-08-06 Thread Stuart Yoder
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/README.txt | 364 ++
 drivers/staging/fsl-mc/TODO   |   4 -
 2 files changed, 364 insertions(+), 4 deletions(-)
 create mode 100644 drivers/staging/fsl-mc/README.txt

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/README.txt
new file mode 100644
index 000..8214102
--- /dev/null
+++ b/drivers/staging/fsl-mc/README.txt
@@ -0,0 +1,364 @@
+Copyright (C) 2015 Freescale Semiconductor Inc.
+
+DPAA2 (Data Path Acceleration Architecture Gen2)
+
+
+This document provides an overview of the Freescale DPAA2 architecture
+and how it is integrated into the Linux kernel.
+
+Contents summary
+   -DPAA2 overview
+   -Overview of DPAA2 objects
+   -DPAA2 Linux driver architecture overview
+-bus driver
+-dprc driver
+-allocator
+-dpio driver
+-Ethernet
+-mac
+
+DPAA2 Overview
+--
+
+DPAA2 is a hardware architecture designed for high-speeed network
+packet processing.  DPAA2 consists of sophisticated mechanisms for
+processing Ethernet packets, queue management, buffer management,
+autonomous L2 switching, virtual Ethernet bridging, and accelerator
+(e.g. crypto) sharing.
+
+A DPAA2 hardware component called the Management Complex (or MC) manages the
+DPAA2 hardware resources.  The MC provides an object-based abstraction for
+software drivers to use the DPAA2 hardware.
+
+The MC uses DPAA2 hardware resources such as queues, buffer pools, and
+network ports to create functional objects/devices such as network
+interfaces, an L2 switch, or accelerator instances.
+
+The MC provides memory-mapped I/O command interfaces (MC portals)
+which DPAA2 software drivers use to operate on DPAA2 objects:
+
+ +--+
+ |  OS  |
+ |DPAA2 drivers |
+ | ||
+ +-|+
+   |
+   | (create,discover,connect
+   |  config,use,destroy)
+   |
+ DPAA2 |
+ +| mc portal |-+
+ | ||
+ |   +- - - - - - - - - - - - -V- - -+  |
+ |   |   |  |
+ |   |   Management Complex (MC) |  |
+ |   |   |  |
+ |   +- - - - - - - - - - - - - - - -+  |
+ |  |
+ | Hardware  Hardware   |
+ | Resources Objects|
+ | - ---|
+ | -queues   -DPRC  |
+ | -buffer pools -DPMCP |
+ | -Eth MACs/ports   -DPIO  |
+ | -network interface-DPNI  |
+ |  profiles -DPMAC |
+ | -queue portals-DPBP  |
+ | -MC portals...   |
+ |  ... |
+ |  |
+ +--+
+
+The MC mediates operations such as create, discover,
+connect, configuration, and destroy.  Fast-path operations
+on data, such as packet transmit/receive, are not mediated by
+the MC and are done directly using memory mapped regions in
+DPIO objects.
+
+Overview of DPAA2 Objects
+-
+The section provides a brief overview of some key objects
+in the DPAA2 hardware.  A simple scenario is described illustrating
+the objects involved in creating a network interfaces.
+
+-DPRC (Datapath Resource Container)
+
+A DPRC is an container object that holds all the other
+types of DPAA2 objects.  In the example diagram below there
+are 8 objects of 5 types (DPMCP, DPIO, DPBP, DPNI, and DPMAC)
+in the container.
+
++-+
+| DPRC|
+| |
+|  +---+  +---+  +---+  +---+  +---+  |
+|  | DPMCP |  | DPIO  |  | DPBP  |  | DPNI  |  | DPMAC |  |
+|  +---+  +---+  +---+  +---+---+  +---+---+  |
+|  | DPMCP |  | DPIO  |   |
+|  +---+  +---+   |
+|  | DPMCP |  |
+|  +---+  |
+| |
++-+
+
+From the point of view of an OS, a DPRC is

[PATCH v2] staging: fsl-mc: add DPAA2 overview readme

2015-08-06 Thread Stuart Yoder
add README file providing an overview of the DPAA2 architecture
and how it is integrated in Linux

Signed-off-by: Stuart Yoder 
---
-v2: added changelog text

 drivers/staging/fsl-mc/README.txt | 364 ++
 drivers/staging/fsl-mc/TODO   |   4 -
 2 files changed, 364 insertions(+), 4 deletions(-)
 create mode 100644 drivers/staging/fsl-mc/README.txt

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/README.txt
new file mode 100644
index 000..8214102
--- /dev/null
+++ b/drivers/staging/fsl-mc/README.txt
@@ -0,0 +1,364 @@
+Copyright (C) 2015 Freescale Semiconductor Inc.
+
+DPAA2 (Data Path Acceleration Architecture Gen2)
+
+
+This document provides an overview of the Freescale DPAA2 architecture
+and how it is integrated into the Linux kernel.
+
+Contents summary
+   -DPAA2 overview
+   -Overview of DPAA2 objects
+   -DPAA2 Linux driver architecture overview
+-bus driver
+-dprc driver
+-allocator
+-dpio driver
+-Ethernet
+-mac
+
+DPAA2 Overview
+--
+
+DPAA2 is a hardware architecture designed for high-speeed network
+packet processing.  DPAA2 consists of sophisticated mechanisms for
+processing Ethernet packets, queue management, buffer management,
+autonomous L2 switching, virtual Ethernet bridging, and accelerator
+(e.g. crypto) sharing.
+
+A DPAA2 hardware component called the Management Complex (or MC) manages the
+DPAA2 hardware resources.  The MC provides an object-based abstraction for
+software drivers to use the DPAA2 hardware.
+
+The MC uses DPAA2 hardware resources such as queues, buffer pools, and
+network ports to create functional objects/devices such as network
+interfaces, an L2 switch, or accelerator instances.
+
+The MC provides memory-mapped I/O command interfaces (MC portals)
+which DPAA2 software drivers use to operate on DPAA2 objects:
+
+ +--+
+ |  OS  |
+ |DPAA2 drivers |
+ | ||
+ +-|+
+   |
+   | (create,discover,connect
+   |  config,use,destroy)
+   |
+ DPAA2 |
+ +| mc portal |-+
+ | ||
+ |   +- - - - - - - - - - - - -V- - -+  |
+ |   |   |  |
+ |   |   Management Complex (MC) |  |
+ |   |   |  |
+ |   +- - - - - - - - - - - - - - - -+  |
+ |  |
+ | Hardware  Hardware   |
+ | Resources Objects|
+ | - ---|
+ | -queues   -DPRC  |
+ | -buffer pools -DPMCP |
+ | -Eth MACs/ports   -DPIO  |
+ | -network interface-DPNI  |
+ |  profiles -DPMAC |
+ | -queue portals-DPBP  |
+ | -MC portals...   |
+ |  ... |
+ |  |
+ +--+
+
+The MC mediates operations such as create, discover,
+connect, configuration, and destroy.  Fast-path operations
+on data, such as packet transmit/receive, are not mediated by
+the MC and are done directly using memory mapped regions in
+DPIO objects.
+
+Overview of DPAA2 Objects
+-
+The section provides a brief overview of some key objects
+in the DPAA2 hardware.  A simple scenario is described illustrating
+the objects involved in creating a network interfaces.
+
+-DPRC (Datapath Resource Container)
+
+A DPRC is an container object that holds all the other
+types of DPAA2 objects.  In the example diagram below there
+are 8 objects of 5 types (DPMCP, DPIO, DPBP, DPNI, and DPMAC)
+in the container.
+
++-+
+| DPRC|
+| |
+|  +---+  +---+  +---+  +---+  +---+  |
+|  | DPMCP |  | DPIO  |  | DPBP  |  | DPNI  |  | DPMAC |  |
+|  +---+  +---+  +---+  +---+---+  +---+---+  |
+|  | DPMCP |  | DPIO  |   |
+|  +---+  +---+   |
+|  | DPMCP

[PATCH v3 0/9] staging: fsl-mc: move bus driver out of staging, add dpio

2016-12-01 Thread Stuart Yoder
This patch series: A) addresses the final item in the staging
TODO list for the fsl-mc bus driver-- adding a functional driver
on top of the bus driver, and B) requests that the fsl-mc bus driver
be moved out of staging.

The proposed destination for the bus driver is drivers/bus.
Proposed location for global header files for fsl-mc and dpaa2
is include/linux/fsl.

The functional driver added is for the DPIO object which provides
queuing services for other DPAA2 drivers.  An overview of the
DPIO object and driver components are in patch 2.  Patches 3-7 are
internal components of the DPIO driver-- bit twiddling of hardware
registers, DPAA2 data structures, and the queuing APIs exposed
to other drivers.

Patch 8 adds the fsl-mc driver for the DPIO object.  It provides
the probe/remove functions, demonstrating a working example of
how fsl-mc drivers initialize, interact with the management
complex hardware, map their mappable MMIO regions, initialize
interrupts, register an ISR, etc.  All other DPAA2 drivers will
follow a similar initialization pattern.

The dpio driver is added under drivers/bus/fsl-mc/dpio.  This
driver provides queueing related services and there is no other
obvious place it would go.  Like the bus driver, it is part of
the DPAA2 infrastucture and putting it under the fsl-mc bus
driver seems like a logical place.

version 3 changes
   -zero memory allocated for a dpio store
   -replace hardcoded dequeue token with a #define and look for
that token when checking for a new result

version 2 changes (mostly feedback from Ioana Radulescu)
   -removed unused structs and defines in dpio command definitions
   -added setter/getter for the FD ctrl field
   -corrected comment for SG format_offset field description
   -added support for short length field in FD
   -fix bug in buffer release command, by setting bpid field
   -handle error (NULL) return value from qbman_swp_mc_complete()
   -fix bug in sending management commands where the verb was
properly initialized
   -use service_select_by_cpu() for re-arming DPIO interrupts
   -replace use of NR_CPUS with num_possible_cpus()
   -handle error case where number of DPIOs exceeds number of possible
CPUs
   -error message cleanup
   -updated MAINTAINERS file with proper location for both fsl-mc bus
driver and dpio driver

Ioana Radulescu (1):
  bus: fsl-mc: dpio: add APIs for DPIO objects

Roy Pledge (6):
  bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs
  bus: fsl-mc: dpio: add global dpaa2 definitions
  bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
  bus: fsl-mc: dpio: add the DPAA2 DPIO service interface
  bus: fsl-mc: dpio: add the DPAA2 DPIO object driver
  bus: fsl-mc: dpio: add maintainer for DPIO

Stuart Yoder (2):
  staging: fsl-mc: move bus driver out of staging
  bus: fsl-mc: dpio: add DPIO driver overview document

 Documentation/dpaa2/dpio-driver.txt|  135 +++
 .../README.txt => Documentation/dpaa2/overview.txt |0
 MAINTAINERS|8 +-
 drivers/bus/Kconfig|3 +
 drivers/bus/Makefile   |3 +
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/Kconfig |   10 +
 .../{staging/fsl-mc/bus => bus/fsl-mc}/Makefile|4 +-
 .../{staging/fsl-mc/bus => bus/fsl-mc}/dpbp-cmd.h  |0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpbp.c  |6 +-
 .../{staging/fsl-mc/bus => bus/fsl-mc}/dpcon-cmd.h |0
 drivers/bus/fsl-mc/dpio/Makefile   |9 +
 drivers/bus/fsl-mc/dpio/dpio-cmd.h |   75 ++
 drivers/bus/fsl-mc/dpio/dpio-driver.c  |  295 ++
 drivers/bus/fsl-mc/dpio/dpio-service.c |  614 
 drivers/bus/fsl-mc/dpio/dpio.c |  229 +
 drivers/bus/fsl-mc/dpio/dpio.h |  108 ++
 drivers/bus/fsl-mc/dpio/qbman-portal.c | 1028 
 drivers/bus/fsl-mc/dpio/qbman-portal.h |  464 +
 .../{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp-cmd.h |0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp.c |5 +-
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp.h |0
 .../{staging/fsl-mc/bus => bus/fsl-mc}/dpmng-cmd.h |0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmng.c |6 +-
 .../{staging/fsl-mc/bus => bus/fsl-mc}/dprc-cmd.h  |0
 .../fsl-mc/bus => bus/fsl-mc}/dprc-driver.c|4 +-
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dprc.c  |6 +-
 .../fsl-mc/bus => bus/fsl-mc}/fsl-mc-allocator.c   |4 +-
 .../fsl-mc/bus => bus/fsl-mc}/fsl-mc-bus.c |6 +-
 .../fsl-mc/bus => bus/fsl-mc}/fsl-mc-msi.c |2 +-
 .../fsl-mc/bus => bus/fsl-mc}/fsl-mc-private.h |4 +-
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/mc-io.c |4 +-
 .../{staging/fsl-mc/bus => bus/fsl-mc}/mc-sys.c|6 +-
 drivers/irqchip/Makefile   |1 

[PATCH v3 5/9] bus: fsl-mc: dpio: add global dpaa2 definitions

2016-12-01 Thread Stuart Yoder
From: Roy Pledge 

Create header for global dpaa2 definitions.  Add definitions
for dequeue results.

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---
 include/linux/fsl/dpaa2-global.h | 203 +++
 1 file changed, 203 insertions(+)
 create mode 100644 include/linux/fsl/dpaa2-global.h

diff --git a/include/linux/fsl/dpaa2-global.h b/include/linux/fsl/dpaa2-global.h
new file mode 100644
index 000..3ee3f29
--- /dev/null
+++ b/include/linux/fsl/dpaa2-global.h
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPAA2_GLOBAL_H
+#define __FSL_DPAA2_GLOBAL_H
+
+#include 
+#include 
+#include 
+
+struct dpaa2_dq {
+   union {
+   struct common {
+   u8 verb;
+   u8 reserved[63];
+   } common;
+   struct dq {
+   u8 verb;
+   u8 stat;
+   __le16 seqnum;
+   __le16 oprid;
+   u8 reserved;
+   u8 tok;
+   __le32 fqid;
+   u32 reserved2;
+   __le32 fq_byte_cnt;
+   __le32 fq_frm_cnt;
+   __le64 fqd_ctx;
+   u8 fd[32];
+   } dq;
+   struct scn {
+   u8 verb;
+   u8 stat;
+   u8 state;
+   u8 reserved;
+   __le32 rid_tok;
+   __le64 ctx;
+   } scn;
+   };
+};
+
+
+/* Parsing frame dequeue results */
+/* FQ empty */
+#define DPAA2_DQ_STAT_FQEMPTY   0x80
+/* FQ held active */
+#define DPAA2_DQ_STAT_HELDACTIVE0x40
+/* FQ force eligible */
+#define DPAA2_DQ_STAT_FORCEELIGIBLE 0x20
+/* valid frame */
+#define DPAA2_DQ_STAT_VALIDFRAME0x10
+/* FQ ODP enable */
+#define DPAA2_DQ_STAT_ODPVALID  0x04
+/* volatile dequeue */
+#define DPAA2_DQ_STAT_VOLATILE  0x02
+/* volatile dequeue command is expired */
+#define DPAA2_DQ_STAT_EXPIRED   0x01
+
+#define DQ_FQID_MASK 0x00FF
+#define DQ_FRAME_COUNT_MASK 0x00FF
+
+/**
+ * dpaa2_dq_flags() - Get the stat field of dequeue response
+ * @dq: the dequeue result.
+ */
+static inline u32 dpaa2_dq_flags(const struct dpaa2_dq *dq)
+{
+   return dq->dq.stat;
+}
+
+/**
+ * dpaa2_dq_is_pull() - Check whether the dq response is from a pull
+ *  command.
+ * @dq: the dequeue result
+ *
+ * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
+ */
+static inline int dpaa2_dq_is_pull(const struct dpaa2_dq *dq)
+{
+   return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_VOLATILE);
+}
+
+/**
+ * dpaa2_dq_is_pull_complete() - Check whether the pull command is completed.
+ * @dq: the dequeue result
+ *
+ * Return boolean.
+ */
+static inline int dpaa2_dq_is_pull_complete(
+   const struct dpaa2_dq *dq)
+{
+   return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_EXPIRED);
+}
+
+/**
+ * dpaa2_dq_seqnum() - Get the seqnum field in dequeue response
+ * @dq: the dequeue result

[PATCH v3 4/9] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs

2016-12-01 Thread Stuart Yoder
From: Roy Pledge 

Add global definitions for DPAA2 frame descriptors and scatter
gather entries.

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v3
   -no changes
-v2
   -added setter/getter for the FD ctrl field
   -corrected comment for SG format_offset field description
   -added support for short length field in FD

 include/linux/fsl/dpaa2-fd.h | 448 +++
 1 file changed, 448 insertions(+)
 create mode 100644 include/linux/fsl/dpaa2-fd.h

diff --git a/include/linux/fsl/dpaa2-fd.h b/include/linux/fsl/dpaa2-fd.h
new file mode 100644
index 000..182c8f4
--- /dev/null
+++ b/include/linux/fsl/dpaa2-fd.h
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPAA2_FD_H
+#define __FSL_DPAA2_FD_H
+
+#include 
+
+/**
+ * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2
+ *
+ * Frame Descriptors (FDs) are used to describe frame data in the DPAA2.
+ * Frames can be enqueued and dequeued to Frame Queues (FQs) which are consumed
+ * by the various DPAA accelerators (WRIOP, SEC, PME, DCE)
+ *
+ * There are three types of frames: single, scatter gather, and frame lists.
+ *
+ * The set of APIs in this file must be used to create, manipulate and
+ * query Frame Descriptors.
+ */
+
+/**
+ * struct dpaa2_fd - Struct describing FDs
+ * @words: for easier/faster copying the whole FD structure
+ * @addr:  address in the FD
+ * @len:   length in the FD
+ * @bpid:  buffer pool ID
+ * @format_offset: format, offset, and short-length fields
+ * @frc:   frame context
+ * @ctrl:  control bits...including dd, sc, va, err, etc
+ * @flc:   flow context address
+ *
+ * This structure represents the basic Frame Descriptor used in the system.
+ */
+struct dpaa2_fd {
+   union {
+   u32 words[8];
+   struct dpaa2_fd_simple {
+   __le64 addr;
+   __le32 len;
+   __le16 bpid;
+   __le16 format_offset;
+   __le32 frc;
+   __le32 ctrl;
+   __le64 flc;
+   } simple;
+   };
+};
+
+#define FD_SHORT_LEN_FLAG_MASK 0x1
+#define FD_SHORT_LEN_FLAG_SHIFT 14
+#define FD_SHORT_LEN_MASK 0x1
+#define FD_OFFSET_MASK 0x0FFF
+#define FD_FORMAT_MASK 0x3
+#define FD_FORMAT_SHIFT 12
+#define SG_SHORT_LEN_FLAG_MASK 0x1
+#define SG_SHORT_LEN_FLAG_SHIFT 14
+#define SG_SHORT_LEN_MASK 0x1
+#define SG_OFFSET_MASK 0x0FFF
+#define SG_FORMAT_MASK 0x3
+#define SG_FORMAT_SHIFT 12
+#define SG_BPID_MASK 0x3FFF
+#define SG_FINAL_FLAG_MASK 0x1
+#define SG_FINAL_FLAG_SHIFT 15
+
+enum dpaa2_fd_format {
+   dpaa2_fd_single = 0,
+   dpaa2_fd_list,
+   dpaa2_fd_sg
+};
+
+/**
+ * dpaa2_fd_get_addr() - get the addr field of frame descriptor
+ * @fd: the given frame descriptor
+ *
+ * Return the address in the frame descriptor.
+ */
+static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
+{
+
+   return (dma_addr_t)fd->simple.addr;
+}
+
+/**
+ * dpaa2_fd_set_addr() - Set the addr field of frame descriptor
+ * @fd: the

[PATCH v3 8/9] bus: fsl-mc: dpio: add the DPAA2 DPIO object driver

2016-12-01 Thread Stuart Yoder
From: Roy Pledge 

The DPIO driver registers with the fsl-mc bus to handle bus-related
events for DPIO objects.  Key responsibility is mapping I/O
regions, setting up interrupt handlers, and calling the DPIO
service initialization during probe.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v3
   -no changes
-v2
   -handle error case where number of DPIOs > NR_CPUs

 drivers/bus/fsl-mc/dpio/Makefile  |   2 +-
 drivers/bus/fsl-mc/dpio/dpio-driver.c | 295 ++
 2 files changed, 296 insertions(+), 1 deletion(-)
 create mode 100644 drivers/bus/fsl-mc/dpio/dpio-driver.c

diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-mc/dpio/Makefile
index 0778da7..837d330 100644
--- a/drivers/bus/fsl-mc/dpio/Makefile
+++ b/drivers/bus/fsl-mc/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o dpio-driver.o
diff --git a/drivers/bus/fsl-mc/dpio/dpio-driver.c 
b/drivers/bus/fsl-mc/dpio/dpio-driver.c
new file mode 100644
index 000..76261d2
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/dpio-driver.c
@@ -0,0 +1,295 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "qbman-portal.h"
+#include "dpio.h"
+#include "dpio-cmd.h"
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Freescale Semiconductor, Inc");
+MODULE_DESCRIPTION("DPIO Driver");
+
+struct dpio_priv {
+   struct dpaa2_io *io;
+};
+
+static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
+{
+   struct device *dev = (struct device *)arg;
+   struct dpio_priv *priv = dev_get_drvdata(dev);
+
+   return dpaa2_io_irq(priv->io);
+}
+
+static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev)
+{
+   struct fsl_mc_device_irq *irq;
+
+   irq = dpio_dev->irqs[0];
+
+   /* clear the affinity hint */
+   irq_set_affinity_hint(irq->msi_desc->irq, NULL);
+}
+
+static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
+{
+   struct dpio_priv *priv;
+   int error;
+   struct fsl_mc_device_irq *irq;
+   cpumask_t mask;
+
+   priv = dev_get_drvdata(&dpio_dev->dev);
+
+   irq = dpio_dev->irqs[0];
+   error = devm_request_irq(&dpio_dev->dev,
+irq->msi_desc->irq,
+dpio_irq_handler,
+0,
+dev_name(&dpio_dev->dev),
+&dpio_dev->dev);
+   if (error < 0) {
+   dev_err(&dpio_dev->dev,
+   "devm_request_irq() failed: %d\n",
+   error);
+   return error;
+   }
+
+   /* set the affinity hint */
+   cpumask_clear(&mask);
+   cpumask_set_cpu(cpu, &mas

[PATCH v3 9/9] bus: fsl-mc: dpio: add maintainer for DPIO

2016-12-01 Thread Stuart Yoder
From: Roy Pledge 

add Roy Pledge as maintainer of DPIO

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v3
   -no changes
-v2
   -corrected location of maintainer entry

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 63b45f4..312c582 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3980,6 +3980,12 @@ S:   Maintained
 F: drivers/char/dtlk.c
 F: include/linux/dtlk.h
 
+DPAA2 DATAPATH I/O (DPIO) DRIVER
+M: Roy Pledge 
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/bus/fsl-mc/dpio
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions 
 L: linux-s...@vger.kernel.org
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 7/9] bus: fsl-mc: dpio: add the DPAA2 DPIO service interface

2016-12-01 Thread Stuart Yoder
From: Roy Pledge 

The DPIO service interface handles initialization of DPIO objects
and exports APIs to be used by other DPAA2 object drivers to perform
queuing and buffer management related operations.  The service allows
registration of callbacks when frames or notifications are received.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v3
   -zero memory allocated for a dpio store (bug fix suggested
by Ioana Radulescu)
-v2
   -use service_select_by_cpu() for re-arming DPIO interrupts
   -replace use of NR_CPUS with num_possible_cpus()

 drivers/bus/fsl-mc/dpio/Makefile   |   2 +-
 drivers/bus/fsl-mc/dpio/dpio-service.c | 614 +
 include/linux/fsl/dpaa2-io.h   | 138 
 3 files changed, 753 insertions(+), 1 deletion(-)
 create mode 100644 drivers/bus/fsl-mc/dpio/dpio-service.c
 create mode 100644 include/linux/fsl/dpaa2-io.h

diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-mc/dpio/Makefile
index 6588498..0778da7 100644
--- a/drivers/bus/fsl-mc/dpio/Makefile
+++ b/drivers/bus/fsl-mc/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o qbman-portal.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o
diff --git a/drivers/bus/fsl-mc/dpio/dpio-service.c 
b/drivers/bus/fsl-mc/dpio/dpio-service.c
new file mode 100644
index 000..01f0293
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/dpio-service.c
@@ -0,0 +1,614 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "dpio.h"
+#include "qbman-portal.h"
+
+struct dpaa2_io {
+   atomic_t refs;
+   struct dpaa2_io_desc dpio_desc;
+   struct qbman_swp_desc swp_desc;
+   struct qbman_swp *swp;
+   struct list_head node;
+   spinlock_t lock_mgmt_cmd;
+   spinlock_t lock_notifications;
+   struct list_head notifications;
+};
+
+struct dpaa2_io_store {
+   unsigned int max;
+   dma_addr_t paddr;
+   struct dpaa2_dq *vaddr;
+   void *alloced_addr;/* unaligned value from kmalloc() */
+   unsigned int idx;  /* position of the next-to-be-returned entry */
+   struct qbman_swp *swp; /* portal used to issue VDQCR */
+   struct device *dev;/* device used for DMA mapping */
+};
+
+/* keep a per cpu array of DPIOs for fast access */
+static struct dpaa2_io *dpio_by_cpu[NR_CPUS];
+static struct list_head dpio_list = LIST_HEAD_INIT(dpio_list);
+static DEFINE_SPINLOCK(dpio_list_lock);
+
+static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
+int cpu)
+{
+   if (d)
+   return d;
+
+   if (unlikely(cpu >= num_possible_cpus()))
+   return NULL;
+
+   /*
+* If cpu == -1, choose the current cpu, with no guarantees about
+* potentially being migrated away.
+*/
+   if (unlikely(cpu < 0))
+   cpu = smp_processor_id();
+
+   /* If a spec

[PATCH v3 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2

2016-12-01 Thread Stuart Yoder
From: Roy Pledge 

Add QBman APIs for frame queue and buffer pool operations.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v3
   -replace hardcoded dequeue token with a #define and check that
token when checking for a new result (bug fix suggested by
Ioana Radulescu)
-v2
   -fix bug in buffer release command, by setting bpid field
   -handle error (NULL) return value from qbman_swp_mc_complete()
   -error message cleanup
   -fix bug in sending management commands where the verb was
properly initialized

 drivers/bus/fsl-mc/dpio/Makefile   |2 +-
 drivers/bus/fsl-mc/dpio/qbman-portal.c | 1028 
 drivers/bus/fsl-mc/dpio/qbman-portal.h |  464 ++
 3 files changed, 1493 insertions(+), 1 deletion(-)
 create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c
 create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h

diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-mc/dpio/Makefile
index 128befc..6588498 100644
--- a/drivers/bus/fsl-mc/dpio/Makefile
+++ b/drivers/bus/fsl-mc/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o
diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c 
b/drivers/bus/fsl-mc/dpio/qbman-portal.c
new file mode 100644
index 000..bbc032c
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c
@@ -0,0 +1,1028 @@
+/*
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "qbman-portal.h"
+
+#define QMAN_REV_4000   0x0400
+#define QMAN_REV_4100   0x0401
+#define QMAN_REV_4101   0x04010001
+
+/* All QBMan command and result structures use this "valid bit" encoding */
+#define QB_VALID_BIT ((u32)0x80)
+
+/* QBMan portal management command codes */
+#define QBMAN_MC_ACQUIRE   0x30
+#define QBMAN_WQCHAN_CONFIGURE 0x46
+
+/* CINH register offsets */
+#define QBMAN_CINH_SWP_EQAR0x8c0
+#define QBMAN_CINH_SWP_DQPI0xa00
+#define QBMAN_CINH_SWP_DCAP0xac0
+#define QBMAN_CINH_SWP_SDQCR   0xb00
+#define QBMAN_CINH_SWP_RAR 0xcc0
+#define QBMAN_CINH_SWP_ISR 0xe00
+#define QBMAN_CINH_SWP_IER 0xe40
+#define QBMAN_CINH_SWP_ISDR0xe80
+#define QBMAN_CINH_SWP_IIR 0xec0
+
+/* CENA register offsets */
+#define QBMAN_CENA_SWP_EQCR(n) (0x000 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_DQRR(n) (0x200 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_RCR(n)  (0x400 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_CR  0x600
+#define QBMAN_CENA_SWP_RR(vb)  (0x700 + ((u32)(vb) >> 1))
+#define QBMAN_CENA_SWP_VDQCR   0x780
+
+/* Reverse mapping of QBMAN_CENA_SWP_DQRR() */
+#define QBMAN_IDX_FROM_DQRR(p) (((unsigned long)p & 0x1ff) >> 6)
+
+/* Define token used to determine if response written to memory is valid */
+#define QMAN_DQ_TOKEN_VALID 1
+
+/* SDQCR attribute codes */
+#define QB_SDQCR_FC_SHIFT   29
+#define QB_SDQCR_FC_MASK0x1
+#define QB_SDQCR_DCT_SHIFT  24
+#define QB_SDQCR_DCT_MASK   0x3
+#define QB_SD

[PATCH v3 3/9] bus: fsl-mc: dpio: add APIs for DPIO objects

2016-12-01 Thread Stuart Yoder
From: Ioana Radulescu 

Add the command build/parse APIs for operating on DPIO objects through
the DPAA2 Management Complex.

Signed-off-by: Ioana Radulescu 
Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v3
  -no changes
-v2
  -removed unused structs and defines

 drivers/bus/fsl-mc/Kconfig |  10 ++
 drivers/bus/fsl-mc/Makefile|   3 +
 drivers/bus/fsl-mc/dpio/Makefile   |   9 ++
 drivers/bus/fsl-mc/dpio/dpio-cmd.h |  75 
 drivers/bus/fsl-mc/dpio/dpio.c | 229 +
 drivers/bus/fsl-mc/dpio/dpio.h | 108 +
 6 files changed, 434 insertions(+)
 create mode 100644 drivers/bus/fsl-mc/dpio/Makefile
 create mode 100644 drivers/bus/fsl-mc/dpio/dpio-cmd.h
 create mode 100644 drivers/bus/fsl-mc/dpio/dpio.c
 create mode 100644 drivers/bus/fsl-mc/dpio/dpio.h

diff --git a/drivers/bus/fsl-mc/Kconfig b/drivers/bus/fsl-mc/Kconfig
index 5c009ab..a10aaf0 100644
--- a/drivers/bus/fsl-mc/Kconfig
+++ b/drivers/bus/fsl-mc/Kconfig
@@ -15,3 +15,13 @@ config FSL_MC_BUS
  architecture.  The fsl-mc bus driver handles discovery of
  DPAA2 objects (which are represented as Linux devices) and
  binding objects to drivers.
+
+config FSL_MC_DPIO
+tristate "QorIQ DPAA2 DPIO driver"
+depends on FSL_MC_BUS
+help
+ Driver for the DPAA2 DPIO object.  A DPIO provides queue and
+ buffer management facilities for software to interact with
+ other DPAA2 objects. This driver does not expose the DPIO
+ objects individually, but groups them under a service layer
+ API.
diff --git a/drivers/bus/fsl-mc/Makefile b/drivers/bus/fsl-mc/Makefile
index d56afee..d18df72 100644
--- a/drivers/bus/fsl-mc/Makefile
+++ b/drivers/bus/fsl-mc/Makefile
@@ -17,3 +17,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \
  fsl-mc-msi.o \
  dpmcp.o \
  dpbp.o
+
+# MC DPIO driver
+obj-$(CONFIG_FSL_MC_DPIO) += dpio/
diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-mc/dpio/Makefile
new file mode 100644
index 000..128befc
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/Makefile
@@ -0,0 +1,9 @@
+#
+# QorIQ DPAA2 DPIO driver
+#
+
+subdir-ccflags-y := -Werror
+
+obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
+
+fsl-mc-dpio-objs := dpio.o
diff --git a/drivers/bus/fsl-mc/dpio/dpio-cmd.h 
b/drivers/bus/fsl-mc/dpio/dpio-cmd.h
new file mode 100644
index 000..3464ed9
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/dpio-cmd.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _FSL_DPIO_CMD_H
+#define _FSL_DPIO_CMD_H
+
+/* DPIO Version */
+#define DPIO_VER_MAJOR 4
+#define DPIO_VER_MINOR 2
+
+/* Command Versioning */
+
+#define DPIO_CMD_ID_OFFSET 4
+#define DPIO_CMD_BASE_VERSION  1
+
+#define DPIO_CMD(id)   ((id << DPIO_CMD_ID_OFFSET) | DPIO_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPIO_CMDID_CLOSE   DPIO_CMD(0x800)
+#define DPIO_CMDID_OPENDPIO_CMD(0x803)
+#define DPIO_CMDID_GET_API_

[PATCH v3 2/9] bus: fsl-mc: dpio: add DPIO driver overview document

2016-12-01 Thread Stuart Yoder
add document describing the dpio driver and it's role, components
and major interfaces

Signed-off-by: Stuart Yoder 
---
 Documentation/dpaa2/dpio-driver.txt | 135 
 1 file changed, 135 insertions(+)
 create mode 100644 Documentation/dpaa2/dpio-driver.txt

diff --git a/Documentation/dpaa2/dpio-driver.txt 
b/Documentation/dpaa2/dpio-driver.txt
new file mode 100644
index 000..5c192b3
--- /dev/null
+++ b/Documentation/dpaa2/dpio-driver.txt
@@ -0,0 +1,135 @@
+Copyright (C) 2016 Freescale Semiconductor Inc.
+
+Introduction
+
+
+A DPAA2 DPIO (Data Path I/O) is a hardware object that provides
+interfaces to enqueue and dequeue frames to/from network interfaces
+and other accelerators.  A DPIO also provides hardware buffer
+pool management for network interfaces.
+
+This document provides an overview the Linux DPIO driver, its
+subcomponents, and its APIs.
+
+See Documentation/dpaa2/overview.txt for a general overview of DPAA2
+and the general DPAA2 driver architecture in Linux.
+
+Driver Overview
+---
+
+The DPIO driver is bound to DPIO objects discovered on the fsl-mc bus and
+provides services that:
+  A) allow other drivers, such as the Ethernet driver, to enqueue and dequeue
+ frames for their respective objects
+  B) allow drivers to register callbacks for data availability notifications
+ when data becomes available on a queue or channel
+  C) allow drivers to manage hardware buffer pools
+
+The Linux DPIO driver consists of 3 primary components--
+   DPIO object driver-- fsl-mc driver that manages the DPIO object
+   DPIO service-- provides APIs to other Linux drivers for services
+   QBman portal interface-- sends portal commands, gets responses
+
+  fsl-mc  other
+   bus   drivers
+|   |
++---++   +--+-+
+|DPIO obj|   |DPIO service|
+| driver |---|  (DPIO)|
+++   +--+-+
+|
+ +--+-+
+ |QBman   |
+ | portal i/f |
+ ++
+|
+ hardware
+
+The diagram below shows how the DPIO driver components fit with the other
+DPAA2 Linux driver components:
+   ++
+   | OS Network |
+   |   Stack|
+ ++++
+ | Allocator  |. . . . . . .   |  Ethernet  |
+ |(DPMCP,DPBP)||   (DPNI)   |
+ +-.--++---+---++
+  .  . ^   |
+ ..|   | dequeue>
++-+ .  |   |
+| DPRC driver |  .++ ++
+|   (DPRC)|   . . |DPIO obj| |DPIO service|
++--+--+   | driver |-|  (DPIO)|
+   |  ++ +--+-+
+   | +--|-+
+   | |   QBman|
+  ++--+  | portal i/f |
+  |   MC-bus driver   |  ++
+  |   | |
+  | /soc/fsl-mc   | |
+  +---+ |
+|
+ =|=|
++-+--DPIO---|---+
+|   |   |
+|QBman Portal   |
++---+
+
+ 
+
+
+DPIO Object Driver (dpio-driver.c)
+--
+
+   The dpio-driver component registers with the fsl-mc bus to handle objects of
+   type "dpio".  The implementation of probe() handles basic initialization
+   of the DPIO including mapping of the DPIO regions (the QBman SW portal)
+   and initializing interrupts and registering irq handlers.  The dpio-driver
+   registers the probed DPIO with dpio-service.
+
+DPIO service  (dpio-service.c, dpaa2-io.h)
+--
+
+   The dpio service component provides queuing, notification, and buffers
+   management services to DPAA2 drivers, such as the Ethernet driver.  A system
+   will typically allocate 1 DPIO object per CPU to allow queuing operations
+   to happen simultaneously across all CPUs.
+
+   Not

[PATCH v3 1/9] staging: fsl-mc: move bus driver out of staging

2016-12-01 Thread Stuart Yoder
Move the source files out of staging into their final locations:
  -include files in drivers/staging/fsl-mc/include go to include/linux/fsl
  -irq-gic-v3-its-fsl-mc-msi.c goes to drivers/irqchip
  -source in drivers/staging/fsl-mc/bus goes to drivers/bus/fsl-mc
  -README.txt, providing and overview of DPAA goes to
   Documentation/dpaa2/overview.txt
  -update MAINTAINERS with new location

Delete other remaining staging files-- Makefile, Kconfig, TODO

Signed-off-by: Stuart Yoder 
---

Notes:
-v3
  -no changes
-v2
  -updated MAINTAINERS with new location

 .../README.txt => Documentation/dpaa2/overview.txt |  0
 MAINTAINERS|  2 +-
 drivers/bus/Kconfig|  3 +++
 drivers/bus/Makefile   |  3 +++
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/Kconfig |  0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/Makefile|  1 -
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpbp-cmd.h  |  0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpbp.c  |  6 +++---
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpcon-cmd.h |  0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp-cmd.h |  0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp.c |  5 +++--
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp.h |  0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmng-cmd.h |  0
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmng.c |  6 +++---
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dprc-cmd.h  |  0
 .../{staging/fsl-mc/bus => bus/fsl-mc}/dprc-driver.c   |  4 ++--
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dprc.c  |  6 +++---
 .../fsl-mc/bus => bus/fsl-mc}/fsl-mc-allocator.c   |  4 ++--
 .../{staging/fsl-mc/bus => bus/fsl-mc}/fsl-mc-bus.c|  6 +++---
 .../{staging/fsl-mc/bus => bus/fsl-mc}/fsl-mc-msi.c|  2 +-
 .../fsl-mc/bus => bus/fsl-mc}/fsl-mc-private.h |  4 ++--
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/mc-io.c |  4 ++--
 drivers/{staging/fsl-mc/bus => bus/fsl-mc}/mc-sys.c|  6 +++---
 drivers/irqchip/Makefile   |  1 +
 .../fsl-mc/bus => irqchip}/irq-gic-v3-its-fsl-mc-msi.c |  2 +-
 drivers/staging/Kconfig|  2 --
 drivers/staging/Makefile   |  1 -
 drivers/staging/fsl-mc/Kconfig |  1 -
 drivers/staging/fsl-mc/Makefile|  2 --
 drivers/staging/fsl-mc/TODO| 18 --
 .../fsl-mc/include => include/linux/fsl}/dpbp.h|  0
 .../fsl-mc/include => include/linux/fsl}/dpmng.h   |  0
 .../fsl-mc/include => include/linux/fsl}/dprc.h|  0
 .../fsl-mc/include => include/linux/fsl}/mc-bus.h  |  2 +-
 .../fsl-mc/include => include/linux/fsl}/mc-cmd.h  |  0
 .../fsl-mc/include => include/linux/fsl}/mc-sys.h  |  0
 .../staging/fsl-mc/include => include/linux/fsl}/mc.h  |  2 +-
 37 files changed, 38 insertions(+), 55 deletions(-)
 rename drivers/staging/fsl-mc/README.txt => Documentation/dpaa2/overview.txt 
(100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/Kconfig (100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/Makefile (91%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpbp-cmd.h (100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpbp.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpcon-cmd.h (100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp-cmd.h (100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmcp.h (100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmng-cmd.h (100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dpmng.c (96%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dprc-cmd.h (100%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dprc-driver.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/dprc.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/fsl-mc-allocator.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/fsl-mc-bus.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/fsl-mc-msi.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/fsl-mc-private.h (96%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/mc-io.c (99%)
 rename drivers/{staging/fsl-mc/bus => bus/fsl-mc}/mc-sys.c (99%)
 rename drivers/{staging/fsl-mc/bus => irqchip}/irq-gic-v3-its-fsl-mc-msi.c 
(99%)
 delete mode 100644 drivers/staging/fsl-mc/Kconfig
 delete mode 100644 drivers/staging/fsl-mc/Makefile
 delete mode 100644 drivers/staging/fsl-mc/TODO
 rename {drivers/staging/fsl-mc/include => include/linux/fsl}/dpbp.h (100%)
 rename {drivers/staging/fsl-mc/include => include/linux/fsl}/dpmng.h (100%)
 rename {drivers/staging/fsl-mc/include => include/linux/fsl}/dprc.

RE: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file

2016-12-06 Thread Stuart Yoder


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, December 06, 2016 4:20 AM
> To: Ruxandra Ioana Radulescu 
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Alexandru
> Marginean ; Bogdan Hamciuc 
> ; Stuart Yoder
> ; Roy Pledge ; Laurentiu Tudor 
> 
> Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> 
> On Tue, Dec 06, 2016 at 10:06:25AM +, Ruxandra Ioana Radulescu wrote:
> > > -Original Message-
> > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > Sent: Tuesday, December 06, 2016 11:58 AM
> > > To: Ruxandra Ioana Radulescu 
> > > Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> > > ag...@suse.de; a...@arndb.de; Alexandru Marginean
> > > ; Bogdan Hamciuc
> > > ; Stuart Yoder ; Roy
> > > Pledge ; Laurentiu Tudor
> > > 
> > > Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> > >
> > > On Tue, Dec 06, 2016 at 03:34:41AM -0600, Ioana Radulescu wrote:
> > > > Add a list of TODO items for the Ethernet driver
> > > >
> > > > Signed-off-by: Ioana Radulescu 
> > > > ---
> > > >  drivers/staging/fsl-dpaa2/ethernet/TODO |9 +
> > > >  1 files changed, 9 insertions(+), 0 deletions(-)
> > > >  create mode 100644 drivers/staging/fsl-dpaa2/ethernet/TODO
> > > >
> > > > diff --git a/drivers/staging/fsl-dpaa2/ethernet/TODO 
> > > > b/drivers/staging/fsl-
> > > dpaa2/ethernet/TODO
> > > > new file mode 100644
> > > > index 000..833265b
> > > > --- /dev/null
> > > > +++ b/drivers/staging/fsl-dpaa2/ethernet/TODO
> > > > @@ -0,0 +1,9 @@
> > > > +* Add a DPAA2 MAC kernel driver in order to allow PHY management;
> > > currently
> > > > +  the DPMAC objects and their link to DPNIs are handled by MC 
> > > > internally
> > > > +  and all PHYs are seen as fixed-link
> > > > +* add more debug support: decide how to expose detailed debug
> > > statistics,
> > > > +  add ingress error queue support
> > > > +* MC firmware uprev; the DPAA2 objects used by the Ethernet driver
> > > need to
> > > > +  be kept in sync with binary interface changes in MC
> > > > +* refine README file
> > > > +* cleanup
> > >
> > > These seem like very minor things, why not just spend a week and do this
> > > work and get it merged to the "correct" portion of the kernel tree?  Why
> > > does this have to go into staging?
> >
> > Actually the first bullet is not minor at all and requires some design
> > choices that we aren't yet completely clear with, and which in turn may
> > affect parts of the Ethernet driver. We figured it would be best to try
> > adding this in staging first (and also provide this way an example of using
> > the fsl-mc bus and dpio driver) than wait until all MAC development
> > questions are ironed-out.
> 
> Ok, that makes sense.
> 
> > I can remove the other bullets from the TODO list if you think they're
> > not worth mentioning.
> 
> No, they should be mentioned, I just didn't think they are all that much
> work, and if you didn't have major things needed to get done, you could
> just knock it all out in a week of local development.
> 
> I'll look into taking this into the tree later today...

Note, as mentioned in the cover letter, in it's current form this patch
series is based on the series:
[PATCH v3 0/9] staging: fsl-mc: move bus driver out of staging, add dpio

...which means that it won't build or run without that series being
applied first, due to header file dependencies.  It also functionally
depends on the DPIO driver.  So we need the dpio driver merged first.

Is moving the fsl-mc bus driver out of staging a possibility now?

Seems like there are several options--
A.  Keep bus driver in drivers/staging for now, create new series to
add dpio driver into staging, add fsl-dpaa2/eth into staging and
refactor it to assume include dependencies in staging directories.
B.  Apply the series:
[PATCH v3 0/9] staging: fsl-mc: move bus driver out of staging, add dpio
...in something close to it's current form.  There is some minor 
feedback on the dpio driver that will require a v4, which I can
send in the next day or so.

The fsl-mc bus driver to do list is complete, with the exception
of demonstrating a functional driver on top of the bus driver,
and as described in the cover letter of the "move bus driver out
of staging" series the dpio driver demonstrates what an fsl-mc
device driver looks like.

Thanks,
Stuart



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file

2016-12-06 Thread Stuart Yoder


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, December 06, 2016 11:56 AM
> To: Stuart Yoder 
> Cc: Ruxandra Ioana Radulescu ; 
> de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Alexandru Marginean 
> ;
> Bogdan Hamciuc ; Roy Pledge ; 
> Laurentiu Tudor
> 
> Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> 
> On Tue, Dec 06, 2016 at 12:59:59PM +, Stuart Yoder wrote:
> >
> >
> > > -Original Message-
> > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > Sent: Tuesday, December 06, 2016 4:20 AM
> > > To: Ruxandra Ioana Radulescu 
> > > Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; 
> > > ag...@suse.de; a...@arndb.de;
> Alexandru
> > > Marginean ; Bogdan Hamciuc 
> > > ; Stuart Yoder
> > > ; Roy Pledge ; Laurentiu Tudor 
> > > 
> > > Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> > >
> > > On Tue, Dec 06, 2016 at 10:06:25AM +, Ruxandra Ioana Radulescu wrote:
> > > > > -Original Message-
> > > > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > > > Sent: Tuesday, December 06, 2016 11:58 AM
> > > > > To: Ruxandra Ioana Radulescu 
> > > > > Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> > > > > ag...@suse.de; a...@arndb.de; Alexandru Marginean
> > > > > ; Bogdan Hamciuc
> > > > > ; Stuart Yoder ; Roy
> > > > > Pledge ; Laurentiu Tudor
> > > > > 
> > > > > Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> > > > >
> > > > > On Tue, Dec 06, 2016 at 03:34:41AM -0600, Ioana Radulescu wrote:
> > > > > > Add a list of TODO items for the Ethernet driver
> > > > > >
> > > > > > Signed-off-by: Ioana Radulescu 
> > > > > > ---
> > > > > >  drivers/staging/fsl-dpaa2/ethernet/TODO |9 +
> > > > > >  1 files changed, 9 insertions(+), 0 deletions(-)
> > > > > >  create mode 100644 drivers/staging/fsl-dpaa2/ethernet/TODO
> > > > > >
> > > > > > diff --git a/drivers/staging/fsl-dpaa2/ethernet/TODO 
> > > > > > b/drivers/staging/fsl-
> > > > > dpaa2/ethernet/TODO
> > > > > > new file mode 100644
> > > > > > index 000..833265b
> > > > > > --- /dev/null
> > > > > > +++ b/drivers/staging/fsl-dpaa2/ethernet/TODO
> > > > > > @@ -0,0 +1,9 @@
> > > > > > +* Add a DPAA2 MAC kernel driver in order to allow PHY management;
> > > > > currently
> > > > > > +  the DPMAC objects and their link to DPNIs are handled by MC 
> > > > > > internally
> > > > > > +  and all PHYs are seen as fixed-link
> > > > > > +* add more debug support: decide how to expose detailed debug
> > > > > statistics,
> > > > > > +  add ingress error queue support
> > > > > > +* MC firmware uprev; the DPAA2 objects used by the Ethernet driver
> > > > > need to
> > > > > > +  be kept in sync with binary interface changes in MC
> > > > > > +* refine README file
> > > > > > +* cleanup
> > > > >
> > > > > These seem like very minor things, why not just spend a week and do 
> > > > > this
> > > > > work and get it merged to the "correct" portion of the kernel tree?  
> > > > > Why
> > > > > does this have to go into staging?
> > > >
> > > > Actually the first bullet is not minor at all and requires some design
> > > > choices that we aren't yet completely clear with, and which in turn may
> > > > affect parts of the Ethernet driver. We figured it would be best to try
> > > > adding this in staging first (and also provide this way an example of 
> > > > using
> > > > the fsl-mc bus and dpio driver) than wait until all MAC development
> > > > questions are ironed-out.
> > >
> > > Ok, that makes sense.
> > >
> > > > I can remove the other bullets from the TODO list if you think they're
> > > > not worth mentioning.
> > >
> > > No, they should be mentioned, I just didn't think they are all that much
> > > work, and if you didn't have major things needed to get done, you could
> > > just knock it all out in a week of local development.
> > >
> > > I'll look into taking this into the tree later today...
> >
> > Note, as mentioned in the cover letter, in it's current form this patch
> > series is based on the series:
> > [PATCH v3 0/9] staging: fsl-mc: move bus driver out of staging, add dpio
> >
> > ...which means that it won't build or run without that series being
> > applied first, due to header file dependencies.  It also functionally
> > depends on the DPIO driver.  So we need the dpio driver merged first.
> >
> > Is moving the fsl-mc bus driver out of staging a possibility now?
> 
> I'm ok with it, but I really haven't looked at the patches in a while, I
> keep seeing others have problems with it.  Want me to review it now?

Yes, would like that very much.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v3 1/9] staging: fsl-mc: move bus driver out of staging

2016-12-07 Thread Stuart Yoder
> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Wednesday, December 07, 2016 9:53 AM
> To: Stuart Yoder 
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Leo Li
> ; Ioana Ciornei ; Catalin Horghidan
> ; Laurentiu Tudor ; 
> Ruxandra Ioana Radulescu
> 
> Subject: Re: [PATCH v3 1/9] staging: fsl-mc: move bus driver out of staging
> 
> On Thu, Dec 01, 2016 at 04:41:26PM -0600, Stuart Yoder wrote:
> > Move the source files out of staging into their final locations:
> >   -include files in drivers/staging/fsl-mc/include go to include/linux/fsl
> >   -irq-gic-v3-its-fsl-mc-msi.c goes to drivers/irqchip
> >   -source in drivers/staging/fsl-mc/bus goes to drivers/bus/fsl-mc
> >   -README.txt, providing and overview of DPAA goes to
> >Documentation/dpaa2/overview.txt
> >   -update MAINTAINERS with new location
> >
> > Delete other remaining staging files-- Makefile, Kconfig, TODO
> 
> Ok, given that I haven't ever reviewed this code, I had a few questions
> that I couldn't easily figure out by looking at your code:
>   - what is the lifecycle of your 'struct device' usage?  Who
> creates it, who frees it, and who accesses it?

We embed a 'struct device' inside our bus specific device struct
'struct fsl_mc_device'.  So, when a new fsl-mc object is discovered
on the bus during initial enumeration or hotplug we create a new
'struct fsl_mc_device' and do a device_initialize()/device_add().
(see fsl_mc_device_add() for where this is done)

'struct device' is freed when a device is removed-- the reverse
of the above.

As far as who accesses it... fsl-mc device drivers will reference
the 'struct device' when registering interrupts, when calling
functions like devm*, dev_err(), and for maintaining driver
private data in 'driver_data'.

Example of registering an irq where you can see the embedded
struct dev (dpio_dev->dev) referenced:

error = devm_request_irq(&dpio_dev->dev,
 irq->msi_desc->irq,
 dpio_irq_handler,
 0,
 dev_name(&dpio_dev->dev),
 &dpio_dev->dev);

>   - do you have any Documentation/ABI entries?

Not currently, but it looks like we need ones for bind/unbind.
I will submit a patch to document these.

>   - root_dprc_count, why are you using an atomic variable for
> this?  What is it for other than "look, I'm running!"?

There can be multiple root buses, and this variable simply tracks the count
of them.  It's is atomic there might be a theoretical race condition where
2 buses might be added at the same time.  The root buses are found in the
device tree and so if there is no chance that device tree processing happens
in parallel on multiple cores then we could remove the atomic.

>   - don't call pr_info() in fsl_mc_bus_driver_init(), no need to
> say anything if all goes well.  Same goes with random
> dev_info() calls, please remove.

Ok, will do.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-mc: add sysfs ABI doc

2016-12-07 Thread Stuart Yoder
define the bind/unbind sysfs interfaces for the fsl-mc bus

Signed-off-by: Stuart Yoder 
---
 Documentation/ABI/testing/sysfs-bus-fsl-mc | 21 +
 1 file changed, 21 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..80256b8
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-fsl-mc
@@ -0,0 +1,21 @@
+What:  /sys/bus/fsl-mc/drivers/.../bind
+Date:  December 2016
+Contact:   stuart.yo...@nxp.com
+Description:
+   Writing a device location to this file will cause
+   the driver to attempt to bind to the device found at
+   this location. The format for the location is Object.Id
+   and is the same as found in /sys/bus/fsl-mc/devices/.
+For example:
+   # echo dpni.2 > /sys/bus/fsl-mc/drivers/fsl_dpaa2_eth/bind
+
+What:  /sys/bus/fsl-mc/drivers/.../unbind
+Date:  December 2016
+Contact:   stuart.yo...@nxp.com
+Description:
+   Writing a device location to this file will cause the
+   driver to attempt to unbind from the device found at
+   this location. The format for the location is Object.Id
+   and is the same as found in /sys/bus/fsl-mc/devices/.
+For example:
+   # echo dpni.2 > /sys/bus/fsl-mc/drivers/fsl_dpaa2_eth/unbind
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-mc: remove unnecessary info prints from bus driver

2016-12-07 Thread Stuart Yoder
remove pr_info/dev_info prints that add unnecessary verbosity

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
index f9fed63..5ac373c 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
@@ -231,7 +231,6 @@ int __fsl_mc_driver_register(struct fsl_mc_driver 
*mc_driver,
return error;
}
 
-   pr_info("driver %s registered\n", mc_driver->driver.name);
return 0;
 }
 EXPORT_SYMBOL_GPL(__fsl_mc_driver_register);
@@ -731,8 +730,6 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
struct mc_version mc_version;
struct resource res;
 
-   dev_info(&pdev->dev, "root DPRC probed");
-
mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL);
if (!mc)
return -ENOMEM;
@@ -822,7 +819,6 @@ static int fsl_mc_bus_remove(struct platform_device *pdev)
fsl_destroy_mc_io(mc->root_mc_bus_dev->mc_io);
mc->root_mc_bus_dev->mc_io = NULL;
 
-   dev_info(&pdev->dev, "root DPRC removed");
return 0;
 }
 
@@ -861,8 +857,6 @@ static int __init fsl_mc_bus_driver_init(void)
goto error_cleanup_cache;
}
 
-   pr_info("bus type registered\n");
-
error = platform_driver_register(&fsl_mc_bus_driver);
if (error < 0) {
pr_err("platform_driver_register() failed: %d\n", error);
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v3 1/9] staging: fsl-mc: move bus driver out of staging

2016-12-08 Thread Stuart Yoder
> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, December 08, 2016 10:05 AM
> To: Stuart Yoder 
> Cc: de...@driverdev.osuosl.org; ag...@suse.de; a...@arndb.de; 
> linux-ker...@vger.kernel.org; Leo Li
> ; Catalin Horghidan ; Ioana 
> Ciornei
> ; Laurentiu Tudor 
> Subject: Re: [PATCH v3 1/9] staging: fsl-mc: move bus driver out of staging
> 
> On Wed, Dec 07, 2016 at 08:19:20PM +, Stuart Yoder wrote:
> > > -Original Message-
> > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > Sent: Wednesday, December 07, 2016 9:53 AM
> > > To: Stuart Yoder 
> > > Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; 
> > > ag...@suse.de; a...@arndb.de; Leo Li
> > > ; Ioana Ciornei ; Catalin 
> > > Horghidan
> > > ; Laurentiu Tudor ; 
> > > Ruxandra Ioana Radulescu
> > > 
> > > Subject: Re: [PATCH v3 1/9] staging: fsl-mc: move bus driver out of 
> > > staging
> > >
> > > On Thu, Dec 01, 2016 at 04:41:26PM -0600, Stuart Yoder wrote:
> > > > Move the source files out of staging into their final locations:
> > > >   -include files in drivers/staging/fsl-mc/include go to 
> > > > include/linux/fsl
> > > >   -irq-gic-v3-its-fsl-mc-msi.c goes to drivers/irqchip
> > > >   -source in drivers/staging/fsl-mc/bus goes to drivers/bus/fsl-mc
> > > >   -README.txt, providing and overview of DPAA goes to
> > > >Documentation/dpaa2/overview.txt
> > > >   -update MAINTAINERS with new location
> > > >
> > > > Delete other remaining staging files-- Makefile, Kconfig, TODO
> > >
> > > Ok, given that I haven't ever reviewed this code, I had a few questions
> > > that I couldn't easily figure out by looking at your code:
> > >   - what is the lifecycle of your 'struct device' usage?  Who
> > > creates it, who frees it, and who accesses it?
> >
> > We embed a 'struct device' inside our bus specific device struct
> > 'struct fsl_mc_device'.  So, when a new fsl-mc object is discovered
> > on the bus during initial enumeration or hotplug we create a new
> > 'struct fsl_mc_device' and do a device_initialize()/device_add().
> > (see fsl_mc_device_add() for where this is done)
> >
> > 'struct device' is freed when a device is removed-- the reverse
> > of the above.
> 
> Where is the device freed?  I see you trying to do some "odd" stuff in
> fsl_mc_device_remove() by deleting and then putting a device structure.
> I can't find a "release()" callback anywhere for your bus, where is it?
> 
> What happens when the reference count falls to 0 for your struct device?

Hrm...something seems wrong in free path, and I think this needs to
be refactored.

IIRC, when German (former maintainer) wrote that code he loosely based
it on the register/unregister platform bus code:

int platform_device_register(struct platform_device *pdev)
{
device_initialize(&pdev->dev);
arch_setup_pdev_archdata(pdev);
return platform_device_add(pdev);
}
void platform_device_unregister(struct platform_device *pdev)
{
platform_device_del(pdev);
platform_device_put(pdev);
}

...I'm puzzling over how that code handles a refcount of zero
as I see no 'release' callback anywhere, but I must be missing
something.

In any case, we'll get this refactored.

> > >   - root_dprc_count, why are you using an atomic variable for
> > > this?  What is it for other than "look, I'm running!"?
> >
> > There can be multiple root buses, and this variable simply tracks the count
> > of them.
> 
> Why does it matter?
> 
> > It's is atomic there might be a theoretical race condition where 2
> > buses might be added at the same time.  The root buses are found in
> > the device tree and so if there is no chance that device tree
> > processing happens in parallel on multiple cores then we could remove
> > the atomic.
> 
> Why not just use a lock, or better yet, not care about a "count" at all?
> I don't see you doing anything with the count, other than emitting a
> WARN() if it drops down below 0 for some reason, or when you call
> fsl_mc_bus_exists() which for some reason is exported yet no one uses
> it...

We can drop this count.  At one time I think there was envisioned an 
external user who needed it, but it's no longer the case.

Given the additional refactoring, I think the fsl-mc bus driver needs
to stay in staging for a bit.  In order to facilitate further review
I'm going to refactor the patch series:
  staging: fsl-mc: move bus driver out of staging, add dpio

...to just add dpio (into staging).  This will allow the Eth driver
series sent earlier this week to go into staging:
  staging: Introduce Freescale DPAA2 Ethernet driver

With all that in staging we'll have a fully functional Ethernet
driver.

Thanks,
Stuart

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v3 1/9] staging: fsl-mc: move bus driver out of staging

2016-12-09 Thread Stuart Yoder
> > > Where is the device freed?  I see you trying to do some "odd" stuff in
> > > fsl_mc_device_remove() by deleting and then putting a device structure.
> > > I can't find a "release()" callback anywhere for your bus, where is it?
> > >
> > > What happens when the reference count falls to 0 for your struct device?
> >
> > Hrm...something seems wrong in free path, and I think this needs to
> > be refactored.
> >
> > IIRC, when German (former maintainer) wrote that code he loosely based
> > it on the register/unregister platform bus code:
> >
> > int platform_device_register(struct platform_device *pdev)
> > {
> > device_initialize(&pdev->dev);
> > arch_setup_pdev_archdata(pdev);
> > return platform_device_add(pdev);
> > }
> > void platform_device_unregister(struct platform_device *pdev)
> > {
> > platform_device_del(pdev);
> > platform_device_put(pdev);
> > }
> >
> > ...I'm puzzling over how that code handles a refcount of zero
> > as I see no 'release' callback anywhere, but I must be missing
> > something.
> >
> > In any case, we'll get this refactored.
> 
> Have you tried removing a device?  The kernel should complain loudly
> about there not being a release function for your device.

Yes, device removal has been working from day 1.  A brief look
seems to indicate that the ref count never goes to zero, which
needs to be debugged.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v3 3/9] bus: fsl-mc: dpio: add APIs for DPIO objects

2016-12-15 Thread Stuart Yoder
> > +#define DPIO_CMD(id)   ((id << DPIO_CMD_ID_OFFSET) | 
> > DPIO_CMD_BASE_VERSION)
> 
> Paranthesis around 'id'?

In all cases these are opcode values and will never be an expression.  If
we really need to future proof these definitions, we should do it for all
objects not just DPIO.  I'd like to see consistency across objects and don't
want to see DPIO gratuitously diverge.  So, my suggestion is to have an
offline discussion and if we think the change is needed, submit a patch for
all objects currently supported.

> > +   /* prepare command */
> > +   cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN,
> > + cmd_flags,
> > + 0);
> > +   dpio_cmd = (struct dpio_cmd_open *)cmd.params;
> > +   dpio_cmd->dpio_id = cpu_to_le32(dpio_id);
> > +
> > +   /* send command to mc*/
> > +   err = mc_send_command(mc_io, &cmd);
> > +   if (err)
> > +   return err;
> > +
> > +   /* retrieve response parameters */
> > +   *token = mc_cmd_hdr_read_token(&cmd);
> 
> Nit: maybe we should drop these repetitive "prepare / send / retrieve" 
> comments
> as the code is pretty self explanatory.

The 'send' comment certainly isn't needed given that the function
is 'mc_send_command()'.  For the others, I think having some comment
is helpful, even though a bit repetitive.

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v3 4/9] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs

2016-12-15 Thread Stuart Yoder


> -Original Message-
> From: Laurentiu Tudor
> Sent: Friday, December 02, 2016 6:12 AM
> To: Stuart Yoder ; gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Leo Li
> ; Ioana Ciornei ; Catalin Horghidan
> ; Ruxandra Ioana Radulescu 
> ; Roy Pledge
> 
> Subject: Re: [PATCH v3 4/9] bus: fsl-mc: dpio: add frame descriptor and 
> scatter/gather APIs
> 
> 
> Some more bits and pieces inside.
> 
> ---
> Best Regards, Laurentiu
> 
> On 12/02/2016 12:41 AM, Stuart Yoder wrote:
> > From: Roy Pledge 
> >
> > Add global definitions for DPAA2 frame descriptors and scatter
> > gather entries.
> >
> > Signed-off-by: Roy Pledge 
> > Signed-off-by: Stuart Yoder 
> > ---
> >
> > Notes:
> > -v3
> >-no changes
> > -v2
> >-added setter/getter for the FD ctrl field
> >-corrected comment for SG format_offset field description
> >-added support for short length field in FD
> >
> >  include/linux/fsl/dpaa2-fd.h | 448 
> > +++
> >  1 file changed, 448 insertions(+)
> >  create mode 100644 include/linux/fsl/dpaa2-fd.h
> >
> > diff --git a/include/linux/fsl/dpaa2-fd.h b/include/linux/fsl/dpaa2-fd.h
> > new file mode 100644
> > index 000..182c8f4
> > --- /dev/null
> > +++ b/include/linux/fsl/dpaa2-fd.h
> > @@ -0,0 +1,448 @@
> > +/*
> > + * Copyright 2014-2016 Freescale Semiconductor Inc.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions are 
> > met:
> > + * * Redistributions of source code must retain the above copyright
> > + *   notice, this list of conditions and the following disclaimer.
> > + * * Redistributions in binary form must reproduce the above copyright
> > + *   notice, this list of conditions and the following disclaimer in 
> > the
> > + *   documentation and/or other materials provided with the 
> > distribution.
> > + * * Neither the name of Freescale Semiconductor nor the
> > + *   names of its contributors may be used to endorse or promote 
> > products
> > + *   derived from this software without specific prior written 
> > permission.
> > + *
> > + * ALTERNATIVELY, this software may be distributed under the terms of the
> > + * GNU General Public License ("GPL") as published by the Free Software
> > + * Foundation, either version 2 of that License or (at your option) any
> > + * later version.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
> > + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> > IMPLIED
> > + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> > + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
> > + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
> > DAMAGES
> > + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
> > SERVICES;
> > + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
> > AND
> > + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
> > TORT
> > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
> > OF THIS
> > + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> > + */
> > +#ifndef __FSL_DPAA2_FD_H
> > +#define __FSL_DPAA2_FD_H
> > +
> > +#include 
> > +
> > +/**
> > + * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2
> > + *
> > + * Frame Descriptors (FDs) are used to describe frame data in the DPAA2.
> > + * Frames can be enqueued and dequeued to Frame Queues (FQs) which are 
> > consumed
> > + * by the various DPAA accelerators (WRIOP, SEC, PME, DCE)
> > + *
> > + * There are three types of frames: single, scatter gather, and frame 
> > lists.
> > + *
> > + * The set of APIs in this file must be used to create, manipulate and
> > + * query Frame Descriptors.
> > + */
> > +
> > +/**
> > + * struct dpaa2_fd - Struct describing FDs
> > + * @words: for easier/faster copying the whole FD structure
> > + * @addr:  address in the FD
> > + * @len:   length in the FD
> > + * @bpid:  buffer pool ID
> > + * @format_offset: format, offset, and short-length f

RE: [PATCH v3 5/9] bus: fsl-mc: dpio: add global dpaa2 definitions

2016-12-15 Thread Stuart Yoder


> -Original Message-
> From: Laurentiu Tudor
> Sent: Friday, December 02, 2016 6:19 AM
> To: Stuart Yoder ; gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Leo Li
> ; Ioana Ciornei ; Catalin Horghidan
> ; Ruxandra Ioana Radulescu 
> ; Roy Pledge
> 
> Subject: Re: [PATCH v3 5/9] bus: fsl-mc: dpio: add global dpaa2 definitions
> 
> On 12/02/2016 12:41 AM, Stuart Yoder wrote:
> > From: Roy Pledge 
> >
> > Create header for global dpaa2 definitions.  Add definitions
> > for dequeue results.
> >
> > Signed-off-by: Roy Pledge 
> > Signed-off-by: Stuart Yoder 
> > ---
> >  include/linux/fsl/dpaa2-global.h | 203 
> > +++
> >  1 file changed, 203 insertions(+)
> >  create mode 100644 include/linux/fsl/dpaa2-global.h
> >
> > diff --git a/include/linux/fsl/dpaa2-global.h 
> > b/include/linux/fsl/dpaa2-global.h
> > new file mode 100644
> > index 000..3ee3f29
> > --- /dev/null
> > +++ b/include/linux/fsl/dpaa2-global.h
> > @@ -0,0 +1,203 @@
> > +/*
> > + * Copyright 2014-2016 Freescale Semiconductor Inc.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions are 
> > met:
> > + * * Redistributions of source code must retain the above copyright
> > + *   notice, this list of conditions and the following disclaimer.
> > + * * Redistributions in binary form must reproduce the above copyright
> > + *   notice, this list of conditions and the following disclaimer in 
> > the
> > + *   documentation and/or other materials provided with the 
> > distribution.
> > + * * Neither the name of Freescale Semiconductor nor the
> > + *   names of its contributors may be used to endorse or promote 
> > products
> > + *   derived from this software without specific prior written 
> > permission.
> > + *
> > + * ALTERNATIVELY, this software may be distributed under the terms of the
> > + * GNU General Public License ("GPL") as published by the Free Software
> > + * Foundation, either version 2 of that License or (at your option) any
> > + * later version.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
> > + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> > IMPLIED
> > + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> > + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
> > + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
> > DAMAGES
> > + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
> > SERVICES;
> > + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
> > AND
> > + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
> > TORT
> > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
> > OF THIS
> > + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> > + */
> > +#ifndef __FSL_DPAA2_GLOBAL_H
> > +#define __FSL_DPAA2_GLOBAL_H
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +struct dpaa2_dq {
> > +   union {
> > +   struct common {
> > +   u8 verb;
> > +   u8 reserved[63];
> > +   } common;
> > +   struct dq {
> > +   u8 verb;
> > +   u8 stat;
> > +   __le16 seqnum;
> > +   __le16 oprid;
> > +   u8 reserved;
> > +   u8 tok;
> > +   __le32 fqid;
> > +   u32 reserved2;
> > +   __le32 fq_byte_cnt;
> > +   __le32 fq_frm_cnt;
> > +   __le64 fqd_ctx;
> > +   u8 fd[32];
> > +   } dq;
> > +   struct scn {
> > +   u8 verb;
> > +   u8 stat;
> > +   u8 state;
> > +   u8 reserved;
> > +   __le32 rid_tok;
> > +   __le64 ctx;
> > +   } scn;
> > +   };
> > +};
> > +
> > +
> 
> Extra blank line.
> 
> > +/* Parsing frame dequeue results */
> > +/* FQ empty */
> > +#define DPAA2_DQ_STAT_FQEMPTY   0x80
>

RE: [PATCH v3 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2

2016-12-15 Thread Stuart Yoder


> -Original Message-
> From: Laurentiu Tudor
> Sent: Friday, December 02, 2016 6:40 AM
> To: Stuart Yoder ; gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Leo Li
> ; Ioana Ciornei ; Catalin Horghidan
> ; Ruxandra Ioana Radulescu 
> ; Roy Pledge
> ; Haiying Wang 
> Subject: Re: [PATCH v3 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> 
> On 12/02/2016 12:41 AM, Stuart Yoder wrote:
> > From: Roy Pledge 
> >
> > Add QBman APIs for frame queue and buffer pool operations.
> >
> > Signed-off-by: Roy Pledge 
> > Signed-off-by: Haiying Wang 
> > Signed-off-by: Stuart Yoder 
> > ---
> >
> > Notes:
> > -v3
> >-replace hardcoded dequeue token with a #define and check that
> > token when checking for a new result (bug fix suggested by
> > Ioana Radulescu)
> > -v2
> >-fix bug in buffer release command, by setting bpid field
> >-handle error (NULL) return value from qbman_swp_mc_complete()
> >-error message cleanup
> >-fix bug in sending management commands where the verb was
> > properly initialized
> >
> >  drivers/bus/fsl-mc/dpio/Makefile   |2 +-
> >  drivers/bus/fsl-mc/dpio/qbman-portal.c | 1028 
> > 
> >  drivers/bus/fsl-mc/dpio/qbman-portal.h |  464 ++
> >  3 files changed, 1493 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c
> >  create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h
> >
> > diff --git a/drivers/bus/fsl-mc/dpio/Makefile 
> > b/drivers/bus/fsl-mc/dpio/Makefile
> > index 128befc..6588498 100644
> > --- a/drivers/bus/fsl-mc/dpio/Makefile
> > +++ b/drivers/bus/fsl-mc/dpio/Makefile
> > @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
> >
> >  obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
> >
> > -fsl-mc-dpio-objs := dpio.o
> > +fsl-mc-dpio-objs := dpio.o qbman-portal.o
> > diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c 
> > b/drivers/bus/fsl-mc/dpio/qbman-portal.c
> > new file mode 100644
> > index 000..bbc032c
> > --- /dev/null
> > +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c
> > @@ -0,0 +1,1028 @@
> > +/*
> > + * Copyright (C) 2014 Freescale Semiconductor, Inc.
> 
> In previous patches the copyright years are 2014 - 2016. Maybe we should
> do the same here too.
> 
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions are 
> > met:
> > + * * Redistributions of source code must retain the above copyright
> > + *   notice, this list of conditions and the following disclaimer.
> > + * * Redistributions in binary form must reproduce the above copyright
> > + *   notice, this list of conditions and the following disclaimer in 
> > the
> > + *   documentation and/or other materials provided with the 
> > distribution.
> > + * * Neither the name of Freescale Semiconductor nor the
> > + *   names of its contributors may be used to endorse or promote 
> > products
> > + *   derived from this software without specific prior written 
> > permission.
> > + *
> > + * ALTERNATIVELY, this software may be distributed under the terms of the
> > + * GNU General Public License ("GPL") as published by the Free Software
> > + * Foundation, either version 2 of that License or (at your option) any
> > + * later version.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
> > + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> > IMPLIED
> > + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> > + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
> > + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
> > DAMAGES
> > + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
> > SERVICES;
> > + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
> > AND
> > + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
> > TORT
> > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
> > OF THIS
> > + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> > + */
> > +#include 
> > +#include 
> > +#include 

RE: [PATCH v3 7/9] bus: fsl-mc: dpio: add the DPAA2 DPIO service interface

2016-12-15 Thread Stuart Yoder
> > +struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc)
> > +{
> > +   struct dpaa2_io *obj = kmalloc(sizeof(*obj), GFP_KERNEL);
> > +
> > +   if (!obj)
> > +   return NULL;
> > +
> > +   /* check if CPU is out of range (-1 means any cpu) */
> > +   if (desc->cpu >= num_possible_cpus())
> 
> We leak 'obj' on this error path.

Will fix.

> > +
> > +/**
> > + * dpaa2_io_service_rearm() - Rearm the notification for the given DPIO 
> > service.
> > + * @service: the given DPIO service.
> 
> s/@service/@d/

Will fix.

> > +/**
> > + * dpaa2_io_store_next() - Determine when the next dequeue result is 
> > available.
> > + * @s: the dpaa2_io_store object.
> > + * @is_last: indicate whether this is the last frame in the pull command.
> > + *
> > + * When an object driver performs dequeues to a dpaa2_io_store, this 
> > function
> > + * can be used to determine when the next frame result is available. Once
> > + * this function returns non-NULL, a subsequent call to it will try to find
> > + * the next dequeue result.
> > + *
> > + * Note that if a pull-dequeue has a NULL result because the target 
> > FQ/channel
> > + * was empty, then this function will also return NULL (rather than 
> > expecting
> > + * the caller to always check for this. As such, "is_last" can be used to
> > + * differentiate between "end-of-empty-dequeue" and "still-waiting".
> > + *
> > + * Return dequeue result for a valid dequeue result, or NULL for empty 
> > dequeue.
> > + */
> > +struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int 
> > *is_last)
> 
> "bool *is_last"?

Same comment here as on the other patch...let's get Roy's input on this
and make it a TODO if deemed a good idea.

Thanks,
Stuartt

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 1/8] bus: fsl-mc: dpio: add DPIO driver overview document

2016-12-15 Thread Stuart Yoder
add document describing the dpio driver and it's role, components
and major interfaces

Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright

 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt | 135 
 1 file changed, 135 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt 
b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
new file mode 100644
index 000..0ba6771
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
@@ -0,0 +1,135 @@
+Copyright 2016 NXP
+
+Introduction
+
+
+A DPAA2 DPIO (Data Path I/O) is a hardware object that provides
+interfaces to enqueue and dequeue frames to/from network interfaces
+and other accelerators.  A DPIO also provides hardware buffer
+pool management for network interfaces.
+
+This document provides an overview the Linux DPIO driver, its
+subcomponents, and its APIs.
+
+See Documentation/dpaa2/overview.txt for a general overview of DPAA2
+and the general DPAA2 driver architecture in Linux.
+
+Driver Overview
+---
+
+The DPIO driver is bound to DPIO objects discovered on the fsl-mc bus and
+provides services that:
+  A) allow other drivers, such as the Ethernet driver, to enqueue and dequeue
+ frames for their respective objects
+  B) allow drivers to register callbacks for data availability notifications
+ when data becomes available on a queue or channel
+  C) allow drivers to manage hardware buffer pools
+
+The Linux DPIO driver consists of 3 primary components--
+   DPIO object driver-- fsl-mc driver that manages the DPIO object
+   DPIO service-- provides APIs to other Linux drivers for services
+   QBman portal interface-- sends portal commands, gets responses
+
+  fsl-mc  other
+   bus   drivers
+|   |
++---++   +--+-+
+|DPIO obj|   |DPIO service|
+| driver |---|  (DPIO)|
+++   +--+-+
+|
+ +--+-+
+ |QBman   |
+ | portal i/f |
+ ++
+|
+ hardware
+
+The diagram below shows how the DPIO driver components fit with the other
+DPAA2 Linux driver components:
+   ++
+   | OS Network |
+   |   Stack|
+ ++++
+ | Allocator  |. . . . . . .   |  Ethernet  |
+ |(DPMCP,DPBP)||   (DPNI)   |
+ +-.--++---+---++
+  .  . ^   |
+ ..|   | dequeue>
++-+ .  |   |
+| DPRC driver |  .++ ++
+|   (DPRC)|   . . |DPIO obj| |DPIO service|
++--+--+   | driver |-|  (DPIO)|
+   |  ++ +--+-+
+   | +--|-+
+   | |   QBman|
+  ++--+  | portal i/f |
+  |   MC-bus driver   |  ++
+  |   | |
+  | /soc/fsl-mc   | |
+  +---+ |
+|
+ =|=|
++-+--DPIO---|---+
+|   |   |
+|QBman Portal   |
++---+
+
+ 
+
+
+DPIO Object Driver (dpio-driver.c)
+--
+
+   The dpio-driver component registers with the fsl-mc bus to handle objects of
+   type "dpio".  The implementation of probe() handles basic initialization
+   of the DPIO including mapping of the DPIO regions (the QBman SW portal)
+   and initializing interrupts and registering irq handlers.  The dpio-driver
+   registers the probed DPIO with dpio-service.
+
+DPIO service  (dpio-service.c, dpaa2-io.h)
+--
+
+   The dpio service component provides queuing, notification, and buffers
+   management services to DPAA2 drivers, such as the Ethernet driver.  A system
+   will typically allocate 1 DPIO object per CPU to allow queuing operat

[PATCH v4 7/8] bus: fsl-mc: dpio: add the DPAA2 DPIO object driver

2016-12-15 Thread Stuart Yoder
From: Roy Pledge 

The DPIO driver registers with the fsl-mc bus to handle bus-related
events for DPIO objects.  Key responsibility is mapping I/O
regions, setting up interrupt handlers, and calling the DPIO
service initialization during probe.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright
   -adjust file location to be in drivers/staging
   -whitespace alignment cleanup
-v3
   -no changes
-v2
   -handle error case where number of DPIOs > NR_CPUs

 drivers/staging/fsl-mc/bus/dpio/Makefile  |   2 +-
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c | 296 ++
 2 files changed, 297 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c

diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
index 0778da7..837d330 100644
--- a/drivers/staging/fsl-mc/bus/dpio/Makefile
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o dpio-driver.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
new file mode 100644
index 000..e36da20
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright NXP 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../../include/mc.h"
+#include "../../include/dpaa2-io.h"
+
+#include "qbman-portal.h"
+#include "dpio.h"
+#include "dpio-cmd.h"
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Freescale Semiconductor, Inc");
+MODULE_DESCRIPTION("DPIO Driver");
+
+struct dpio_priv {
+   struct dpaa2_io *io;
+};
+
+static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
+{
+   struct device *dev = (struct device *)arg;
+   struct dpio_priv *priv = dev_get_drvdata(dev);
+
+   return dpaa2_io_irq(priv->io);
+}
+
+static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev)
+{
+   struct fsl_mc_device_irq *irq;
+
+   irq = dpio_dev->irqs[0];
+
+   /* clear the affinity hint */
+   irq_set_affinity_hint(irq->msi_desc->irq, NULL);
+}
+
+static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
+{
+   struct dpio_priv *priv;
+   int error;
+   struct fsl_mc_device_irq *irq;
+   cpumask_t mask;
+
+   priv = dev_get_drvdata(&dpio_dev->dev);
+
+   irq = dpio_dev->irqs[0];
+   error = devm_request_irq(&dpio_dev->dev,
+irq->msi_desc->irq,
+dpio_irq_handler,
+0,
+dev_name(&dpio_dev->dev),
+&dpio_dev->dev);
+   if (error < 0) {
+   

[PATCH v4 0/8] staging: fsl-mc: add dpio driver

2016-12-15 Thread Stuart Yoder
This patch series adds the driver for the DPIO object which is a 
step to addressing the final item in the staging TODO list-- adding
a functional driver on top of the bus driver.  The DPIO driver is a
dependency for other functional drivers such as Ethernet.

An overview of the DPIO object and driver components are in patch 1.
Patches 2-6 are internal components of the DPIO driver-- bit twiddling
of hardware registers, DPAA2 data structures, and the queuing APIs exposed
to other drivers.

Patch 7 adds the fsl-mc driver for the DPIO object.  It provides
the probe/remove functions, demonstrating a working example of
how fsl-mc drivers initialize, interact with the management
complex hardware, map their mappable MMIO regions, initialize
interrupts, register an ISR, etc.  All other DPAA2 drivers will
follow a similar initialization pattern.

version 4 changes
   -removed the patch moving the bus driver out of staging, updated
all paths referenced in dpio (e.g. includes) to be drivers/staging
   -defined macros for constants where needed
   -copyright updates
   -cleanup: fixed whitespace, alignment issues, typos, removed unneeded
comments
   -fixed bug in SDQCR #define
   -adding missing free in an error path

version 3 changes
   -zero memory allocated for a dpio store
   -replace hardcoded dequeue token with a #define and look for
that token when checking for a new result

version 2 changes (mostly feedback from Ioana Radulescu)
   -removed unused structs and defines in dpio command definitions
   -added setter/getter for the FD ctrl field
   -corrected comment for SG format_offset field description
   -added support for short length field in FD
   -fix bug in buffer release command, by setting bpid field
   -handle error (NULL) return value from qbman_swp_mc_complete()
   -fix bug in sending management commands where the verb was
properly initialized
   -use service_select_by_cpu() for re-arming DPIO interrupts
   -replace use of NR_CPUS with num_possible_cpus()
   -handle error case where number of DPIOs exceeds number of possible
CPUs
   -error message cleanup
   -updated MAINTAINERS file with proper location for both fsl-mc bus
driver and dpio driver


Ioana Radulescu (1):
  bus: fsl-mc: dpio: add APIs for DPIO objects

Roy Pledge (6):
  bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs
  bus: fsl-mc: dpio: add global dpaa2 definitions
  bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
  bus: fsl-mc: dpio: add the DPAA2 DPIO service interface
  bus: fsl-mc: dpio: add the DPAA2 DPIO object driver
  bus: fsl-mc: dpio: add maintainer for DPIO

Stuart Yoder (1):
  bus: fsl-mc: dpio: add DPIO driver overview document

 MAINTAINERS |6 +
 drivers/staging/fsl-mc/bus/Kconfig  |   10 +
 drivers/staging/fsl-mc/bus/Makefile |3 +
 drivers/staging/fsl-mc/bus/dpio/Makefile|9 +
 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h  |   76 ++
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c   |  296 +++
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt |  135 +++
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c  |  616 ++
 drivers/staging/fsl-mc/bus/dpio/dpio.c  |  224 +
 drivers/staging/fsl-mc/bus/dpio/dpio.h  |  109 +++
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c  | 1033 +++
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h  |  469 ++
 drivers/staging/fsl-mc/include/dpaa2-fd.h   |  448 ++
 drivers/staging/fsl-mc/include/dpaa2-global.h   |  202 +
 drivers/staging/fsl-mc/include/dpaa2-io.h   |  139 +++
 15 files changed, 3775 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/Makefile
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-service.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.h
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-fd.h
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-global.h
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-io.h

-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 8/8] bus: fsl-mc: dpio: add maintainer for DPIO

2016-12-15 Thread Stuart Yoder
From: Roy Pledge 

add Roy Pledge as maintainer of DPIO

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -adjust file location to be in drivers/staging
-v3
   -no changes
-v2
   -corrected location of maintainer entry

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8695516..add3de4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3980,6 +3980,12 @@ S:   Maintained
 F: drivers/char/dtlk.c
 F: include/linux/dtlk.h
 
+DPAA2 DATAPATH I/O (DPIO) DRIVER
+M: Roy Pledge 
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-mc/bus/dpio
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions 
 L: linux-s...@vger.kernel.org
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 2/8] bus: fsl-mc: dpio: add APIs for DPIO objects

2016-12-15 Thread Stuart Yoder
From: Ioana Radulescu 

Add the command build/parse APIs for operating on DPIO objects through
the DPAA2 Management Complex.

Signed-off-by: Ioana Radulescu 
Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
  -adjust file location to be in drivers/staging
  -remove unneeded comments
  -updated copyright
-v3
  -no changes
-v2
  -removed unused structs and defines

 drivers/staging/fsl-mc/bus/Kconfig |  10 ++
 drivers/staging/fsl-mc/bus/Makefile|   3 +
 drivers/staging/fsl-mc/bus/dpio/Makefile   |   9 ++
 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h |  76 ++
 drivers/staging/fsl-mc/bus/dpio/dpio.c | 224 +
 drivers/staging/fsl-mc/bus/dpio/dpio.h | 109 ++
 6 files changed, 431 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/Makefile
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.h

diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 5c009ab..a10aaf0 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -15,3 +15,13 @@ config FSL_MC_BUS
  architecture.  The fsl-mc bus driver handles discovery of
  DPAA2 objects (which are represented as Linux devices) and
  binding objects to drivers.
+
+config FSL_MC_DPIO
+tristate "QorIQ DPAA2 DPIO driver"
+depends on FSL_MC_BUS
+help
+ Driver for the DPAA2 DPIO object.  A DPIO provides queue and
+ buffer management facilities for software to interact with
+ other DPAA2 objects. This driver does not expose the DPIO
+ objects individually, but groups them under a service layer
+ API.
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index 38716fd..577e9fa 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -18,3 +18,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \
  irq-gic-v3-its-fsl-mc-msi.o \
  dpmcp.o \
  dpbp.o
+
+# MC DPIO driver
+obj-$(CONFIG_FSL_MC_DPIO) += dpio/
diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
new file mode 100644
index 000..128befc
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -0,0 +1,9 @@
+#
+# QorIQ DPAA2 DPIO driver
+#
+
+subdir-ccflags-y := -Werror
+
+obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
+
+fsl-mc-dpio-objs := dpio.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h 
b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
new file mode 100644
index 000..c237d5f
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _FSL_DPIO_CMD_H
+#define _FSL_DPIO_CMD_H
+
+/* DPIO Version */
+#define DPIO_VER_MAJOR 4
+#define DPIO_VER_MINOR 2
+
+/* Command Versioning */
+
+#define DPIO_CMD_ID

[PATCH v4 3/8] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs

2016-12-15 Thread Stuart Yoder
From: Roy Pledge 

Add global definitions for DPAA2 frame descriptors and scatter
gather entries.

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright
   -adjust file location to be in drivers/staging
   -address cleanup comments-- whitespace cleanup, use !! consistently
to convert expression to bool, remove unneeded parenthesis
-v3
   -no changes
-v2
   -added setter/getter for the FD ctrl field
   -corrected comment for SG format_offset field description
   -added support for short length field in FD

 drivers/staging/fsl-mc/include/dpaa2-fd.h | 448 ++
 1 file changed, 448 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-fd.h

diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h 
b/drivers/staging/fsl-mc/include/dpaa2-fd.h
new file mode 100644
index 000..21102e6
--- /dev/null
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPAA2_FD_H
+#define __FSL_DPAA2_FD_H
+
+#include 
+
+/**
+ * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2
+ *
+ * Frame Descriptors (FDs) are used to describe frame data in the DPAA2.
+ * Frames can be enqueued and dequeued to Frame Queues (FQs) which are consumed
+ * by the various DPAA accelerators (WRIOP, SEC, PME, DCE)
+ *
+ * There are three types of frames: single, scatter gather, and frame lists.
+ *
+ * The set of APIs in this file must be used to create, manipulate and
+ * query Frame Descriptors.
+ */
+
+/**
+ * struct dpaa2_fd - Struct describing FDs
+ * @words: for easier/faster copying the whole FD structure
+ * @addr:  address in the FD
+ * @len:   length in the FD
+ * @bpid:  buffer pool ID
+ * @format_offset: format, offset, and short-length fields
+ * @frc:   frame context
+ * @ctrl:  control bits...including dd, sc, va, err, etc
+ * @flc:   flow context address
+ *
+ * This structure represents the basic Frame Descriptor used in the system.
+ */
+struct dpaa2_fd {
+   union {
+   u32 words[8];
+   struct dpaa2_fd_simple {
+   __le64 addr;
+   __le32 len;
+   __le16 bpid;
+   __le16 format_offset;
+   __le32 frc;
+   __le32 ctrl;
+   __le64 flc;
+   } simple;
+   };
+};
+
+#define FD_SHORT_LEN_FLAG_MASK 0x1
+#define FD_SHORT_LEN_FLAG_SHIFT14
+#define FD_SHORT_LEN_MASK  0x1
+#define FD_OFFSET_MASK 0x0FFF
+#define FD_FORMAT_MASK 0x3
+#define FD_FORMAT_SHIFT12
+#define SG_SHORT_LEN_FLAG_MASK 0x1
+#define SG_SHORT_LEN_FLAG_SHIFT14
+#define SG_SHORT_LEN_MASK  0x1
+#define SG_OFFSET_MASK 0x0FFF
+#define SG_FORMAT_MASK 0x3
+#define SG_FORMAT_SHIFT12
+#define SG_BPID_MASK   0x3FFF
+#define SG_FINAL_FLAG_MASK 0x1
+#define SG_FINAL_FLAG_SHIFT15
+
+enum dpaa2_fd_format {
+   dpaa2_fd_single = 0,
+

[PATCH v4 6/8] bus: fsl-mc: dpio: add the DPAA2 DPIO service interface

2016-12-15 Thread Stuart Yoder
From: Roy Pledge 

The DPIO service interface handles initialization of DPIO objects
and exports APIs to be used by other DPAA2 object drivers to perform
queuing and buffer management related operations.  The service allows
registration of callbacks when frames or notifications are received.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright
   -adjust file location to be in drivers/staging
   -updated copyright
   -added missing free on error path
   -fixed typo in comment
   -whitespace and alignment cleanup
-v3
   -zero memory allocated for a dpio store (bug fix suggested
by Ioana Radulescu)
-v2
   -use service_select_by_cpu() for re-arming DPIO interrupts
   -replace use of NR_CPUS with num_possible_cpus()

 drivers/staging/fsl-mc/bus/dpio/Makefile   |   2 +-
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 616 +
 drivers/staging/fsl-mc/include/dpaa2-io.h  | 139 ++
 3 files changed, 756 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-service.c
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-io.h

diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
index 6588498..0778da7 100644
--- a/drivers/staging/fsl-mc/bus/dpio/Makefile
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o qbman-portal.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
new file mode 100644
index 000..394727b
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -0,0 +1,616 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include 
+#include "../../include/mc.h"
+#include "../../include/dpaa2-io.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "dpio.h"
+#include "qbman-portal.h"
+
+struct dpaa2_io {
+   atomic_t refs;
+   struct dpaa2_io_desc dpio_desc;
+   struct qbman_swp_desc swp_desc;
+   struct qbman_swp *swp;
+   struct list_head node;
+   spinlock_t lock_mgmt_cmd;
+   spinlock_t lock_notifications;
+   struct list_head notifications;
+};
+
+struct dpaa2_io_store {
+   unsigned int max;
+   dma_addr_t paddr;
+   struct dpaa2_dq *vaddr;
+   void *alloced_addr;/* unaligned value from kmalloc() */
+   unsigned int idx;  /* position of the next-to-be-returned entry */
+   struct qbman_swp *swp; /* portal used to issue VDQCR */
+   struct device *dev;/* device used for DMA mapping */
+};
+
+/* keep a per cpu array of DPIOs for fast access */
+static struct dpaa2_io *dpio_by_cpu[NR_CPUS];
+static struct list_head dpio_list = LIST_HEAD_INIT(dpio_list);
+static DEFINE_SPINLOCK(dpio_list_lock);
+
+static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
+ 

[PATCH v4 5/8] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2

2016-12-15 Thread Stuart Yoder
From: Roy Pledge 

Add QBman APIs for frame queue and buffer pool operations.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -adjust file location to be in drivers/staging
   -updated copyright
   -added definition for static dequeue token value
   -fixed bug in SDQCR #define
   -added missing #include guard in qbman-portal.h
   -added #define for QMAN_REV_MASK
   -whitespace, alignment cleanup
-v3
   -replace hardcoded dequeue token with a #define and check that
token when checking for a new result (bug fix suggested by
Ioana Radulescu)
-v2
   -fix bug in buffer release command, by setting bpid field
   -handle error (NULL) return value from qbman_swp_mc_complete()
   -error message cleanup
   -fix bug in sending management commands where the verb was
properly initialized

 drivers/staging/fsl-mc/bus/dpio/Makefile   |2 +-
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 1033 
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h |  469 +++
 3 files changed, 1503 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h

diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
index 128befc..6588498 100644
--- a/drivers/staging/fsl-mc/bus/dpio/Makefile
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c 
b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
new file mode 100644
index 000..a5b5d2b
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -0,0 +1,1033 @@
+/*
+ * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include "../../include/dpaa2-global.h"
+
+#include "qbman-portal.h"
+
+#define QMAN_REV_4000   0x0400
+#define QMAN_REV_4100   0x0401
+#define QMAN_REV_4101   0x04010001
+#define QMAN_REV_MASK   0x
+
+/* All QBMan command and result structures use this "valid bit" encoding */
+#define QB_VALID_BIT ((u32)0x80)
+
+/* QBMan portal management command codes */
+#define QBMAN_MC_ACQUIRE   0x30
+#define QBMAN_WQCHAN_CONFIGURE 0x46
+
+/* CINH register offsets */
+#define QBMAN_CINH_SWP_EQAR0x8c0
+#define QBMAN_CINH_SWP_DQPI0xa00
+#define QBMAN_CINH_SWP_DCAP0xac0
+#define QBMAN_CINH_SWP_SDQCR   0xb00
+#define QBMAN_CINH_SWP_RAR 0xcc0
+#define QBMAN_CINH_SWP_ISR 0xe00
+#define QBMAN_CINH_SWP_IER 0xe40
+#define QBMAN_CINH_SWP_ISDR0xe80
+#define QBMAN_CINH_SWP_IIR 0xec0
+
+/* CENA register offsets */
+#define QBMAN_CENA_SWP_EQCR(n) (0x000 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_DQRR(n) (0x200 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_RCR(n)  (0x400 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_CR  0x600
+#define QBMAN_CENA_

[PATCH v4 4/8] bus: fsl-mc: dpio: add global dpaa2 definitions

2016-12-15 Thread Stuart Yoder
From: Roy Pledge 

Create header for global dpaa2 definitions.  Add definitions
for dequeue results.

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -adjust file location to be in drivers/staging
   -whitespace/alignment cleanup, make dpaa2_dq_is_pull_complete()
return bool, fix spelling typo
   -updated copyright

 drivers/staging/fsl-mc/include/dpaa2-global.h | 202 ++
 1 file changed, 202 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-global.h

diff --git a/drivers/staging/fsl-mc/include/dpaa2-global.h 
b/drivers/staging/fsl-mc/include/dpaa2-global.h
new file mode 100644
index 000..0326447
--- /dev/null
+++ b/drivers/staging/fsl-mc/include/dpaa2-global.h
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPAA2_GLOBAL_H
+#define __FSL_DPAA2_GLOBAL_H
+
+#include 
+#include 
+#include "dpaa2-fd.h"
+
+struct dpaa2_dq {
+   union {
+   struct common {
+   u8 verb;
+   u8 reserved[63];
+   } common;
+   struct dq {
+   u8 verb;
+   u8 stat;
+   __le16 seqnum;
+   __le16 oprid;
+   u8 reserved;
+   u8 tok;
+   __le32 fqid;
+   u32 reserved2;
+   __le32 fq_byte_cnt;
+   __le32 fq_frm_cnt;
+   __le64 fqd_ctx;
+   u8 fd[32];
+   } dq;
+   struct scn {
+   u8 verb;
+   u8 stat;
+   u8 state;
+   u8 reserved;
+   __le32 rid_tok;
+   __le64 ctx;
+   } scn;
+   };
+};
+
+/* Parsing frame dequeue results */
+/* FQ empty */
+#define DPAA2_DQ_STAT_FQEMPTY   0x80
+/* FQ held active */
+#define DPAA2_DQ_STAT_HELDACTIVE0x40
+/* FQ force eligible */
+#define DPAA2_DQ_STAT_FORCEELIGIBLE 0x20
+/* valid frame */
+#define DPAA2_DQ_STAT_VALIDFRAME0x10
+/* FQ ODP enable */
+#define DPAA2_DQ_STAT_ODPVALID  0x04
+/* volatile dequeue */
+#define DPAA2_DQ_STAT_VOLATILE  0x02
+/* volatile dequeue command is expired */
+#define DPAA2_DQ_STAT_EXPIRED   0x01
+
+#define DQ_FQID_MASK   0x00FF
+#define DQ_FRAME_COUNT_MASK0x00FF
+
+/**
+ * dpaa2_dq_flags() - Get the stat field of dequeue response
+ * @dq: the dequeue result.
+ */
+static inline u32 dpaa2_dq_flags(const struct dpaa2_dq *dq)
+{
+   return dq->dq.stat;
+}
+
+/**
+ * dpaa2_dq_is_pull() - Check whether the dq response is from a pull
+ *  command.
+ * @dq: the dequeue result
+ *
+ * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
+ */
+static inline int dpaa2_dq_is_pull(const struct dpaa2_dq *dq)
+{
+   return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_VOLATILE);
+}
+
+/**
+ * dpaa2_dq_is_pull_complete() - Check whether the pull command is completed.
+ * @dq: the dequeue result
+ *
+ 

RE: [PATCH v4 5/8] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2

2016-12-16 Thread Stuart Yoder


> -Original Message-
> From: kbuild test robot [mailto:l...@intel.com]
> Sent: Friday, December 16, 2016 1:57 AM
> To: Stuart Yoder 
> Cc: kbuild-...@01.org; gre...@linuxfoundation.org; 
> de...@driverdev.osuosl.org; ag...@suse.de;
> a...@arndb.de; Haiying Wang ; Roy Pledge 
> ; linux-
> ker...@vger.kernel.org; Leo Li ; Catalin Horghidan 
> ;
> Ioana Ciornei ; Stuart Yoder ; 
> Laurentiu Tudor
> 
> Subject: Re: [PATCH v4 5/8] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> 
> Hi Roy,
> 
> [auto build test ERROR on staging/staging-testing]
> [also build test ERROR on next-20161215]
> [cannot apply to v4.9]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-
> ci%2Flinux%2Fcommits%2FStuart-Yoder%2Fstaging-fsl-mc-add-dpio-driver%2F20161216-
> 114620&data=01%7C01%7Cstuart.yoder%40nxp.com%7C0eec622fda6c4ba7b20808d425893386%7C686ea1d3bc2b4c6fa92cd9
> 9c5c301635%7C0&sdata=3DcsmOyC%2FMv%2B8A1n%2Fzq%2FWIxSsP3EjA%2F2XLyKTkvbRSA%3D&reserved=0
> config: arm64-allmodconfig (attached as .config)
> compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> wget
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel.org%2Fcgit%2Flinux%2Fkerne
> l%2Fgit%2Fwfg%2Flkp-
> tests.git%2Fplain%2Fsbin%2Fmake.cross&data=01%7C01%7Cstuart.yoder%40nxp.com%7C0eec622fda6c4ba7b20808d425
> 893386%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=tKbhJjq7jjDBYPLhMB%2FfnR1t%2BKEffwh8mZb7leKtxF4%3D&r
> eserved=0 -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=arm64
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers/staging/fsl-mc/bus/dpio/qbman-portal.c:996:10: error: expected 
> >> declaration specifiers or
> '...' before numeric constant
>  64 ctx)
>  ^~
> 
> vim +996 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
> 
>990u16 ch;
>991u8 reserved[60];
>992};
>993
>994int qbman_swp_CDAN_set(struct qbman_swp *s, u16 channelid,
>995   u8 we_mask, u8 cdan_en,
>  > 996   64 ctx)
>997{
>998struct qbman_cdan_ctrl_desc *p = NULL;
>999struct qbman_cdan_ctrl_rslt *r = NULL;

Ugh...made a last minute fix to the alignment and made a typo, and
while I could have sworn I recompiled everything I obviously didn't.
Will respin.

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 1/8] bus: fsl-mc: dpio: add DPIO driver overview document

2016-12-16 Thread Stuart Yoder
add document describing the dpio driver and it's role, components
and major interfaces

Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright

 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt | 135 
 1 file changed, 135 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt 
b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
new file mode 100644
index 000..0ba6771
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
@@ -0,0 +1,135 @@
+Copyright 2016 NXP
+
+Introduction
+
+
+A DPAA2 DPIO (Data Path I/O) is a hardware object that provides
+interfaces to enqueue and dequeue frames to/from network interfaces
+and other accelerators.  A DPIO also provides hardware buffer
+pool management for network interfaces.
+
+This document provides an overview the Linux DPIO driver, its
+subcomponents, and its APIs.
+
+See Documentation/dpaa2/overview.txt for a general overview of DPAA2
+and the general DPAA2 driver architecture in Linux.
+
+Driver Overview
+---
+
+The DPIO driver is bound to DPIO objects discovered on the fsl-mc bus and
+provides services that:
+  A) allow other drivers, such as the Ethernet driver, to enqueue and dequeue
+ frames for their respective objects
+  B) allow drivers to register callbacks for data availability notifications
+ when data becomes available on a queue or channel
+  C) allow drivers to manage hardware buffer pools
+
+The Linux DPIO driver consists of 3 primary components--
+   DPIO object driver-- fsl-mc driver that manages the DPIO object
+   DPIO service-- provides APIs to other Linux drivers for services
+   QBman portal interface-- sends portal commands, gets responses
+
+  fsl-mc  other
+   bus   drivers
+|   |
++---++   +--+-+
+|DPIO obj|   |DPIO service|
+| driver |---|  (DPIO)|
+++   +--+-+
+|
+ +--+-+
+ |QBman   |
+ | portal i/f |
+ ++
+|
+ hardware
+
+The diagram below shows how the DPIO driver components fit with the other
+DPAA2 Linux driver components:
+   ++
+   | OS Network |
+   |   Stack|
+ ++++
+ | Allocator  |. . . . . . .   |  Ethernet  |
+ |(DPMCP,DPBP)||   (DPNI)   |
+ +-.--++---+---++
+  .  . ^   |
+ ..|   | dequeue>
++-+ .  |   |
+| DPRC driver |  .++ ++
+|   (DPRC)|   . . |DPIO obj| |DPIO service|
++--+--+   | driver |-|  (DPIO)|
+   |  ++ +--+-+
+   | +--|-+
+   | |   QBman|
+  ++--+  | portal i/f |
+  |   MC-bus driver   |  ++
+  |   | |
+  | /soc/fsl-mc   | |
+  +---+ |
+|
+ =|=|
++-+--DPIO---|---+
+|   |   |
+|QBman Portal   |
++---+
+
+ 
+
+
+DPIO Object Driver (dpio-driver.c)
+--
+
+   The dpio-driver component registers with the fsl-mc bus to handle objects of
+   type "dpio".  The implementation of probe() handles basic initialization
+   of the DPIO including mapping of the DPIO regions (the QBman SW portal)
+   and initializing interrupts and registering irq handlers.  The dpio-driver
+   registers the probed DPIO with dpio-service.
+
+DPIO service  (dpio-service.c, dpaa2-io.h)
+--
+
+   The dpio service component provides queuing, notification, and buffers
+   management services to DPAA2 drivers, such as the Ethernet driver.  A system
+   will typically allocate 1 DPIO object per CPU to allow queuing operat

[PATCH v5 4/8] bus: fsl-mc: dpio: add global dpaa2 definitions

2016-12-16 Thread Stuart Yoder
From: Roy Pledge 

Create header for global dpaa2 definitions.  Add definitions
for dequeue results.

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -adjust file location to be in drivers/staging
   -whitespace/alignment cleanup, make dpaa2_dq_is_pull_complete()
return bool, fix spelling typo
   -updated copyright

 drivers/staging/fsl-mc/include/dpaa2-global.h | 202 ++
 1 file changed, 202 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-global.h

diff --git a/drivers/staging/fsl-mc/include/dpaa2-global.h 
b/drivers/staging/fsl-mc/include/dpaa2-global.h
new file mode 100644
index 000..0326447
--- /dev/null
+++ b/drivers/staging/fsl-mc/include/dpaa2-global.h
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPAA2_GLOBAL_H
+#define __FSL_DPAA2_GLOBAL_H
+
+#include 
+#include 
+#include "dpaa2-fd.h"
+
+struct dpaa2_dq {
+   union {
+   struct common {
+   u8 verb;
+   u8 reserved[63];
+   } common;
+   struct dq {
+   u8 verb;
+   u8 stat;
+   __le16 seqnum;
+   __le16 oprid;
+   u8 reserved;
+   u8 tok;
+   __le32 fqid;
+   u32 reserved2;
+   __le32 fq_byte_cnt;
+   __le32 fq_frm_cnt;
+   __le64 fqd_ctx;
+   u8 fd[32];
+   } dq;
+   struct scn {
+   u8 verb;
+   u8 stat;
+   u8 state;
+   u8 reserved;
+   __le32 rid_tok;
+   __le64 ctx;
+   } scn;
+   };
+};
+
+/* Parsing frame dequeue results */
+/* FQ empty */
+#define DPAA2_DQ_STAT_FQEMPTY   0x80
+/* FQ held active */
+#define DPAA2_DQ_STAT_HELDACTIVE0x40
+/* FQ force eligible */
+#define DPAA2_DQ_STAT_FORCEELIGIBLE 0x20
+/* valid frame */
+#define DPAA2_DQ_STAT_VALIDFRAME0x10
+/* FQ ODP enable */
+#define DPAA2_DQ_STAT_ODPVALID  0x04
+/* volatile dequeue */
+#define DPAA2_DQ_STAT_VOLATILE  0x02
+/* volatile dequeue command is expired */
+#define DPAA2_DQ_STAT_EXPIRED   0x01
+
+#define DQ_FQID_MASK   0x00FF
+#define DQ_FRAME_COUNT_MASK0x00FF
+
+/**
+ * dpaa2_dq_flags() - Get the stat field of dequeue response
+ * @dq: the dequeue result.
+ */
+static inline u32 dpaa2_dq_flags(const struct dpaa2_dq *dq)
+{
+   return dq->dq.stat;
+}
+
+/**
+ * dpaa2_dq_is_pull() - Check whether the dq response is from a pull
+ *  command.
+ * @dq: the dequeue result
+ *
+ * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
+ */
+static inline int dpaa2_dq_is_pull(const struct dpaa2_dq *dq)
+{
+   return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_VOLATILE);
+}
+
+/**
+ * dpaa2_dq_is_pull_complete() - Check whether the pull command is completed.
+ * @dq: the dequeue result
+ *
+ 

[PATCH v5 3/8] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs

2016-12-16 Thread Stuart Yoder
From: Roy Pledge 

Add global definitions for DPAA2 frame descriptors and scatter
gather entries.

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright
   -adjust file location to be in drivers/staging
   -address cleanup comments-- whitespace cleanup, use !! consistently
to convert expression to bool, remove unneeded parenthesis
-v3
   -no changes
-v2
   -added setter/getter for the FD ctrl field
   -corrected comment for SG format_offset field description
   -added support for short length field in FD

 drivers/staging/fsl-mc/include/dpaa2-fd.h | 448 ++
 1 file changed, 448 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-fd.h

diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h 
b/drivers/staging/fsl-mc/include/dpaa2-fd.h
new file mode 100644
index 000..21102e6
--- /dev/null
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPAA2_FD_H
+#define __FSL_DPAA2_FD_H
+
+#include 
+
+/**
+ * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2
+ *
+ * Frame Descriptors (FDs) are used to describe frame data in the DPAA2.
+ * Frames can be enqueued and dequeued to Frame Queues (FQs) which are consumed
+ * by the various DPAA accelerators (WRIOP, SEC, PME, DCE)
+ *
+ * There are three types of frames: single, scatter gather, and frame lists.
+ *
+ * The set of APIs in this file must be used to create, manipulate and
+ * query Frame Descriptors.
+ */
+
+/**
+ * struct dpaa2_fd - Struct describing FDs
+ * @words: for easier/faster copying the whole FD structure
+ * @addr:  address in the FD
+ * @len:   length in the FD
+ * @bpid:  buffer pool ID
+ * @format_offset: format, offset, and short-length fields
+ * @frc:   frame context
+ * @ctrl:  control bits...including dd, sc, va, err, etc
+ * @flc:   flow context address
+ *
+ * This structure represents the basic Frame Descriptor used in the system.
+ */
+struct dpaa2_fd {
+   union {
+   u32 words[8];
+   struct dpaa2_fd_simple {
+   __le64 addr;
+   __le32 len;
+   __le16 bpid;
+   __le16 format_offset;
+   __le32 frc;
+   __le32 ctrl;
+   __le64 flc;
+   } simple;
+   };
+};
+
+#define FD_SHORT_LEN_FLAG_MASK 0x1
+#define FD_SHORT_LEN_FLAG_SHIFT14
+#define FD_SHORT_LEN_MASK  0x1
+#define FD_OFFSET_MASK 0x0FFF
+#define FD_FORMAT_MASK 0x3
+#define FD_FORMAT_SHIFT12
+#define SG_SHORT_LEN_FLAG_MASK 0x1
+#define SG_SHORT_LEN_FLAG_SHIFT14
+#define SG_SHORT_LEN_MASK  0x1
+#define SG_OFFSET_MASK 0x0FFF
+#define SG_FORMAT_MASK 0x3
+#define SG_FORMAT_SHIFT12
+#define SG_BPID_MASK   0x3FFF
+#define SG_FINAL_FLAG_MASK 0x1
+#define SG_FINAL_FLAG_SHIFT15
+
+enum dpaa2_fd_format {
+   dpaa2_fd_single = 0,
+

[PATCH v5 5/8] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2

2016-12-16 Thread Stuart Yoder
From: Roy Pledge 

Add QBman APIs for frame queue and buffer pool operations.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v5
   -fixed typo that caused a compile error
-v4
   -adjust file location to be in drivers/staging
   -updated copyright
   -added definition for static dequeue token value
   -fixed bug in SDQCR #define
   -added missing #include guard in qbman-portal.h
   -added #define for QMAN_REV_MASK
   -whitespace, alignment cleanup
-v3
   -replace hardcoded dequeue token with a #define and check that
token when checking for a new result (bug fix suggested by
Ioana Radulescu)
-v2
   -fix bug in buffer release command, by setting bpid field
   -handle error (NULL) return value from qbman_swp_mc_complete()
   -error message cleanup
   -fix bug in sending management commands where the verb was
properly initialized

 drivers/staging/fsl-mc/bus/dpio/Makefile   |2 +-
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 1033 
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h |  469 +++
 3 files changed, 1503 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h

diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
index 128befc..6588498 100644
--- a/drivers/staging/fsl-mc/bus/dpio/Makefile
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c 
b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
new file mode 100644
index 000..4949102
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -0,0 +1,1033 @@
+/*
+ * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include "../../include/dpaa2-global.h"
+
+#include "qbman-portal.h"
+
+#define QMAN_REV_4000   0x0400
+#define QMAN_REV_4100   0x0401
+#define QMAN_REV_4101   0x04010001
+#define QMAN_REV_MASK   0x
+
+/* All QBMan command and result structures use this "valid bit" encoding */
+#define QB_VALID_BIT ((u32)0x80)
+
+/* QBMan portal management command codes */
+#define QBMAN_MC_ACQUIRE   0x30
+#define QBMAN_WQCHAN_CONFIGURE 0x46
+
+/* CINH register offsets */
+#define QBMAN_CINH_SWP_EQAR0x8c0
+#define QBMAN_CINH_SWP_DQPI0xa00
+#define QBMAN_CINH_SWP_DCAP0xac0
+#define QBMAN_CINH_SWP_SDQCR   0xb00
+#define QBMAN_CINH_SWP_RAR 0xcc0
+#define QBMAN_CINH_SWP_ISR 0xe00
+#define QBMAN_CINH_SWP_IER 0xe40
+#define QBMAN_CINH_SWP_ISDR0xe80
+#define QBMAN_CINH_SWP_IIR 0xec0
+
+/* CENA register offsets */
+#define QBMAN_CENA_SWP_EQCR(n) (0x000 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_DQRR(n) (0x200 + ((u32)(n) << 6))
+#define QBMAN_CENA_SWP_RCR(n)  (0x400 + ((u32)(n) << 6))

[PATCH v5 7/8] bus: fsl-mc: dpio: add the DPAA2 DPIO object driver

2016-12-16 Thread Stuart Yoder
From: Roy Pledge 

The DPIO driver registers with the fsl-mc bus to handle bus-related
events for DPIO objects.  Key responsibility is mapping I/O
regions, setting up interrupt handlers, and calling the DPIO
service initialization during probe.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright
   -adjust file location to be in drivers/staging
   -whitespace alignment cleanup
-v3
   -no changes
-v2
   -handle error case where number of DPIOs > NR_CPUs

 drivers/staging/fsl-mc/bus/dpio/Makefile  |   2 +-
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c | 296 ++
 2 files changed, 297 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c

diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
index 0778da7..837d330 100644
--- a/drivers/staging/fsl-mc/bus/dpio/Makefile
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o dpio-driver.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
new file mode 100644
index 000..e36da20
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright NXP 2016
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../../include/mc.h"
+#include "../../include/dpaa2-io.h"
+
+#include "qbman-portal.h"
+#include "dpio.h"
+#include "dpio-cmd.h"
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Freescale Semiconductor, Inc");
+MODULE_DESCRIPTION("DPIO Driver");
+
+struct dpio_priv {
+   struct dpaa2_io *io;
+};
+
+static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
+{
+   struct device *dev = (struct device *)arg;
+   struct dpio_priv *priv = dev_get_drvdata(dev);
+
+   return dpaa2_io_irq(priv->io);
+}
+
+static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev)
+{
+   struct fsl_mc_device_irq *irq;
+
+   irq = dpio_dev->irqs[0];
+
+   /* clear the affinity hint */
+   irq_set_affinity_hint(irq->msi_desc->irq, NULL);
+}
+
+static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
+{
+   struct dpio_priv *priv;
+   int error;
+   struct fsl_mc_device_irq *irq;
+   cpumask_t mask;
+
+   priv = dev_get_drvdata(&dpio_dev->dev);
+
+   irq = dpio_dev->irqs[0];
+   error = devm_request_irq(&dpio_dev->dev,
+irq->msi_desc->irq,
+dpio_irq_handler,
+0,
+dev_name(&dpio_dev->dev),
+&dpio_dev->dev);
+   if (error < 0) {
+   

[PATCH v5 6/8] bus: fsl-mc: dpio: add the DPAA2 DPIO service interface

2016-12-16 Thread Stuart Yoder
From: Roy Pledge 

The DPIO service interface handles initialization of DPIO objects
and exports APIs to be used by other DPAA2 object drivers to perform
queuing and buffer management related operations.  The service allows
registration of callbacks when frames or notifications are received.

Signed-off-by: Roy Pledge 
Signed-off-by: Haiying Wang 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -updated copyright
   -adjust file location to be in drivers/staging
   -updated copyright
   -added missing free on error path
   -fixed typo in comment
   -whitespace and alignment cleanup
-v3
   -zero memory allocated for a dpio store (bug fix suggested
by Ioana Radulescu)
-v2
   -use service_select_by_cpu() for re-arming DPIO interrupts
   -replace use of NR_CPUS with num_possible_cpus()

 drivers/staging/fsl-mc/bus/dpio/Makefile   |   2 +-
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 616 +
 drivers/staging/fsl-mc/include/dpaa2-io.h  | 139 ++
 3 files changed, 756 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-service.c
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-io.h

diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
index 6588498..0778da7 100644
--- a/drivers/staging/fsl-mc/bus/dpio/Makefile
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
 
 obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
 
-fsl-mc-dpio-objs := dpio.o qbman-portal.o
+fsl-mc-dpio-objs := dpio.o qbman-portal.o dpio-service.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
new file mode 100644
index 000..394727b
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -0,0 +1,616 @@
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include 
+#include "../../include/mc.h"
+#include "../../include/dpaa2-io.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "dpio.h"
+#include "qbman-portal.h"
+
+struct dpaa2_io {
+   atomic_t refs;
+   struct dpaa2_io_desc dpio_desc;
+   struct qbman_swp_desc swp_desc;
+   struct qbman_swp *swp;
+   struct list_head node;
+   spinlock_t lock_mgmt_cmd;
+   spinlock_t lock_notifications;
+   struct list_head notifications;
+};
+
+struct dpaa2_io_store {
+   unsigned int max;
+   dma_addr_t paddr;
+   struct dpaa2_dq *vaddr;
+   void *alloced_addr;/* unaligned value from kmalloc() */
+   unsigned int idx;  /* position of the next-to-be-returned entry */
+   struct qbman_swp *swp; /* portal used to issue VDQCR */
+   struct device *dev;/* device used for DMA mapping */
+};
+
+/* keep a per cpu array of DPIOs for fast access */
+static struct dpaa2_io *dpio_by_cpu[NR_CPUS];
+static struct list_head dpio_list = LIST_HEAD_INIT(dpio_list);
+static DEFINE_SPINLOCK(dpio_list_lock);
+
+static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
+ 

[PATCH v5 8/8] bus: fsl-mc: dpio: add maintainer for DPIO

2016-12-16 Thread Stuart Yoder
From: Roy Pledge 

add Roy Pledge as maintainer of DPIO

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
   -adjust file location to be in drivers/staging
-v3
   -no changes
-v2
   -corrected location of maintainer entry

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8695516..add3de4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3980,6 +3980,12 @@ S:   Maintained
 F: drivers/char/dtlk.c
 F: include/linux/dtlk.h
 
+DPAA2 DATAPATH I/O (DPIO) DRIVER
+M: Roy Pledge 
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-mc/bus/dpio
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions 
 L: linux-s...@vger.kernel.org
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 2/8] bus: fsl-mc: dpio: add APIs for DPIO objects

2016-12-16 Thread Stuart Yoder
From: Ioana Radulescu 

Add the command build/parse APIs for operating on DPIO objects through
the DPAA2 Management Complex.

Signed-off-by: Ioana Radulescu 
Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---

Notes:
-v4
  -adjust file location to be in drivers/staging
  -remove unneeded comments
  -updated copyright
-v3
  -no changes
-v2
  -removed unused structs and defines

 drivers/staging/fsl-mc/bus/Kconfig |  10 ++
 drivers/staging/fsl-mc/bus/Makefile|   3 +
 drivers/staging/fsl-mc/bus/dpio/Makefile   |   9 ++
 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h |  76 ++
 drivers/staging/fsl-mc/bus/dpio/dpio.c | 224 +
 drivers/staging/fsl-mc/bus/dpio/dpio.h | 109 ++
 6 files changed, 431 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/Makefile
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.h

diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 5c009ab..a10aaf0 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -15,3 +15,13 @@ config FSL_MC_BUS
  architecture.  The fsl-mc bus driver handles discovery of
  DPAA2 objects (which are represented as Linux devices) and
  binding objects to drivers.
+
+config FSL_MC_DPIO
+tristate "QorIQ DPAA2 DPIO driver"
+depends on FSL_MC_BUS
+help
+ Driver for the DPAA2 DPIO object.  A DPIO provides queue and
+ buffer management facilities for software to interact with
+ other DPAA2 objects. This driver does not expose the DPIO
+ objects individually, but groups them under a service layer
+ API.
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index 38716fd..577e9fa 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -18,3 +18,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \
  irq-gic-v3-its-fsl-mc-msi.o \
  dpmcp.o \
  dpbp.o
+
+# MC DPIO driver
+obj-$(CONFIG_FSL_MC_DPIO) += dpio/
diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile 
b/drivers/staging/fsl-mc/bus/dpio/Makefile
new file mode 100644
index 000..128befc
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/Makefile
@@ -0,0 +1,9 @@
+#
+# QorIQ DPAA2 DPIO driver
+#
+
+subdir-ccflags-y := -Werror
+
+obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
+
+fsl-mc-dpio-objs := dpio.o
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h 
b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
new file mode 100644
index 000..c237d5f
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _FSL_DPIO_CMD_H
+#define _FSL_DPIO_CMD_H
+
+/* DPIO Version */
+#define DPIO_VER_MAJOR 4
+#define DPIO_VER_MINOR 2
+
+/* Command Versioning */
+
+#define DPIO_CMD_ID

[PATCH v5 0/8] staging: fsl-mc: add dpio driver

2016-12-16 Thread Stuart Yoder
This patch series adds the driver for the DPIO object which is a 
step to addressing the final item in the staging TODO list-- adding
a functional driver on top of the bus driver.  The DPIO driver is a
dependency for other functional drivers such as Ethernet.

An overview of the DPIO object and driver components are in patch 1.
Patches 2-6 are internal components of the DPIO driver-- bit twiddling
of hardware registers, DPAA2 data structures, and the queuing APIs exposed
to other drivers.

Patch 7 adds the fsl-mc driver for the DPIO object.  It provides
the probe/remove functions, demonstrating a working example of
how fsl-mc drivers initialize, interact with the management
complex hardware, map their mappable MMIO regions, initialize
interrupts, register an ISR, etc.  All other DPAA2 drivers will
follow a similar initialization pattern.

version 5 changes
   -fixed typo in patch 5 that caused compile issue

version 4 changes
   -removed the patch moving the bus driver out of staging, updated
all paths referenced in dpio (e.g. includes) to be drivers/staging
   -defined macros for constants where needed
   -copyright updates
   -cleanup: fixed whitespace, alignment issues, typos, removed unneeded
comments
   -fixed bug in SDQCR #define
   -adding missing free in an error path

version 3 changes
   -zero memory allocated for a dpio store
   -replace hardcoded dequeue token with a #define and look for
that token when checking for a new result

version 2 changes (mostly feedback from Ioana Radulescu)
   -removed unused structs and defines in dpio command definitions
   -added setter/getter for the FD ctrl field
   -corrected comment for SG format_offset field description
   -added support for short length field in FD
   -fix bug in buffer release command, by setting bpid field
   -handle error (NULL) return value from qbman_swp_mc_complete()
   -fix bug in sending management commands where the verb was
properly initialized
   -use service_select_by_cpu() for re-arming DPIO interrupts
   -replace use of NR_CPUS with num_possible_cpus()
   -handle error case where number of DPIOs exceeds number of possible
CPUs
   -error message cleanup
   -updated MAINTAINERS file with proper location for both fsl-mc bus
driver and dpio driver


Ioana Radulescu (1):
  bus: fsl-mc: dpio: add APIs for DPIO objects

Roy Pledge (6):
  bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs
  bus: fsl-mc: dpio: add global dpaa2 definitions
  bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
  bus: fsl-mc: dpio: add the DPAA2 DPIO service interface
  bus: fsl-mc: dpio: add the DPAA2 DPIO object driver
  bus: fsl-mc: dpio: add maintainer for DPIO

Stuart Yoder (1):
  bus: fsl-mc: dpio: add DPIO driver overview document

 MAINTAINERS |6 +
 drivers/staging/fsl-mc/bus/Kconfig  |   10 +
 drivers/staging/fsl-mc/bus/Makefile |3 +
 drivers/staging/fsl-mc/bus/dpio/Makefile|9 +
 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h  |   76 ++
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c   |  296 +++
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt |  135 +++
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c  |  616 ++
 drivers/staging/fsl-mc/bus/dpio/dpio.c  |  224 +
 drivers/staging/fsl-mc/bus/dpio/dpio.h  |  109 +++
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c  | 1033 +++
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h  |  469 ++
 drivers/staging/fsl-mc/include/dpaa2-fd.h   |  448 ++
 drivers/staging/fsl-mc/include/dpaa2-global.h   |  202 +
 drivers/staging/fsl-mc/include/dpaa2-io.h   |  139 +++
 15 files changed, 3775 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/Makefile
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-service.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.h
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
 create mode 100644 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-fd.h
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-global.h
 create mode 100644 drivers/staging/fsl-mc/include/dpaa2-io.h

-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file

2017-01-03 Thread Stuart Yoder

> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, January 03, 2017 10:48 AM
> To: Stuart Yoder 
> Cc: de...@driverdev.osuosl.org; a...@arndb.de; Roy Pledge 
> ; Alexandru Marginean
> ; linux-ker...@vger.kernel.org; ag...@suse.de; 
> Bogdan Hamciuc
> ; Laurentiu Tudor 
> Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> 
> On Tue, Dec 06, 2016 at 06:10:38PM +, Stuart Yoder wrote:
> >
> >
> > > -Original Message-
> > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > Sent: Tuesday, December 06, 2016 11:56 AM
> > > To: Stuart Yoder 
> > > Cc: Ruxandra Ioana Radulescu ; 
> > > de...@driverdev.osuosl.org; linux-
> > > ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Alexandru Marginean
> ;
> > > Bogdan Hamciuc ; Roy Pledge ; 
> > > Laurentiu Tudor
> > > 
> > > Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> > >
> > > On Tue, Dec 06, 2016 at 12:59:59PM +, Stuart Yoder wrote:
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > > > Sent: Tuesday, December 06, 2016 4:20 AM
> > > > > To: Ruxandra Ioana Radulescu 
> > > > > Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; 
> > > > > ag...@suse.de; a...@arndb.de;
> > > Alexandru
> > > > > Marginean ; Bogdan Hamciuc 
> > > > > ; Stuart Yoder
> > > > > ; Roy Pledge ; Laurentiu 
> > > > > Tudor
> 
> > > > > Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> > > > >
> > > > > On Tue, Dec 06, 2016 at 10:06:25AM +, Ruxandra Ioana Radulescu 
> > > > > wrote:
> > > > > > > -Original Message-
> > > > > > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > > > > > Sent: Tuesday, December 06, 2016 11:58 AM
> > > > > > > To: Ruxandra Ioana Radulescu 
> > > > > > > Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> > > > > > > ag...@suse.de; a...@arndb.de; Alexandru Marginean
> > > > > > > ; Bogdan Hamciuc
> > > > > > > ; Stuart Yoder ; Roy
> > > > > > > Pledge ; Laurentiu Tudor
> > > > > > > 
> > > > > > > Subject: Re: [PATCH 7/8] staging: fsl-dpaa2/eth: Add TODO file
> > > > > > >
> > > > > > > On Tue, Dec 06, 2016 at 03:34:41AM -0600, Ioana Radulescu wrote:
> > > > > > > > Add a list of TODO items for the Ethernet driver
> > > > > > > >
> > > > > > > > Signed-off-by: Ioana Radulescu 
> > > > > > > > ---
> > > > > > > >  drivers/staging/fsl-dpaa2/ethernet/TODO |9 +
> > > > > > > >  1 files changed, 9 insertions(+), 0 deletions(-)
> > > > > > > >  create mode 100644 drivers/staging/fsl-dpaa2/ethernet/TODO
> > > > > > > >
> > > > > > > > diff --git a/drivers/staging/fsl-dpaa2/ethernet/TODO 
> > > > > > > > b/drivers/staging/fsl-
> > > > > > > dpaa2/ethernet/TODO
> > > > > > > > new file mode 100644
> > > > > > > > index 000..833265b
> > > > > > > > --- /dev/null
> > > > > > > > +++ b/drivers/staging/fsl-dpaa2/ethernet/TODO
> > > > > > > > @@ -0,0 +1,9 @@
> > > > > > > > +* Add a DPAA2 MAC kernel driver in order to allow PHY 
> > > > > > > > management;
> > > > > > > currently
> > > > > > > > +  the DPMAC objects and their link to DPNIs are handled by MC 
> > > > > > > > internally
> > > > > > > > +  and all PHYs are seen as fixed-link
> > > > > > > > +* add more debug support: decide how to expose detailed debug
> > > > > > > statistics,
> > > > > > > > +  add ingress error queue support
> > > > > > > > +* MC firmware uprev; the DPAA2 objects used by the Ethernet 
> > > > > > > > driver
> > > > > > > need to
> > > > > > > > +  be kept in sync with binary interface changes in 

RE: [PATCH 3/9] staging: fsl-mc: add device release callback

2017-02-02 Thread Stuart Yoder

> -Original Message-
> From: upstream-release-boun...@linux.freescale.net [mailto:upstream-release-
> boun...@linux.freescale.net] On Behalf Of laurentiu.tu...@nxp.com
> Sent: Wednesday, February 01, 2017 5:43 AM
> To: gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; a...@arndb.de; Ruxandra Ioana Radulescu 
> ;
> Roy Pledge ; linux-ker...@vger.kernel.org; ag...@suse.de; 
> Catalin Horghidan
> ; Leo Li ; Stuart Yoder 
> ;
> Laurentiu Tudor 
> Subject: [upstream-release] [PATCH 3/9] staging: fsl-mc: add device release 
> callback
> 
> From: Laurentiu Tudor 
> 
> When hot unplugging a mc-bus device the kernel displays
> this pertinent message, followed by a stack dump:
> "Device 'foo.N' does not have a release() function,
>  it is broken and must be fixed."
> Add the required callback to fix.
> 
> Signed-off-by: Laurentiu Tudor 
> ---
>  drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
> b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
> index 7c6a43b..6601bde 100644
> --- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
> +++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
> @@ -419,6 +419,22 @@ bool fsl_mc_is_root_dprc(struct device *dev)
>   return dev == root_dprc_dev;
>  }
> 
> +static void fsl_mc_device_release(struct device *dev)
> +{
> + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
> + struct fsl_mc_bus *mc_bus = NULL;
> +
> + kfree(mc_dev->regions);
> +
> + if (strcmp(mc_dev->obj_desc.type, "dprc") == 0)
> + mc_bus = to_fsl_mc_bus(mc_dev);
> +
> + if (mc_bus)
> + devm_kfree(mc_dev->dev.parent, mc_bus);
> + else
> + kmem_cache_free(mc_dev_cache, mc_dev);
> +}
> +
>  /**
>   * Add a newly discovered fsl-mc device to be visible in Linux
>   */
> @@ -460,6 +476,7 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
>   device_initialize(&mc_dev->dev);
>   mc_dev->dev.parent = parent_dev;
>   mc_dev->dev.bus = &fsl_mc_bus_type;
> + mc_dev->dev.release = fsl_mc_device_release;
>   dev_set_name(&mc_dev->dev, "%s.%d", obj_desc->type, obj_desc->id);
> 
>   if (strcmp(obj_desc->type, "dprc") == 0) {
> --

With this patch applied, you still have this:

void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
{
struct fsl_mc_bus *mc_bus = NULL;

kfree(mc_dev->regions);

/*
 * The device-specific remove callback will get invoked by device_del()
 */
device_del(&mc_dev->dev);
put_device(&mc_dev->dev);

if (strcmp(mc_dev->obj_desc.type, "dprc") == 0)
mc_bus = to_fsl_mc_bus(mc_dev);

if (mc_bus)
devm_kfree(mc_dev->dev.parent, mc_bus);
else
kmem_cache_free(mc_dev_cache, mc_dev);
}

...i.e. you are doing the same thing in 2 places.  You
need to remove the kfree/devm_kfree/ kmem_cache_free,
here, no?

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 4/9] staging: fsl-mc: don't use devres api for refcounted objects

2017-02-02 Thread Stuart Yoder


> -Original Message-
> From: laurentiu.tu...@nxp.com [mailto:laurentiu.tu...@nxp.com]
> Sent: Wednesday, February 01, 2017 5:43 AM
> To: gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Ioana
> Ciornei ; Ruxandra Ioana Radulescu 
> ; Bharat Bhushan
> ; Stuart Yoder ; Catalin 
> Horghidan
> ; Leo Li ; Roy Pledge 
> ; Laurentiu
> Tudor 
> Subject: [PATCH 4/9] staging: fsl-mc: don't use devres api for refcounted 
> objects
> 
> From: Laurentiu Tudor 
> 
> Mixing two memory management systems, in this case
> managed device resource api and refcounted objects
> is a bad idea. Lifetime of an object is controlled
> by its refcount so allocating it with other apis
> that have their own lifetime control is not ok.
> Drop devm_*() apis in favor of plain allocations.
> 
> While at it, let's drop the slab cache for objects
> until we actually have proof that it improves
> performance. This allows for some code cleanup.

Those 2 changes (dropping devm_* apis and slab cache
changes) are 2 orthogonal things, right?  It would
be better to split those into separate patches.  Mixing
them makes it harder to review.

> Signed-off-by: Laurentiu Tudor 
> ---
>  drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 43 
> +
>  1 file changed, 6 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
> b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
> index 6601bde..c493427 100644
> --- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
> +++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
> @@ -27,8 +27,6 @@
>  #include "fsl-mc-private.h"
>  #include "dprc-cmd.h"
> 
> -static struct kmem_cache *mc_dev_cache;
> -
>  /**
>   * Default DMA mask for devices on a fsl-mc bus
>   */
> @@ -422,17 +420,12 @@ bool fsl_mc_is_root_dprc(struct device *dev)
>  static void fsl_mc_device_release(struct device *dev)
>  {
>   struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
> - struct fsl_mc_bus *mc_bus = NULL;
> 
>   kfree(mc_dev->regions);
> -
> - if (strcmp(mc_dev->obj_desc.type, "dprc") == 0)
> - mc_bus = to_fsl_mc_bus(mc_dev);
> -
> - if (mc_bus)
> - devm_kfree(mc_dev->dev.parent, mc_bus);
> + if (!strcmp(mc_dev->obj_desc.type, "dprc"))
> + kfree(to_fsl_mc_bus(mc_dev));
>   else
> - kmem_cache_free(mc_dev_cache, mc_dev);
> + kfree(mc_dev);
>  }
> 
>  /**
> @@ -457,7 +450,7 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
>   /*
>* Allocate an MC bus device object:
>*/
> - mc_bus = devm_kzalloc(parent_dev, sizeof(*mc_bus), GFP_KERNEL);
> + mc_bus = kzalloc(sizeof(*mc_bus), GFP_KERNEL);
>   if (!mc_bus)
>   return -ENOMEM;
> 
> @@ -466,7 +459,7 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
>   /*
>* Allocate a regular fsl_mc_device object:
>*/
> - mc_dev = kmem_cache_zalloc(mc_dev_cache, GFP_KERNEL);
> + mc_dev = kzalloc(sizeof(*mc_dev), GFP_KERNEL);
>   if (!mc_dev)
>   return -ENOMEM;
>   }
> @@ -561,10 +554,7 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
> 
>  error_cleanup_dev:
>   kfree(mc_dev->regions);
> - if (mc_bus)
> - devm_kfree(parent_dev, mc_bus);
> - else
> - kmem_cache_free(mc_dev_cache, mc_dev);
> + kfree(mc_bus ? (void *)mc_bus : (void *)mc_dev);
> 
>   return error;
>  }
> @@ -578,23 +568,11 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
>   */
>  void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
>  {
> - struct fsl_mc_bus *mc_bus = NULL;
> -
> - kfree(mc_dev->regions);
> -
>   /*
>* The device-specific remove callback will get invoked by device_del()
>*/
>   device_del(&mc_dev->dev);
>   put_device(&mc_dev->dev);
> -
> - if (strcmp(mc_dev->obj_desc.type, "dprc") == 0)
> - mc_bus = to_fsl_mc_bus(mc_dev);
> -
> - if (mc_bus)
> - devm_kfree(mc_dev->dev.parent, mc_bus);
> - else
> - kmem_cache_free(mc_dev_cache, mc_dev);
>  }

The above changes in fsl_mc_device_remove(), I think 
actually belong in patch #3 of this series.

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 9/9] staging: fsl-mc: dprc: drop unused APIs

2017-02-02 Thread Stuart Yoder
> --- a/drivers/staging/fsl-mc/include/dprc.h
> +++ b/drivers/staging/fsl-mc/include/dprc.h
> @@ -42,20 +42,6 @@
> 
>  struct fsl_mc_io;
> 
> -/**
> - * Set this value as the icid value in dprc_cfg structure when creating a
> - * container, in case the ICID is not selected by the user and should be
> - * allocated by the DPRC from the pool of ICIDs.
> - */
> -#define DPRC_GET_ICID_FROM_POOL  (u16)(~(0))
> -
> -/**
> - * Set this value as the portal_id value in dprc_cfg structure when creating 
> a
> - * container, in case the portal ID is not specifically selected by the
> - * user and should be allocated by the DPRC from the pool of portal ids.
> - */
> -#define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
> -
>  int dprc_open(struct fsl_mc_io *mc_io,
> u32 cmd_flags,
> int container_id,
> @@ -65,79 +51,6 @@ int dprc_close(struct fsl_mc_io *mc_io,
>  u32 cmd_flags,
>  u16 token);
> 
> -/**
> - * Container general options
> - *
> - * These options may be selected at container creation by the container 
> creator
> - * and can be retrieved using dprc_get_attributes()
> - */
> -
> -/*
> - * Spawn Policy Option allowed - Indicates that the new container is allowed
> - * to spawn and have its own child containers.
> - */
> -#define DPRC_CFG_OPT_SPAWN_ALLOWED   0x0001
> -
> -/*
> - * General Container allocation policy - Indicates that the new container is
> - * allowed to allocate requested resources from its parent container; if not
> - * set, the container is only allowed to use resources in its own pools; Note
> - * that this is a container's global policy, but the parent container may
> - * override it and set specific quota per resource type.
> - */
> -#define DPRC_CFG_OPT_ALLOC_ALLOWED   0x0002
> -
> -/*
> - * Object initialization allowed - software context associated with this
> - * container is allowed to invoke object initialization operations.
> - */
> -#define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED  0x0004
> -
> -/*
> - * Topology change allowed - software context associated with this
> - * container is allowed to invoke topology operations, such as attach/detach
> - * of network objects.
> - */
> -#define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED0x0008
> -
> -/* AIOP - Indicates that container belongs to AIOP.  */
> -#define DPRC_CFG_OPT_AIOP0x0020
> -
> -/* IRQ Config - Indicates that the container allowed to configure its IRQs.  
> */
> -#define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x0040
> -
> -/**
> - * struct dprc_cfg - Container configuration options
> - * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
> - *   ICID value is allocated by the DPRC
> - * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
> - *   portal ID is allocated by the DPRC
> - * @options: Combination of 'DPRC_CFG_OPT_' options
> - * @label: Object's label
> - */
> -struct dprc_cfg {
> - u16 icid;
> - int portal_id;
> - u64 options;
> - char label[16];
> -};
> -
> -int dprc_create_container(struct fsl_mc_io *mc_io,
> -   u32 cmd_flags,
> -   u16 token,
> -   struct dprc_cfg *cfg,
> -   int *child_container_id,
> -   u64 *child_portal_offset);
> -
> -int dprc_destroy_container(struct fsl_mc_io *mc_io,
> -u32 cmd_flags,
> -u16 token,
> -int child_container_id);
> -
> -int dprc_reset_container(struct fsl_mc_io *mc_io,
> -  u32 cmd_flags,
> -  u16 token,
> -  int child_container_id);
> 
>  /* IRQ */
> 
> @@ -233,6 +146,7 @@ int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
> u8 irq_index,
> u32 status);
> 
> +

Extra, uneeded newline added above.

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 00/10][v2] staging: fsl-mc: fixes and cleanups

2017-02-07 Thread Stuart Yoder


> -Original Message-
> From: laurentiu.tu...@nxp.com [mailto:laurentiu.tu...@nxp.com]
> Sent: Tuesday, February 07, 2017 8:15 AM
> To: gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Ioana
> Ciornei ; Ruxandra Ioana Radulescu 
> ; Bharat Bhushan
> ; Stuart Yoder ; Catalin 
> Horghidan
> ; Leo Li ; Roy Pledge 
> ; linux-arm-
> ker...@lists.infradead.org; Laurentiu Tudor 
> Subject: [PATCH 00/10][v2] staging: fsl-mc: fixes and cleanups
> 
> From: Laurentiu Tudor 
> 
> First 4 patches fix several driver model related
> issues and drop an useless atomic global.
> The rest of the patches are cleanups mostly
> consisting in removing dead code.
> 
> v2:
>  - split slab cache removal in distinct patch
>  - redundant deallocation dropped in patch that adds release callback

Laurentiu,

A few nits about this submission:

-every patch in the series should have had "v2" in the patch
 subject.  In your submission only the cover letter had it.
 Without that it's harder to keep track of which version of
 patch I'm looking at.  Just use this when formatting your
 patches:
 --patch-subject="PATCH v2"

-for each patch, you should note below the "---" what changed in the
 patch, and if there were no changes you put "no changes".  For
 an example see:
 https://patchwork.kernel.org/patch/9478093/

 (You can use "git notes" to manage the below the "---" comments
  if it helps)

Can you reformat this series with "v3" and add the the comments
to note what did not change and what did change?

Thanks,
Stuart

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v3 00/10] staging: fsl-mc: fixes and cleanups

2017-02-08 Thread Stuart Yoder


> -Original Message-
> From: laurentiu.tu...@nxp.com [mailto:laurentiu.tu...@nxp.com]
> Sent: Tuesday, February 07, 2017 9:44 AM
> To: gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; ag...@suse.de; 
> a...@arndb.de; Ioana
> Ciornei ; Ruxandra Ioana Radulescu 
> ; Bharat Bhushan
> ; Stuart Yoder ; Catalin 
> Horghidan
> ; Leo Li ; Roy Pledge 
> ; linux-arm-
> ker...@lists.infradead.org; Laurentiu Tudor 
> Subject: [PATCH v3 00/10] staging: fsl-mc: fixes and cleanups
> 
> From: Laurentiu Tudor 
> 
> First 4 patches fix several driver model related
> issues and drop an useless atomic global.
> The rest of the patches are cleanups mostly
> consisting in removing dead code.
> 
> Only patch 3, 4, 5 and 10 changed. See individual patch notes for
> details.
> 
> Laurentiu Tudor (10):
>   staging: fsl-mc: drop root dprc counting
>   staging: fsl-mc: fix device ref counting
>   staging: fsl-mc: add device release callback
>   staging: fsl-mc: don't use devres api for refcounted objects
>   staging: fsl-mc: remove slab cache for mc devices
>   staging: fsl-mc: dpmcp: drop unused APIs
>   staging: fsl-mc: dpmng: drop unused prototype
>   staging: fsl-mc: dpbp: drop unused APIs
>   staging: fsl-mc: dpbp: add a few missing EXPORT_SYMBOL()s
>   staging: fsl-mc: dprc: drop unused APIs

For the series:

Acked-by: Stuart Yoder 


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-mc: update MAINTAINERS

2017-02-09 Thread Stuart Yoder
Add Laurentiu Tudor as a second maintainer and update Stuart Yoder's
email address.

Signed-off-by: Stuart Yoder 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index c2395ea..6050912 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10177,7 +10177,8 @@ F:  include/uapi/linux/qnx4_fs.h
 F: include/uapi/linux/qnxtypes.h
 
 QORIQ DPAA2 FSL-MC BUS DRIVER
-M: Stuart Yoder 
+M: Stuart Yoder 
+M: Laurentiu Tudor 
 L: linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-mc/
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] fsl mc-bus: Move mc-io destroy to bus remove

2016-06-20 Thread Stuart Yoder


> -Original Message-
> From: Bharat Bhushan [mailto:bharat.bhus...@nxp.com]
> Sent: Thursday, June 16, 2016 1:52 AM
> To: gre...@linuxfoundation.org; Stuart Yoder 
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; Bharat Bhushan 
> 
> Subject: [PATCH] fsl mc-bus: Move mc-io destroy to bus remove
> 
> fsl_mc_device_add() is called when a new mc device is added and
> fsl_mc_device_remove() is called when a mc device is removed.
> Now mc portals (fsl_create_mc_io) are not created during device
> addition i.e fsl_mc_device_add(). But mc portal are being destroyed
> when an mc device are removed i.e fsl_mc_device_remove(), which is
> not correct way of reverting what is done during device addition.
> 
> Now this leads to the problem with VFIO driver where we do not want
> the portal to be destroyed when an mc-device is removed. VFIO
> creates one mc-portal for all dprc-containers bound to it and it
> destroys the mc portal when driver itself is removed.
> 
> This change moves the mc-portal destroy part to bus-remove for
> mc-bus and dprc-driver remove for child DPRCs. This also makes
> fsl_mc_device_remove() exactly reverting what is done in
> fsl_mc_device_add() with respect to mc portal creation.

I think we need to improve and clarify this commit message.
This change is needed, but I don't think the message
makes it clear what is going on.

> Signed-off-by: Bharat Bhushan 
> ---
>  drivers/staging/fsl-mc/bus/dprc-driver.c | 3 +++
>  drivers/staging/fsl-mc/bus/mc-bus.c  | 8 
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
> b/drivers/staging/fsl-mc/bus/dprc-driver.c
> index 7fc4717..14f9c82 100644
> --- a/drivers/staging/fsl-mc/bus/dprc-driver.c
> +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
> @@ -801,6 +801,9 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
>   dev_set_msi_domain(&mc_dev->dev, NULL);
>   }
> 
> + fsl_destroy_mc_io(mc_dev->mc_io);
> + mc_dev->mc_io = NULL;
> +

We need to do the destroy here, but we need to add a check and
only do this for child containers.

Thanks,
Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/11] staging: fsl-mc: add support for the modalias sysfs attribute

2016-06-22 Thread Stuart Yoder
In order to support uevent based module loading implement modalias support
for the fsl-mc bus driver. Aliases are based on vendor and object/device
id and are of the form "fsl-mc:vNdN".

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 4053643..d8776dd 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -82,10 +82,35 @@ static int fsl_mc_bus_uevent(struct device *dev, struct 
kobj_uevent_env *env)
return 0;
 }
 
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+
+   return sprintf(buf, "fsl-mc:v%08Xd%s\n", mc_dev->obj_desc.vendor,
+  mc_dev->obj_desc.type);
+}
+static DEVICE_ATTR_RO(modalias);
+
+static struct attribute *fsl_mc_dev_attrs[] = {
+   &dev_attr_modalias.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.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/11] staging: fsl-mc: clean up the device id struct

2016-06-22 Thread Stuart Yoder
-rename the struct used for fsl-mc device ids to be more
 consistent with other busses
-remove the now obsolete and unused version fields

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c  |  2 +-
 drivers/staging/fsl-mc/bus/mc-allocator.c |  2 +-
 drivers/staging/fsl-mc/bus/mc-bus.c   |  2 +-
 drivers/staging/fsl-mc/include/mc.h   | 10 +++---
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 7fc4717..f865d18 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -805,7 +805,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
return 0;
 }
 
-static const struct fsl_mc_device_match_id match_id_table[] = {
+static const struct fsl_mc_device_id match_id_table[] = {
{
 .vendor = FSL_MC_VENDOR_FREESCALE,
 .obj_type = "dprc"},
diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c 
b/drivers/staging/fsl-mc/bus/mc-allocator.c
index fb08f22..e59d850 100644
--- a/drivers/staging/fsl-mc/bus/mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
@@ -717,7 +717,7 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device 
*mc_dev)
return 0;
 }
 
-static const struct fsl_mc_device_match_id match_id_table[] = {
+static const struct fsl_mc_device_id match_id_table[] = {
{
 .vendor = FSL_MC_VENDOR_FREESCALE,
 .obj_type = "dpbp",
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index cf92a1c..e975adc 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -36,7 +36,7 @@ static bool fsl_mc_is_root_dprc(struct device *dev);
  */
 static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
 {
-   const struct fsl_mc_device_match_id *id;
+   const struct fsl_mc_device_id *id;
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
bool found = false;
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index ac7c1ce..bc0d45c 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -39,7 +39,7 @@ struct fsl_mc_bus;
  */
 struct fsl_mc_driver {
struct device_driver driver;
-   const struct fsl_mc_device_match_id *match_id_table;
+   const struct fsl_mc_device_id *match_id_table;
int (*probe)(struct fsl_mc_device *dev);
int (*remove)(struct fsl_mc_device *dev);
void (*shutdown)(struct fsl_mc_device *dev);
@@ -51,20 +51,16 @@ struct fsl_mc_driver {
container_of(_drv, struct fsl_mc_driver, driver)
 
 /**
- * struct fsl_mc_device_match_id - MC object device Id entry for driver 
matching
+ * struct fsl_mc_device_id - MC object device Id entry for driver matching
  * @vendor: vendor ID
  * @obj_type: MC object type
- * @ver_major: MC object version major number
- * @ver_minor: MC object version minor number
  *
  * Type of entries in the "device Id" table for MC object devices supported by
  * a MC object device driver. The last entry of the table has vendor set to 0x0
  */
-struct fsl_mc_device_match_id {
+struct fsl_mc_device_id {
u16 vendor;
const char obj_type[16];
-   u32 ver_major;
-   u32 ver_minor;
 };
 
 /**
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/11] staging: fsl-mc: implement uevent callback and set the modalias

2016-06-22 Thread Stuart Yoder
Replace placeholder code in the uevent callback to properly
set the MODALIAS env variable.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index d8776dd..cf92a1c 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -78,7 +78,13 @@ out:
  */
 static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
-   pr_debug("%s invoked\n", __func__);
+   struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+
+   if (add_uevent_var(env, "MODALIAS=fsl-mc:v%08Xd%s",
+  mc_dev->obj_desc.vendor,
+  mc_dev->obj_desc.type))
+   return -ENOMEM;
+
return 0;
 }
 
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/11] staging: fsl-mc: make fsl_mc_is_root_dprc() global

2016-06-22 Thread Stuart Yoder
make fsl_mc_is_root_dprc() global so that the dprc driver
can use it

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 28 +---
 drivers/staging/fsl-mc/include/mc.h |  2 ++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index e975adc..a49186e 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
@@ -247,19 +245,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;
-   return dev == root_dprc_dev;
-}
-
 static int get_dprc_attr(struct fsl_mc_io *mc_io,
 int container_id, struct dprc_attributes *attr)
 {
@@ -424,6 +409,19 @@ error_cleanup_regions:
 }
 
 /**
+ * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
+ */
+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;
+   return dev == root_dprc_dev;
+}
+
+/**
  * Add a newly discovered MC object device to be visible in Linux
  */
 int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index a9a9d23..853cbf3 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -207,6 +207,8 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device 
*mc_dev);
 
 void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
 
+bool fsl_mc_is_root_dprc(struct device *dev);
+
 extern struct bus_type fsl_mc_bus_type;
 
 #endif /* _FSL_MC_H_ */
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/11] staging: fsl-mc: fix asymmetry in destroy of mc_io

2016-06-22 Thread Stuart Yoder
From: Bharat Bhushan 

An mc_io represents a mapped MC portal.  Previously, an mc_io was
created for the root dprc in fsl_mc_bus_probe() and for child dprcs
in dprc_probe().  But the free of that data structure happened in the
general bus remove callback.  This asymmetry resulted in some bugs due
to unwanted destroys of mc_io object in some scenarios (e.g. vfio).

Fix this bug by making things symmetric-- mc_io created in
fsl_mc_bus_probe() is freed in fsl_mc_bus_remove().  The mc_io created
in dprc_probe() is freed in dprc_remove().

Signed-off-by: Bharat Bhushan 
[Stuart: added check for root dprc and reworded commit message]
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c | 5 +
 drivers/staging/fsl-mc/bus/mc-bus.c  | 8 
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index f865d18..1a6bcc4 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -801,6 +801,11 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
dev_set_msi_domain(&mc_dev->dev, NULL);
}
 
+   if (!fsl_mc_is_root_dprc(&mc_dev->dev)) {
+   fsl_destroy_mc_io(mc_dev->mc_io);
+   mc_dev->mc_io = NULL;
+   }
+
dev_info(&mc_dev->dev, "DPRC device unbound from driver");
return 0;
 }
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index a49186e..db3afdb 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -579,10 +579,6 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
 
if (strcmp(mc_dev->obj_desc.type, "dprc") == 0) {
mc_bus = to_fsl_mc_bus(mc_dev);
-   if (mc_dev->mc_io) {
-   fsl_destroy_mc_io(mc_dev->mc_io);
-   mc_dev->mc_io = NULL;
-   }
 
if (fsl_mc_is_root_dprc(&mc_dev->dev)) {
if (atomic_read(&root_dprc_count) > 0)
@@ -810,6 +806,10 @@ static int fsl_mc_bus_remove(struct platform_device *pdev)
return -EINVAL;
 
fsl_mc_device_remove(mc->root_mc_bus_dev);
+
+   fsl_destroy_mc_io(mc->root_mc_bus_dev->mc_io);
+   mc->root_mc_bus_dev->mc_io = NULL;
+
dev_info(&pdev->dev, "Root MC bus device removed");
return 0;
 }
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/11] staging: fsl-mc: dprc: fix ordering problem freeing resources in remove of dprc

2016-06-22 Thread Stuart Yoder
When unbinding a dprc from the dprc driver the cleanup of
the resource pools must happen after irq pool cleanup
is done.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 96ee1b7..d2a71f1 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -796,16 +796,18 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
dprc_teardown_irq(mc_dev);
 
device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
-   dprc_cleanup_all_resource_pools(mc_dev);
-   error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
-   if (error < 0)
-   dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);
 
if (dev_get_msi_domain(&mc_dev->dev)) {
fsl_mc_cleanup_irq_pool(mc_bus);
dev_set_msi_domain(&mc_dev->dev, NULL);
}
 
+   dprc_cleanup_all_resource_pools(mc_dev);
+
+   error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
+   if (error < 0)
+   dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);
+
if (!fsl_mc_is_root_dprc(&mc_dev->dev)) {
fsl_destroy_mc_io(mc_dev->mc_io);
mc_dev->mc_io = NULL;
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/11] staging: fsl-mc: export mc_get_version

2016-06-22 Thread Stuart Yoder
some drivers (built as modules) rely on mc_get_version()

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dpmng.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/fsl-mc/bus/dpmng.c 
b/drivers/staging/fsl-mc/bus/dpmng.c
index f633fcd..a31fa9b 100644
--- a/drivers/staging/fsl-mc/bus/dpmng.c
+++ b/drivers/staging/fsl-mc/bus/dpmng.c
@@ -67,6 +67,7 @@ int mc_get_version(struct fsl_mc_io *mc_io,
 
return 0;
 }
+EXPORT_SYMBOL(mc_get_version);
 
 /**
  * dpmng_get_container_id() - Get container ID associated with a given portal.
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/11] staging: fsl-mc: properly set hwirq in msi set_desc

2016-06-22 Thread Stuart Yoder
For an MSI domain the hwirq is an arbitrary but unique
id to identify an interrupt.  Previously the hwirq was set to
the MSI index of the interrupt, but that only works if there is
one DPRC.  Additional DPRCs require an expanded namespace.  Use
both the ICID (which is unique per DPRC) and the MSI index to
compose a hwirq value.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/mc-msi.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-msi.c 
b/drivers/staging/fsl-mc/bus/mc-msi.c
index e202b2b..c7be156 100644
--- a/drivers/staging/fsl-mc/bus/mc-msi.c
+++ b/drivers/staging/fsl-mc/bus/mc-msi.c
@@ -20,11 +20,26 @@
 #include "../include/mc-sys.h"
 #include "dprc-cmd.h"
 
+/*
+ * Generate a unique ID identifying the interrupt (only used within the MSI
+ * irqdomain.  Combine the icid with the interrupt index.
+ */
+static irq_hw_number_t fsl_mc_domain_calc_hwirq(struct fsl_mc_device *dev,
+   struct msi_desc *desc)
+{
+   /*
+* Make the base hwirq value for ICID*1 so it is readable
+* as a decimal value in /proc/interrupts.
+*/
+   return (irq_hw_number_t)(desc->fsl_mc.msi_index + (dev->icid * 1));
+}
+
 static void fsl_mc_msi_set_desc(msi_alloc_info_t *arg,
struct msi_desc *desc)
 {
arg->desc = desc;
-   arg->hwirq = (irq_hw_number_t)desc->fsl_mc.msi_index;
+   arg->hwirq = fsl_mc_domain_calc_hwirq(to_fsl_mc_device(desc->dev),
+ desc);
 }
 
 static void fsl_mc_msi_update_dom_ops(struct msi_domain_info *info)
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/11] staging: fsl-mc: dprc: add missing irq free

2016-06-22 Thread Stuart Yoder
add missing free of the Linux irq when tearing down interrupts

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 1a6bcc4..96ee1b7 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -760,7 +760,12 @@ error_cleanup_msi_domain:
  */
 static void dprc_teardown_irq(struct fsl_mc_device *mc_dev)
 {
+   struct fsl_mc_device_irq *irq = mc_dev->irqs[0];
+
(void)disable_dprc_irq(mc_dev);
+
+   devm_free_irq(&mc_dev->dev, irq->msi_desc->irq, &mc_dev->dev);
+
fsl_mc_free_irqs(mc_dev);
 }
 
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/11] staging: fsl-mc: module loading support, fixes, and cleanup

2016-06-22 Thread Stuart Yoder
This patch series does some cleanup and further sets the stage for
additional fsl-mc device drivers.

-Patches 1-4 add missing fsl-mc support for modalias and udev-based
 module loading of drivers.
-Patch 5 exports a function some drivers rely on.
-Patch 6 makes a needed helper function visible to the dprc driver.
-Patch 7 fixes a bug where an asymmetry existed in how mc_io structs
 were destroyed.
-Patch 8 fixes a bug where an irq free was missing in the dprc driver.
-Patch 9 fixes a bug where there was an ordering issue with how resources
 were freed.
-Patch 10 fixes a bug with how hwirq numbers were determined, which
 prevented more than one dprc from being used by the kernel
-Patch 11 is a cleanup patch to improve the readability/maintainability of
 the functions that build/parse MC commands.  It uses structs instead
 of the previous shift/mask macros.  This sets the precedence we want other
 new drivers to follow.

Bharat Bhushan (1):
  staging: fsl-mc: fix asymmetry in destroy of mc_io

Ioana Radulescu (1):
  staging: fsl-mc: convert mc command build/parse to use C structs

Stuart Yoder (9):
  staging: fsl-mc: add support for the modalias sysfs attribute
  staging: fsl-mc: implement uevent callback and set the modalias
  staging: fsl-mc: clean up the device id struct
  staging: fsl-mc: add support for device table matching
  staging: fsl-mc: export mc_get_version
  staging: fsl-mc: make fsl_mc_is_root_dprc() global
  staging: fsl-mc: dprc: add missing irq free
  staging: fsl-mc: dprc: fix ordering problem freeing resources in
remove of dprc
  staging: fsl-mc: properly set hwirq in msi set_desc

 drivers/staging/fsl-mc/bus/dpbp.c | 132 --
 drivers/staging/fsl-mc/bus/dpmcp-cmd.h|  86 +++-
 drivers/staging/fsl-mc/bus/dpmcp.c|  89 ++--
 drivers/staging/fsl-mc/bus/dpmng-cmd.h|  12 +-
 drivers/staging/fsl-mc/bus/dpmng.c|  15 +-
 drivers/staging/fsl-mc/bus/dprc-cmd.h | 379 +++-
 drivers/staging/fsl-mc/bus/dprc-driver.c  |  20 +-
 drivers/staging/fsl-mc/bus/dprc.c | 715 ++
 drivers/staging/fsl-mc/bus/mc-allocator.c |   2 +-
 drivers/staging/fsl-mc/bus/mc-bus.c   |  71 ++-
 drivers/staging/fsl-mc/bus/mc-msi.c   |  17 +-
 drivers/staging/fsl-mc/bus/mc-sys.c   |  46 +-
 drivers/staging/fsl-mc/include/dpbp-cmd.h | 125 +-
 drivers/staging/fsl-mc/include/mc-cmd.h   |  91 ++--
 drivers/staging/fsl-mc/include/mc.h   |  21 +-
 include/linux/mod_devicetable.h   |  16 +
 scripts/mod/devicetable-offsets.c |   4 +
 scripts/mod/file2alias.c  |  12 +
 18 files changed, 1175 insertions(+), 678 deletions(-)

-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/11] staging: fsl-mc: add support for device table matching

2016-06-22 Thread Stuart Yoder
Move the definition of fsl_mc_device_id to its proper location in
mod_devicetable.h, and add fsl-mc bus support to devicetable-offsets.c
and file2alias.c to enable device table matching.  With this patch udev
based module loading of fsl-mc drivers is supported.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/include/mc.h | 13 -
 include/linux/mod_devicetable.h | 16 
 scripts/mod/devicetable-offsets.c   |  4 
 scripts/mod/file2alias.c| 12 
 4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index bc0d45c..a9a9d23 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -51,19 +51,6 @@ struct fsl_mc_driver {
container_of(_drv, struct fsl_mc_driver, driver)
 
 /**
- * struct fsl_mc_device_id - MC object device Id entry for driver matching
- * @vendor: vendor ID
- * @obj_type: MC object type
- *
- * Type of entries in the "device Id" table for MC object devices supported by
- * a MC object device driver. The last entry of the table has vendor set to 0x0
- */
-struct fsl_mc_device_id {
-   u16 vendor;
-   const char obj_type[16];
-};
-
-/**
  * enum fsl_mc_pool_type - Types of allocatable MC bus resources
  *
  * Entries in these enum are used as indices in the array of resource
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 6e4c645..ed84c07 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -657,4 +657,20 @@ struct ulpi_device_id {
kernel_ulong_t driver_data;
 };
 
+/**
+ * struct fsl_mc_device_id - MC object device identifier
+ * @vendor: vendor ID
+ * @obj_type: MC object type
+ * @ver_major: MC object version major number
+ * @ver_minor: MC object version minor number
+ *
+ * Type of entries in the "device Id" table for MC object devices supported by
+ * a MC object device driver. The last entry of the table has vendor set to 0x0
+ */
+struct fsl_mc_device_id {
+   __u16 vendor;
+   const char obj_type[16];
+};
+
+
 #endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/scripts/mod/devicetable-offsets.c 
b/scripts/mod/devicetable-offsets.c
index 840b973..e4d90e5 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -202,5 +202,9 @@ int main(void)
DEVID_FIELD(hda_device_id, rev_id);
DEVID_FIELD(hda_device_id, api_version);
 
+   DEVID(fsl_mc_device_id);
+   DEVID_FIELD(fsl_mc_device_id, vendor);
+   DEVID_FIELD(fsl_mc_device_id, obj_type);
+
return 0;
 }
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index a915507..b3f88a3 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1289,6 +1289,18 @@ static int do_hda_entry(const char *filename, void 
*symval, char *alias)
 }
 ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry);
 
+/* Looks like: fsl-mc:vNdN */
+static int do_fsl_mc_entry(const char *filename, void *symval,
+  char *alias)
+{
+   DEF_FIELD(symval, fsl_mc_device_id, vendor);
+   DEF_FIELD_ADDR(symval, fsl_mc_device_id, obj_type);
+
+   sprintf(alias, "fsl-mc:v%08Xd%s", vendor, *obj_type);
+   return 1;
+}
+ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, do_fsl_mc_entry);
+
 /* Does namelen bytes of name exactly match the symbol? */
 static bool sym_is(const char *name, unsigned namelen, const char *symbol)
 {
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/11] staging: fsl-mc: convert mc command build/parse to use C structs

2016-06-22 Thread Stuart Yoder
From: Ioana Radulescu 

The layer abstracting the building of commands and extracting
responses is currently based on macros that shift and mask the command
fields and requires exposing offset/size values as macro parameters
and makes the code harder to read.

For clarity and maintainability, instead use an implementation based on
mapping the MC command definitions to C structures. These structures
contain the hardware command fields (which are naturally-aligned)
and individual fields are little-endian ordering (the byte ordering
of the hardware).

As such, there is no need to perform the conversion between core and
hardware (LE) endianness in mc_send_command(), but instead each
individual field in a command will be converted separately if needed
by the function building the command or extracting the response.

This patch does not introduce functional changes, both the hardware
ABIs and the APIs exposed for the DPAA2 objects remain the same.

Signed-off-by: Ioana Radulescu 
Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dpbp.c | 132 --
 drivers/staging/fsl-mc/bus/dpmcp-cmd.h|  86 +++-
 drivers/staging/fsl-mc/bus/dpmcp.c|  89 ++--
 drivers/staging/fsl-mc/bus/dpmng-cmd.h|  12 +-
 drivers/staging/fsl-mc/bus/dpmng.c|  14 +-
 drivers/staging/fsl-mc/bus/dprc-cmd.h | 379 +++-
 drivers/staging/fsl-mc/bus/dprc.c | 715 ++
 drivers/staging/fsl-mc/bus/mc-sys.c   |  46 +-
 drivers/staging/fsl-mc/include/dpbp-cmd.h | 125 +-
 drivers/staging/fsl-mc/include/mc-cmd.h   |  91 ++--
 10 files changed, 1056 insertions(+), 633 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpbp.c 
b/drivers/staging/fsl-mc/bus/dpbp.c
index c31fe1b..fe271fb 100644
--- a/drivers/staging/fsl-mc/bus/dpbp.c
+++ b/drivers/staging/fsl-mc/bus/dpbp.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 Freescale Semiconductor Inc.
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
@@ -57,12 +57,14 @@ int dpbp_open(struct fsl_mc_io *mc_io,
  u16 *token)
 {
struct mc_command cmd = { 0 };
+   struct dpbp_cmd_open *cmd_params;
int err;
 
/* prepare command */
cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN,
  cmd_flags, 0);
-   cmd.params[0] |= mc_enc(0, 32, dpbp_id);
+   cmd_params = (struct dpbp_cmd_open *)cmd.params;
+   cmd_params->dpbp_id = cpu_to_le32(dpbp_id);
 
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
@@ -70,7 +72,7 @@ int dpbp_open(struct fsl_mc_io *mc_io,
return err;
 
/* retrieve response parameters */
-   *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+   *token = mc_cmd_hdr_read_token(&cmd);
 
return err;
 }
@@ -143,7 +145,7 @@ int dpbp_create(struct fsl_mc_io *mc_io,
return err;
 
/* retrieve response parameters */
-   *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+   *token = mc_cmd_hdr_read_token(&cmd);
 
return 0;
 }
@@ -231,6 +233,7 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io,
int *en)
 {
struct mc_command cmd = { 0 };
+   struct dpbp_rsp_is_enabled *rsp_params;
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPBP_CMDID_IS_ENABLED, cmd_flags,
@@ -242,7 +245,8 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io,
return err;
 
/* retrieve response parameters */
-   *en = (int)mc_dec(cmd.params[0], 0, 1);
+   rsp_params = (struct dpbp_rsp_is_enabled *)cmd.params;
+   *en = rsp_params->enabled & DPBP_ENABLE;
 
return 0;
 }
@@ -286,14 +290,16 @@ int dpbp_set_irq(struct fsl_mc_io *mc_io,
 struct dpbp_irq_cfg *irq_cfg)
 {
struct mc_command cmd = { 0 };
+   struct dpbp_cmd_set_irq *cmd_params;
 
/* prepare command */
cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ,
  cmd_flags, token);
-   cmd.params[0] |= mc_enc(0, 8, irq_index);
-   cmd.params[0] |= mc_enc(32, 32, irq_cfg->val);
-   cmd.params[1] |= mc_enc(0, 64, irq_cfg->addr);
-   cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
+   cmd_params = (struct dpbp_cmd_set_irq *)cmd.params;
+   cmd_params->irq_index = irq_index;
+   cmd_params->irq_val = cpu_to_le32(irq_cfg->val);
+   cmd_params->irq_addr = cpu_to_le64(irq_cfg->addr);
+   cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num);
 
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
@@ -319,12 +325,15 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io,
 struct dpbp_irq_cfg *irq_cfg)
 {
struct mc_command cmd = { 0 };
+   struct dpbp_

RE: [PATCH 06/11] staging: fsl-mc: make fsl_mc_is_root_dprc() global

2016-06-29 Thread Stuart Yoder


> -Original Message-
> From: Matthias Brugger [mailto:mbrug...@suse.com]
> Sent: Wednesday, June 29, 2016 9:17 AM
> To: Stuart Yoder ; gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; ag...@suse.de; a...@arndb.de; Jose Rivera 
> ;
> linux-ker...@vger.kernel.org; Yang-Leo Li 
> Subject: Re: [PATCH 06/11] staging: fsl-mc: make fsl_mc_is_root_dprc() global
> 
> On 22/06/16 23:40, Stuart Yoder wrote:
> > make fsl_mc_is_root_dprc() global so that the dprc driver
> > can use it
> >
> > Signed-off-by: Stuart Yoder 
> > ---
> >   drivers/staging/fsl-mc/bus/mc-bus.c | 28 +---
> >   drivers/staging/fsl-mc/include/mc.h |  2 ++
> >   2 files changed, 15 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
> > b/drivers/staging/fsl-mc/bus/mc-bus.c
> > index e975adc..a49186e 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
> > @@ -247,19 +245,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;
> > -   return dev == root_dprc_dev;
> > -}
> > -
> >   static int get_dprc_attr(struct fsl_mc_io *mc_io,
> >  int container_id, struct dprc_attributes *attr)
> >   {
> > @@ -424,6 +409,19 @@ error_cleanup_regions:
> >   }
> >
> >   /**
> > + * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
> > + */
> > +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;
> > +   return dev == root_dprc_dev;
> > +}
> > +
> > +/**
> 
> Is there any reason why apart from deleting "static" you move
> fsl_mc_is_root to a different line?

I moved it just to keep internal consistency inside the source file where all 
the
static functions were grouped together in the first part of the file, and public
functions were in the second part.

Stuart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v2] fsl-mc: add helper macro to determine if a device is of fsl_mc type

2016-07-11 Thread Stuart Yoder


> -Original Message-
> From: Nipun Gupta [mailto:nipun.gu...@nxp.com]
> Sent: Wednesday, June 29, 2016 12:15 PM
> To: gre...@linuxfoundation.org; Stuart Yoder 
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; Nipun Gupta 
> ; Bharat
> Bhushan 
> Subject: [PATCH v2] fsl-mc: add helper macro to determine if a device is of 
> fsl_mc type
> 
> Add a helper macro to return if a device has a bus type of fsl_mc.
> This makes the bus driver code more readable and provides a way for
> drivers like the SMMU driver to easily check the bus type.
> 
> Signed-off-by: Nipun Gupta 
> Signed-off-by: Bharat Bhushan 
> ---
>  drivers/staging/fsl-mc/bus/dprc-driver.c   | 4 ++--
>  drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c | 2 +-
>  drivers/staging/fsl-mc/bus/mc-allocator.c  | 6 +++---
>  drivers/staging/fsl-mc/bus/mc-bus.c| 6 +++---
>  drivers/staging/fsl-mc/include/mc.h| 7 +++
>  5 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
> b/drivers/staging/fsl-mc/bus/dprc-driver.c
> index 7fc4717..cd6d75a 100644
> --- a/drivers/staging/fsl-mc/bus/dprc-driver.c
> +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
> @@ -649,7 +649,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
>   /*
>* This is a child DPRC:
>*/
> - if (WARN_ON(parent_dev->bus != &fsl_mc_bus_type))
> + if (WARN_ON(!dev_is_fsl_mc(parent_dev)))
>   return -EINVAL;
> 
>   if (WARN_ON(mc_dev->obj_desc.region_count == 0))
> @@ -681,7 +681,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
>*/
>   struct irq_domain *mc_msi_domain;
> 
> - if (WARN_ON(parent_dev->bus == &fsl_mc_bus_type))
> + if (WARN_ON(dev_is_fsl_mc(parent_dev)))
>   return -EINVAL;
> 
>   error = fsl_mc_find_msi_domain(parent_dev,
> diff --git a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c 
> b/drivers/staging/fsl-mc/bus/irq-
> gic-v3-its-fsl-mc-msi.c
> index 720e2b0..d0c20d6 100644
> --- a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> +++ b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> @@ -35,7 +35,7 @@ static int its_fsl_mc_msi_prepare(struct irq_domain 
> *msi_domain,
>   struct fsl_mc_device *mc_bus_dev;
>   struct msi_domain_info *msi_info;
> 
> - if (WARN_ON(dev->bus != &fsl_mc_bus_type))
> + if (WARN_ON(!dev_is_fsl_mc(dev)))
>   return -EINVAL;
> 
>   mc_bus_dev = to_fsl_mc_device(dev);
> diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c 
> b/drivers/staging/fsl-mc/bus/mc-allocator.c
> index fb08f22..9216c32 100644
> --- a/drivers/staging/fsl-mc/bus/mc-allocator.c
> +++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
> @@ -281,7 +281,7 @@ int __must_check fsl_mc_portal_allocate(struct 
> fsl_mc_device *mc_dev,
>   if (mc_dev->flags & FSL_MC_IS_DPRC) {
>   mc_bus_dev = mc_dev;
>   } else {
> - if (WARN_ON(mc_dev->dev.parent->bus != &fsl_mc_bus_type))
> + if (WARN_ON(!dev_is_fsl_mc(mc_dev->dev.parent)))
>   return error;
> 
>   mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> @@ -420,7 +420,7 @@ int __must_check fsl_mc_object_allocate(struct 
> fsl_mc_device *mc_dev,
>   if (WARN_ON(mc_dev->flags & FSL_MC_IS_DPRC))
>   goto error;
> 
> - if (WARN_ON(mc_dev->dev.parent->bus != &fsl_mc_bus_type))
> + if (WARN_ON(!dev_is_fsl_mc(mc_dev->dev.parent)))
>   goto error;
> 
>   if (WARN_ON(pool_type == FSL_MC_POOL_DPMCP))
> @@ -678,7 +678,7 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device 
> *mc_dev)
>   return -EINVAL;
> 
>   mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> - if (WARN_ON(mc_bus_dev->dev.bus != &fsl_mc_bus_type))
> + if (WARN_ON(!dev_is_fsl_mc(&mc_bus_dev->dev)))
>   return -EINVAL;
> 
>   mc_bus = to_fsl_mc_bus(mc_bus_dev);
> diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
> b/drivers/staging/fsl-mc/bus/mc-bus.c
> index 4053643..098f07c 100644
> --- a/drivers/staging/fsl-mc/bus/mc-bus.c
> +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
> @@ -207,11 +207,11 @@ static void fsl_mc_get_root_dprc(struct device *dev,
>  {
>   if (WARN_ON(!dev)) {
>   *root_dprc_dev = NULL;
> - } else if (WARN_ON(dev->bus != &fsl_mc_bus_type)) {
> + } else if (WARN_ON(!dev_is_fsl_mc(dev))) {
> 

[PATCH 04/14] staging: fsl-mc: move resource pool init/cleanup into allocator

2016-08-23 Thread Stuart Yoder
The resource pool init/cleanup functions logically belong in the
allocator.  Move them to the allocator and rename to reflect the
move out of the dprc-driver.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c  | 55 ++-
 drivers/staging/fsl-mc/bus/fsl-mc-allocator.c | 49 
 drivers/staging/fsl-mc/include/mc-bus.h   |  4 ++
 3 files changed, 56 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 83e72b3..89d53da 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -190,55 +190,6 @@ static void dprc_add_new_devices(struct fsl_mc_device 
*mc_bus_dev,
}
 }
 
-static void dprc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
-{
-   int pool_type;
-   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
-
-   for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++) {
-   struct fsl_mc_resource_pool *res_pool =
-   &mc_bus->resource_pools[pool_type];
-
-   res_pool->type = pool_type;
-   res_pool->max_count = 0;
-   res_pool->free_count = 0;
-   res_pool->mc_bus = mc_bus;
-   INIT_LIST_HEAD(&res_pool->free_list);
-   mutex_init(&res_pool->mutex);
-   }
-}
-
-static void dprc_cleanup_resource_pool(struct fsl_mc_device *mc_bus_dev,
-  enum fsl_mc_pool_type pool_type)
-{
-   struct fsl_mc_resource *resource;
-   struct fsl_mc_resource *next;
-   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
-   struct fsl_mc_resource_pool *res_pool =
-   &mc_bus->resource_pools[pool_type];
-   int free_count = 0;
-
-   WARN_ON(res_pool->type != pool_type);
-   WARN_ON(res_pool->free_count != res_pool->max_count);
-
-   list_for_each_entry_safe(resource, next, &res_pool->free_list, node) {
-   free_count++;
-   WARN_ON(resource->type != res_pool->type);
-   WARN_ON(resource->parent_pool != res_pool);
-   devm_kfree(&mc_bus_dev->dev, resource);
-   }
-
-   WARN_ON(free_count != res_pool->free_count);
-}
-
-static void dprc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
-{
-   int pool_type;
-
-   for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++)
-   dprc_cleanup_resource_pool(mc_bus_dev, pool_type);
-}
-
 /**
  * dprc_scan_objects - Discover objects in a DPRC
  *
@@ -363,7 +314,7 @@ int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
unsigned int irq_count;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
 
-   dprc_init_all_resource_pools(mc_bus_dev);
+   fsl_mc_init_all_resource_pools(mc_bus_dev);
 
/*
 * Discover objects in the DPRC:
@@ -390,7 +341,7 @@ int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
 
return 0;
 error:
-   dprc_cleanup_all_resource_pools(mc_bus_dev);
+   fsl_mc_cleanup_all_resource_pools(mc_bus_dev);
return error;
 }
 EXPORT_SYMBOL_GPL(dprc_scan_container);
@@ -802,7 +753,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
dev_set_msi_domain(&mc_dev->dev, NULL);
}
 
-   dprc_cleanup_all_resource_pools(mc_dev);
+   fsl_mc_cleanup_all_resource_pools(mc_dev);
 
error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
if (error < 0)
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
index 6550564..9695f44 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
@@ -668,6 +668,55 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev)
 }
 EXPORT_SYMBOL_GPL(fsl_mc_free_irqs);
 
+void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
+{
+   int pool_type;
+   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
+
+   for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++) {
+   struct fsl_mc_resource_pool *res_pool =
+   &mc_bus->resource_pools[pool_type];
+
+   res_pool->type = pool_type;
+   res_pool->max_count = 0;
+   res_pool->free_count = 0;
+   res_pool->mc_bus = mc_bus;
+   INIT_LIST_HEAD(&res_pool->free_list);
+   mutex_init(&res_pool->mutex);
+   }
+}
+
+static void fsl_mc_cleanup_resource_pool(struct fsl_mc_device *mc_bus_dev,
+enum fsl_mc_pool_type pool_type)
+{
+   struct fsl_mc_resource *resource;
+   struct fsl_mc_resource *next;
+   struct fsl_mc_bus

[PATCH 10/14] staging: fsl-mc: move bus definitions from mc.h to mc-bus.h

2016-08-23 Thread Stuart Yoder
move public bus-related definitions to the proper mc-bus.h header.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/include/mc-bus.h | 16 
 drivers/staging/fsl-mc/include/mc.h | 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/fsl-mc/include/mc-bus.h 
b/drivers/staging/fsl-mc/include/mc-bus.h
index 7eba588..2cdb538 100644
--- a/drivers/staging/fsl-mc/include/mc-bus.h
+++ b/drivers/staging/fsl-mc/include/mc-bus.h
@@ -24,6 +24,13 @@ struct msi_domain_info;
  */
 #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256
 
+#ifdef CONFIG_FSL_MC_BUS
+#define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type)
+#else
+/* If fsl-mc bus is not present device cannot belong to fsl-mc bus */
+#define dev_is_fsl_mc(_dev) (0)
+#endif
+
 /**
  * struct fsl_mc_resource_pool - Pool of MC resources of a given
  * type
@@ -93,4 +100,13 @@ void fsl_mc_init_all_resource_pools(struct fsl_mc_device 
*mc_bus_dev);
 
 void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
 
+bool fsl_mc_bus_exists(void);
+
+void fsl_mc_get_root_dprc(struct device *dev,
+ struct device **root_dprc_dev);
+
+bool fsl_mc_is_root_dprc(struct device *dev);
+
+extern struct bus_type fsl_mc_bus_type;
+
 #endif /* _FSL_MC_MCBUS_H_ */
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index b093aba..789e6a8 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -160,13 +160,6 @@ struct fsl_mc_device {
 #define to_fsl_mc_device(_dev) \
container_of(_dev, struct fsl_mc_device, dev)
 
-#ifdef CONFIG_FSL_MC_BUS
-#define dev_is_fsl_mc(_dev) ((_dev)->bus == &fsl_mc_bus_type)
-#else
-/* If fsl-mc bus is not present device cannot belong to fsl-mc bus */
-#define dev_is_fsl_mc(_dev) (0)
-#endif
-
 /*
  * module_fsl_mc_driver() - Helper macro for drivers that don't do
  * anything special in module init/exit.  This eliminates a lot of
@@ -188,11 +181,6 @@ int __must_check __fsl_mc_driver_register(struct 
fsl_mc_driver *fsl_mc_driver,
 
 void fsl_mc_driver_unregister(struct fsl_mc_driver *driver);
 
-bool fsl_mc_bus_exists(void);
-
-void fsl_mc_get_root_dprc(struct device *dev,
- struct device **root_dprc_dev);
-
 int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
u16 mc_io_flags,
struct fsl_mc_io **new_mc_io);
@@ -211,8 +199,4 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device 
*mc_dev);
 
 void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
 
-bool fsl_mc_is_root_dprc(struct device *dev);
-
-extern struct bus_type fsl_mc_bus_type;
-
 #endif /* _FSL_MC_H_ */
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/14] staging: fsl-mc: restructuring and cleanup

2016-08-23 Thread Stuart Yoder
In preparation for moving this driver out of staging a review of the
.h files intended to be public in include/linux/fsl turned up some
needed cleanup.  This patch series makes no functional changes to 
the driver, but does some restructuring to put public/private
definitions in the right places and have a clear split between
driver sub-components.
   -update the public mc.h and mc-bus.h files to contain only public
definitions
   -move all private definitions to their corresponding .c files or
to the new fsl-mc-private.h file for definitions private to the
bus driver
   -rename some source files to improve clarity
   -create a new mc-io component to contain all APIs related to the
mc-io abstraction
   -remove unneeded includes and forward definitions

Stuart Yoder (14):
  staging: fsl-mc: rename mc-private.h to mc-bus.h
  staging: fsl-mc: improve naming of source files
  staging: fsl-mc: move allocator private definitions out of mc-bus.h
  staging: fsl-mc: move resource pool init/cleanup into allocator
  staging: fsl-mc: create private include for fsl-mc bus components
  staging: fsl-mc: move dprc-driver private definitions out of mc-bus.h
  staging: fsl-mc: move bus private definitions into fsl-mc-bus.c
  staging: fsl-mc: make fsl_mc_get_root_dprc public
  staging: fsl-mc: remove unneeded forward declarations
  staging: fsl-mc: move bus definitions from mc.h to mc-bus.h
  staging: fsl-mc: remove unneeded includes
  staging: fsl-mc: split mc-io definitions into a separate file
  staging: fsl-mc: explicitly include files where they are needed
  staging: fsl-mc: make order of includes consistent

 drivers/staging/fsl-mc/bus/Makefile|   7 +-
 drivers/staging/fsl-mc/bus/dpmcp.c |   1 +
 drivers/staging/fsl-mc/bus/dpmng.c |   1 +
 drivers/staging/fsl-mc/bus/dprc-driver.c   |  67 +
 drivers/staging/fsl-mc/bus/dprc.c  |   1 +
 .../bus/{mc-allocator.c => fsl-mc-allocator.c} | 202 -
 .../staging/fsl-mc/bus/{mc-bus.c => fsl-mc-bus.c}  |  43 ++-
 .../staging/fsl-mc/bus/{mc-msi.c => fsl-mc-msi.c}  |   4 +-
 drivers/staging/fsl-mc/bus/fsl-mc-private.h|  52 
 .../staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c |   4 +-
 drivers/staging/fsl-mc/bus/mc-io.c | 320 +
 drivers/staging/fsl-mc/bus/mc-sys.c| 155 +-
 .../fsl-mc/include/{mc-private.h => mc-bus.h}  |  91 ++
 drivers/staging/fsl-mc/include/mc-sys.h|  15 -
 drivers/staging/fsl-mc/include/mc.h|  20 --
 15 files changed, 520 insertions(+), 463 deletions(-)
 rename drivers/staging/fsl-mc/bus/{mc-allocator.c => fsl-mc-allocator.c} (80%)
 rename drivers/staging/fsl-mc/bus/{mc-bus.c => fsl-mc-bus.c} (94%)
 rename drivers/staging/fsl-mc/bus/{mc-msi.c => fsl-mc-msi.c} (98%)
 create mode 100644 drivers/staging/fsl-mc/bus/fsl-mc-private.h
 create mode 100644 drivers/staging/fsl-mc/bus/mc-io.c
 rename drivers/staging/fsl-mc/include/{mc-private.h => mc-bus.h} (53%)

-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/14] staging: fsl-mc: create private include for fsl-mc bus components

2016-08-23 Thread Stuart Yoder
The mc-bus.h header file is intended to be public for system related
drivers that may need to make fsl-mc bus specific calls-- gic its,
smmu, vfio.  But, currently it contains definitions private/internal
to the fsl-mc bus itself.  Split those definitions out into a new
fsl-mc bus private header.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c  |  1 +
 drivers/staging/fsl-mc/bus/fsl-mc-allocator.c |  1 +
 drivers/staging/fsl-mc/bus/fsl-mc-bus.c   |  1 +
 drivers/staging/fsl-mc/bus/fsl-mc-private.h   | 44 +++
 drivers/staging/fsl-mc/include/mc-bus.h   | 23 --
 5 files changed, 47 insertions(+), 23 deletions(-)
 create mode 100644 drivers/staging/fsl-mc/bus/fsl-mc-private.h

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 89d53da..576244b 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include "dprc-cmd.h"
+#include "fsl-mc-private.h"
 
 struct dprc_child_objs {
int child_count;
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
index 9695f44..e865375 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
@@ -15,6 +15,7 @@
 #include "../include/dpcon-cmd.h"
 #include "dpmcp-cmd.h"
 #include "dpmcp.h"
+#include "fsl-mc-private.h"
 #include 
 
 #define FSL_MC_IS_ALLOCATABLE(_obj_type) \
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
index 975d30b..180ff07 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
@@ -20,6 +20,7 @@
 #include 
 #include "../include/dpmng.h"
 #include "../include/mc-sys.h"
+#include "fsl-mc-private.h"
 #include "dprc-cmd.h"
 
 static struct kmem_cache *mc_dev_cache;
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-private.h 
b/drivers/staging/fsl-mc/bus/fsl-mc-private.h
new file mode 100644
index 000..1479934
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-private.h
@@ -0,0 +1,44 @@
+/*
+ * Freescale Management Complex (MC) bus private declarations
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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_PRIVATE_H_
+#define _FSL_MC_PRIVATE_H_
+
+int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
+  struct fsl_mc_io *mc_io,
+  struct device *parent_dev,
+  struct fsl_mc_device **new_mc_dev);
+
+void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
+
+int __init dprc_driver_init(void);
+
+void dprc_driver_exit(void);
+
+int __init fsl_mc_allocator_driver_init(void);
+
+void fsl_mc_allocator_driver_exit(void);
+
+int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
+ enum fsl_mc_pool_type pool_type,
+ struct fsl_mc_resource
+ **new_resource);
+
+void fsl_mc_resource_free(struct fsl_mc_resource *resource);
+
+int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
+unsigned int irq_count);
+
+void fsl_mc_msi_domain_free_irqs(struct device *dev);
+
+int __init its_fsl_mc_msi_init(void);
+
+void its_fsl_mc_msi_cleanup(void);
+
+#endif /* _FSL_MC_PRIVATE_H_ */
diff --git a/drivers/staging/fsl-mc/include/mc-bus.h 
b/drivers/staging/fsl-mc/include/mc-bus.h
index 2098b3c..8a32e55 100644
--- a/drivers/staging/fsl-mc/include/mc-bus.h
+++ b/drivers/staging/fsl-mc/include/mc-bus.h
@@ -102,13 +102,6 @@ struct fsl_mc_bus {
 #define to_fsl_mc_bus(_mc_dev) \
container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
 
-int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
-  struct fsl_mc_io *mc_io,
-  struct device *parent_dev,
-  struct fsl_mc_device **new_mc_dev);
-
-void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
-
 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev);
 
 int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
@@ -122,13 +115,6 @@ int __init fsl_mc_allocator_driver_init(void);
 
 void fsl_mc_allocator_driver_exit(void);
 
-int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
- enum fsl_mc_pool_type pool_type,
- struct fsl_mc_resource
- **new_resource);
-
-v

[PATCH 07/14] staging: fsl-mc: move bus private definitions into fsl-mc-bus.c

2016-08-23 Thread Stuart Yoder
Move definitions that are private to fsl-mc-bus.c out of the
public mc-bus.h and mc.h headers.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 33 +
 drivers/staging/fsl-mc/include/mc-bus.h | 28 
 drivers/staging/fsl-mc/include/mc.h |  5 -
 3 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
index 180ff07..08363f8 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
@@ -26,6 +26,39 @@
 static struct kmem_cache *mc_dev_cache;
 
 /**
+ * Default DMA mask for devices on a fsl-mc bus
+ */
+#define FSL_MC_DEFAULT_DMA_MASK(~0ULL)
+
+/**
+ * struct fsl_mc - Private data of a "fsl,qoriq-mc" platform device
+ * @root_mc_bus_dev: MC object device representing the root DPRC
+ * @num_translation_ranges: number of entries in addr_translation_ranges
+ * @translation_ranges: array of bus to system address translation ranges
+ */
+struct fsl_mc {
+   struct fsl_mc_device *root_mc_bus_dev;
+   u8 num_translation_ranges;
+   struct fsl_mc_addr_translation_range *translation_ranges;
+};
+
+/**
+ * struct fsl_mc_addr_translation_range - bus to system address translation
+ * range
+ * @mc_region_type: Type of MC region for the range being translated
+ * @start_mc_offset: Start MC offset of the range being translated
+ * @end_mc_offset: MC offset of the first byte after the range (last MC
+ * offset of the range is end_mc_offset - 1)
+ * @start_phys_addr: system physical address corresponding to start_mc_addr
+ */
+struct fsl_mc_addr_translation_range {
+   enum dprc_region_type mc_region_type;
+   u64 start_mc_offset;
+   u64 end_mc_offset;
+   phys_addr_t start_phys_addr;
+};
+
+/**
  * fsl_mc_bus_match - device to driver matching callback
  * @dev: the MC object device structure to match against
  * @drv: the device driver to search for matching MC object device id
diff --git a/drivers/staging/fsl-mc/include/mc-bus.h 
b/drivers/staging/fsl-mc/include/mc-bus.h
index 3f80506..9ea023b 100644
--- a/drivers/staging/fsl-mc/include/mc-bus.h
+++ b/drivers/staging/fsl-mc/include/mc-bus.h
@@ -29,34 +29,6 @@ struct irq_domain;
 struct msi_domain_info;
 
 /**
- * struct fsl_mc - Private data of a "fsl,qoriq-mc" platform device
- * @root_mc_bus_dev: MC object device representing the root DPRC
- * @num_translation_ranges: number of entries in addr_translation_ranges
- * @translation_ranges: array of bus to system address translation ranges
- */
-struct fsl_mc {
-   struct fsl_mc_device *root_mc_bus_dev;
-   u8 num_translation_ranges;
-   struct fsl_mc_addr_translation_range *translation_ranges;
-};
-
-/**
- * struct fsl_mc_addr_translation_range - bus to system address translation
- * range
- * @mc_region_type: Type of MC region for the range being translated
- * @start_mc_offset: Start MC offset of the range being translated
- * @end_mc_offset: MC offset of the first byte after the range (last MC
- * offset of the range is end_mc_offset - 1)
- * @start_phys_addr: system physical address corresponding to start_mc_addr
- */
-struct fsl_mc_addr_translation_range {
-   enum dprc_region_type mc_region_type;
-   u64 start_mc_offset;
-   u64 end_mc_offset;
-   phys_addr_t start_phys_addr;
-};
-
-/**
  * struct fsl_mc_resource_pool - Pool of MC resources of a given
  * type
  * @type: type of resources in the pool
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index 2d67535..ab439fa 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -112,11 +112,6 @@ struct fsl_mc_device_irq {
 #define FSL_MC_IS_DPRC 0x0001
 
 /**
- * Default DMA mask for devices on a fsl-mc bus
- */
-#define FSL_MC_DEFAULT_DMA_MASK(~0ULL)
-
-/**
  * struct fsl_mc_device - MC object device object
  * @dev: Linux driver model device object
  * @dma_mask: Default DMA mask
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/14] staging: fsl-mc: remove unneeded forward declarations

2016-08-23 Thread Stuart Yoder
Remove unneeded and duplicated forward declarations.

Signed-off-by: Stuart Yoder 
---
 drivers/staging/fsl-mc/include/mc-bus.h | 4 
 drivers/staging/fsl-mc/include/mc.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/drivers/staging/fsl-mc/include/mc-bus.h 
b/drivers/staging/fsl-mc/include/mc-bus.h
index 9ea023b..7eba588 100644
--- a/drivers/staging/fsl-mc/include/mc-bus.h
+++ b/drivers/staging/fsl-mc/include/mc-bus.h
@@ -24,10 +24,6 @@ struct msi_domain_info;
  */
 #define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256
 
-struct device_node;
-struct irq_domain;
-struct msi_domain_info;
-
 /**
  * struct fsl_mc_resource_pool - Pool of MC resources of a given
  * type
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index a71342d..b093aba 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -21,7 +21,6 @@
 
 struct fsl_mc_device;
 struct fsl_mc_io;
-struct fsl_mc_bus;
 
 /**
  * struct fsl_mc_driver - MC object device driver object
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >