[PATCH] staging: ks7010: ks7010_sdio.c: Fixing multiple assignments

2016-10-21 Thread Nick Rosbrook
Running checkpatch on ks7010_sdio.c shows two locations where
multiple assignment statements are used.

This patch modifies the assignments into single assignments.

Signed-off-by: Nick Rosbrook 
---
 drivers/staging/ks7010/ks7010_sdio.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b02980d..6771cd8 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -659,10 +659,12 @@ static void ks_sdio_interrupt(struct sdio_func *func)
 static int trx_device_init(struct ks_wlan_private *priv)
 {
/* initialize values (tx) */
-   priv->tx_dev.qtail = priv->tx_dev.qhead = 0;
+   priv->tx_dev.qhead = 0;
+   priv->tx_dev.qtail = 0;
 
/* initialize values (rx) */
-   priv->rx_dev.qtail = priv->rx_dev.qhead = 0;
+   priv->rx_dev.qhead = 0;
+   priv->rx_dev.qtail = 0;
 
/* initialize spinLock (tx,rx) */
spin_lock_init(&priv->tx_dev.tx_dev_lock);
-- 
2.7.4

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


Re: [PATCH] vme: Convert documentation to reStructuredText, move under driver APIs

2016-10-21 Thread Jonathan Corbet
On Fri, 21 Oct 2016 22:15:27 +0100
Martyn Welch  wrote:

> Perform a relatively simple conversion of vme_api.txt to reStructuredText
> and move under driver-api, which seems the most logical place for this
> documentation.

Makes sense to me, applied to the docs tree.

Now if only the VME stuff had proper kerneldoc comments in the source! :)

Thanks,

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


[PATCH] vme: Convert documentation to reStructuredText, move under driver APIs

2016-10-21 Thread Martyn Welch
From: Martyn Welch 

Perform a relatively simple conversion of vme_api.txt to reStructuredText
and move under driver-api, which seems the most logical place for this
documentation.

Signed-off-by: Martyn Welch 
---
 Documentation/driver-api/index.rst|   1 +
 Documentation/{vme_api.txt => driver-api/vme.rst} | 115 +-
 MAINTAINERS   |   2 +-
 3 files changed, 90 insertions(+), 28 deletions(-)
 rename Documentation/{vme_api.txt => driver-api/vme.rst} (92%)

diff --git a/Documentation/driver-api/index.rst 
b/Documentation/driver-api/index.rst
index 8e259c5d..b567907 100644
--- a/Documentation/driver-api/index.rst
+++ b/Documentation/driver-api/index.rst
@@ -24,3 +24,4 @@ available subsections can be seen below.
i2c
hsi
miscellaneous
+   vme
diff --git a/Documentation/vme_api.txt b/Documentation/driver-api/vme.rst
similarity index 92%
rename from Documentation/vme_api.txt
rename to Documentation/driver-api/vme.rst
index 9000655..89776fb 100644
--- a/Documentation/vme_api.txt
+++ b/Documentation/driver-api/vme.rst
@@ -1,13 +1,15 @@
-   VME Device Driver API
-   =
+VME Device Drivers
+==
 
 Driver registration
-===
+---
 
 As with other subsystems within the Linux kernel, VME device drivers register
 with the VME subsystem, typically called from the devices init routine.  This 
is
 achieved via a call to the following function:
 
+.. code-block:: c
+
int vme_register_driver (struct vme_driver *driver, unsigned int ndevs);
 
 If driver registration is successful this function returns zero, if an error
@@ -17,6 +19,8 @@ A pointer to a structure of type 'vme_driver' must be 
provided to the
 registration function. Along with ndevs, which is the number of devices your
 driver is able to support. The structure is as follows:
 
+.. code-block:: c
+
struct vme_driver {
struct list_head node;
const char *name;
@@ -38,6 +42,8 @@ with the driver. The match function should return 1 if a 
device should be
 probed and 0 otherwise. This example match function (from vme_user.c) limits
 the number of devices probed to one:
 
+.. code-block:: c
+
#define USER_BUS_MAX1
...
static int vme_user_match(struct vme_dev *vdev)
@@ -51,6 +57,8 @@ The '.probe' element should contain a pointer to the probe 
routine. The
 probe routine is passed a 'struct vme_dev' pointer as an argument. The
 'struct vme_dev' structure looks like the following:
 
+.. code-block:: c
+
struct vme_dev {
int num;
struct vme_bridge *bridge;
@@ -66,11 +74,13 @@ dev->bridge->num.
 A function is also provided to unregister the driver from the VME core and is
 usually called from the device driver's exit routine:
 
+.. code-block:: c
+
void vme_unregister_driver (struct vme_driver *driver);
 
 
 Resource management
-===
+---
 
 Once a driver has registered with the VME core the provided match routine will
 be called the number of times specified during the registration. If a match
@@ -86,6 +96,8 @@ specific window or DMA channel (which may be used by a 
different driver) this
 driver allows a resource to be assigned based on the required attributes of the
 driver in question:
 
+.. code-block:: c
+
struct vme_resource * vme_master_request(struct vme_dev *dev,
u32 aspace, u32 cycle, u32 width);
 
@@ -112,6 +124,8 @@ Functions are also provided to free window allocations once 
they are no longer
 required. These functions should be passed the pointer to the resource provided
 during resource allocation:
 
+.. code-block:: c
+
void vme_master_free(struct vme_resource *res);
 
void vme_slave_free(struct vme_resource *res);
@@ -120,7 +134,7 @@ during resource allocation:
 
 
 Master windows
-==
+--
 
 Master windows provide access from the local processor[s] out onto the VME bus.
 The number of windows available and the available access modes is dependent on
@@ -128,11 +142,13 @@ the underlying chipset. A window must be configured 
before it can be used.
 
 
 Master window configuration

+~~~
 
 Once a master window has been assigned the following functions can be used to
 configure it and retrieve the current settings:
 
+.. code-block:: c
+
int vme_master_set (struct vme_resource *res, int enabled,
unsigned long long base, unsigned long long size, u32 aspace,
u32 cycle, u32 width);
@@ -149,11 +165,13 @@ These functions return 0 on success or an error code 
should the call fail.
 
 
 Master window access
-
+
 
 The following functions can be used to read from and write to configured master
 windows. These functions return the number of by

Re: [PATCH v2 3/3] doc: add documentation for uio-hv-generic

2016-10-21 Thread Jonathan Corbet
On Mon, 17 Oct 2016 12:33:19 -0700
Stephen Hemminger  wrote:

> From: Stephen Hemminger 
> 
> Update UIO documentation to include basic information about
> uio_hv_generic.

I've applied this to the docs tree, thanks.

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


[PATCH] vme: vme_get_size potentially returning incorrect value on failure

2016-10-21 Thread Martyn Welch
The function vme_get_size returns the size of the window to the caller,
however it doesn't check the return value of the call to vme_master_get.

Return 0 on failure rather than anything else.

Suggested-by: Dan Carpenter 
Signed-off-by: Martyn Welch 
---
 drivers/vme/vme.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 15b6407..bdbadaa 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -156,12 +156,16 @@ size_t vme_get_size(struct vme_resource *resource)
case VME_MASTER:
retval = vme_master_get(resource, &enabled, &base, &size,
&aspace, &cycle, &dwidth);
+   if (retval)
+   return 0;
 
return size;
break;
case VME_SLAVE:
retval = vme_slave_get(resource, &enabled, &base, &size,
&buf_base, &aspace, &cycle);
+   if (retval)
+   return 0;
 
return size;
break;
-- 
2.1.4

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


[PATCH] Staging:vt6656:main_usb: fix Block comments should align the * on each line

2016-10-21 Thread Nadim Almas
Block comments should align the * on each line as reported by checkpatch.pl

Signed-off-by: Nadim Almas 
---
 drivers/staging/vt6656/main_usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index fe84da3..50d02d9 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -326,9 +326,9 @@ static int vnt_init_registers(struct vnt_private *priv)
priv->current_net_addr);
 
/*
-   * set BB and packet type at the same time
-   * set Short Slot Time, xIFS, and RSPINF
-   */
+* set BB and packet type at the same time
+* set Short Slot Time, xIFS, and RSPINF
+*/
if (priv->bb_type == BB_TYPE_11A)
priv->short_slot_time = true;
else
-- 
2.7.4

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


Re: [bug report] vme: Adding Fake VME driver

2016-10-21 Thread Martyn Welch
On Fri, Sep 30, 2016 at 02:37:01PM +0300, Dan Carpenter wrote:
> Hello Martyn Welch,
> 
> The patch 658bcdae9c67: "vme: Adding Fake VME driver" from Jul 7,
> 2016, leads to the following static checker warning:
> 
>   drivers/vme/bridges/vme_fake.c:338 fake_master_set()
>   warn: 'spin_lock:&image->lock' is sometimes locked here and sometimes 
> unlocked.
> 
> drivers/vme/bridges/vme_fake.c
>255  static int fake_master_set(struct vme_master_resource *image, int 
> enabled,
>256  unsigned long long vme_base, unsigned long long size,
>257  u32 aspace, u32 cycle, u32 dwidth)
>258  {
>259  int retval = 0;
>260  unsigned int i;
>261  struct vme_bridge *fake_bridge;
>262  struct fake_driver *bridge;
>263  
>264  fake_bridge = image->parent;
>265  
>266  bridge = fake_bridge->driver_priv;
>267  
>268  /* Verify input data */
>269  if (vme_base & 0x) {
> 
> Unlock?
> 

Wei Yongjun removed the spurious spin_unlock()'s in the other code paths in
commit db08948b97180a3c9f49ce91caf1fb643a8110be. I assume that was why the
static checker was suggesting locking here...

Martyn

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


[PATCH]: Staging: Greybus: Fix trailing */ in block comments

2016-10-21 Thread Rahul Krishnan
This patch fixes the following checkpath.pl warning
WARNING: Block comments use a trailing */ on a separate line

Signed-off-by: Rahul Krishnan  
---
 drivers/staging/greybus/log.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/log.c b/drivers/staging/greybus/log.c
index 70dd9e5..1a18ab1 100644
--- a/drivers/staging/greybus/log.c
+++ b/drivers/staging/greybus/log.c
@@ -55,8 +55,10 @@ static int gb_log_request_handler(struct gb_operation *op)
/* Ensure the buffer is 0 terminated */
receive->msg[len - 1] = '\0';
 
-   /* Print with dev_dbg() so that it can be easily turned off using
-* dynamic debugging (and prevent any DoS) */
+   /*
+* Print with dev_dbg() so that it can be easily turned off using
+* dynamic debugging (and prevent any DoS)
+*/
dev_dbg(dev, "%s", receive->msg);
 
return 0;
-- 
1.9.1

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


Re: [PATCH net-next] hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf()

2016-10-21 Thread David Miller
From: Vitaly Kuznetsov 
Date: Wed, 19 Oct 2016 15:53:01 +0200

> Fix in commit 880988348270 ("hv_netvsc: set nvdev link after populating
> chn_table") turns out to be incomplete. A crash in
> netvsc_get_next_send_section() is observed on mtu change when the device
> is under load. The race I identified is: if we get to netvsc_send() after
> we set net_device_ctx->nvdev link in netvsc_device_add() but before we
> finish netvsc_connect_vsp()->netvsc_init_buf() send_section_map is not
> allocated and we crash. Unfortunately we can't set net_device_ctx->nvdev
> link after the netvsc_init_buf() call as during the negotiation we need
> to receive packets and on the receive path we check for it. It would
> probably be possible to split nvdev into a pair of nvdev_in and nvdev_out
> links and check them accordingly in get_outbound_net_device()/
> get_inbound_net_device() but this looks like an overkill.
> 
> Check that send_section_map is allocated in netvsc_send().
> 
> Signed-off-by: Vitaly Kuznetsov 

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


Re: [PATCH net-next] hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf()

2016-10-21 Thread David Miller
From: Vitaly Kuznetsov 
Date: Fri, 21 Oct 2016 17:17:18 +0200

> David Miller  writes:
> 
>> From: Vitaly Kuznetsov 
>> Date: Fri, 21 Oct 2016 13:15:53 +0200
>>
>>> David Miller  writes:
>>> 
 From: Vitaly Kuznetsov 
 Date: Thu, 20 Oct 2016 10:51:04 +0200

> Stephen Hemminger  writes:
> 
>> Do we need ACCESS_ONCE() here to avoid check/use issues?
>>
> 
> I think we don't: this is the only place in the function where we read
> the variable so we'll get normal read. We're not trying to syncronize
> with netvsc_init_buf() as that would require locking, if we read stale
> NULL value after it was already updated on a different CPU we're fine,
> we'll just return -EAGAIN.

 The concern is if we race with netvsc_destroy_buf() and this pointer
 becomes NULL after the test you are adding.
>>> 
>>> Thanks, this is interesting.
>>> 
>>> We may reach to netvsc_destroy_buf() by 3 pathes:
>>> 
>>> 1) cleanup path in netvsc_init_buf(). It is never called with
>>> send_section_map being not NULL so it seems we're safe.
>>> 
>>> 2) from netvsc_remove() when the device is being removed. As far as I
>>> understand we can't be on the transmit path after we call
>>> unregister_netdev() so we're safe.
>>> 
>>> 3) from netvsc_change_mtu() and netvsc_set_channels(). These pathes are
>>> specific to netvsc driver as basically we need to remove the device and
>>> add it back to change mtu/number of channels. The underligning 'struct
>>> net_device' stays but the rest is being removed and added back. On both
>>> pathes we first call netvsc_close() which does netif_tx_disable() and as
>>> far as I understand (I may be wrong) this guarantees that we won't be in
>>> netvsc_send().
>>> 
>>> So *I think* that we can't ever free send_section_map while in
>>> netvsc_send() and we can't even get to netvsc_send() after it is freed
>>> but I may have missed something.
>>
>> Ok you may be right.
>>
>> Can't the device be taken down by asynchronous events as well?  For example
>> if the peer end of the interface in the other guest disappears.
> 
> The device may be hot removed from host's side. In this case we follow
> the following call chain:
> 
> ... -> vmbus_device_unregister() -> ... -> vmbus_remove() -> netvsc_remove()
> 
>  and netvsc_remove() does netif_tx_disable(); unregister_netdev();
> before calling rndis_filter_device_remove() leading to netvsc_destroy_buf().
> 
> So it seems we can't be in netvsc_send() when the device is
> disappearing.

Ok, it all looks good then.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next] hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf()

2016-10-21 Thread Vitaly Kuznetsov
David Miller  writes:

> From: Vitaly Kuznetsov 
> Date: Fri, 21 Oct 2016 13:15:53 +0200
>
>> David Miller  writes:
>> 
>>> From: Vitaly Kuznetsov 
>>> Date: Thu, 20 Oct 2016 10:51:04 +0200
>>>
 Stephen Hemminger  writes:
 
> Do we need ACCESS_ONCE() here to avoid check/use issues?
>
 
 I think we don't: this is the only place in the function where we read
 the variable so we'll get normal read. We're not trying to syncronize
 with netvsc_init_buf() as that would require locking, if we read stale
 NULL value after it was already updated on a different CPU we're fine,
 we'll just return -EAGAIN.
>>>
>>> The concern is if we race with netvsc_destroy_buf() and this pointer
>>> becomes NULL after the test you are adding.
>> 
>> Thanks, this is interesting.
>> 
>> We may reach to netvsc_destroy_buf() by 3 pathes:
>> 
>> 1) cleanup path in netvsc_init_buf(). It is never called with
>> send_section_map being not NULL so it seems we're safe.
>> 
>> 2) from netvsc_remove() when the device is being removed. As far as I
>> understand we can't be on the transmit path after we call
>> unregister_netdev() so we're safe.
>> 
>> 3) from netvsc_change_mtu() and netvsc_set_channels(). These pathes are
>> specific to netvsc driver as basically we need to remove the device and
>> add it back to change mtu/number of channels. The underligning 'struct
>> net_device' stays but the rest is being removed and added back. On both
>> pathes we first call netvsc_close() which does netif_tx_disable() and as
>> far as I understand (I may be wrong) this guarantees that we won't be in
>> netvsc_send().
>> 
>> So *I think* that we can't ever free send_section_map while in
>> netvsc_send() and we can't even get to netvsc_send() after it is freed
>> but I may have missed something.
>
> Ok you may be right.
>
> Can't the device be taken down by asynchronous events as well?  For example
> if the peer end of the interface in the other guest disappears.

The device may be hot removed from host's side. In this case we follow
the following call chain:

... -> vmbus_device_unregister() -> ... -> vmbus_remove() -> netvsc_remove()

 and netvsc_remove() does netif_tx_disable(); unregister_netdev();
before calling rndis_filter_device_remove() leading to netvsc_destroy_buf().

So it seems we can't be in netvsc_send() when the device is
disappearing.

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


Re: [PATCH net-next] hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf()

2016-10-21 Thread David Miller
From: Vitaly Kuznetsov 
Date: Fri, 21 Oct 2016 13:15:53 +0200

> David Miller  writes:
> 
>> From: Vitaly Kuznetsov 
>> Date: Thu, 20 Oct 2016 10:51:04 +0200
>>
>>> Stephen Hemminger  writes:
>>> 
 Do we need ACCESS_ONCE() here to avoid check/use issues?

>>> 
>>> I think we don't: this is the only place in the function where we read
>>> the variable so we'll get normal read. We're not trying to syncronize
>>> with netvsc_init_buf() as that would require locking, if we read stale
>>> NULL value after it was already updated on a different CPU we're fine,
>>> we'll just return -EAGAIN.
>>
>> The concern is if we race with netvsc_destroy_buf() and this pointer
>> becomes NULL after the test you are adding.
> 
> Thanks, this is interesting.
> 
> We may reach to netvsc_destroy_buf() by 3 pathes:
> 
> 1) cleanup path in netvsc_init_buf(). It is never called with
> send_section_map being not NULL so it seems we're safe.
> 
> 2) from netvsc_remove() when the device is being removed. As far as I
> understand we can't be on the transmit path after we call
> unregister_netdev() so we're safe.
> 
> 3) from netvsc_change_mtu() and netvsc_set_channels(). These pathes are
> specific to netvsc driver as basically we need to remove the device and
> add it back to change mtu/number of channels. The underligning 'struct
> net_device' stays but the rest is being removed and added back. On both
> pathes we first call netvsc_close() which does netif_tx_disable() and as
> far as I understand (I may be wrong) this guarantees that we won't be in
> netvsc_send().
> 
> So *I think* that we can't ever free send_section_map while in
> netvsc_send() and we can't even get to netvsc_send() after it is freed
> but I may have missed something.

Ok you may be right.

Can't the device be taken down by asynchronous events as well?  For example
if the peer end of the interface in the other guest disappears.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2016-10-21 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 
---
 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 | 198 
 drivers/bus/fsl-mc/dpio/dpio.c | 229 +
 drivers/bus/fsl-mc/dpio/dpio.h | 108 +
 6 files changed, 557 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..b25a4cc
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/dpio-cmd.h
@@ -0,0 +1,198 @@
+/*
+ * 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_CREATE  DPIO_CMD(0x903)
+#define DPIO_CMDID_DESTROY DPIO_

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

2016-10-21 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.

This series depends on the patch series:
  [PATCH 00/14] staging: fsl-mc: cleanup and uprev to MC v10.x
  https://www.spinics.net/lists/kernel/msg2362567.html

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|6 +
 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 |  198 
 drivers/bus/fsl-mc/dpio/dpio-driver.c  |  289 ++
 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 | 1009 
 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 +
 .../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 -
 include/linux/fsl/dpaa2-fd.h   |  415 
 include/linux/fsl/dpaa2-global.h   |  203 
 include/linux/fsl/dpaa2-io.h   |  138 +++
 .../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 => i

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

2016-10-21 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 
---
 drivers/bus/fsl-mc/dpio/Makefile   |2 +-
 drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009 
 drivers/bus/fsl-mc/dpio/qbman-portal.h |  464 +++
 3 files changed, 1474 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..1eb3dd9
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c
@@ -0,0 +1,1009 @@
+/*
+ * 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)
+
+/* 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_SDQCR_SRC_SHIFT  0
+#define QB_SDQCR_SRC_MASK   0xff
+
+enum qbman_sdqcr_dct {
+   qbman_sdqcr_dct_null = 0,
+   qbman_sdqcr_dct_prio_ics,
+   qbman_sdqcr_dct_active_ics,
+   qbman_sdqcr_dct_active
+};
+
+enum qbman_sdqcr_fc {
+   qbman_sdqcr_fc_one = 0,
+   qbman_sdqcr_fc_up_to_3 = 1
+};
+
+/* Portal Access */
+
+static inline u32 qbman_read_register(struct qbman_swp *p, u32 offset)
+{
+   return readl_relaxed(p->addr_cinh + offset);
+}
+
+static inline void qbman_write_register(struct qbman_swp *p, u32 offset,
+   u32 value)
+{
+   writel_relaxed(value, p->addr_cinh 

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

2016-10-21 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 
---
 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..7a455a7
--- /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 >= NR_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 specific cpu was requested, pick it up immediately */
+   return dpio_by_cpu[cpu];
+}
+
+static inline struct dpaa2_io *service_select(struct dpaa2_io *d)
+{
+   if (d)
+   return d;
+
+   spin_lock(&dpio_list_lock);
+   d = list_entry(dpio_list.next, struct dpaa2_io, node);
+   

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

2016-10-21 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.
+
+   Notification handling
+ 

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

2016-10-21 Thread Stuart Yoder
From: Roy Pledge 

add Roy Pledge as maintainer of DPIO

Signed-off-by: Roy Pledge 
Signed-off-by: Stuart Yoder 
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 797a08a..1aa991e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5097,6 +5097,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-mc/
 
+DPAA2 DATAPATH I/O (DPIO) DRIVER
+M: Roy Pledge 
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/bus/fsl-mc/dpio
+
 FREEVXFS FILESYSTEM
 M: Christoph Hellwig 
 W: ftp://ftp.openlinux.org/pub/people/hch/vxfs
-- 
1.9.0

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


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

2016-10-21 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 
---
 drivers/bus/fsl-mc/dpio/Makefile  |   2 +-
 drivers/bus/fsl-mc/dpio/dpio-driver.c | 289 ++
 2 files changed, 290 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..ad04a2c
--- /dev/null
+++ b/drivers/bus/fsl-mc/dpio/dpio-driver.c
@@ -0,0 +1,289 @@
+/*
+ * 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, &mask);
+   if (irq_set_affinity_hint(irq->msi_desc->irq, &mask))
+   dev_err(&dpio_dev->dev,
+  "irq_set_affinity failed irq %d cpu %d\n",
+  irq->msi_desc->irq, cpu);
+
+   return 0;
+}
+
+static int dpaa2_dp

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

2016-10-21 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 
---
 include/linux/fsl/dpaa2-fd.h | 415 +++
 1 file changed, 415 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..b3fa9ff
--- /dev/null
+++ b/include/linux/fsl/dpaa2-fd.h
@@ -0,0 +1,415 @@
+/*
+ * 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 and offset 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_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 given frame descriptor
+ * @addr: the address needs to be set in frame descriptor
+ */
+static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
+{
+   fd->simple.addr = addr;
+}
+
+/**
+ * dpaa2_fd_get_frc() - Get the frame context in the frame descriptor
+ * @fd: the given frame descriptor
+ *
+ * Return the frame context field in

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

2016-10-21 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

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

cc: Thomas Gleixner 
cc: Jason Cooper 
cc: Marc Zyngier 
Signed-off-by: Stuart Yoder 
---
 .../README.txt => Documentation/dpaa2/overview.txt |  0
 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 +-
 36 files changed, 37 insertions(+), 54 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.h (100%)
 rename {drivers/staging/fsl-mc/include => include/linux/fsl}/mc-bus.h (99%)
 rename {drivers/staging/fsl-mc/include => include/linux/fsl}/mc-cmd.h (100%)
 rename {drivers/staging/fsl-mc/include => include/linux/fsl}/mc-sys.h (100%)
 rename {drivers/staging/fsl-mc/include => include/

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

2016-10-21 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
+ *
+ * seqnum is valid only if VALIDFRA

[PATCH] Staging:wilc1000:host_interface: fixed 80 character line limit coding style issue

2016-10-21 Thread Nadim Almas
Fixed coding style issue

Signed-off-by: Nadim Almas 
---
 drivers/staging/wilc1000/host_interface.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 0c5dea7..6e6540f 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -497,10 +497,12 @@ static void handle_cfg_param(struct wilc_vif *vif,
if (cfg_param_attr->flag & POWER_MANAGEMENT) {
if (cfg_param_attr->power_mgmt_mode < 5) {
wid_list[i].id = WID_POWER_MANAGEMENT;
-   wid_list[i].val = (s8 
*)&cfg_param_attr->power_mgmt_mode;
+   wid_list[i].val = (s8 *)&cfg_param_attr->
+  power_mgmt_mode;
wid_list[i].type = WID_CHAR;
wid_list[i].size = sizeof(char);
-   hif_drv->cfg_values.power_mgmt_mode = 
(u8)cfg_param_attr->power_mgmt_mode;
+   hif_drv->cfg_values.power_mgmt_mode =
+  (u8)cfg_param_attr->power_mgmt_mode;
} else {
netdev_err(vif->ndev, "Invalid power mode\n");
goto unlock;
-- 
2.7.4

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


[PATCH] Staging:wlan-ng:hfa384x: fixed 80 character line limit coding style issue

2016-10-21 Thread Nadim Almas
Fixed coding style issue

Signed-off-by: Nadim Almas 
---
 drivers/staging/wlan-ng/hfa384x.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h 
b/drivers/staging/wlan-ng/hfa384x.h
index 6337b1d..cca2652 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -1349,7 +1349,9 @@ struct hfa384x {
  * interface
  */
 
-   struct hfa384x_caplevel cap_act_sta_mfi; /* sta f/w to modem interface 
*/
+   struct hfa384x_caplevel cap_act_sta_mfi; /*
+ * sta f/w to modem interface
+ */
 
struct hfa384x_caplevel cap_act_ap_cfi; /*
 * ap f/w to controller
@@ -1371,7 +1373,9 @@ struct hfa384x {
 
struct hfa384x_inf_frame *scanresults;
 
-   struct prism2sta_authlist authlist; /* Authenticated station list. 
*/
+   struct prism2sta_authlist authlist; /*
+* Authenticated station list
+*/
unsigned int accessmode;/* Access mode. */
struct prism2sta_accesslist allow;  /* Allowed station list. */
struct prism2sta_accesslist deny;   /* Denied station list. */
-- 
2.7.4

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


Re: [PATCH net-next] hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf()

2016-10-21 Thread Vitaly Kuznetsov
David Miller  writes:

> From: Vitaly Kuznetsov 
> Date: Thu, 20 Oct 2016 10:51:04 +0200
>
>> Stephen Hemminger  writes:
>> 
>>> Do we need ACCESS_ONCE() here to avoid check/use issues?
>>>
>> 
>> I think we don't: this is the only place in the function where we read
>> the variable so we'll get normal read. We're not trying to syncronize
>> with netvsc_init_buf() as that would require locking, if we read stale
>> NULL value after it was already updated on a different CPU we're fine,
>> we'll just return -EAGAIN.
>
> The concern is if we race with netvsc_destroy_buf() and this pointer
> becomes NULL after the test you are adding.

Thanks, this is interesting.

We may reach to netvsc_destroy_buf() by 3 pathes:

1) cleanup path in netvsc_init_buf(). It is never called with
send_section_map being not NULL so it seems we're safe.

2) from netvsc_remove() when the device is being removed. As far as I
understand we can't be on the transmit path after we call
unregister_netdev() so we're safe.

3) from netvsc_change_mtu() and netvsc_set_channels(). These pathes are
specific to netvsc driver as basically we need to remove the device and
add it back to change mtu/number of channels. The underligning 'struct
net_device' stays but the rest is being removed and added back. On both
pathes we first call netvsc_close() which does netif_tx_disable() and as
far as I understand (I may be wrong) this guarantees that we won't be in
netvsc_send().

So *I think* that we can't ever free send_section_map while in
netvsc_send() and we can't even get to netvsc_send() after it is freed
but I may have missed something.

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


Re: [PATCH 4/6] gpio: cbc-presence: Add CBC presence detect as GPIO driver

2016-10-21 Thread Linus Walleij
On Fri, Oct 7, 2016 at 5:20 PM, Pantelis Antoniou
 wrote:

> From: Georgi Vlaev 
>
> This driver exports the CB FPGA presence detect bits from a
> single 32bit CB register as GPIOs.
>
> Signed-off-by: Georgi Vlaev 
> Signed-off-by: Guenter Roeck 
> [Ported from Juniper kernel]
> Signed-off-by: Pantelis Antoniou 

This needs some more verbose commit message and explanation.

Note: GPIO = General Purpose Input/Output.

This doesn't really sound like general purpose, more like special
purpose.

Consider drivers/input and drivers/connector classes for example.

> +config GPIO_CBC_PRESENCE
> +   tristate "Juniper Networks PTX1K CBC presence detect as GPIO"
> +   depends on MFD_JUNIPER_CBC && OF
> +   default y if JNX_CONNECTOR
> +   help
> + This driver exports the CH_PRS and OTHER_CH_PRS presence detect
> + bits of the PTX1K RCB CBC FPGA as GPIOs on the relevant Juniper
> + platforms. Select if JNX_CONNECTOR is selected.
> +
> + This driver can also be built as a module.  If so, the module
> + will be called gpio-cbc-presence.

At least tell us *what* it is detecting the presence of.

Apart from this it has some of the same issues pointed out in the
other drivers, correct these as well.

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


Re: [PATCH 3/6] gpio: gpio-cbc: Document bindings of CBC FPGA GPIO block

2016-10-21 Thread Linus Walleij
On Fri, Oct 7, 2016 at 5:20 PM, Pantelis Antoniou
 wrote:

> From: Georgi Vlaev 
>
> Add device tree bindings document for the GPIO driver of
> Juniper's CBC FPGA.
>
> Signed-off-by: Georgi Vlaev 
> [Ported from Juniper kernel]
> Signed-off-by: Pantelis Antoniou 
> ---
>  .../devicetree/bindings/gpio/jnx,gpio-cbc.txt  | 30 
> ++
>  1 file changed, 30 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/jnx,gpio-cbc.txt
>
> diff --git a/Documentation/devicetree/bindings/gpio/jnx,gpio-cbc.txt 
> b/Documentation/devicetree/bindings/gpio/jnx,gpio-cbc.txt
> new file mode 100644
> index 000..d205d0b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/jnx,gpio-cbc.txt
> @@ -0,0 +1,30 @@
> +Juniper CBC FPGA GPIO block
> +
> +Required properties:
> +
> +- compatible:
> +Must be "jnx,cbc-gpio"
> +
> +Optional properties:
> +
> +- reg:
> +Address and length of the register set for the device. This is optional 
> since
> +usually the parent MFD driver fills it in.
> +
> +- #gpio-cells:
> +Should be <2>.  The first cell is the pin number (within the controller's
> +pin space), and the second is used for the following flags:
> +   bit[0]: direction (0 = out, 1 = in)
> +   bit[1]: init high
> +   bit[2]: active low

Can't you just refer to the generic bindings?

Apart from that it looks fine.

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


Re: [PATCH 2/6] gpio: Add support for PTX1K CBC FPGA spare GPIOs

2016-10-21 Thread Linus Walleij
On Fri, Oct 7, 2016 at 5:20 PM, Pantelis Antoniou
 wrote:

> From: Georgi Vlaev 
>
> Add support for the GPIO block in Juniper's CBC FPGA.
>
> A number of GPIOs exported by different kind of boards
> is supported.
>
> Signed-off-by: Georgi Vlaev 
> Signed-off-by: Guenter Roeck 
> [Ported from Juniper kernel]
> Signed-off-by: Pantelis Antoniou 

Again pretty much the same comments.

The drivers not supporting IRQ will be pretty quick and
easy to fix up I guess, the IRQ drivers will require some
effort. An approach is to split these in two: one for the basic
GPIO and a separate add-on patch for the IRQ functionality.

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


Re: [PATCH] Staging: lustre: lov: check return value of lov_sub_get()

2016-10-21 Thread Greg Kroah-Hartman
On Fri, Oct 21, 2016 at 07:33:52AM +0800, Jinshan Xiong wrote:
> Check return value of lov_sub_get() in lov_io_read_ahead().
> 
> Signed-off-by: Jinshan Xiong 

No reported-by: tag?

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