Re: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread Greg KH
On Fri, Dec 02, 2016 at 07:14:03AM +, KY Srinivasan wrote:
> > In other words, why do you need this and PCI or USB doesn't?  Why is
> > hyperv "special"?
> 
> On Hyper-V, each VF interface (SR-IOV interface)
> is paired with an instance of the 
> synthetic interface that is managed by netvsc.
> When the VF interface comes up, we
> need to associate the VF instance with 
> the corresponding netvsc instance. To do this
> without modifying the VF drivers, netvsc registers 
> for netdev events.

Why not modify the VF drivers?  You have the full source to them...

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


RE: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread KY Srinivasan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, December 1, 2016 10:48 PM
> To: KY Srinivasan 
> Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org;
> o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com;
> jasow...@redhat.com; leann.ogasaw...@canonical.com; Haiyang Zhang
> 
> Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device
> 
> On Fri, Dec 02, 2016 at 06:02:29AM +, KY Srinivasan wrote:
> >
> >
> > > -Original Message-
> > > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > > Sent: Thursday, December 1, 2016 12:36 PM
> > > To: KY Srinivasan 
> > > Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org;
> > > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com;
> > > jasow...@redhat.com; leann.ogasaw...@canonical.com; Haiyang Zhang
> > > 
> > > Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device
> 
> Ugh, please fix your email client...
> 
> > >
> > > On Thu, Dec 01, 2016 at 09:28:39AM -0800, k...@exchange.microsoft.com
> > > wrote:
> > > > From: Haiyang Zhang 
> > > >
> > > > Signed-off-by: Haiyang Zhang 
> > > > Signed-off-by: K. Y. Srinivasan 
> > > > ---
> > > >  drivers/hv/vmbus_drv.c |6 ++
> > > >  include/linux/hyperv.h |2 ++
> > > >  2 files changed, 8 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > > > index 0276d2e..1730ac0 100644
> > > > --- a/drivers/hv/vmbus_drv.c
> > > > +++ b/drivers/hv/vmbus_drv.c
> > > > @@ -692,6 +692,12 @@ struct onmessage_work_context {
> > > > struct hv_message msg;
> > > >  };
> > > >
> > > > +bool device_is_hyperv(struct device *dev)
> > > > +{
> > > > +   return dev->release == vmbus_device_release;
> > > > +}
> > > > +EXPORT_SYMBOL_GPL(device_is_hyperv);
> > >
> > > Wait, eek, no!  That's NOT how you determine a device type, if you
> > > really even ever need to do that.
> > >
> > > Why are you needing this?  You should always "just know" what type of
> > > device a struct device * is, that's what we rely on in the driver model.
> > > Otherwise things get messy very very quickly.
> > >
> > > Sorry, I can't take this without a ton of justification, and even then,
> > > you need to do this correctly (and no, I'm not going to tell you how to
> > > do that as I don't like it being done...)
> > >
> > Greg,
> >
> > To support SR-IOV, netvsc registers for all netdev events. For netdev
> events related to the
> > VF interface, we need to do some special processing. And so, we need to
> determine
> > if the device that is generating the netdev event is Hyper-V device or not
> > (passed through the PCI pass through driver). Is this justification 
> > sufficient.
> > As you have observed, currently there is no user of this API and that is
> because netvsc
> > will be the user. To avoid cross-tree dependency, we wanted to get this
> functionality in first
> > before submitting the netvsc patch.
> 
> See, you do have some text for a changelog!
> 
> {grumble...}
> 
> No, I don't think this is a good justification, where are you going to
> put this "check" into the networking stack?  Your driver should only be
> binding to devices of this "type" anyway, so by that logic, it already
> "knows" that the device is of this type.
> 
> In other words, why do you need this and PCI or USB doesn't?  Why is
> hyperv "special"?

On Hyper-V, each VF interface (SR-IOV interface)
is paired with an instance of the 
synthetic interface that is managed by netvsc.
When the VF interface comes up, we
need to associate the VF instance with 
the corresponding netvsc instance. To do this
without modifying the VF drivers, netvsc registers 
for netdev events. In the netdev
event handler (in netvsc) currently I am 
doing the association based on the MAC
address - this code is currently committed 
upstream (see drivers/net/hyperv/netvsc_drv.c 
netvsc_register_vf()). Going forward, we want to 
base this association based on a sequence
number that the host publishes both for the 
VF as well as the corresponding
synthetic (netvsc) instance.

You are right, netvsc already knows that the 
devices it is managing belong to vmbus.
Since we are registering for netdev events, 
we will get notified for devices that may not
be vmbus devices and that is where this new 
API will be used. If the device is a vmbus device
we can extract the sequence number to implement the match.

Regards,

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


Re: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread Greg KH
On Fri, Dec 02, 2016 at 06:02:29AM +, KY Srinivasan wrote:
> 
> 
> > -Original Message-
> > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > Sent: Thursday, December 1, 2016 12:36 PM
> > To: KY Srinivasan 
> > Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org;
> > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com;
> > jasow...@redhat.com; leann.ogasaw...@canonical.com; Haiyang Zhang
> > 
> > Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device

Ugh, please fix your email client...

> > 
> > On Thu, Dec 01, 2016 at 09:28:39AM -0800, k...@exchange.microsoft.com
> > wrote:
> > > From: Haiyang Zhang 
> > >
> > > Signed-off-by: Haiyang Zhang 
> > > Signed-off-by: K. Y. Srinivasan 
> > > ---
> > >  drivers/hv/vmbus_drv.c |6 ++
> > >  include/linux/hyperv.h |2 ++
> > >  2 files changed, 8 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > > index 0276d2e..1730ac0 100644
> > > --- a/drivers/hv/vmbus_drv.c
> > > +++ b/drivers/hv/vmbus_drv.c
> > > @@ -692,6 +692,12 @@ struct onmessage_work_context {
> > >   struct hv_message msg;
> > >  };
> > >
> > > +bool device_is_hyperv(struct device *dev)
> > > +{
> > > + return dev->release == vmbus_device_release;
> > > +}
> > > +EXPORT_SYMBOL_GPL(device_is_hyperv);
> > 
> > Wait, eek, no!  That's NOT how you determine a device type, if you
> > really even ever need to do that.
> > 
> > Why are you needing this?  You should always "just know" what type of
> > device a struct device * is, that's what we rely on in the driver model.
> > Otherwise things get messy very very quickly.
> > 
> > Sorry, I can't take this without a ton of justification, and even then,
> > you need to do this correctly (and no, I'm not going to tell you how to
> > do that as I don't like it being done...)
> > 
> Greg,
> 
> To support SR-IOV, netvsc registers for all netdev events. For netdev events 
> related to the
> VF interface, we need to do some special processing. And so, we need to 
> determine
> if the device that is generating the netdev event is Hyper-V device or not
> (passed through the PCI pass through driver). Is this justification 
> sufficient.
> As you have observed, currently there is no user of this API and that is 
> because netvsc
> will be the user. To avoid cross-tree dependency, we wanted to get this 
> functionality in first
> before submitting the netvsc patch.

See, you do have some text for a changelog!

{grumble...}

No, I don't think this is a good justification, where are you going to
put this "check" into the networking stack?  Your driver should only be
binding to devices of this "type" anyway, so by that logic, it already
"knows" that the device is of this type.

In other words, why do you need this and PCI or USB doesn't?  Why is
hyperv "special"?

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


RE: [PATCH 06/15] hv: acquire vmbus_connection.channel_mutex in vmbus_free_channels()

2016-12-01 Thread KY Srinivasan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, December 1, 2016 12:37 PM
> To: KY Srinivasan 
> Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org;
> o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com;
> jasow...@redhat.com; leann.ogasaw...@canonical.com
> Subject: Re: [PATCH 06/15] hv: acquire vmbus_connection.channel_mutex in
> vmbus_free_channels()
> 
> On Thu, Dec 01, 2016 at 09:28:43AM -0800, k...@exchange.microsoft.com
> wrote:
> > From: Vitaly Kuznetsov 
> >
> > "kernel BUG at drivers/hv/channel_mgmt.c:350!" is observed when
> hv_vmbus
> > module is unloaded. BUG_ON() was introduced in commit 85d9aa705184
> > ("Drivers: hv: vmbus: add an API vmbus_hvsock_device_unregister()") as
> > vmbus_free_channels() codepath was apparently forgotten.
> >
> > Fixes: 85d9aa705184 ("Drivers: hv: vmbus: add an API
> vmbus_hvsock_device_unregister()")
> > Signed-off-by: Vitaly Kuznetsov 
> > Signed-off-by: K. Y. Srinivasan 
> > ---
> >  drivers/hv/channel_mgmt.c |2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> Shouldn't this go to stable kernels?

Yes; I will resubmit.

Regards,

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


RE: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread KY Srinivasan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, December 1, 2016 12:36 PM
> To: KY Srinivasan 
> Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org;
> o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com;
> jasow...@redhat.com; leann.ogasaw...@canonical.com; Haiyang Zhang
> 
> Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device
> 
> On Thu, Dec 01, 2016 at 09:28:39AM -0800, k...@exchange.microsoft.com
> wrote:
> > From: Haiyang Zhang 
> >
> > Signed-off-by: Haiyang Zhang 
> > Signed-off-by: K. Y. Srinivasan 
> > ---
> >  drivers/hv/vmbus_drv.c |6 ++
> >  include/linux/hyperv.h |2 ++
> >  2 files changed, 8 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 0276d2e..1730ac0 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -692,6 +692,12 @@ struct onmessage_work_context {
> > struct hv_message msg;
> >  };
> >
> > +bool device_is_hyperv(struct device *dev)
> > +{
> > +   return dev->release == vmbus_device_release;
> > +}
> > +EXPORT_SYMBOL_GPL(device_is_hyperv);
> 
> Wait, eek, no!  That's NOT how you determine a device type, if you
> really even ever need to do that.
> 
> Why are you needing this?  You should always "just know" what type of
> device a struct device * is, that's what we rely on in the driver model.
> Otherwise things get messy very very quickly.
> 
> Sorry, I can't take this without a ton of justification, and even then,
> you need to do this correctly (and no, I'm not going to tell you how to
> do that as I don't like it being done...)
> 
Greg,

To support SR-IOV, netvsc registers for all netdev events. For netdev events 
related to the
VF interface, we need to do some special processing. And so, we need to 
determine
if the device that is generating the netdev event is Hyper-V device or not
(passed through the PCI pass through driver). Is this justification sufficient.
As you have observed, currently there is no user of this API and that is 
because netvsc
will be the user. To avoid cross-tree dependency, we wanted to get this 
functionality in first
before submitting the netvsc patch.

Regards,

K. Y  

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


RE: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread KY Srinivasan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, December 1, 2016 12:34 PM
> To: KY Srinivasan 
> Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org;
> o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com;
> jasow...@redhat.com; leann.ogasaw...@canonical.com; Haiyang Zhang
> 
> Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device
> 
> On Thu, Dec 01, 2016 at 09:28:39AM -0800, k...@exchange.microsoft.com
> wrote:
> > From: Haiyang Zhang 
> >
> > Signed-off-by: Haiyang Zhang 
> > Signed-off-by: K. Y. Srinivasan 
> > ---
> >  drivers/hv/vmbus_drv.c |6 ++
> >  include/linux/hyperv.h |2 ++
> >  2 files changed, 8 insertions(+), 0 deletions(-)
> 
> I can't, and you shouldn't, take patches with no changelog comments at
> all.
> 
> sorry.

Sorry about this; this will be fixed.

K. Y
> 
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/14] rtlwifi: btcoexist: Add vendor definition for new btcoexist

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

Routine halbtc_get() will need to be able to get the vendor ID.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 3 +++
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 7 +++
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index be451473..9a89ae0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -364,6 +364,9 @@ static bool halbtc_get(void *void_btcoexist, u8 get_type, 
void *out_buf)
case BTC_GET_U4_BT_PATCH_VER:
*u32_tmp = halbtc_get_bt_patch_version(btcoexist);
break;
+   case BTC_GET_U4_VENDOR:
+   *u32_tmp = BTC_VENDOR_OTHER;
+   break;
case BTC_GET_U1_WIFI_DOT11_CHNL:
*u8_tmp = rtlphy->current_channel;
break;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index d4da3a1..103abd8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -251,6 +251,7 @@ enum btc_get_type {
BTC_GET_U4_WIFI_FW_VER,
BTC_GET_U4_WIFI_LINK_STATUS,
BTC_GET_U4_BT_PATCH_VER,
+   BTC_GET_U4_VENDOR,
 
/* type u1Byte */
BTC_GET_U1_WIFI_DOT11_CHNL,
@@ -268,6 +269,12 @@ enum btc_get_type {
BTC_GET_MAX
 };
 
+enum btc_vendor {
+   BTC_VENDOR_LENOVO,
+   BTC_VENDOR_ASUS,
+   BTC_VENDOR_OTHER
+};
+
 enum btc_set_type {
/* type bool */
BTC_SET_BL_BT_DISABLE,
-- 
2.10.2

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


[PATCH 14/14] rtlwifi: Add work queue for c2h cmd.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

btcoex needs to sleep, thus it must run in thread context.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/base.c| 92 ++
 drivers/net/wireless/realtek/rtlwifi/base.h|  3 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c| 15 +++-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|  3 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/sw.c|  1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c| 18 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h|  3 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c|  1 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c| 18 -
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h|  3 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/sw.c|  1 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h| 14 
 12 files changed, 159 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index edab6ec..a1cfec3 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -478,6 +478,8 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
  (void *)rtl_swlps_rfon_wq_callback);
INIT_DELAYED_WORK(>works.fwevt_wq,
  (void *)rtl_fwevt_wq_callback);
+   INIT_DELAYED_WORK(>works.c2hcmd_wq,
+ (void *)rtl_c2hcmd_wq_callback);
 
 }
 
@@ -492,6 +494,7 @@ void rtl_deinit_deferred_work(struct ieee80211_hw *hw)
cancel_delayed_work(>works.ps_work);
cancel_delayed_work(>works.ps_rfon_wq);
cancel_delayed_work(>works.fwevt_wq);
+   cancel_delayed_work(>works.c2hcmd_wq);
 }
 EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
 
@@ -559,6 +562,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
spin_lock_init(>locks.rf_lock);
spin_lock_init(>locks.waitq_lock);
spin_lock_init(>locks.entry_list_lock);
+   spin_lock_init(>locks.c2hcmd_lock);
spin_lock_init(>locks.cck_and_rw_pagea_lock);
spin_lock_init(>locks.check_sendpkt_lock);
spin_lock_init(>locks.fw_ps_lock);
@@ -566,6 +570,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
spin_lock_init(>locks.iqk_lock);
/* <5> init list */
INIT_LIST_HEAD(>entry_list);
+   INIT_LIST_HEAD(>c2hcmd_list);
 
rtlmac->link_state = MAC80211_NOLINK;
 
@@ -578,6 +583,7 @@ EXPORT_SYMBOL_GPL(rtl_init_core);
 
 void rtl_deinit_core(struct ieee80211_hw *hw)
 {
+   rtl_c2hcmd_launcher(hw, 0);
 }
 EXPORT_SYMBOL_GPL(rtl_deinit_core);
 
@@ -1826,6 +1832,92 @@ void rtl_fwevt_wq_callback(void *data)
 
rtlpriv->cfg->ops->c2h_command_handle(hw);
 }
+
+void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   unsigned long flags;
+   struct rtl_c2hcmd *c2hcmd;
+
+   c2hcmd = kmalloc(sizeof(*c2hcmd), GFP_KERNEL);
+
+   if (!c2hcmd)
+   goto label_err;
+
+   c2hcmd->val = kmalloc(len, GFP_KERNEL);
+
+   if (!c2hcmd->val)
+   goto label_err2;
+
+   /* fill data */
+   c2hcmd->tag = tag;
+   c2hcmd->len = len;
+   memcpy(c2hcmd->val, val, len);
+
+   /* enqueue */
+   spin_lock_irqsave(>locks.c2hcmd_lock, flags);
+
+   list_add_tail(>list, >c2hcmd_list);
+
+   spin_unlock_irqrestore(>locks.c2hcmd_lock, flags);
+
+   /* wake up wq */
+   queue_delayed_work(rtlpriv->works.rtl_wq, >works.c2hcmd_wq, 0);
+
+   return;
+
+label_err2:
+   kfree(c2hcmd);
+
+label_err:
+   RT_TRACE(rtlpriv, COMP_CMD, DBG_WARNING,
+"C2H cmd enqueue fail.\n");
+}
+EXPORT_SYMBOL(rtl_c2hcmd_enqueue);
+
+void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   unsigned long flags;
+   struct rtl_c2hcmd *c2hcmd;
+
+   while (true) {
+   /* dequeue a task */
+   spin_lock_irqsave(>locks.c2hcmd_lock, flags);
+
+   c2hcmd = list_first_entry_or_null(>c2hcmd_list,
+ struct rtl_c2hcmd, list);
+
+   if (c2hcmd)
+   list_del(>list);
+
+   spin_unlock_irqrestore(>locks.c2hcmd_lock, flags);
+
+   /* do it */
+   if (!c2hcmd)
+   break;
+
+   if (rtlpriv->cfg->ops->c2h_content_parsing && exec)
+   rtlpriv->cfg->ops->c2h_content_parsing(hw,
+   c2hcmd->tag, c2hcmd->len, c2hcmd->val);
+
+   /* free */
+   kfree(c2hcmd->val);
+
+   kfree(c2hcmd);
+   }
+}
+
+void rtl_c2hcmd_wq_callback(void *data)
+{
+   struct rtl_works *rtlworks = container_of_dwork_rtl(data,
+ 

[PATCH 11/14] rtlwifi: Add a new enumeration value to btc_set_type

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

The new value is needed for future capability.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index 190826f..d4da3a1 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -286,6 +286,7 @@ enum btc_set_type {
/* type trigger some action */
BTC_SET_ACT_GET_BT_RSSI,
BTC_SET_ACT_AGGREGATE_CTRL,
+   BTC_SET_ACT_ANTPOSREGRISTRY_CTRL,
 
/* for 1Ant **/
/* type bool */
-- 
2.10.2

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


[PATCH 08/14] rtlwifi: rtl8723be: btcoex: add package_type function to btcoex

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

The new code handles the package-type of the chip.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   |  7 +
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |  2 ++
 drivers/net/wireless/realtek/rtlwifi/efuse.c   |  5 ++--
 drivers/net/wireless/realtek/rtlwifi/efuse.h   |  1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c| 33 ++
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  9 ++
 6 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index d69bf32..d2e4960 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -163,6 +163,13 @@ u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
return num;
 }
 
+u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv)
+{
+   struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
+
+   return rtlhal->package_type;
+}
+
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index bba7e23e..fff5117 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -50,6 +50,8 @@ u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv);
+u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv);
+
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c 
b/drivers/net/wireless/realtek/rtlwifi/efuse.c
index 7becfef..a6985e1 100644
--- a/drivers/net/wireless/realtek/rtlwifi/efuse.c
+++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c
@@ -70,8 +70,6 @@ static void efuse_word_enable_data_read(u8 word_en, u8 
*sourdata,
u8 *targetdata);
 static u8 enable_efuse_data_write(struct ieee80211_hw *hw,
  u16 efuse_addr, u8 word_en, u8 *data);
-static void efuse_power_switch(struct ieee80211_hw *hw, u8 write,
-  u8 pwrstate);
 static u16 efuse_get_current_size(struct ieee80211_hw *hw);
 static u8 efuse_calculate_word_cnts(u8 word_en);
 
@@ -1121,7 +1119,7 @@ static u8 enable_efuse_data_write(struct ieee80211_hw *hw,
return badworden;
 }
 
-static void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate)
+void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -1207,6 +1205,7 @@ static void efuse_power_switch(struct ieee80211_hw *hw, 
u8 write, u8 pwrstate)
}
}
 }
+EXPORT_SYMBOL(efuse_power_switch);
 
 static u16 efuse_get_current_size(struct ieee80211_hw *hw)
 {
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.h 
b/drivers/net/wireless/realtek/rtlwifi/efuse.h
index 51aa121..49a5fb2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/efuse.h
+++ b/drivers/net/wireless/realtek/rtlwifi/efuse.h
@@ -109,6 +109,7 @@ bool efuse_shadow_update_chk(struct ieee80211_hw *hw);
 void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw);
 void efuse_force_write_vendor_Id(struct ieee80211_hw *hw);
 void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx);
+void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate);
 int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv,
   int max_size, u8 *hwinfo, int *params);
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 54a26da..c2cd99f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2022,6 +2022,37 @@ static void 
_rtl8723be_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
"eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
 }
 
+static u8 _rtl8723be_read_package_type(struct ieee80211_hw *hw)
+{
+   u8 package_type;
+   u8 value;
+
+   efuse_power_switch(hw, false, true);
+   if (!efuse_one_byte_read(hw, 0x1FB, ))
+   value = 0;
+   efuse_power_switch(hw, false, false);
+
+   switch (value & 0x7) {
+   case 0x4:
+   package_type = PACKAGE_TFBGA79;
+   break;
+   case 0x5:
+   package_type = PACKAGE_TFBGA90;
+   break;
+   case 0x6:
+   package_type = 

[PATCH 13/14] rtlwifi: rtl8723be: fix ant_sel code

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

When ant_sel is set, we need to fill single_ant_path to select correct
antenna path.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index c2cd99f..00473a6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2700,9 +2700,13 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct 
ieee80211_hw *hw,
}
 
/* override ant_num / ant_path */
-   if (mod_params->ant_sel)
+   if (mod_params->ant_sel) {
rtlpriv->btcoexist.btc_info.ant_num =
(mod_params->ant_sel == 1 ? ANT_X2 : ANT_X1);
+
+   rtlpriv->btcoexist.btc_info.single_ant_path =
+   (mod_params->ant_sel == 1 ? 0 : 1);
+   }
 }
 
 void rtl8723be_bt_reg_init(struct ieee80211_hw *hw)
-- 
2.10.2

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


[PATCH 09/14] rtlwifi: ibtcoex: move bt_type declaration

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

Routine rtl_get_hwpg_bt_type() is better in halbtcoutsrc.c than in
rtl_btc.c.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 5 +
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c  | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index d2e4960..be451473 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -151,6 +151,11 @@ u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
return rtlpriv->btcoexist.btc_info.single_ant_path;
 }
 
+u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
+{
+   return rtlpriv->btcoexist.btc_info.bt_type;
+}
+
 u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
 {
u8 num;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index 54e893c..46e0fa6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -198,11 +198,6 @@ u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv)
return rtlpriv->btcoexist.btc_info.btcoexist;
 }
 
-u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
-{
-   return rtlpriv->btcoexist.btc_info.bt_type;
-}
-
 MODULE_AUTHOR("Page He ");
 MODULE_AUTHOR("Realtek WlanFAE ");
 MODULE_AUTHOR("Larry Finger");
-- 
2.10.2

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


[PATCH 10/14] rtlwifi: Add BTC_TRACE_STRING to new btcoex

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

Add a new debugging function.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   | 23 ++
 drivers/net/wireless/realtek/rtlwifi/debug.h   | 14 +
 2 files changed, 37 insertions(+)

Index: 
wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
===
--- 
wireless-drivers-next.orig/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ 
wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -27,6 +27,29 @@
 
 #include   "../wifi.h"
 
+#ifdef CONFIG_RTLWIFI_DEBUG
+
+#define BTC_SPRINTF(ptr, ...)  snprintf(ptr, ##__VA_ARGS__)
+#define BTC_TRACE(fmt) \
+do {   \
+   struct rtl_priv *rtlpriv = gl_bt_coexist.adapter;   \
+   if (!rtlpriv)   \
+   break;  \
+   RT_TRACE_STRING(rtlpriv, COMP_COEX, DBG_LOUD, fmt); \
+} while (0)
+
+#else
+
+static inline void BTC_SPRINTF(char *ptr, ...)
+{
+}
+
+static inline void BTC_TRACE(const char *ptr)
+{
+}
+
+#endif
+
 #defineNORMAL_EXEC false
 #defineFORCE_EXEC  true
 
Index: wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/debug.h
===
--- wireless-drivers-next.orig/drivers/net/wireless/realtek/rtlwifi/debug.h
+++ wireless-drivers-next/drivers/net/wireless/realtek/rtlwifi/debug.h
@@ -194,6 +194,15 @@ do {   
\
}   \
 } while (0)
 
+#define RT_TRACE_STRING(__priv, comp, level, string)   \
+do {   \
+   if (unlikely(((comp) & __priv->dbg.global_debugcomponents) &&   \
+((level) <= __priv->dbg.global_debuglevel))) { \
+   printk(KBUILD_MODNAME ":%s():<%lx> %s", \
+  __func__, in_interrupt(), string);   \
+   }   \
+} while (0)
+
 #define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata,  \
  _hexdatalen)  \
 do {   \
@@ -230,6 +239,11 @@ static inline void RTPRINT(struct rtl_pr
 {
 }
 
+static inline void RT_TRACE_STRING(struct rtl_priv *rtlpriv,
+  u64 comp, int level, const char *string)
+{
+}
+
 static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
 u64 comp, int level,
 const char *titlestring,
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/14] rtlwifi: Add TX report and disable key will wait until report acked.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

When using EAPOL to do a PTK rekey, there is a possible race condition.
When msg 3/4 is received, the supplicant will send msg 4/4 and install
the new key immediately; however, the driver must make sure that msg 4/4
is sent before installing the new key. We use TX report to ensure it is
sent.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/base.c| 117 ++---
 drivers/net/wireless/realtek/rtlwifi/base.h|   7 ++
 drivers/net/wireless/realtek/rtlwifi/core.c|   2 +
 drivers/net/wireless/realtek/rtlwifi/debug.c   |   2 +-
 drivers/net/wireless/realtek/rtlwifi/debug.h   |   1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   |   8 ++
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   |   8 ++
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.h   |  12 +++
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|   3 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   |   8 ++
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.h   |  13 +++
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  10 ++
 14 files changed, 180 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index fa2d26a..edab6ec 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1107,6 +1107,9 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
if (txrate)
tcb_desc->hw_rate = txrate->hw_value;
 
+   if (rtl_is_tx_report_skb(hw, skb))
+   tcb_desc->use_spe_rpt = 1;
+
if (ieee80211_is_data(fc)) {
/*
 *we set data rate INX 0
@@ -1315,21 +1318,13 @@ static void setup_arp_tx(struct rtl_priv *rtlpriv, 
struct rtl_ps_ctl *ppsc)
ppsc->last_delaylps_stamp_jiffies = jiffies;
 }
 
-/*should call before software enc*/
-u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
-  bool is_enc)
+static const u8 *rtl_skb_ether_type_ptr(struct ieee80211_hw *hw,
+   struct sk_buff *skb, bool is_enc)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
-   struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-   __le16 fc = rtl_get_fc(skb);
-   u16 ether_type;
u8 mac_hdr_len = ieee80211_get_hdrlen_from_skb(skb);
u8 encrypt_header_len = 0;
u8 offset;
-   const struct iphdr *ip;
-
-   if (!ieee80211_is_data(fc))
-   goto end;
 
switch (rtlpriv->sec.pairwise_enc_algorithm) {
case WEP40_ENCRYPTION:
@@ -1349,10 +1344,29 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx,
offset = mac_hdr_len + SNAP_SIZE;
if (is_enc)
offset += encrypt_header_len;
-   ether_type = be16_to_cpup((__be16 *)(skb->data + offset));
+
+   return skb->data + offset;
+}
+
+/*should call before software enc*/
+u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
+  bool is_enc)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
+   __le16 fc = rtl_get_fc(skb);
+   u16 ether_type;
+   const u8 *ether_type_ptr;
+   const struct iphdr *ip;
+
+   if (!ieee80211_is_data(fc))
+   goto end;
+
+   ether_type_ptr = rtl_skb_ether_type_ptr(hw, skb, is_enc);
+   ether_type = be16_to_cpup((__be16 *)ether_type_ptr);
 
if (ETH_P_IP == ether_type) {
-   ip = (struct iphdr *)((u8 *)skb->data + offset +
+   ip = (struct iphdr *)((u8 *)ether_type_ptr +
 PROTOC_TYPE_SIZE);
if (IPPROTO_UDP == ip->protocol) {
struct udphdr *udp = (struct udphdr *)((u8 *)ip +
@@ -1402,6 +1416,85 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx,
 }
 EXPORT_SYMBOL_GPL(rtl_is_special_data);
 
+bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+   u16 ether_type;
+   const u8 *ether_type_ptr;
+
+   ether_type_ptr = rtl_skb_ether_type_ptr(hw, skb, true);
+   ether_type = be16_to_cpup((__be16 *)ether_type_ptr);
+
+   /* EAPOL */
+   if (ether_type == ETH_P_PAE)
+   return true;
+
+   return false;
+}
+
+u16 rtl_get_tx_report_sn(struct ieee80211_hw *hw)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_tx_report *tx_report = >tx_report;
+   u16 sn;
+
+   sn = atomic_inc_return(_report->sn) & 0x0FFF;
+
+   tx_report->last_sent_sn = sn;
+   tx_report->last_sent_time = jiffies;
+
+   RT_TRACE(rtlpriv, COMP_TX_REPORT, DBG_DMESG,
+ 

[PATCH 06/14] rtlwifi: rtl8723be: btcoexist: Add single_ant_path

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

Some devices with RTL8732BE wifi/Bluetooth adapters are shipped with only
a single antenna. On a subset of these, the EEPROM is incorectly coded
to indicate the wrong connection. The resulting problems have been fixed
for wifi. This change handles them for BT.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 5 +
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h  | 1 +
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c   | 1 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h   | 1 +
 4 files changed, 8 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 91cc139..0a47f135 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -146,6 +146,11 @@ static u8 halbtc_get_wifi_central_chnl(struct btc_coexist 
*btcoexist)
return chnl;
 }
 
+u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
+{
+   return rtlpriv->btcoexist.btc_info.single_ant_path;
+}
+
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index ccd5a0f..65c1c52 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -49,6 +49,7 @@ struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
 u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
+u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv);
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index aba60c3..5e98c26 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2661,6 +2661,7 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct 
ieee80211_hw *hw,
rtlpriv->btcoexist.btc_info.btcoexist = 0;
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
rtlpriv->btcoexist.btc_info.ant_num = ANT_X2;
+   rtlpriv->btcoexist.btc_info.single_ant_path = 0;
}
 
/* override ant_num / ant_path */
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 80e6f5e..4e3b441 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2471,6 +2471,7 @@ struct rtl_btc_info {
u8 bt_type;
u8 btcoexist;
u8 ant_num;
+   u8 single_ant_path;
 };
 
 struct bt_coexist_info {
-- 
2.10.2

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


[PATCH 07/14] rtlwifi: move btcoex's ant_num declaration

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

File halbtcoutsrc.c is a better place for routine rtl_get_hwpg_ant_num()
than file rtl_btc.c.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c| 12 
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c | 11 ---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h |  2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c  |  2 ++
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 0a47f135..d69bf32 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -151,6 +151,18 @@ u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
return rtlpriv->btcoexist.btc_info.single_ant_path;
 }
 
+u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
+{
+   u8 num;
+
+   if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
+   num = 2;
+   else
+   num = 1;
+
+   return num;
+}
+
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index d3fd921..54e893c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -178,17 +178,6 @@ struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
 }
 EXPORT_SYMBOL(rtl_btc_get_ops_pointer);
 
-u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
-{
-   u8 num;
-
-   if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
-   num = 2;
-   else
-   num = 1;
-
-   return num;
-}
 
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw)
 {
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index 65c1c52..bba7e23e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -46,9 +46,9 @@ void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, 
u8 pkt_type);
 
 struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
 
-u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
+u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv);
 enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw);
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 5e98c26..54a26da 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2657,6 +2657,8 @@ void rtl8723be_read_bt_coexist_info_from_hwpg(struct 
ieee80211_hw *hw,
value = hwinfo[EEPROM_RF_BT_SETTING_8723B];
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
rtlpriv->btcoexist.btc_info.ant_num = (value & 0x1);
+   rtlpriv->btcoexist.btc_info.single_ant_path =
+(value & 0x40);/*0xc3[6]*/
} else {
rtlpriv->btcoexist.btc_info.btcoexist = 0;
rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8723B;
-- 
2.10.2

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


[PATCH 03/14] rtlwifi: Set retry limit depends on vif type.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

We assign different retry limit according to vif type, because
it can boost performance in field.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: shaofu 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/core.c | 21 ++---
 drivers/net/wireless/realtek/rtlwifi/pci.c  |  7 +++
 drivers/net/wireless/realtek/rtlwifi/ps.c   |  3 +++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index 7c2ac24..35b620a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -234,6 +234,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
int err = 0;
+   u8 retry_limit = 0x30;
 
if (mac->vif) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
@@ -272,6 +273,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
(u8 *)(>basic_rates));
 
+   retry_limit = 0x07;
break;
case NL80211_IFTYPE_P2P_GO:
mac->p2p = P2P_ROLE_GO;
@@ -288,6 +290,8 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
mac->basic_rates = 0xff0;
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
  (u8 *)(>basic_rates));
+
+   retry_limit = 0x07;
break;
case NL80211_IFTYPE_MESH_POINT:
RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
@@ -301,6 +305,8 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
mac->basic_rates = 0xff0;
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
(u8 *)(>basic_rates));
+
+   retry_limit = 0x07;
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
@@ -322,6 +328,10 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
memcpy(mac->mac_addr, vif->addr, ETH_ALEN);
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
 
+   mac->retry_long = retry_limit;
+   mac->retry_short = retry_limit;
+   rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
+   (u8 *)(_limit));
 out:
mutex_unlock(>locks.conf_mutex);
return err;
@@ -647,10 +657,15 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 
changed)
RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
 hw->conf.long_frame_max_tx_count);
-   mac->retry_long = hw->conf.long_frame_max_tx_count;
-   mac->retry_short = hw->conf.long_frame_max_tx_count;
-   rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
+   /* brought up everything changes (changed == ~0) indicates first
+* open, so use our default value instead of that of wiphy.
+*/
+   if (changed != ~0) {
+   mac->retry_long = hw->conf.long_frame_max_tx_count;
+   mac->retry_short = hw->conf.long_frame_max_tx_count;
+   rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
(u8 *)(>conf.long_frame_max_tx_count));
+   }
}
 
if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c 
b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 8bfe020..0991298 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -1214,6 +1214,10 @@ static void _rtl_pci_init_struct(struct ieee80211_hw *hw,
mac->current_ampdu_density = 7;
mac->current_ampdu_factor = 3;
 
+   /*Retry Limit*/
+   mac->retry_short = 7;
+   mac->retry_long = 7;
+
/*QOS*/
rtlpci->acm_method = EACMWAY2_SW;
 
@@ -1820,6 +1824,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
+   struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
 
int err;
 
@@ -1837,6 +1842,8 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
 "Failed to config hardware!\n");
return err;
}
+   rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
+   >retry_long);
 
rtlpriv->cfg->ops->enable_interrupt(hw);
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 

[PATCH 01/14] rtlwifi: Correct power save capability while init mac80211

2016-12-01 Thread Larry Finger
Set IEEE80211_HW_SUPPORTS_PS when driver is fwlps
Because mac80211 control SW-LPS only, we add constraints to avoid errors.

Signed-off-by: Vincent Fann 
Signed-off-by: shaofu 
Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/core.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 4ac928b..fa2d26a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -406,6 +406,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
ieee80211_hw_set(hw, SUPPORTS_PS);
ieee80211_hw_set(hw, PS_NULLFUNC_STACK);
}
+   if (rtlpriv->psc.fwctrl_lps)
+   ieee80211_hw_set(hw, SUPPORTS_PS);
hw->wiphy->interface_modes =
BIT(NL80211_IFTYPE_AP) |
BIT(NL80211_IFTYPE_STATION) |
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index 2caa4ad..7c2ac24 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -620,7 +620,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 
changed)
}
 
/*For LPS */
-   if (changed & IEEE80211_CONF_CHANGE_PS) {
+   if ((changed & IEEE80211_CONF_CHANGE_PS) &&
+   rtlpriv->psc.swctrl_lps && !rtlpriv->psc.fwctrl_lps) {
cancel_delayed_work(>works.ps_work);
cancel_delayed_work(>works.ps_rfon_wq);
if (conf->flags & IEEE80211_CONF_PS) {
-- 
2.10.2

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


[PATCH 02/14] rtlwifi: Fix programing CAM content sequence.

2016-12-01 Thread Larry Finger
From: Ping-Ke Shih 

There is a potential race condition when the control byte of a CAM
entry is written first. Write in reverse order to correct the condition.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: shaofu 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/cam.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/cam.c 
b/drivers/net/wireless/realtek/rtlwifi/cam.c
index 8fe8b4c..5d58ec0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/cam.c
+++ b/drivers/net/wireless/realtek/rtlwifi/cam.c
@@ -45,12 +45,13 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, 
u32 entry_no,
 
u32 target_command;
u32 target_content = 0;
-   u8 entry_i;
+   s8 entry_i;
 
RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_DMESG, "Key content :",
  key_cont_128, 16);
 
-   for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
+   /* 0-1 config + mac, 2-5 fill 128key,6-7 are reserved */
+   for (entry_i = CAM_CONTENT_COUNT - 1; entry_i >= 0; entry_i--) {
target_command = entry_i + CAM_CONTENT_COUNT * entry_no;
target_command = target_command | BIT(31) | BIT(16);
 
@@ -102,7 +103,6 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, 
u32 entry_no,
target_content);
rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
target_command);
-   udelay(100);
 
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
 "WRITE A4: %x\n", target_content);
-- 
2.10.2

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


[PATCH 00/14] rtlwifi: Various updates

2016-12-01 Thread Larry Finger
Realtek has finished an extensive review and rewrite of the rtlwifi
drivers. Much of that work resulted in major changes to btcoexist.
Those changes are not included here, but will be submitted later.

These 14 changes fix a number of deficiencies. None of them are
serious enough to be pushed to stable; however they help in the
stability of the drivers, and in the robustness of authentication/
association.

This material should be sent to the 4.11 stream.

Signed-off-by: Larry Finger 

Vincent Fann (1)
  rtlwifi: Correct power save capability while init mac80211
Ping-Ke Shih (13)
  rtlwifi: Fix programing CAM content sequence.
  rtlwifi: Set retry limit depends on vif type.
  rtlwifi: extend debug_comp to u64
  rtlwifi: Add TX report and disable key will wait until report acked.
  rtlwifi: rtl8723be: btcoexist: Add single_ant_path
  rtlwifi: move btcoex's ant_num declaration
  rtlwifi: rtl8723be: btcoex: add package_type function to btcoex
  rtlwifi: ibtcoex: move bt_type declaration
  rtlwifi: Add BTC_TRACE_STRING to new btcoex
  rtlwifi: Add a new enumeration value to btc_set_type
  rtlwifi: btcoexist: Add vendor definition for new btcoexist
  rtlwifi: rtl8723be: fix ant_sel code
  rtlwifi: Add work queue for c2h cmd.

 drivers/net/wireless/realtek/rtlwifi/base.c| 211 +++--
 drivers/net/wireless/realtek/rtlwifi/base.h|  10 +
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   |  32 
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  31 +++
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |  16 --
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   5 +-
 drivers/net/wireless/realtek/rtlwifi/cam.c |   6 +-
 drivers/net/wireless/realtek/rtlwifi/core.c|  26 ++-
 drivers/net/wireless/realtek/rtlwifi/debug.c   |   4 +-
 drivers/net/wireless/realtek/rtlwifi/debug.h   |  19 +-
 drivers/net/wireless/realtek/rtlwifi/efuse.c   |   5 +-
 drivers/net/wireless/realtek/rtlwifi/efuse.h   |   1 +
 drivers/net/wireless/realtek/rtlwifi/pci.c |   7 +
 drivers/net/wireless/realtek/rtlwifi/ps.c  |   3 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|  16 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/sw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   |   8 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|  19 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h|   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c|  42 +++-
 .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   |   8 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.h   |  12 ++
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|  21 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h|   3 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/sw.c|   1 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   |   8 +
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.h   |  13 ++
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  34 
 30 files changed, 512 insertions(+), 57 deletions(-)

-- 
2.10.2

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


[PATCH 03/14] rtlwifi: extend debug_comp to u64

2016-12-01 Thread Larry Finger
The number of debugging conditions will exceed the capabilities of a
32-bit word.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
---
 drivers/net/wireless/realtek/rtlwifi/debug.c | 2 +-
 drivers/net/wireless/realtek/rtlwifi/debug.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.c 
b/drivers/net/wireless/realtek/rtlwifi/debug.c
index 33905bb..3e75ebc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/debug.c
+++ b/drivers/net/wireless/realtek/rtlwifi/debug.c
@@ -50,7 +50,7 @@ void rtl_dbgp_flag_init(struct ieee80211_hw *hw)
 EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
 
 #ifdef CONFIG_RTLWIFI_DEBUG
-void _rtl_dbg_trace(struct rtl_priv *rtlpriv, int comp, int level,
+void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
const char *modname, const char *fmt, ...)
 {
if (unlikely((comp & rtlpriv->dbg.global_debugcomponents) &&
diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.h 
b/drivers/net/wireless/realtek/rtlwifi/debug.h
index 6156a79..9c77ddaf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/debug.h
+++ b/drivers/net/wireless/realtek/rtlwifi/debug.h
@@ -178,7 +178,7 @@ do {
\
 struct rtl_priv;
 
 __printf(5, 6)
-void _rtl_dbg_trace(struct rtl_priv *rtlpriv, int comp, int level,
+void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
const char *modname, const char *fmt, ...);
 
 #define RT_TRACE(rtlpriv, comp, level, fmt, ...)   \
@@ -217,7 +217,7 @@ static inline void RT_ASSERT(int exp, const char *fmt, ...)
 
 __printf(4, 5)
 static inline void RT_TRACE(struct rtl_priv *rtlpriv,
-   int comp, int level,
+   u64 comp, int level,
const char *fmt, ...)
 {
 }
@@ -230,7 +230,7 @@ static inline void RTPRINT(struct rtl_priv *rtlpriv,
 }
 
 static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
-int comp, int level,
+u64 comp, int level,
 const char *titlestring,
 const void *hexdata, size_t hexdatalen)
 {
-- 
2.10.2

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


Re: [PATCH v2 0/7] Tests for sync infrastructure

2016-12-01 Thread Shuah Khan
On 10/19/2016 06:49 AM, Emilio López wrote:
> Hello everyone,
> 
> This is a series of tests to exercise the sync kernel infrastructure. It is
> meant to be a test suite for the work Gustavo has been doing to destage it.
> 
> These tests were originally part of a battery of tests shipping with
> Android's libsync that were rewritten to use the new userspace interfaces.
> 
> This is the second iteration of the test suite. Main changes over v1 are
> a reworked Makefile and small code style fixes.
> 
> If you are testing this on v4.9-rc1, do note that the last test will
> currently fail due to a regression[0].

Hi Emilio,

Thanks. I will apply these to linux-kselftest next for 4.10-rc1

-- Shuah
> 
> As usual, all comments are welcome.
> 
> Cheers!
> Emilio
> 
> [0] https://patchwork.kernel.org/patch/9343347/
> 
> Emilio López (7):
>   selftest: sync: basic tests for sw_sync framework
>   selftest: sync: fence tests for sw_sync framework
>   selftest: sync: merge tests for sw_sync framework
>   selftest: sync: wait tests for sw_sync framework
>   selftest: sync: stress test for parallelism
>   selftest: sync: stress consumer/producer test
>   selftest: sync: stress test for merges
> 
>  tools/testing/selftests/Makefile   |   1 +
>  tools/testing/selftests/sync/.gitignore|   1 +
>  tools/testing/selftests/sync/Makefile  |  24 +++
>  tools/testing/selftests/sync/sw_sync.h |  46 +
>  tools/testing/selftests/sync/sync.c| 221 
> +
>  tools/testing/selftests/sync/sync.h|  40 
>  tools/testing/selftests/sync/sync_alloc.c  |  74 +++
>  tools/testing/selftests/sync/sync_fence.c  | 132 
>  tools/testing/selftests/sync/sync_merge.c  |  60 ++
>  .../testing/selftests/sync/sync_stress_consumer.c  | 185 +
>  tools/testing/selftests/sync/sync_stress_merge.c   | 115 +++
>  .../selftests/sync/sync_stress_parallelism.c   | 111 +++
>  tools/testing/selftests/sync/sync_test.c   |  79 
>  tools/testing/selftests/sync/sync_wait.c   |  91 +
>  tools/testing/selftests/sync/synctest.h|  66 ++
>  15 files changed, 1246 insertions(+)
>  create mode 100644 tools/testing/selftests/sync/.gitignore
>  create mode 100644 tools/testing/selftests/sync/Makefile
>  create mode 100644 tools/testing/selftests/sync/sw_sync.h
>  create mode 100644 tools/testing/selftests/sync/sync.c
>  create mode 100644 tools/testing/selftests/sync/sync.h
>  create mode 100644 tools/testing/selftests/sync/sync_alloc.c
>  create mode 100644 tools/testing/selftests/sync/sync_fence.c
>  create mode 100644 tools/testing/selftests/sync/sync_merge.c
>  create mode 100644 tools/testing/selftests/sync/sync_stress_consumer.c
>  create mode 100644 tools/testing/selftests/sync/sync_stress_merge.c
>  create mode 100644 tools/testing/selftests/sync/sync_stress_parallelism.c
>  create mode 100644 tools/testing/selftests/sync/sync_test.c
>  create mode 100644 tools/testing/selftests/sync/sync_wait.c
>  create mode 100644 tools/testing/selftests/sync/synctest.h
> 

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


Re: [PATCH v3] x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic

2016-12-01 Thread Thomas Gleixner
Vitaly,

On Thu, 1 Dec 2016, Vitaly Kuznetsov wrote:

> There is a feature in Hyper-V (Debug-VM --InjectNonMaskableInterrupt) which
> injects NMI to the guest. Prior to WS2016 the NMI is injected to all CPUs
> of the guest and WS2016 injects it to CPU0 only. When unknown_nmi_panic is
> enabled and we'd like to do kdump we need to perform some minimal cleanup
> so the kdump kernel will be able to initialize VMBus devices, this cleanup
> includes sending CHANNELMSG_UNLOAD to the host waiting for
> CHANNELMSG_UNLOAD_RESPONSE to arrive. WS2012R2 always sends the response
> to the CPU which was used to send CHANNELMSG_REQUESTOFFERS on VMBus module
> load and not to the CPU which is sending CHANNELMSG_UNLOAD. As we can't do
> any cross-CPU work reliably on crash we have vmbus_wait_for_unload()
> function which tries to read CHANNELMSG_UNLOAD_RESPONSE on all CPUs message
> pages and this sometimes works. It was discovered that in case the host
> wants to send more than one message to a secondary CPU (not the CPU running
> vmbus_wait_for_unload()) we're unable to get it as after reading the first
> message we're supposed to do EOMing by doing wrmsrl(HV_X64_MSR_EOM, 0) but
> this is per-CPU. I have a feeling that this was working some time ago when
> I implemented vmbus_wait_for_unload(), the host was re-trying to deliver a
> message even without wrmsrl() but apparently this doesn't work any more.
> Unfortunately there is not that much we can do when all CPUs get NMI as
> all but the first one are getting blocked with interrupts disabled. What we
> can do is limit processing unknown interrupts to the first CPU which gets
> it in case we're about to crash.

This is completely unreadable and I really tried hard to make sense of it.

Please structure it in a way that people who are not familiar with the
inner workings of hyperv can at least understand the problem you are trying
to solve and the concept of the solution w/o needing to figure out what all
the acronyms and constants actually mean.

Also visual structuring in paragraphs helps readability a lot.

AFAICT this tries to deal with different problems of different hypervisor
versions, but even that is unclear as you talk about version WS2016,
versions prior to WS2016 and then about WS2012R2 in particular.

Another issue I have with this is:

" I have a feeling that this was working "

Changes like this are not about feelings. We want to have changes based on
facts.

Thanks,

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


[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.h (100%)
 rename {drivers/staging/fsl-mc/include => include/linux/fsl}/mc-bus.h (99%)
 rename {drivers/staging/fsl-mc/include => 

[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.
+
+   

[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_OPEN   

[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 

[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 = 

[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 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 

[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(_dev->dev);
+
+   irq = dpio_dev->irqs[0];
+   error = devm_request_irq(_dev->dev,
+irq->msi_desc->irq,
+dpio_irq_handler,
+0,
+dev_name(_dev->dev),
+_dev->dev);
+   if (error < 0) {
+   dev_err(_dev->dev,
+   "devm_request_irq() failed: %d\n",
+   error);
+   return error;
+   }
+
+   /* set the affinity hint */
+   cpumask_clear();
+   cpumask_set_cpu(cpu, );
+   if (irq_set_affinity_hint(irq->msi_desc->irq, ))
+   dev_err(_dev->dev,
+  

[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 +
 .../bus => irqchip}/irq-gic-v3-its-fsl-mc-msi.c|2 +-
 

[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
+ * 

[PATCH 2/3] staging: lustre: osc: create cli_name to get obd name

2016-12-01 Thread James Simmons
From: Jinshan Xiong 

Create the inline function cli_name() to get the name
of the OSC device.

Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108
Reviewed-on: http://review.whamcloud.com/10458
Reviewed-by: Bobi Jam 
Reviewed-by: Fan Yong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/osc/osc_cache.c|8 
 drivers/staging/lustre/lustre/osc/osc_internal.h |5 +
 drivers/staging/lustre/lustre/osc/osc_page.c |   12 +---
 drivers/staging/lustre/lustre/osc/osc_quota.c|4 ++--
 drivers/staging/lustre/lustre/osc/osc_request.c  |   13 +
 5 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c 
b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 0b5f4b2..462a3ad 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -961,7 +961,7 @@ static int osc_extent_wait(const struct lu_env *env, struct 
osc_extent *ext,
if (rc == -ETIMEDOUT) {
OSC_EXTENT_DUMP(D_ERROR, ext,
"%s: wait ext to %u timedout, recovery in 
progress?\n",
-   osc_export(obj)->exp_obd->obd_name, state);
+   cli_name(osc_cli(obj)), state);
 
lwi = LWI_INTR(NULL, NULL);
rc = l_wait_event(ext->oe_waitq, extent_wait_cb(ext, state),
@@ -1384,7 +1384,7 @@ static int osc_completion(const struct lu_env *env, 
struct osc_async_page *oap,
CDEBUG(lvl, "%s: grant { dirty: %ld/%ld dirty_pages: %ld/%lu "\
   "dropped: %ld avail: %ld, reserved: %ld, flight: %d }" \
   "lru {in list: %ld, left: %ld, waiters: %d }" fmt "\n",\
-  __tmp->cl_import->imp_obd->obd_name,   \
+  cli_name(__tmp),   \
   __tmp->cl_dirty_pages, __tmp->cl_dirty_max_pages,  \
   atomic_long_read(_dirty_pages), obd_max_dirty_pages,   \
   __tmp->cl_lost_grant, __tmp->cl_avail_grant,   \
@@ -1622,7 +1622,7 @@ static int osc_enter_cache(const struct lu_env *env, 
struct client_obd *cli,
osc_io_unplug_async(env, cli, NULL);
 
CDEBUG(D_CACHE, "%s: sleeping for cache space @ %p for %p\n",
-  cli->cl_import->imp_obd->obd_name, , oap);
+  cli_name(cli), , oap);
 
rc = l_wait_event(ocw.ocw_waitq, ocw_granted(cli, ), );
 
@@ -1666,7 +1666,7 @@ static int osc_enter_cache(const struct lu_env *env, 
struct client_obd *cli,
break;
default:
CDEBUG(D_CACHE, "%s: event for cache space @ %p never arrived 
due to %d, fall back to sync i/o\n",
-  cli->cl_import->imp_obd->obd_name, , rc);
+  cli_name(cli), , rc);
break;
}
 out:
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h 
b/drivers/staging/lustre/lustre/osc/osc_internal.h
index 981b7e1..c5b58e9 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -155,6 +155,11 @@ static inline unsigned long rpcs_in_flight(struct 
client_obd *cli)
return cli->cl_r_in_flight + cli->cl_w_in_flight;
 }
 
+static inline char *cli_name(struct client_obd *cli)
+{
+   return cli->cl_import->imp_obd->obd_name;
+}
+
 struct osc_device {
struct cl_deviceod_cl;
struct obd_export  *od_exp;
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c 
b/drivers/staging/lustre/lustre/osc/osc_page.c
index 2cdc30a..54c483c 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -385,7 +385,7 @@ int lru_queue_work(const struct lu_env *env, void *data)
 {
struct client_obd *cli = data;
 
-   CDEBUG(D_CACHE, "Run LRU work for client obd %p.\n", cli);
+   CDEBUG(D_CACHE, "%s: run LRU work for client obd\n", cli_name(cli));
 
if (osc_cache_too_much(cli))
osc_lru_shrink(env, cli, lru_shrink_max, true);
@@ -675,8 +675,7 @@ long osc_lru_reclaim(struct client_obd *cli)
}
 
CDEBUG(D_CACHE, "%s: cli %p no free slots, pages: %ld, busy: %ld.\n",
-  cli->cl_import->imp_obd->obd_name, cli,
-  atomic_long_read(>cl_lru_in_list),
+  cli_name(cli), cli, atomic_long_read(>cl_lru_in_list),
   atomic_long_read(>cl_lru_busy));
 
/* Reclaim LRU slots from other client_obd as it can't free enough
@@ -694,7 +693,7 @@ long osc_lru_reclaim(struct client_obd *cli)
 cl_lru_osc);
 

[PATCH 1/3] staging: lustre: osc: add and fixup comments for LRU handling

2016-12-01 Thread James Simmons
From: Jinshan Xiong 

Add new information about the fields in struct client_obd.

Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108
Reviewed-on: http://review.whamcloud.com/10458
Reviewed-by: Bobi Jam 
Reviewed-by: Fan Yong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h  |   27 ++---
 drivers/staging/lustre/lustre/osc/osc_page.c |   17 +++
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index d4d2ffa..6d6e479 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -247,15 +247,34 @@ struct client_obd {
struct obd_histogram cl_read_offset_hist;
struct obd_histogram cl_write_offset_hist;
 
-   /* lru for osc caching pages */
+   /* LRU for osc caching pages */
struct cl_client_cache  *cl_cache;
-   struct list_head cl_lru_osc; /* member of cl_cache->ccc_lru */
+   /** member of cl_cache->ccc_lru */
+   struct list_head cl_lru_osc;
+   /** # of available LRU slots left in the per-OSC cache.
+* Available LRU slots are shared by all OSCs of the same file system,
+* therefore this is a pointer to cl_client_cache::ccc_lru_left.
+*/
atomic_long_t   *cl_lru_left;
+   /** # of busy LRU pages. A page is considered busy if it's in writeback
+* queue, or in transfer. Busy pages can't be discarded so they are not
+* in LRU cache.
+*/
atomic_long_tcl_lru_busy;
+   /** # of LRU pages in the cache for this client_obd */
atomic_long_tcl_lru_in_list;
+   /** # of threads are shrinking LRU cache. To avoid contention, it's not
+* allowed to have multiple threads shrinking LRU cache.
+*/
atomic_t cl_lru_shrinkers;
-   struct list_head cl_lru_list; /* lru page list */
-   spinlock_t   cl_lru_list_lock; /* page list protector */
+   /** List of LRU pages for this client_obd */
+   struct list_head cl_lru_list;
+   /** Lock for LRU page list */
+   spinlock_t   cl_lru_list_lock;
+   /** # of unstable pages in this client_obd.
+* An unstable page is a page state that WRITE RPC has finished but
+* the transaction has NOT yet committed.
+*/
atomic_long_tcl_unstable_count;
 
/* number of in flight destroy rpcs is limited to max_rpcs_in_flight */
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c 
b/drivers/staging/lustre/lustre/osc/osc_page.c
index 7a1f102..2cdc30a 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -343,16 +343,17 @@ void osc_page_submit(const struct lu_env *env, struct 
osc_page *opg,
  * OSC to free slots voluntarily to maintain a reasonable number of free slots
  * at any time.
  */
-
 static DECLARE_WAIT_QUEUE_HEAD(osc_lru_waitq);
-/* LRU pages are freed in batch mode. OSC should at least free this
- * number of pages to avoid running out of LRU budget, and..
+
+/**
+ * LRU pages are freed in batch mode. OSC should at least free this
+ * number of pages to avoid running out of LRU slots.
  */
 static const int lru_shrink_min = 2 << (20 - PAGE_SHIFT);  /* 2M */
-/* free this number at most otherwise it will take too long time to finish. */
 static const int lru_shrink_max = 8 << (20 - PAGE_SHIFT); /* 8M */
 
-/* Check if we can free LRU slots from this OSC. If there exists LRU waiters,
+/**
+ * Check if we can free LRU slots from this OSC. If there exists LRU waiters,
  * we should free slots aggressively. In this way, slots are freed in a steady
  * step to maintain fairness among OSCs.
  *
@@ -643,6 +644,12 @@ long osc_lru_shrink(const struct lu_env *env, struct 
client_obd *cli,
return count > 0 ? count : rc;
 }
 
+/**
+ * Reclaim LRU pages by an IO thread. The caller wants to reclaim at least
+ * \@npages of LRU slots. For performance consideration, it's better to drop
+ * LRU pages in batch. Therefore, the actual number is adjusted at least
+ * max_pages_per_rpc.
+ */
 long osc_lru_reclaim(struct client_obd *cli)
 {
struct lu_env *env;
-- 
1.7.1

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


[PATCH 3/3] staging: lustre: osc: Performance tune for LRU

2016-12-01 Thread James Simmons
From: Jinshan Xiong 

Early launch page LRU work in osc_io_rw_iter_init();
Change the page LRU shrinking policy by OSC attributes;
Delete the contented lock osc_object::oo_seatbelt

Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108
Reviewed-on: http://review.whamcloud.com/10458
Reviewed-by: Bobi Jam 
Reviewed-by: Fan Yong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/lustre/include/obd.h|8 ++
 drivers/staging/lustre/lustre/osc/lproc_osc.c  |6 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c  |   26 +---
 .../staging/lustre/lustre/osc/osc_cl_internal.h|   19 ---
 drivers/staging/lustre/lustre/osc/osc_internal.h   |2 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |   13 ++-
 drivers/staging/lustre/lustre/osc/osc_object.c |9 --
 drivers/staging/lustre/lustre/osc/osc_page.c   |  119 
 drivers/staging/lustre/lustre/osc/osc_request.c|4 +-
 9 files changed, 106 insertions(+), 100 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 6d6e479..0f48e9c 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -267,6 +267,14 @@ struct client_obd {
 * allowed to have multiple threads shrinking LRU cache.
 */
atomic_t cl_lru_shrinkers;
+   /** The time when this LRU cache was last used. */
+   time64_t cl_lru_last_used;
+   /** stats: how many reclaims have happened for this client_obd.
+* reclaim and shrink - shrink is async, voluntarily rebalancing;
+* reclaim is sync, initiated by IO thread when the LRU slots are
+* in shortage.
+*/
+   u64  cl_lru_reclaim;
/** List of LRU pages for this client_obd */
struct list_head cl_lru_list;
/** Lock for LRU page list */
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c 
b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index 4f56a49..575b296 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -183,10 +183,12 @@ static int osc_cached_mb_seq_show(struct seq_file *m, 
void *v)
 
seq_printf(m,
   "used_mb: %ld\n"
-  "busy_cnt: %ld\n",
+  "busy_cnt: %ld\n"
+  "reclaim: %llu\n",
   (atomic_long_read(>cl_lru_in_list) +
atomic_long_read(>cl_lru_busy)) >> shift,
-  atomic_long_read(>cl_lru_busy));
+  atomic_long_read(>cl_lru_busy),
+  cli->cl_lru_reclaim);
 
return 0;
 }
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c 
b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 462a3ad..b0f030c 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -1329,7 +1329,6 @@ static int osc_completion(const struct lu_env *env, 
struct osc_async_page *oap,
 {
struct osc_page *opg = oap2osc_page(oap);
struct cl_page*page = oap2cl_page(oap);
-   struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj);
enum cl_req_type crt;
int srvlock;
 
@@ -1344,13 +1343,6 @@ static int osc_completion(const struct lu_env *env, 
struct osc_async_page *oap,
/* Clear opg->ops_transfer_pinned before VM lock is released. */
opg->ops_transfer_pinned = 0;
 
-   spin_lock(>oo_seatbelt);
-   LASSERT(opg->ops_submitter);
-   LASSERT(!list_empty(>ops_inflight));
-   list_del_init(>ops_inflight);
-   opg->ops_submitter = NULL;
-   spin_unlock(>oo_seatbelt);
-
opg->ops_submit_time = 0;
srvlock = oap->oap_brw_flags & OBD_BRW_SRVLOCK;
 
@@ -1381,7 +1373,7 @@ static int osc_completion(const struct lu_env *env, 
struct osc_async_page *oap,
 
 #define OSC_DUMP_GRANT(lvl, cli, fmt, args...) do {  \
struct client_obd *__tmp = (cli); \
-   CDEBUG(lvl, "%s: grant { dirty: %ld/%ld dirty_pages: %ld/%lu "\
+   CDEBUG(lvl, "%s: grant { dirty: %lu/%lu dirty_pages: %ld/%lu "\
   "dropped: %ld avail: %ld, reserved: %ld, flight: %d }" \
   "lru {in list: %ld, left: %ld, waiters: %d }" fmt "\n",\
   cli_name(__tmp),   \
@@ -2246,14 +2238,9 @@ static int osc_io_unplug0(const struct lu_env *env, 
struct client_obd *cli,
return 0;
 
if (!async) {
-   /* disable osc_lru_shrink() temporarily to avoid
-* potential stack overrun problem. LU-2859
-*/
-   

[PATCH 0/3] staging: lustre: osc: performance tuning for LRU

2016-12-01 Thread James Simmons
Early launch page LRU work in osc_io_rw_iter_init();
Change the page LRU shrinking policy by OSC attributes;
Delete the contented lock osc_object::oo_seatbelt
Original patch has been broken into 3 parts for upstream
merger.

Signed-off-by: Jinshan Xiong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108
Reviewed-on: http://review.whamcloud.com/10458
Reviewed-by: Bobi Jam 
Reviewed-by: Fan Yong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 

Jinshan Xiong (3):
  staging: lustre: osc: add and fixup comments for LRU handling
  staging: lustre: osc: create cli_name to get obd name
  staging: lustre: osc: Performance tune for LRU

 drivers/staging/lustre/lustre/include/obd.h|   35 -
 drivers/staging/lustre/lustre/osc/lproc_osc.c  |6 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c  |   34 ++---
 .../staging/lustre/lustre/osc/osc_cl_internal.h|   19 ---
 drivers/staging/lustre/lustre/osc/osc_internal.h   |7 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |   13 ++-
 drivers/staging/lustre/lustre/osc/osc_object.c |9 --
 drivers/staging/lustre/lustre/osc/osc_page.c   |  148 
 drivers/staging/lustre/lustre/osc/osc_quota.c  |4 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|   17 +--
 10 files changed, 162 insertions(+), 130 deletions(-)

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


[PATCH v5 2/3] staging: comedi: s626: use preferred kernel type u16

2016-12-01 Thread Saber Rezvani
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u16' over 'uint16_t'

Signed-off-by: Saber Rezvani 
Reviewed-by: Ian Abbott 
---
Changes in v2:
  - include a public mailing list in the 'Cc:'.
  - other types u16, u32 added to the patch series.
Changes in v3:
  - remove messy header from the patches.
Changes in v4:
  - change in s626_dio_reset_irq() prototype reverted to its origin. Because
  - it should be in different patch.
Changes in v5:
  - add information about what has changed in this version and previous ones.

 drivers/staging/comedi/drivers/s626.c | 96 +--
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index 59a4aeb..baf997d 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -81,7 +81,7 @@ struct s626_private {
int ai_convert_count;   /* conversion counter */
unsigned int ai_convert_timer;  /* time between conversion in
 * units of the timer */
-   uint16_t counter_int_enabs; /* counter interrupt enable mask
+   u16 counter_int_enabs;  /* counter interrupt enable mask
 * for MISC2 register */
u8 adc_items;   /* number of items in ADC poll list */
struct s626_buffer_dma rps_buf; /* DMA buffer used to hold ADC (RPS1)
@@ -90,7 +90,7 @@ struct s626_private {
 * and hold DAC data */
uint32_t *dac_wbuf; /* pointer to logical adrs of DMA buffer
 * used to hold DAC data */
-   uint16_t dacpol;/* image of DAC polarity register */
+   u16 dacpol; /* image of DAC polarity register */
u8 trim_setpoint[12];   /* images of TrimDAC setpoints */
uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
 * (board rev dependent) */
@@ -179,7 +179,7 @@ static void s626_debi_transfer(struct comedi_device *dev)
 /*
  * Read a value from a gate array register.
  */
-static uint16_t s626_debi_read(struct comedi_device *dev, uint16_t addr)
+static u16 s626_debi_read(struct comedi_device *dev, u16 addr)
 {
/* Set up DEBI control register value in shadow RAM */
writel(S626_DEBI_CMD_RDWORD | addr, dev->mmio + S626_P_DEBICMD);
@@ -193,8 +193,8 @@ static uint16_t s626_debi_read(struct comedi_device *dev, 
uint16_t addr)
 /*
  * Write a value to a gate array register.
  */
-static void s626_debi_write(struct comedi_device *dev, uint16_t addr,
-   uint16_t wdata)
+static void s626_debi_write(struct comedi_device *dev, u16 addr,
+   u16 wdata)
 {
/* Set up DEBI control register value in shadow RAM */
writel(S626_DEBI_CMD_WRWORD | addr, dev->mmio + S626_P_DEBICMD);
@@ -516,10 +516,10 @@ static int s626_send_dac(struct comedi_device *dev, 
uint32_t val)
  * Private helper function: Write setpoint to an application DAC channel.
  */
 static int s626_set_dac(struct comedi_device *dev,
-   uint16_t chan, int16_t dacdata)
+   u16 chan, int16_t dacdata)
 {
struct s626_private *devpriv = dev->private;
-   uint16_t signmask;
+   u16 signmask;
uint32_t ws_image;
uint32_t val;
 
@@ -535,7 +535,7 @@ static int s626_set_dac(struct comedi_device *dev,
}
 
/* Limit DAC setpoint value to valid range. */
-   if ((uint16_t)dacdata > 0x1FFF)
+   if ((u16)dacdata > 0x1FFF)
dacdata = 0x1FFF;
 
/*
@@ -661,7 +661,7 @@ static int s626_load_trim_dacs(struct comedi_device *dev)
  * latches B.
  */
 static void s626_set_latch_source(struct comedi_device *dev,
- unsigned int chan, uint16_t value)
+ unsigned int chan, u16 value)
 {
s626_debi_replace(dev, S626_LP_CRB(chan),
  ~(S626_CRBMSK_INTCTRL | S626_CRBMSK_LATCHSRC),
@@ -686,7 +686,7 @@ static void s626_preload(struct comedi_device *dev,
 static void s626_reset_cap_flags(struct comedi_device *dev,
 unsigned int chan)
 {
-   uint16_t set;
+   u16 set;
 
set = S626_SET_CRB_INTRESETCMD(1);
if (chan < 3)
@@ -704,12 +704,12 @@ static void s626_reset_cap_flags(struct comedi_device 
*dev,
  * ClkPol, ClkEnab, IndexSrc, IndexPol, LoadSrc.
  */
 static void s626_set_mode_a(struct comedi_device *dev,
-   unsigned int chan, uint16_t setup,
-   uint16_t disable_int_src)
+   unsigned int chan, u16 setup,
+   u16 disable_int_src)
 {
struct s626_private *devpriv = dev->private;
-  

[PATCH v5 3/3] staging: comedi: s626: use preferred kernel type u32

2016-12-01 Thread Saber Rezvani
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: Saber Rezvani 
Reviewed-by: Ian Abbott 
---
Changes in v2:
  - include a public mailing list in the 'Cc:'.
  - other types u16, u32 added to the patch series.
Changes in v3:
  - remove messy header from the patches.
Changes in v4:
  - change in s626_dio_reset_irq() prototype reverted to its origin. Because
  - it should be in different patch.
Changes in v5:
  - add information about what has changed in this version and previous ones.

 drivers/staging/comedi/drivers/s626.c | 58 +--
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index baf997d..0dd5fe2 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -88,11 +88,11 @@ struct s626_private {
 * program */
struct s626_buffer_dma ana_buf; /* DMA buffer used to receive ADC data
 * and hold DAC data */
-   uint32_t *dac_wbuf; /* pointer to logical adrs of DMA buffer
+   u32 *dac_wbuf;  /* pointer to logical adrs of DMA buffer
 * used to hold DAC data */
u16 dacpol; /* image of DAC polarity register */
u8 trim_setpoint[12];   /* images of TrimDAC setpoints */
-   uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
+   u32 i2c_adrs;   /* I2C device address for onboard EEPROM
 * (board rev dependent) */
 };
 
@@ -241,7 +241,7 @@ static int s626_i2c_handshake_eoc(struct comedi_device *dev,
return -EBUSY;
 }
 
-static int s626_i2c_handshake(struct comedi_device *dev, uint32_t val)
+static int s626_i2c_handshake(struct comedi_device *dev, u32 val)
 {
unsigned int ctrl;
int ret;
@@ -357,7 +357,7 @@ static int s626_send_dac_eoc(struct comedi_device *dev,
  * channel 2.  Assumes: (1) TSL2 slot records initialized, and (2)
  * dacpol contains valid target image.
  */
-static int s626_send_dac(struct comedi_device *dev, uint32_t val)
+static int s626_send_dac(struct comedi_device *dev, u32 val)
 {
struct s626_private *devpriv = dev->private;
int ret;
@@ -520,8 +520,8 @@ static int s626_set_dac(struct comedi_device *dev,
 {
struct s626_private *devpriv = dev->private;
u16 signmask;
-   uint32_t ws_image;
-   uint32_t val;
+   u32 ws_image;
+   u32 val;
 
/*
 * Adjust DAC data polarity and set up Polarity Control Register image.
@@ -575,9 +575,9 @@ static int s626_set_dac(struct comedi_device *dev,
 * (write to non-existent trimdac). */
val |= 0x4000;  /* Address the two main dual-DAC devices
 * (TSL's chip select enables target device). */
-   val |= ((uint32_t)(chan & 1) << 15);/* Address the DAC channel
+   val |= ((u32)(chan & 1) << 15); /* Address the DAC channel
 * within the device. */
-   val |= (uint32_t)dacdata;   /* Include DAC setpoint data. */
+   val |= (u32)dacdata;/* Include DAC setpoint data. */
return s626_send_dac(dev, val);
 }
 
@@ -585,7 +585,7 @@ static int s626_write_trim_dac(struct comedi_device *dev,
   u8 logical_chan, u8 dac_data)
 {
struct s626_private *devpriv = dev->private;
-   uint32_t chan;
+   u32 chan;
 
/*
 * Save the new setpoint in case the application needs to read it back
@@ -672,7 +672,7 @@ static void s626_set_latch_source(struct comedi_device *dev,
  * Write value into counter preload register.
  */
 static void s626_preload(struct comedi_device *dev,
-unsigned int chan, uint32_t value)
+unsigned int chan, u32 value)
 {
s626_debi_write(dev, S626_LP_CNTR(chan), value);
s626_debi_write(dev, S626_LP_CNTR(chan) + 2, value >> 16);
@@ -1196,7 +1196,7 @@ static bool s626_handle_eos_interrupt(struct 
comedi_device *dev)
 * first uint16_t in the buffer because it contains junk data
 * from the final ADC of the previous poll list scan.
 */
-   uint32_t *readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1;
+   u32 *readaddr = (u32 *)devpriv->ana_buf.logical_base + 1;
int i;
 
/* get the data and hand it over to comedi */
@@ -1231,7 +1231,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
 {
struct comedi_device *dev = d;
unsigned long flags;
-   uint32_t irqtype, irqstatus;
+   u32 irqtype, irqstatus;
 
if (!dev->attached)
return IRQ_NONE;
@@ -1277,20 +1277,20 @@ static void 

[PATCH v5 1/3] staging: comedi: s626: use preferred kernel type u8

2016-12-01 Thread Saber Rezvani
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u8' over 'uint8_t'

Signed-off-by: Saber Rezvani 
Reviewed-by: Ian Abbott 
---
Changes in v2:
  - include a public mailing list in the 'Cc:'.
  - other types u16, u32 added to the patch series.
Changes in v3:
  - remove messy header from the patches.
Changes in v4:
  - change in s626_dio_reset_irq() prototype reverted to its origin. Because
  - it should be in different patch.
Changes in v5:
  - add information about what has changed in this version and previous ones.

 drivers/staging/comedi/drivers/s626.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index c14a025..59a4aeb 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -75,7 +75,7 @@ struct s626_buffer_dma {
 };
 
 struct s626_private {
-   uint8_t ai_cmd_running; /* ai_cmd is running */
+   u8 ai_cmd_running;  /* ai_cmd is running */
unsigned int ai_sample_timer;   /* time between samples in
 * units of the timer */
int ai_convert_count;   /* conversion counter */
@@ -83,7 +83,7 @@ struct s626_private {
 * units of the timer */
uint16_t counter_int_enabs; /* counter interrupt enable mask
 * for MISC2 register */
-   uint8_t adc_items;  /* number of items in ADC poll list */
+   u8 adc_items;   /* number of items in ADC poll list */
struct s626_buffer_dma rps_buf; /* DMA buffer used to hold ADC (RPS1)
 * program */
struct s626_buffer_dma ana_buf; /* DMA buffer used to receive ADC data
@@ -91,7 +91,7 @@ struct s626_private {
uint32_t *dac_wbuf; /* pointer to logical adrs of DMA buffer
 * used to hold DAC data */
uint16_t dacpol;/* image of DAC polarity register */
-   uint8_t trim_setpoint[12];  /* images of TrimDAC setpoints */
+   u8 trim_setpoint[12];   /* images of TrimDAC setpoints */
uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
 * (board rev dependent) */
 };
@@ -267,8 +267,8 @@ static int s626_i2c_handshake(struct comedi_device *dev, 
uint32_t val)
return ctrl & S626_I2C_ERR;
 }
 
-/* Read uint8_t from EEPROM. */
-static uint8_t s626_i2c_read(struct comedi_device *dev, uint8_t addr)
+/* Read u8 from EEPROM. */
+static u8 s626_i2c_read(struct comedi_device *dev, u8 addr)
 {
struct s626_private *devpriv = dev->private;
 
@@ -304,10 +304,10 @@ static uint8_t s626_i2c_read(struct comedi_device *dev, 
uint8_t addr)
 /* ***  DAC FUNCTIONS *** */
 
 /* TrimDac LogicalChan-to-PhysicalChan mapping table. */
-static const uint8_t s626_trimchan[] = { 10, 9, 8, 3, 2, 7, 6, 1, 0, 5, 4 };
+static const u8 s626_trimchan[] = { 10, 9, 8, 3, 2, 7, 6, 1, 0, 5, 4 };
 
 /* TrimDac LogicalChan-to-EepromAdrs mapping table. */
-static const uint8_t s626_trimadrs[] = {
+static const u8 s626_trimadrs[] = {
0x40, 0x41, 0x42, 0x50, 0x51, 0x52, 0x53, 0x60, 0x61, 0x62, 0x63
 };
 
@@ -582,7 +582,7 @@ static int s626_set_dac(struct comedi_device *dev,
 }
 
 static int s626_write_trim_dac(struct comedi_device *dev,
-  uint8_t logical_chan, uint8_t dac_data)
+  u8 logical_chan, u8 dac_data)
 {
struct s626_private *devpriv = dev->private;
uint32_t chan;
@@ -591,7 +591,7 @@ static int s626_write_trim_dac(struct comedi_device *dev,
 * Save the new setpoint in case the application needs to read it back
 * later.
 */
-   devpriv->trim_setpoint[logical_chan] = (uint8_t)dac_data;
+   devpriv->trim_setpoint[logical_chan] = (u8)dac_data;
 
/* Map logical channel number to physical channel number. */
chan = s626_trimchan[logical_chan];
@@ -633,7 +633,7 @@ static int s626_write_trim_dac(struct comedi_device *dev,
 
 static int s626_load_trim_dacs(struct comedi_device *dev)
 {
-   uint8_t i;
+   u8 i;
int ret;
 
/* Copy TrimDac setpoint values from EEPROM to TrimDacs. */
@@ -1062,7 +1062,7 @@ static int s626_dio_clear_irq(struct comedi_device *dev)
 }
 
 static void s626_handle_dio_interrupt(struct comedi_device *dev,
- uint16_t irqbit, uint8_t group)
+ uint16_t irqbit, u8 group)
 {
struct s626_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
@@ -,7 +,7 @@ static void s626_handle_dio_interrupt(struct 
comedi_device *dev,
 static void s626_check_dio_interrupts(struct 

[PATCH v4] staging: greybus: arche-platform: fix line over 80 characters style warnings

2016-12-01 Thread Andrea Ghittino
Fixes greybus "line over 80 characters" style warnings
found by checkpatch.pl tool

Signed-off-by: Andrea Ghittino 
---
changelog:
v2) Review patch based on Vaibhav Hiremath review
v3) Fixed email text
v4) Review the patch based on received comments

drivers/staging/greybus/arche-apb-ctrl.c |2 +-
drivers/staging/greybus/arche-platform.c |   21 +++--
drivers/staging/greybus/audio_codec.c|2 +-
3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/greybus/arche-apb-ctrl.c 
b/drivers/staging/greybus/arche-apb-ctrl.c
index 3fda0cd..806871c 100644
--- a/drivers/staging/greybus/arche-apb-ctrl.c
+++ b/drivers/staging/greybus/arche-apb-ctrl.c
@@ -168,7 +168,7 @@ static int standby_boot_seq(struct platform_device *pdev)
if (apb->init_disabled)
return 0;
 
-   /* Even if it is in OFF state, then we do not want to change the state 
*/
+   /* Don't change state if it is in standby, or off */
if (apb->state == ARCHE_PLATFORM_STATE_STANDBY ||
apb->state == ARCHE_PLATFORM_STATE_OFF)
return 0;
diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 338c2d3..2f6f90d 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -312,9 +312,11 @@ static irqreturn_t arche_platform_wd_irq(int irq, void 
*devid)
if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
arche_pdata->wake_detect_start = jiffies;
/*
-* In the begining, when wake/detect goes low (first 
time), we assume
-* it is meant for coldboot and set the flag. If 
wake/detect line stays low
-* beyond 30msec, then it is coldboot else fallback to 
standby boot.
+* In the beginning, when wake/detect goes low (first
+* time), we assume it is meant for coldboot and set
+* the flag. If wake/detect line stays low beyond
+* 30msec, then it is coldboot else fallback to 
+* standby boot.
 */
arche_platform_set_wake_detect_state(arche_pdata,
 
WD_STATE_BOOT_INIT);
@@ -561,7 +563,8 @@ static int arche_platform_probe(struct platform_device 
*pdev)
struct device_node *np = dev->of_node;
int ret;
 
-   arche_pdata = devm_kzalloc(>dev, sizeof(*arche_pdata), 
GFP_KERNEL);
+   arche_pdata = devm_kzalloc(>dev, sizeof(*arche_pdata),
+ GFP_KERNEL);
if (!arche_pdata)
return -ENOMEM;
 
@@ -780,12 +783,18 @@ static SIMPLE_DEV_PM_OPS(arche_platform_pm_ops,
arche_platform_resume);
 
 static const struct of_device_id arche_platform_of_match[] = {
-   { .compatible = "google,arche-platform", }, /* Use PID/VID of SVC 
device */
+   {
+/* Use PID/VID of SVC device */
+   .compatible = "google,arche-platform",
+   },
{ },
 };
 
 static const struct of_device_id arche_combined_id[] = {
-   { .compatible = "google,arche-platform", }, /* Use PID/VID of SVC 
device */
+   {
+   /* Use PID/VID of SVC device */
+   .compatible = "google,arche-platform",
+   },
{ .compatible = "usb,2", },
{ },
 };
diff --git a/drivers/staging/greybus/audio_codec.c 
b/drivers/staging/greybus/audio_codec.c
index f8862c6..f01752a 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -831,7 +831,7 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
snd_soc_dapm_link_component_dai_widgets(codec->card,
>dapm);
 #ifdef CONFIG_SND_JACK
-   /* register jack devices for this module from codec->jack_list 
*/
+   /* register jack devices from codec->jack_list */
list_for_each_entry(jack, >jack_list, list) {
if ((jack == >headset_jack)
|| (jack == >button_jack))
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 1/3] staging: comedi: s626: use preferred kernel type u8

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 11:56:18PM +0330, Saber Rezvani wrote:
> Fix the checkpatch.pl issue:
> CHECK: Prefer kernel type 'u8' over 'uint8_t'
> 
> Signed-off-by: Saber Rezvani 
> Reviewed-by: Ian Abbott 
> ---
>  drivers/staging/comedi/drivers/s626.c | 30 +++---
>  1 file changed, 15 insertions(+), 15 deletions(-)

No information about what changed in this version, or previous versions?
Please see this:

https://kernelnewbies.org/FirstKernelPatch#head-5c81b3c517a1d0bbc24f92594cb734e155fcbbcb

for how to properly version things.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 09:35:47PM +0100, Greg KH wrote:
> On Thu, Dec 01, 2016 at 09:28:39AM -0800, k...@exchange.microsoft.com wrote:
> > From: Haiyang Zhang 
> > 
> > Signed-off-by: Haiyang Zhang 
> > Signed-off-by: K. Y. Srinivasan 
> > ---
> >  drivers/hv/vmbus_drv.c |6 ++
> >  include/linux/hyperv.h |2 ++
> >  2 files changed, 8 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 0276d2e..1730ac0 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -692,6 +692,12 @@ struct onmessage_work_context {
> > struct hv_message msg;
> >  };
> >  
> > +bool device_is_hyperv(struct device *dev)
> > +{
> > +   return dev->release == vmbus_device_release;
> > +}
> > +EXPORT_SYMBOL_GPL(device_is_hyperv);
> 
> Wait, eek, no!  That's NOT how you determine a device type, if you
> really even ever need to do that.
> 
> Why are you needing this?  You should always "just know" what type of
> device a struct device * is, that's what we rely on in the driver model.
> Otherwise things get messy very very quickly.
> 
> Sorry, I can't take this without a ton of justification, and even then,
> you need to do this correctly (and no, I'm not going to tell you how to
> do that as I don't like it being done...)

And, to make this even worse, you never use this function in this
series, making this something that no one even needs!!!

ugh.

I'm dropping this whole series, sorry, get it together, this was a
mess...

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


Re: [PATCH 06/15] hv: acquire vmbus_connection.channel_mutex in vmbus_free_channels()

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 09:28:43AM -0800, k...@exchange.microsoft.com wrote:
> From: Vitaly Kuznetsov 
> 
> "kernel BUG at drivers/hv/channel_mgmt.c:350!" is observed when hv_vmbus
> module is unloaded. BUG_ON() was introduced in commit 85d9aa705184
> ("Drivers: hv: vmbus: add an API vmbus_hvsock_device_unregister()") as
> vmbus_free_channels() codepath was apparently forgotten.
> 
> Fixes: 85d9aa705184 ("Drivers: hv: vmbus: add an API 
> vmbus_hvsock_device_unregister()")
> Signed-off-by: Vitaly Kuznetsov 
> Signed-off-by: K. Y. Srinivasan 
> ---
>  drivers/hv/channel_mgmt.c |2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)

Shouldn't this go to stable kernels?

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


Re: [PATCH 05/15] Drivers: hv: vmbus: Enhance the rescind callback functionality

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 09:28:42AM -0800, k...@exchange.microsoft.com wrote:
> From: K. Y. Srinivasan 
> 
> Signed-off-by: K. Y. Srinivasan 
> ---
>  drivers/hv/channel_mgmt.c |   11 +++
>  include/linux/hyperv.h|7 ---
>  2 files changed, 11 insertions(+), 7 deletions(-)

no commit log == will not be committed
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 04/15] Drivers: hv: vmbus: Prevent sending data on a rescinded channel

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 09:28:41AM -0800, k...@exchange.microsoft.com wrote:
> From: K. Y. Srinivasan 
> 
> After the channel is rescinded, the host does not read from the rescinded 
> channel.
> Fail writes to a channel that has already been rescinded
> Signed-off-by: K. Y. Srinivasan 

{sigh}

What's wrong with this picture...

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


Re: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 09:28:39AM -0800, k...@exchange.microsoft.com wrote:
> From: Haiyang Zhang 
> 
> Signed-off-by: Haiyang Zhang 
> Signed-off-by: K. Y. Srinivasan 
> ---
>  drivers/hv/vmbus_drv.c |6 ++
>  include/linux/hyperv.h |2 ++
>  2 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 0276d2e..1730ac0 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -692,6 +692,12 @@ struct onmessage_work_context {
>   struct hv_message msg;
>  };
>  
> +bool device_is_hyperv(struct device *dev)
> +{
> + return dev->release == vmbus_device_release;
> +}
> +EXPORT_SYMBOL_GPL(device_is_hyperv);

Wait, eek, no!  That's NOT how you determine a device type, if you
really even ever need to do that.

Why are you needing this?  You should always "just know" what type of
device a struct device * is, that's what we rely on in the driver model.
Otherwise things get messy very very quickly.

Sorry, I can't take this without a ton of justification, and even then,
you need to do this correctly (and no, I'm not going to tell you how to
do that as I don't like it being done...)

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


Re: [PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 09:28:39AM -0800, k...@exchange.microsoft.com wrote:
> From: Haiyang Zhang 
> 
> Signed-off-by: Haiyang Zhang 
> Signed-off-by: K. Y. Srinivasan 
> ---
>  drivers/hv/vmbus_drv.c |6 ++
>  include/linux/hyperv.h |2 ++
>  2 files changed, 8 insertions(+), 0 deletions(-)

I can't, and you shouldn't, take patches with no changelog comments at
all.

sorry.

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


[PATCH v4 3/3] staging: comedi: s626: use preferred kernel type u32

2016-12-01 Thread Saber Rezvani
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: Saber Rezvani 
Reviewed-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/s626.c | 58 +--
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index baf997d..0dd5fe2 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -88,11 +88,11 @@ struct s626_private {
 * program */
struct s626_buffer_dma ana_buf; /* DMA buffer used to receive ADC data
 * and hold DAC data */
-   uint32_t *dac_wbuf; /* pointer to logical adrs of DMA buffer
+   u32 *dac_wbuf;  /* pointer to logical adrs of DMA buffer
 * used to hold DAC data */
u16 dacpol; /* image of DAC polarity register */
u8 trim_setpoint[12];   /* images of TrimDAC setpoints */
-   uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
+   u32 i2c_adrs;   /* I2C device address for onboard EEPROM
 * (board rev dependent) */
 };
 
@@ -241,7 +241,7 @@ static int s626_i2c_handshake_eoc(struct comedi_device *dev,
return -EBUSY;
 }
 
-static int s626_i2c_handshake(struct comedi_device *dev, uint32_t val)
+static int s626_i2c_handshake(struct comedi_device *dev, u32 val)
 {
unsigned int ctrl;
int ret;
@@ -357,7 +357,7 @@ static int s626_send_dac_eoc(struct comedi_device *dev,
  * channel 2.  Assumes: (1) TSL2 slot records initialized, and (2)
  * dacpol contains valid target image.
  */
-static int s626_send_dac(struct comedi_device *dev, uint32_t val)
+static int s626_send_dac(struct comedi_device *dev, u32 val)
 {
struct s626_private *devpriv = dev->private;
int ret;
@@ -520,8 +520,8 @@ static int s626_set_dac(struct comedi_device *dev,
 {
struct s626_private *devpriv = dev->private;
u16 signmask;
-   uint32_t ws_image;
-   uint32_t val;
+   u32 ws_image;
+   u32 val;
 
/*
 * Adjust DAC data polarity and set up Polarity Control Register image.
@@ -575,9 +575,9 @@ static int s626_set_dac(struct comedi_device *dev,
 * (write to non-existent trimdac). */
val |= 0x4000;  /* Address the two main dual-DAC devices
 * (TSL's chip select enables target device). */
-   val |= ((uint32_t)(chan & 1) << 15);/* Address the DAC channel
+   val |= ((u32)(chan & 1) << 15); /* Address the DAC channel
 * within the device. */
-   val |= (uint32_t)dacdata;   /* Include DAC setpoint data. */
+   val |= (u32)dacdata;/* Include DAC setpoint data. */
return s626_send_dac(dev, val);
 }
 
@@ -585,7 +585,7 @@ static int s626_write_trim_dac(struct comedi_device *dev,
   u8 logical_chan, u8 dac_data)
 {
struct s626_private *devpriv = dev->private;
-   uint32_t chan;
+   u32 chan;
 
/*
 * Save the new setpoint in case the application needs to read it back
@@ -672,7 +672,7 @@ static void s626_set_latch_source(struct comedi_device *dev,
  * Write value into counter preload register.
  */
 static void s626_preload(struct comedi_device *dev,
-unsigned int chan, uint32_t value)
+unsigned int chan, u32 value)
 {
s626_debi_write(dev, S626_LP_CNTR(chan), value);
s626_debi_write(dev, S626_LP_CNTR(chan) + 2, value >> 16);
@@ -1196,7 +1196,7 @@ static bool s626_handle_eos_interrupt(struct 
comedi_device *dev)
 * first uint16_t in the buffer because it contains junk data
 * from the final ADC of the previous poll list scan.
 */
-   uint32_t *readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1;
+   u32 *readaddr = (u32 *)devpriv->ana_buf.logical_base + 1;
int i;
 
/* get the data and hand it over to comedi */
@@ -1231,7 +1231,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
 {
struct comedi_device *dev = d;
unsigned long flags;
-   uint32_t irqtype, irqstatus;
+   u32 irqtype, irqstatus;
 
if (!dev->attached)
return IRQ_NONE;
@@ -1277,20 +1277,20 @@ static void s626_reset_adc(struct comedi_device *dev, 
u8 *ppl)
struct s626_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_cmd *cmd = >async->cmd;
-   uint32_t *rps;
-   uint32_t jmp_adrs;
+   u32 *rps;
+   u32 jmp_adrs;
u16 i;
u16 n;
-   uint32_t local_ppl;
+   u32 local_ppl;
 
/* Stop RPS 

[PATCH v4 1/3] staging: comedi: s626: use preferred kernel type u8

2016-12-01 Thread Saber Rezvani
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u8' over 'uint8_t'

Signed-off-by: Saber Rezvani 
Reviewed-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/s626.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index c14a025..59a4aeb 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -75,7 +75,7 @@ struct s626_buffer_dma {
 };
 
 struct s626_private {
-   uint8_t ai_cmd_running; /* ai_cmd is running */
+   u8 ai_cmd_running;  /* ai_cmd is running */
unsigned int ai_sample_timer;   /* time between samples in
 * units of the timer */
int ai_convert_count;   /* conversion counter */
@@ -83,7 +83,7 @@ struct s626_private {
 * units of the timer */
uint16_t counter_int_enabs; /* counter interrupt enable mask
 * for MISC2 register */
-   uint8_t adc_items;  /* number of items in ADC poll list */
+   u8 adc_items;   /* number of items in ADC poll list */
struct s626_buffer_dma rps_buf; /* DMA buffer used to hold ADC (RPS1)
 * program */
struct s626_buffer_dma ana_buf; /* DMA buffer used to receive ADC data
@@ -91,7 +91,7 @@ struct s626_private {
uint32_t *dac_wbuf; /* pointer to logical adrs of DMA buffer
 * used to hold DAC data */
uint16_t dacpol;/* image of DAC polarity register */
-   uint8_t trim_setpoint[12];  /* images of TrimDAC setpoints */
+   u8 trim_setpoint[12];   /* images of TrimDAC setpoints */
uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
 * (board rev dependent) */
 };
@@ -267,8 +267,8 @@ static int s626_i2c_handshake(struct comedi_device *dev, 
uint32_t val)
return ctrl & S626_I2C_ERR;
 }
 
-/* Read uint8_t from EEPROM. */
-static uint8_t s626_i2c_read(struct comedi_device *dev, uint8_t addr)
+/* Read u8 from EEPROM. */
+static u8 s626_i2c_read(struct comedi_device *dev, u8 addr)
 {
struct s626_private *devpriv = dev->private;
 
@@ -304,10 +304,10 @@ static uint8_t s626_i2c_read(struct comedi_device *dev, 
uint8_t addr)
 /* ***  DAC FUNCTIONS *** */
 
 /* TrimDac LogicalChan-to-PhysicalChan mapping table. */
-static const uint8_t s626_trimchan[] = { 10, 9, 8, 3, 2, 7, 6, 1, 0, 5, 4 };
+static const u8 s626_trimchan[] = { 10, 9, 8, 3, 2, 7, 6, 1, 0, 5, 4 };
 
 /* TrimDac LogicalChan-to-EepromAdrs mapping table. */
-static const uint8_t s626_trimadrs[] = {
+static const u8 s626_trimadrs[] = {
0x40, 0x41, 0x42, 0x50, 0x51, 0x52, 0x53, 0x60, 0x61, 0x62, 0x63
 };
 
@@ -582,7 +582,7 @@ static int s626_set_dac(struct comedi_device *dev,
 }
 
 static int s626_write_trim_dac(struct comedi_device *dev,
-  uint8_t logical_chan, uint8_t dac_data)
+  u8 logical_chan, u8 dac_data)
 {
struct s626_private *devpriv = dev->private;
uint32_t chan;
@@ -591,7 +591,7 @@ static int s626_write_trim_dac(struct comedi_device *dev,
 * Save the new setpoint in case the application needs to read it back
 * later.
 */
-   devpriv->trim_setpoint[logical_chan] = (uint8_t)dac_data;
+   devpriv->trim_setpoint[logical_chan] = (u8)dac_data;
 
/* Map logical channel number to physical channel number. */
chan = s626_trimchan[logical_chan];
@@ -633,7 +633,7 @@ static int s626_write_trim_dac(struct comedi_device *dev,
 
 static int s626_load_trim_dacs(struct comedi_device *dev)
 {
-   uint8_t i;
+   u8 i;
int ret;
 
/* Copy TrimDac setpoint values from EEPROM to TrimDacs. */
@@ -1062,7 +1062,7 @@ static int s626_dio_clear_irq(struct comedi_device *dev)
 }
 
 static void s626_handle_dio_interrupt(struct comedi_device *dev,
- uint16_t irqbit, uint8_t group)
+ uint16_t irqbit, u8 group)
 {
struct s626_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
@@ -,7 +,7 @@ static void s626_handle_dio_interrupt(struct 
comedi_device *dev,
 static void s626_check_dio_interrupts(struct comedi_device *dev)
 {
uint16_t irqbit;
-   uint8_t group;
+   u8 group;
 
for (group = 0; group < S626_DIO_BANKS; group++) {
/* read interrupt type */
@@ -1272,7 +1272,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
 /*
  * This function builds the RPS program for hardware driven acquisition.
  */
-static void s626_reset_adc(struct 

[PATCH v4 2/3] staging: comedi: s626: use preferred kernel type u16

2016-12-01 Thread Saber Rezvani
Fix the checkpatch.pl issue:
CHECK: Prefer kernel type 'u16' over 'uint16_t'

Signed-off-by: Saber Rezvani 
Reviewed-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/s626.c | 96 +--
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index 59a4aeb..baf997d 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -81,7 +81,7 @@ struct s626_private {
int ai_convert_count;   /* conversion counter */
unsigned int ai_convert_timer;  /* time between conversion in
 * units of the timer */
-   uint16_t counter_int_enabs; /* counter interrupt enable mask
+   u16 counter_int_enabs;  /* counter interrupt enable mask
 * for MISC2 register */
u8 adc_items;   /* number of items in ADC poll list */
struct s626_buffer_dma rps_buf; /* DMA buffer used to hold ADC (RPS1)
@@ -90,7 +90,7 @@ struct s626_private {
 * and hold DAC data */
uint32_t *dac_wbuf; /* pointer to logical adrs of DMA buffer
 * used to hold DAC data */
-   uint16_t dacpol;/* image of DAC polarity register */
+   u16 dacpol; /* image of DAC polarity register */
u8 trim_setpoint[12];   /* images of TrimDAC setpoints */
uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
 * (board rev dependent) */
@@ -179,7 +179,7 @@ static void s626_debi_transfer(struct comedi_device *dev)
 /*
  * Read a value from a gate array register.
  */
-static uint16_t s626_debi_read(struct comedi_device *dev, uint16_t addr)
+static u16 s626_debi_read(struct comedi_device *dev, u16 addr)
 {
/* Set up DEBI control register value in shadow RAM */
writel(S626_DEBI_CMD_RDWORD | addr, dev->mmio + S626_P_DEBICMD);
@@ -193,8 +193,8 @@ static uint16_t s626_debi_read(struct comedi_device *dev, 
uint16_t addr)
 /*
  * Write a value to a gate array register.
  */
-static void s626_debi_write(struct comedi_device *dev, uint16_t addr,
-   uint16_t wdata)
+static void s626_debi_write(struct comedi_device *dev, u16 addr,
+   u16 wdata)
 {
/* Set up DEBI control register value in shadow RAM */
writel(S626_DEBI_CMD_WRWORD | addr, dev->mmio + S626_P_DEBICMD);
@@ -516,10 +516,10 @@ static int s626_send_dac(struct comedi_device *dev, 
uint32_t val)
  * Private helper function: Write setpoint to an application DAC channel.
  */
 static int s626_set_dac(struct comedi_device *dev,
-   uint16_t chan, int16_t dacdata)
+   u16 chan, int16_t dacdata)
 {
struct s626_private *devpriv = dev->private;
-   uint16_t signmask;
+   u16 signmask;
uint32_t ws_image;
uint32_t val;
 
@@ -535,7 +535,7 @@ static int s626_set_dac(struct comedi_device *dev,
}
 
/* Limit DAC setpoint value to valid range. */
-   if ((uint16_t)dacdata > 0x1FFF)
+   if ((u16)dacdata > 0x1FFF)
dacdata = 0x1FFF;
 
/*
@@ -661,7 +661,7 @@ static int s626_load_trim_dacs(struct comedi_device *dev)
  * latches B.
  */
 static void s626_set_latch_source(struct comedi_device *dev,
- unsigned int chan, uint16_t value)
+ unsigned int chan, u16 value)
 {
s626_debi_replace(dev, S626_LP_CRB(chan),
  ~(S626_CRBMSK_INTCTRL | S626_CRBMSK_LATCHSRC),
@@ -686,7 +686,7 @@ static void s626_preload(struct comedi_device *dev,
 static void s626_reset_cap_flags(struct comedi_device *dev,
 unsigned int chan)
 {
-   uint16_t set;
+   u16 set;
 
set = S626_SET_CRB_INTRESETCMD(1);
if (chan < 3)
@@ -704,12 +704,12 @@ static void s626_reset_cap_flags(struct comedi_device 
*dev,
  * ClkPol, ClkEnab, IndexSrc, IndexPol, LoadSrc.
  */
 static void s626_set_mode_a(struct comedi_device *dev,
-   unsigned int chan, uint16_t setup,
-   uint16_t disable_int_src)
+   unsigned int chan, u16 setup,
+   u16 disable_int_src)
 {
struct s626_private *devpriv = dev->private;
-   uint16_t cra;
-   uint16_t crb;
+   u16 cra;
+   u16 crb;
unsigned int cntsrc, clkmult, clkpol;
 
/* Initialize CRA and CRB images. */
@@ -782,12 +782,12 @@ static void s626_set_mode_a(struct comedi_device *dev,
 }
 
 static void s626_set_mode_b(struct comedi_device *dev,
-   unsigned int chan, uint16_t setup,
- 

Re: [PATCH] staging: wilc1000: fixed the wrong error code

2016-12-01 Thread Dan Carpenter
This doesn't apply.  Here is a howto on sending a v2 patch.

https://kernelnewbies.org/FirstKernelPatch#head-5c81b3c517a1d0bbc24f92594cb734e155fcbbcb

regards,
dan carpenter

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


Re: [PATCH] staging: wilc1000: remove memory allocate failure message

2016-12-01 Thread Greg KH
On Fri, Dec 02, 2016 at 12:35:54AM +0530, Amit Kushwaha wrote:
> This patch cleanup following warning reported by checkpatch.pl
> WARNING: Possible unnecessary 'out of memory' message
> With no available memory, a warn on message already gets printed
> by page alloc functions
> 
> Signed-off-by: Amit Kushwaha 
> ---
>  drivers/staging/wilc1000/host_interface.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/wilc1000/host_interface.c
> b/drivers/staging/wilc1000/host_interface.c
> index b00ea75..23abdd4 100644
> --- a/drivers/staging/wilc1000/host_interface.c
> +++ b/drivers/staging/wilc1000/host_interface.c
> @@ -1691,7 +1691,6 @@ static int Handle_Key(struct wilc_vif *vif,
>   } else if (pstrHostIFkeyAttr->action & ADDKEY) {
>   pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
>   if (!pu8keybuf) {
> - netdev_err(vif->ndev, "No buffer send PTK\n");
>   ret = -ENOMEM;
>   goto _WPAPtk_end_case_;
>   }
> -- 
> 2.10.2.windows.1

"windows"?

Anyway, you are obviously not testing your patches actually can be
applied, and you have now changed your email address, so I'm going to
assume there is something really wrong here and now just add your
emails to a blacklist.

I suggest working on a different open source project for a while to get
some experience.

best of luck,

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


[PATCH] staging: wilc1000: remove memory allocate failure message

2016-12-01 Thread Amit Kushwaha
This patch cleanup following warning reported by checkpatch.pl
WARNING: Possible unnecessary 'out of memory' message
With no available memory, a warn on message already gets printed
by page alloc functions

Signed-off-by: Amit Kushwaha 
---
 drivers/staging/wilc1000/host_interface.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.c
b/drivers/staging/wilc1000/host_interface.c
index b00ea75..23abdd4 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1691,7 +1691,6 @@ static int Handle_Key(struct wilc_vif *vif,
  } else if (pstrHostIFkeyAttr->action & ADDKEY) {
  pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
  if (!pu8keybuf) {
- netdev_err(vif->ndev, "No buffer send PTK\n");
  ret = -ENOMEM;
  goto _WPAPtk_end_case_;
  }
-- 
2.10.2.windows.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: sm750fb: Aligning Block comments

2016-12-01 Thread SRIKANT RITOLIA
Fix checkpatch.pl warnings:-
Block comments should align the * on each line

Signed-off-by: Srikant Ritolia 
---
 drivers/staging/sm750fb/ddk750.h   | 20 ++--
 drivers/staging/sm750fb/ddk750_chip.c  | 14 +++---
 drivers/staging/sm750fb/ddk750_chip.h  | 10 +-
 drivers/staging/sm750fb/ddk750_mode.c  | 12 ++--
 drivers/staging/sm750fb/ddk750_swi2c.c | 22 +++---
 drivers/staging/sm750fb/ddk750_swi2c.h | 22 +++---
 6 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750.h b/drivers/staging/sm750fb/ddk750.h
index 2c10a08ed964..7ee371443e28 100644
--- a/drivers/staging/sm750fb/ddk750.h
+++ b/drivers/staging/sm750fb/ddk750.h
@@ -1,16 +1,16 @@
 #ifndef DDK750_H__
 #define DDK750_H__
 /***
-*
-* Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
-*
-*  All rights are reserved. Reproduction or in part is prohibited
-*  without the written consent of the copyright owner.
-*
-*  RegSC.h --- SM718 SDK
-*  This file contains the definitions for the System Configuration registers.
-*
-***/
+ *
+ * Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
+ *
+ *  All rights are reserved. Reproduction or in part is prohibited
+ *  without the written consent of the copyright owner.
+ *
+ *  RegSC.h --- SM718 SDK
+ *  This file contains the definitions for the System Configuration registers.
+ *
+ ***/
 #include "ddk750_reg.h"
 #include "ddk750_mode.h"
 #include "ddk750_chip.h"
diff --git a/drivers/staging/sm750fb/ddk750_chip.c
b/drivers/staging/sm750fb/ddk750_chip.c
index 839d6730bde9..b7697ac206cf 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -63,17 +63,17 @@ static void setChipClock(unsigned int frequency)

  if (frequency) {
  /*
- * Set up PLL, a structure to hold the value to be set in clocks.
- */
+ * Set up PLL, a structure to hold the value to be set in clocks.
+ */
  pll.inputFreq = DEFAULT_INPUT_CLOCK; /* Defined in CLOCK.H */
  pll.clockType = MXCLK_PLL;

  /*
- * Call calcPllValue() to fill the other fields of PLL structure.
- * Sometime, the chip cannot set up the exact clock
- * required by the User.
- * Return value of calcPllValue gives the actual possible clock.
- */
+ * Call calcPllValue() to fill the other fields of PLL structure.
+ * Sometime, the chip cannot set up the exact clock
+ * required by the User.
+ * Return value of calcPllValue gives the actual possible clock.
+ */
  ulActualMxClk = calcPllValue(frequency, );

  /* Master Clock Control: MXCLK_PLL */
diff --git a/drivers/staging/sm750fb/ddk750_chip.h
b/drivers/staging/sm750fb/ddk750_chip.h
index 14357fd1cc6b..20031f4e03fa 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -40,27 +40,27 @@ pll_value_t;
 /* input struct to initChipParam() function */
 typedef struct _initchip_param_t {
  unsigned short powerMode;/* Use power mode 0 or 1 */
- unsigned short chipClock;/**
+ unsigned short chipClock;/*
   * Speed of main chip clock in MHz unit
   * 0 = keep the current clock setting
   * Others = the new main chip clock
   */
- unsigned short memClock; /**
+ unsigned short memClock; /*
   * Speed of memory clock in MHz unit
   * 0 = keep the current clock setting
   * Others = the new memory clock
   */
- unsigned short masterClock;  /**
+ unsigned short masterClock;  /*
   * Speed of master clock in MHz unit
   * 0 = keep the current clock setting
   * Others = the new master clock
   */
- unsigned short setAllEngOff; /**
+ unsigned short setAllEngOff; /*
   * 0 = leave all engine state untouched.
   * 1 = make sure they are off: 2D, Overlay,
   * video alpha, alpha, hardware cursors
   */
- unsigned char resetMemory;   /**
+ unsigned char resetMemory;   /*
   * 0 = Do not reset the memory controller
   * 1 = Reset the memory controller
   */
diff --git a/drivers/staging/sm750fb/ddk750_mode.c
b/drivers/staging/sm750fb/ddk750_mode.c
index 05b83646c2d5..4c0012b81c7f 100644
--- a/drivers/staging/sm750fb/ddk750_mode.c
+++ b/drivers/staging/sm750fb/ddk750_mode.c
@@ -177,12 +177,12 @@ static int programModeRegisters(mode_parameter_t
*pModeParam, pll_value_t *pll)
   DISPLAY_CTRL_PLANE);

  /* May a hardware bug or just my test chip (not confirmed).
- * PANEL_DISPLAY_CTRL register seems requiring few writes
- * before a value can be successfully written in.
- * Added some masks to mask out the reserved bits.
- * Note: This problem happens by design. The hardware will wait for the
- *   next vertical sync to turn on/off the plane.
- */
+ * PANEL_DISPLAY_CTRL register seems requiring few writes
+ * before a value can be 

Re: [PATCH] staging: wilc1000: fixed the wrong error code

2016-12-01 Thread Atul Raj
On Thu, Dec 1, 2016 at 1:03 AM, Dan Carpenter  wrote:
> On Thu, Dec 01, 2016 at 12:58:45AM +0530, Atul Raj wrote:
>> ENOENT is error code for 
>> ENOMEM should be used for 
>>
>> Signed-off-by: Atul Raj 

> Changelog doesn't match the patch.

Sorry for the mistake. Please check the corrected version.

EFAULT is error code for 
ENOMEM should be used for 


Signed-off-by: Atul Raj 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 60d8b05..971956f 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1642,7 +1642,7 @@ static int mgmt_tx(struct wiphy *wiphy,
if (ieee80211_is_mgmt(mgmt->frame_control)) {
mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
if (!mgmt_tx)
-   return -EFAULT;
+   return -ENOMEM;

mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
if (!mgmt_tx->buff) {
--
2.10.2.windows.1

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


[PATCH v3] x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic

2016-12-01 Thread Vitaly Kuznetsov
There is a feature in Hyper-V (Debug-VM --InjectNonMaskableInterrupt) which
injects NMI to the guest. Prior to WS2016 the NMI is injected to all CPUs
of the guest and WS2016 injects it to CPU0 only. When unknown_nmi_panic is
enabled and we'd like to do kdump we need to perform some minimal cleanup
so the kdump kernel will be able to initialize VMBus devices, this cleanup
includes sending CHANNELMSG_UNLOAD to the host waiting for
CHANNELMSG_UNLOAD_RESPONSE to arrive. WS2012R2 always sends the response
to the CPU which was used to send CHANNELMSG_REQUESTOFFERS on VMBus module
load and not to the CPU which is sending CHANNELMSG_UNLOAD. As we can't do
any cross-CPU work reliably on crash we have vmbus_wait_for_unload()
function which tries to read CHANNELMSG_UNLOAD_RESPONSE on all CPUs message
pages and this sometimes works. It was discovered that in case the host
wants to send more than one message to a secondary CPU (not the CPU running
vmbus_wait_for_unload()) we're unable to get it as after reading the first
message we're supposed to do EOMing by doing wrmsrl(HV_X64_MSR_EOM, 0) but
this is per-CPU. I have a feeling that this was working some time ago when
I implemented vmbus_wait_for_unload(), the host was re-trying to deliver a
message even without wrmsrl() but apparently this doesn't work any more.
Unfortunately there is not that much we can do when all CPUs get NMI as
all but the first one are getting blocked with interrupts disabled. What we
can do is limit processing unknown interrupts to the first CPU which gets
it in case we're about to crash.

Signed-off-by: Vitaly Kuznetsov 
Acked-by: K. Y. Srinivasan 
---
Changes since v2:
- Supply NMI_UNKNOWN instead of NMI_LOCAL for register_nmi_handler()
- Retain KY's ACK (hopefully stands with the above mentioned change)

Changes since v1:
- Put everything under #ifdef CONFIG_X86_LOCAL_APIC as unknown_nmi_panic is
  otherwise undefined. [kbuild test robot]
- Add KY's Ack (hopefully stands with the above mentioned change)
---
 arch/x86/kernel/cpu/mshyperv.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 8f44c5a..f228f74 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);
@@ -158,6 +159,26 @@ static unsigned char hv_get_nmi_reason(void)
return 0;
 }
 
+#ifdef CONFIG_X86_LOCAL_APIC
+/*
+ * Prior to WS2016 Debug-VM sends NMIs to all CPUs which makes
+ * it dificult to process CHANNELMSG_UNLOAD in case of crash. Handle
+ * unknown NMI on the first CPU which gets it.
+ */
+static int hv_nmi_unknown(unsigned int val, struct pt_regs *regs)
+{
+   static atomic_t nmi_cpu = ATOMIC_INIT(-1);
+
+   if (!unknown_nmi_panic)
+   return NMI_DONE;
+
+   if (atomic_cmpxchg(_cpu, -1, raw_smp_processor_id()) != -1)
+   return NMI_HANDLED;
+
+   return NMI_DONE;
+}
+#endif
+
 static void __init ms_hyperv_init_platform(void)
 {
/*
@@ -183,6 +204,9 @@ static void __init ms_hyperv_init_platform(void)
pr_info("HyperV: LAPIC Timer Frequency: %#x\n",
lapic_timer_frequency);
}
+
+   register_nmi_handler(NMI_UNKNOWN, hv_nmi_unknown, NMI_FLAG_FIRST,
+"hv_nmi_unknown");
 #endif
 
if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
-- 
2.9.3

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


Re: [PATCH v2] x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic

2016-12-01 Thread Vitaly Kuznetsov
Vitaly Kuznetsov  writes:

[snip]

>  static void __init ms_hyperv_init_platform(void)
>  {
>   /*
> @@ -183,6 +204,9 @@ static void __init ms_hyperv_init_platform(void)
>   pr_info("HyperV: LAPIC Timer Frequency: %#x\n",
>   lapic_timer_frequency);
>   }
> +
> + register_nmi_handler(NMI_LOCAL, hv_nmi_unknown, NMI_FLAG_FIRST,
> +  "hv_nmi_unknown");

This should probably be NMI_UNKNOWN instead of NMI_LOCAL. While it works
regardless and we don't have other NMIs on Hyper-V VMs (or do we?) I
think it would be better to do v3.

Sorry for the inconvenience.

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


[PATCH 04/15] Drivers: hv: vmbus: Prevent sending data on a rescinded channel

2016-12-01 Thread kys
From: K. Y. Srinivasan 

After the channel is rescinded, the host does not read from the rescinded 
channel.
Fail writes to a channel that has already been rescinded
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index cd49cb1..72f649d 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -298,6 +298,9 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
unsigned long flags = 0;
struct hv_ring_buffer_info *outring_info = >outbound;
 
+   if (channel->rescind)
+   return -ENODEV;
+
for (i = 0; i < kv_count; i++)
totalbytes_towrite += kv_list[i].iov_len;
 
-- 
1.7.4.1

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


[PATCH 12/15] hv: don't reset hv_context.tsc_page on crash

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

It may happen that secondary CPUs are still alive and resetting
hv_context.tsc_page will cause a consequent crash in read_hv_clock_tsc()
as we don't check for it being not NULL there. It is safe as we're not
freeing this page anyways.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 4ece040..04a0fd8 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -309,9 +309,10 @@ void hv_cleanup(bool crash)
 
hypercall_msr.as_uint64 = 0;
wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
-   if (!crash)
+   if (!crash) {
vfree(hv_context.tsc_page);
-   hv_context.tsc_page = NULL;
+   hv_context.tsc_page = NULL;
+   }
}
 #endif
 }
-- 
1.7.4.1

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


[PATCH 11/15] hv: make CPU offlining prevention fine-grained

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

Since commit e513229b4c38 ("Drivers: hv: vmbus: prevent cpu offlining on
newer hypervisors") cpu offlining was disabled. It is still true that we
can't offline CPUs which have VMBus channels bound to them but we may have
'free' CPUs (e.v. we booted with maxcpus= parameter and onlined CPUs after
VMBus was initialized), these CPUs may be disabled without issues.

In future, we may even allow closing CPUs which have only sub-channels
assinged to them by closing these sub-channels. All devices will continue
to work.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv.c|   31 +++
 drivers/hv/vmbus_drv.c |9 -
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index b3f6a1b..4ece040 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -586,10 +586,41 @@ int hv_synic_cleanup(unsigned int cpu)
union hv_synic_simp simp;
union hv_synic_siefp siefp;
union hv_synic_scontrol sctrl;
+   struct vmbus_channel *channel, *sc;
+   bool channel_found = false;
+   unsigned long flags;
 
if (!hv_context.synic_initialized)
return -EFAULT;
 
+   /*
+* Search for channels which are bound to the CPU we're about to
+* cleanup. In case we find one and vmbus is still connected we need to
+* fail, this will effectively prevent CPU offlining. There is no way
+* we can re-bind channels to different CPUs for now.
+*/
+   mutex_lock(_connection.channel_mutex);
+   list_for_each_entry(channel, _connection.chn_list, listentry) {
+   if (channel->target_cpu == cpu) {
+   channel_found = true;
+   break;
+   }
+   spin_lock_irqsave(>lock, flags);
+   list_for_each_entry(sc, >sc_list, sc_list) {
+   if (sc->target_cpu == cpu) {
+   channel_found = true;
+   break;
+   }
+   }
+   spin_unlock_irqrestore(>lock, flags);
+   if (channel_found)
+   break;
+   }
+   mutex_unlock(_connection.channel_mutex);
+
+   if (channel_found && vmbus_connection.conn_state == CONNECTED)
+   return -EBUSY;
+
/* Turn off clockevent device */
if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) {
clockevents_unbind_device(hv_context.clk_evt[cpu], cpu);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index cafd273..1e2a413 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -861,9 +861,6 @@ static int vmbus_bus_init(void)
if (ret)
goto err_connect;
 
-   if (vmbus_proto_version > VERSION_WIN7)
-   cpu_hotplug_disable();
-
/*
 * Only register if the crash MSRs are available
 */
@@ -1334,6 +1331,9 @@ static void hv_kexec_handler(void)
 {
hv_synic_clockevents_cleanup();
vmbus_initiate_unload(false);
+   vmbus_connection.conn_state = DISCONNECTED;
+   /* Make sure conn_state is set as hv_synic_cleanup checks for it */
+   mb();
cpuhp_remove_state(hyperv_cpuhp_online);
hv_cleanup(false);
 };
@@ -1346,6 +1346,7 @@ static void hv_crash_handler(struct pt_regs *regs)
 * doing the cleanup for current CPU only. This should be sufficient
 * for kdump.
 */
+   vmbus_connection.conn_state = DISCONNECTED;
hv_synic_cleanup(smp_processor_id());
hv_cleanup(true);
 };
@@ -1414,8 +1415,6 @@ static void __exit vmbus_exit(void)
cpuhp_remove_state(hyperv_cpuhp_online);
hv_synic_free();
acpi_bus_unregister_driver(_acpi_driver);
-   if (vmbus_proto_version > VERSION_WIN7)
-   cpu_hotplug_enable();
 }
 
 
-- 
1.7.4.1

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


[PATCH 14/15] uio-hv-generic: new userspace i/o driver for VMBus

2016-12-01 Thread kys
From: Stephen Hemminger 

This is a new driver to enable userspace networking on VMBus.
It is based largely on the similar driver that already exists
for PCI, and earlier work done by Brocade to support DPDK.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 MAINTAINERS  |1 +
 drivers/hv/connection.c  |1 +
 drivers/uio/Kconfig  |9 ++
 drivers/uio/Makefile |1 +
 drivers/uio/uio_hv_generic.c |  218 ++
 5 files changed, 230 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_hv_generic.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 2f89c3b..6d6bea9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5851,6 +5851,7 @@ F:drivers/input/serio/hyperv-keyboard.c
 F: drivers/pci/host/pci-hyperv.c
 F: drivers/net/hyperv/
 F: drivers/scsi/storvsc_drv.c
+F: drivers/uio/uio_hv_generic.c
 F: drivers/video/fbdev/hyperv_fb.c
 F: include/linux/hyperv.h
 F: tools/hv/
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 840b6db..9b72ebc 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -39,6 +39,7 @@ struct vmbus_connection vmbus_connection = {
.conn_state = DISCONNECTED,
.next_gpadl_handle  = ATOMIC_INIT(0xE1E10),
 };
+EXPORT_SYMBOL_GPL(vmbus_connection);
 
 /*
  * Negotiated protocol version with the host.
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 52c98ce..7e8dc78 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -155,4 +155,13 @@ config UIO_MF624
 
  If you compile this as a module, it will be called uio_mf624.
 
+config UIO_HV_GENERIC
+   tristate "Generic driver for Hyper-V VMBus"
+   depends on HYPERV
+   help
+ Generic driver that you can bind, dynamically, to any
+ Hyper-V VMBus device. It is useful to provide direct access
+ to network and storage devices from userspace.
+
+ If you compile this as a module, it will be called uio_hv_generic.
 endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 8560dad..e9663bb 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_UIO_NETX)  += uio_netx.o
 obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o
 obj-$(CONFIG_UIO_MF624) += uio_mf624.o
 obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o
+obj-$(CONFIG_UIO_HV_GENERIC)   += uio_hv_generic.o
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
new file mode 100644
index 000..ad3ab58
--- /dev/null
+++ b/drivers/uio/uio_hv_generic.c
@@ -0,0 +1,218 @@
+/*
+ * uio_hv_generic - generic UIO driver for VMBus
+ *
+ * Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+ * Copyright (c) 2016, Microsoft Corporation.
+ *
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ *
+ * Since the driver does not declare any device ids, you must allocate
+ * id and bind the device to the driver yourself.  For example:
+ *
+ * # echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" \
+ *> /sys/bus/vmbus/drivers/uio_hv_generic
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *> /sys/bus/vmbus/drivers/hv_netvsc/unbind
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *> /sys/bus/vmbus/drivers/uio_hv_generic/bind
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../hv/hyperv_vmbus.h"
+
+#define DRIVER_VERSION "0.02.0"
+#define DRIVER_AUTHOR  "Stephen Hemminger "
+#define DRIVER_DESC"Generic UIO driver for VMBus devices"
+
+/*
+ * List of resources to be mapped to user space
+ * can be extended up to MAX_UIO_MAPS(5) items
+ */
+enum hv_uio_map {
+   TXRX_RING_MAP = 0,
+   INT_PAGE_MAP,
+   MON_PAGE_MAP,
+};
+
+#define HV_RING_SIZE   512
+
+struct hv_uio_private_data {
+   struct uio_info info;
+   struct hv_device *device;
+};
+
+static int
+hv_uio_mmap(struct uio_info *info, struct vm_area_struct *vma)
+{
+   int mi;
+
+   if (vma->vm_pgoff >= MAX_UIO_MAPS)
+   return -EINVAL;
+
+   if (info->mem[vma->vm_pgoff].size == 0)
+   return -EINVAL;
+
+   mi = (int)vma->vm_pgoff;
+
+   return remap_pfn_range(vma, vma->vm_start,
+   virt_to_phys((void *)info->mem[mi].addr) >> PAGE_SHIFT,
+   vma->vm_end - vma->vm_start, vma->vm_page_prot);
+}
+
+/*
+ * This is the irqcontrol callback to be registered to uio_info.
+ * It can be used to disable/enable interrupt from user space processes.
+ *
+ * @param info
+ *  pointer to uio_info.
+ * @param irq_state
+ *  state value. 1 to enable interrupt, 0 to disable interrupt.
+ */
+static int
+hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
+{
+   struct 

[PATCH 05/15] Drivers: hv: vmbus: Enhance the rescind callback functionality

2016-12-01 Thread kys
From: K. Y. Srinivasan 

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |   11 +++
 include/linux/hyperv.h|7 ---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index f9c5827..d83c1ac 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -825,8 +825,10 @@ static void vmbus_onoffer_rescind(struct 
vmbus_channel_message_header *hdr)
 
if (channel->device_obj) {
if (channel->chn_rescind_callback) {
-   channel->chn_rescind_callback(channel);
-   goto out;
+   channel->chn_rescind_callback(channel,
+ channel->rescind_arg);
+   if (is_hvsock_channel(channel))
+   goto out;
}
/*
 * We will have to unregister this device from the
@@ -1215,9 +1217,10 @@ bool vmbus_are_subchannels_present(struct vmbus_channel 
*primary)
 }
 EXPORT_SYMBOL_GPL(vmbus_are_subchannels_present);
 
-void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel,
-   void (*chn_rescind_cb)(struct vmbus_channel *))
+void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel, void *arg,
+   void (*chn_rescind_cb)(struct vmbus_channel *, void *))
 {
channel->chn_rescind_callback = chn_rescind_cb;
+   channel->rescind_arg = arg;
 }
 EXPORT_SYMBOL_GPL(vmbus_set_chn_rescind_callback);
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 5a2d2dd..5051eca 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -800,7 +800,8 @@ struct vmbus_channel {
 * Channel rescind callback. Some channels (the hvsock ones), need to
 * register a callback which is invoked in vmbus_onoffer_rescind().
 */
-   void (*chn_rescind_callback)(struct vmbus_channel *channel);
+   void (*chn_rescind_callback)(struct vmbus_channel *channel, void *arg);
+   void *rescind_arg;
 
/*
 * The spinlock to protect the structure. It is being used to protect
@@ -959,8 +960,8 @@ static inline void clear_low_latency_mode(struct 
vmbus_channel *c)
 void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
void (*sc_cr_cb)(struct vmbus_channel *new_sc));
 
-void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel,
-   void (*chn_rescind_cb)(struct vmbus_channel *));
+void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel, void *arg,
+   void (*chn_rescind_cb)(struct vmbus_channel *, void *));
 
 /*
  * Retrieve the (sub) channel on which to send an outgoing request.
-- 
1.7.4.1

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


[PATCH 15/15] Tools: hv: kvp: configurable external scripts path

2016-12-01 Thread kys
From: Alex Fluter 

error when running hypervkvpd:
$ sudo ./hv_kvp_daemon -n

sh: hv_get_dns_info: command not found
sh: hv_get_dhcp_info: command not found
sh: hv_get_dns_info: command not found
sh: hv_get_dhcp_info: command not found

The external scripts are not installed in system path,
adding a configurable macro.

Signed-off-by: Alex Fluter 
Signed-off-by: K. Y. Srinivasan 
---
 tools/hv/hv_kvp_daemon.c |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index d791dbf..f1758fc 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -93,6 +93,10 @@ enum {
 
 #define KVP_CONFIG_LOC "/var/lib/hyperv"
 
+#ifndef KVP_SCRIPTS_PATH
+#define KVP_SCRIPTS_PATH "/usr/libexec/hypervkvpd/"
+#endif
+
 #define MAX_FILE_NAME 100
 #define ENTRIES_PER_BLOCK 50
 
@@ -818,7 +822,7 @@ static void kvp_get_ipconfig_info(char *if_name,
 * .
 */
 
-   sprintf(cmd, "%s",  "hv_get_dns_info");
+   sprintf(cmd, KVP_SCRIPTS_PATH "%s",  "hv_get_dns_info");
 
/*
 * Execute the command to gather DNS info.
@@ -835,7 +839,7 @@ static void kvp_get_ipconfig_info(char *if_name,
 * Enabled: DHCP enabled.
 */
 
-   sprintf(cmd, "%s %s", "hv_get_dhcp_info", if_name);
+   sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name);
 
file = popen(cmd, "r");
if (file == NULL)
@@ -1341,7 +1345,8 @@ static int kvp_set_ip_info(char *if_name, struct 
hv_kvp_ipaddr_value *new_val)
 * invoke the external script to do its magic.
 */
 
-   snprintf(cmd, sizeof(cmd), "%s %s", "hv_set_ifconfig", if_file);
+   snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
+"hv_set_ifconfig", if_file);
if (system(cmd)) {
syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s",
cmd, errno, strerror(errno));
-- 
1.7.4.1

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


[PATCH 10/15] hv: switch to cpuhp state machine for synic init/cleanup

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

To make it possible to online/offline CPUs switch to cpuhp infrastructure
for doing hv_synic_init()/hv_synic_cleanup().

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv.c   |   15 +++
 drivers/hv/hyperv_vmbus.h |4 ++--
 drivers/hv/vmbus_drv.c|   19 +++
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index c11393c..b3f6a1b 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -495,7 +495,7 @@ void hv_synic_free(void)
  * retrieve the initialized message and event pages.  Otherwise, we create and
  * initialize the message and event pages.
  */
-void hv_synic_init(void *arg)
+int hv_synic_init(unsigned int cpu)
 {
u64 version;
union hv_synic_simp simp;
@@ -504,10 +504,8 @@ void hv_synic_init(void *arg)
union hv_synic_scontrol sctrl;
u64 vp_index;
 
-   int cpu = smp_processor_id();
-
if (!hv_context.hypercall_page)
-   return;
+   return -EFAULT;
 
/* Check the version */
rdmsrl(HV_X64_MSR_SVERSION, version);
@@ -562,7 +560,7 @@ void hv_synic_init(void *arg)
HV_TIMER_FREQUENCY,
HV_MIN_DELTA_TICKS,
HV_MAX_MAX_DELTA_TICKS);
-   return;
+   return 0;
 }
 
 /*
@@ -582,16 +580,15 @@ void hv_synic_clockevents_cleanup(void)
 /*
  * hv_synic_cleanup - Cleanup routine for hv_synic_init().
  */
-void hv_synic_cleanup(void *arg)
+int hv_synic_cleanup(unsigned int cpu)
 {
union hv_synic_sint shared_sint;
union hv_synic_simp simp;
union hv_synic_siefp siefp;
union hv_synic_scontrol sctrl;
-   int cpu = smp_processor_id();
 
if (!hv_context.synic_initialized)
-   return;
+   return -EFAULT;
 
/* Turn off clockevent device */
if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) {
@@ -623,4 +620,6 @@ void hv_synic_cleanup(void *arg)
rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
sctrl.enable = 0;
wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
+
+   return 0;
 }
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 27982df..83beea7 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -505,9 +505,9 @@ extern int hv_post_message(union hv_connection_id 
connection_id,
 
 extern void hv_synic_free(void);
 
-extern void hv_synic_init(void *irqarg);
+extern int hv_synic_init(unsigned int cpu);
 
-extern void hv_synic_cleanup(void *arg);
+extern int hv_synic_cleanup(unsigned int cpu);
 
 extern void hv_synic_clockevents_cleanup(void);
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 1730ac0..cafd273 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -49,6 +49,7 @@
 
 static struct completion probe_event;
 
+static int hyperv_cpuhp_online;
 
 static void hyperv_report_panic(struct pt_regs *regs)
 {
@@ -850,7 +851,12 @@ static int vmbus_bus_init(void)
 * Initialize the per-cpu interrupt state and
 * connect to the host.
 */
-   on_each_cpu(hv_synic_init, NULL, 1);
+   ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv:online",
+   hv_synic_init, hv_synic_cleanup);
+   if (ret < 0)
+   goto err_alloc;
+   hyperv_cpuhp_online = ret;
+
ret = vmbus_connect();
if (ret)
goto err_connect;
@@ -872,7 +878,7 @@ static int vmbus_bus_init(void)
return 0;
 
 err_connect:
-   on_each_cpu(hv_synic_cleanup, NULL, 1);
+   cpuhp_remove_state(hyperv_cpuhp_online);
 err_alloc:
hv_synic_free();
hv_remove_vmbus_irq();
@@ -1326,12 +1332,9 @@ static int vmbus_acpi_add(struct acpi_device *device)
 
 static void hv_kexec_handler(void)
 {
-   int cpu;
-
hv_synic_clockevents_cleanup();
vmbus_initiate_unload(false);
-   for_each_online_cpu(cpu)
-   smp_call_function_single(cpu, hv_synic_cleanup, NULL, 1);
+   cpuhp_remove_state(hyperv_cpuhp_online);
hv_cleanup(false);
 };
 
@@ -1343,7 +1346,7 @@ static void hv_crash_handler(struct pt_regs *regs)
 * doing the cleanup for current CPU only. This should be sufficient
 * for kdump.
 */
-   hv_synic_cleanup(NULL);
+   hv_synic_cleanup(smp_processor_id());
hv_cleanup(true);
 };
 
@@ -1407,8 +1410,8 @@ static void __exit vmbus_exit(void)
hv_cleanup(false);
for_each_online_cpu(cpu) {
tasklet_kill(hv_context.event_dpc[cpu]);
-   smp_call_function_single(cpu, hv_synic_cleanup, NULL, 1);
}
+   cpuhp_remove_state(hyperv_cpuhp_online);
hv_synic_free();

[PATCH 13/15] vmbus: add support for dynamic device id's

2016-12-01 Thread kys
From: Stephen Hemminger 

This patch adds sysfs interface to dynamically bind new UUID values
to existing VMBus device. This is useful for generic UIO driver to
act similar to uio_pci_generic.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/vmbus_drv.c |  174 +--
 include/linux/hyperv.h |6 ++
 2 files changed, 172 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 1e2a413..fbf1422 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -45,6 +45,11 @@
 #include 
 #include "hyperv_vmbus.h"
 
+struct vmbus_dynid {
+   struct list_head node;
+   struct hv_vmbus_device_id id;
+};
+
 static struct acpi_device  *hv_acpi_dev;
 
 static struct completion probe_event;
@@ -501,7 +506,7 @@ static ssize_t device_show(struct device *dev,
 static DEVICE_ATTR_RO(device);
 
 /* Set up per device attributes in /sys/bus/vmbus/devices/ */
-static struct attribute *vmbus_attrs[] = {
+static struct attribute *vmbus_dev_attrs[] = {
_attr_id.attr,
_attr_state.attr,
_attr_monitor_id.attr,
@@ -529,7 +534,7 @@ static ssize_t device_show(struct device *dev,
_attr_device.attr,
NULL,
 };
-ATTRIBUTE_GROUPS(vmbus);
+ATTRIBUTE_GROUPS(vmbus_dev);
 
 /*
  * vmbus_uevent - add uevent for our device
@@ -566,10 +571,29 @@ static inline bool is_null_guid(const uuid_le *guid)
  * Return a matching hv_vmbus_device_id pointer.
  * If there is no match, return NULL.
  */
-static const struct hv_vmbus_device_id *hv_vmbus_get_id(
-   const struct hv_vmbus_device_id *id,
+static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
const uuid_le *guid)
 {
+   const struct hv_vmbus_device_id *id = NULL;
+   struct vmbus_dynid *dynid;
+
+   /* Look at the dynamic ids first, before the static ones */
+   spin_lock(>dynids.lock);
+   list_for_each_entry(dynid, >dynids.list, node) {
+   if (!uuid_le_cmp(dynid->id.guid, *guid)) {
+   id = >id;
+   break;
+   }
+   }
+   spin_unlock(>dynids.lock);
+
+   if (id)
+   return id;
+
+   id = drv->id_table;
+   if (id == NULL)
+   return NULL; /* empty device table */
+
for (; !is_null_guid(>guid); id++)
if (!uuid_le_cmp(id->guid, *guid))
return id;
@@ -577,6 +601,134 @@ static inline bool is_null_guid(const uuid_le *guid)
return NULL;
 }
 
+/* vmbus_add_dynid - add a new device ID to this driver and re-probe devices */
+static int vmbus_add_dynid(struct hv_driver *drv, uuid_le *guid)
+{
+   struct vmbus_dynid *dynid;
+
+   dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
+   if (!dynid)
+   return -ENOMEM;
+
+   dynid->id.guid = *guid;
+
+   spin_lock(>dynids.lock);
+   list_add_tail(>node, >dynids.list);
+   spin_unlock(>dynids.lock);
+
+   return driver_attach(>driver);
+}
+
+static void vmbus_free_dynids(struct hv_driver *drv)
+{
+   struct vmbus_dynid *dynid, *n;
+
+   spin_lock(>dynids.lock);
+   list_for_each_entry_safe(dynid, n, >dynids.list, node) {
+   list_del(>node);
+   kfree(dynid);
+   }
+   spin_unlock(>dynids.lock);
+}
+
+/* Parse string of form: 1b4e28ba-2fa1-11d2-883f-b9a761bde3f */
+static int get_uuid_le(const char *str, uuid_le *uu)
+{
+   unsigned int b[16];
+   int i;
+
+   if (strlen(str) < 37)
+   return -1;
+
+   for (i = 0; i < 36; i++) {
+   switch (i) {
+   case 8: case 13: case 18: case 23:
+   if (str[i] != '-')
+   return -1;
+   break;
+   default:
+   if (!isxdigit(str[i]))
+   return -1;
+   }
+   }
+
+   /* unparse little endian output byte order */
+   if (sscanf(str,
+  "%2x%2x%2x%2x-%2x%2x-%2x%2x-%2x%2x-%2x%2x%2x%2x%2x%2x",
+  [3], [2], [1], [0],
+  [5], [4], [7], [6], [8], [9],
+  [10], [11], [12], [13], [14], [15]) != 16)
+   return -1;
+
+   for (i = 0; i < 16; i++)
+   uu->b[i] = b[i];
+   return 0;
+}
+
+/*
+ * store_new_id - sysfs frontend to vmbus_add_dynid()
+ *
+ * Allow GUIDs to be added to an existing driver via sysfs.
+ */
+static ssize_t new_id_store(struct device_driver *driver, const char *buf,
+   size_t count)
+{
+   struct hv_driver *drv = drv_to_hv_drv(driver);
+   uuid_le guid = NULL_UUID_LE;
+   ssize_t retval;
+
+   if (get_uuid_le(buf, ) != 0)
+   return -EINVAL;
+
+   if 

[PATCH 01/15] Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

DoS protection conditions were altered in WS2016 and now it's easy to get
-EAGAIN returned from vmbus_post_msg() (e.g. when we try changing MTU on a
netvsc device in a loop). All vmbus_post_msg() callers don't retry the
operation and we usually end up with a non-functional device or crash.

While host's DoS protection conditions are unknown to me my tests show that
it can take up to 10 seconds before the message is sent so doing udelay()
is not an option, we really need to sleep. Almost all vmbus_post_msg()
callers are ready to sleep but there is one special case:
vmbus_initiate_unload() which can be called from interrupt/NMI context and
we can't sleep there. I'm also not sure about the lonely
vmbus_send_tl_connect_request() which has no in-tree users but its external
users are most likely waiting for the host to reply so sleeping there is
also appropriate.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |   17 +
 drivers/hv/channel_mgmt.c |   10 ++
 drivers/hv/connection.c   |   17 -
 drivers/hv/hyperv_vmbus.h |2 +-
 4 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 5fb4c6d..d5b8d9f 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -181,7 +181,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
send_ringbuffer_size,
spin_unlock_irqrestore(_connection.channelmsg_lock, flags);
 
ret = vmbus_post_msg(open_msg,
-  sizeof(struct vmbus_channel_open_channel));
+sizeof(struct vmbus_channel_open_channel), true);
 
if (ret != 0) {
err = ret;
@@ -233,7 +233,7 @@ int vmbus_send_tl_connect_request(const uuid_le 
*shv_guest_servie_id,
conn_msg.guest_endpoint_id = *shv_guest_servie_id;
conn_msg.host_service_id = *shv_host_servie_id;
 
-   return vmbus_post_msg(_msg, sizeof(conn_msg));
+   return vmbus_post_msg(_msg, sizeof(conn_msg), true);
 }
 EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request);
 
@@ -419,7 +419,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, 
void *kbuffer,
spin_unlock_irqrestore(_connection.channelmsg_lock, flags);
 
ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
-  sizeof(*msginfo));
+sizeof(*msginfo), true);
if (ret != 0)
goto cleanup;
 
@@ -433,8 +433,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, 
void *kbuffer,
gpadl_body->gpadl = next_gpadl_handle;
 
ret = vmbus_post_msg(gpadl_body,
-submsginfo->msgsize -
-sizeof(*submsginfo));
+submsginfo->msgsize - sizeof(*submsginfo),
+true);
if (ret != 0)
goto cleanup;
 
@@ -485,8 +485,8 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 
gpadl_handle)
list_add_tail(>msglistentry,
  _connection.chn_msg_list);
spin_unlock_irqrestore(_connection.channelmsg_lock, flags);
-   ret = vmbus_post_msg(msg,
-  sizeof(struct vmbus_channel_gpadl_teardown));
+   ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown),
+true);
 
if (ret)
goto post_msg_err;
@@ -557,7 +557,8 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
msg->child_relid = channel->offermsg.child_relid;
 
-   ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel));
+   ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel),
+true);
 
if (ret) {
pr_err("Close failed: close post msg return is %d\n", ret);
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index cbb96f2..dc6b675 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -321,7 +321,8 @@ static void vmbus_release_relid(u32 relid)
memset(, 0, sizeof(struct vmbus_channel_relid_released));
msg.child_relid = relid;
msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
-   vmbus_post_msg(, sizeof(struct vmbus_channel_relid_released));
+   vmbus_post_msg(, sizeof(struct vmbus_channel_relid_released),
+  true);
 }
 
 void hv_event_tasklet_disable(struct vmbus_channel *channel)
@@ -726,7 +727,8 @@ void vmbus_initiate_unload(bool crash)
init_completion(_connection.unload_event);
memset(, 0, sizeof(struct vmbus_channel_message_header));
hdr.msgtype = CHANNELMSG_UNLOAD;
-   vmbus_post_msg(, sizeof(struct 

[PATCH 07/15] hv: allocate synic pages for all present CPUs

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

It may happen that not all CPUs are online when we do hv_synic_alloc() and
in case more CPUs come online later we may try accessing these allocated
structures.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 60dbd6c..e4bb498 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -411,7 +411,7 @@ int hv_synic_alloc(void)
goto err;
}
 
-   for_each_online_cpu(cpu) {
+   for_each_present_cpu(cpu) {
hv_context.event_dpc[cpu] = kmalloc(size, GFP_ATOMIC);
if (hv_context.event_dpc[cpu] == NULL) {
pr_err("Unable to allocate event dpc\n");
@@ -482,7 +482,7 @@ void hv_synic_free(void)
int cpu;
 
kfree(hv_context.hv_numa_map);
-   for_each_online_cpu(cpu)
+   for_each_present_cpu(cpu)
hv_synic_free_cpu(cpu);
 }
 
-- 
1.7.4.1

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


[PATCH 03/15] hyperv: Fix spelling of HV_UNKOWN

2016-12-01 Thread kys
From: Haiyang Zhang 

Changed it to HV_UNKNOWN

Signed-off-by: Haiyang Zhang 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |6 +++---
 include/linux/hyperv.h|2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index dc6b675..f9c5827 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -134,7 +134,7 @@
},
 
/* Unknown GUID */
-   { .dev_type = HV_UNKOWN,
+   { .dev_type = HV_UNKNOWN,
  .perf_device = false,
},
 };
@@ -163,9 +163,9 @@ static u16 hv_get_dev_type(const struct vmbus_channel 
*channel)
u16 i;
 
if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid))
-   return HV_UNKOWN;
+   return HV_UNKNOWN;
 
-   for (i = HV_IDE; i < HV_UNKOWN; i++) {
+   for (i = HV_IDE; i < HV_UNKNOWN; i++) {
if (!uuid_le_cmp(*guid, vmbus_devs[i].guid))
return i;
}
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index fdd541c..5a2d2dd 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -696,7 +696,7 @@ enum vmbus_device_type {
HV_FCOPY,
HV_BACKUP,
HV_DM,
-   HV_UNKOWN,
+   HV_UNKNOWN,
 };
 
 struct vmbus_device {
-- 
1.7.4.1

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


[PATCH 02/15] hyperv: Add a function to detect hv_device

2016-12-01 Thread kys
From: Haiyang Zhang 

Signed-off-by: Haiyang Zhang 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/vmbus_drv.c |6 ++
 include/linux/hyperv.h |2 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 0276d2e..1730ac0 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -692,6 +692,12 @@ struct onmessage_work_context {
struct hv_message msg;
 };
 
+bool device_is_hyperv(struct device *dev)
+{
+   return dev->release == vmbus_device_release;
+}
+EXPORT_SYMBOL_GPL(device_is_hyperv);
+
 static void vmbus_onmessage_work(struct work_struct *work)
 {
struct onmessage_work_context *ctx;
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 2a52d9a..fdd541c 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -946,6 +946,8 @@ static inline void clear_low_latency_mode(struct 
vmbus_channel *c)
c->low_latency = false;
 }
 
+bool device_is_hyperv(struct device *dev);
+
 void vmbus_onmessage(void *context);
 
 int vmbus_request_offers(void);
-- 
1.7.4.1

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


[PATCH 08/15] hv: init percpu_list in hv_synic_alloc()

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

Initializing hv_context.percpu_list in hv_synic_alloc() helps to prevent a
crash in percpu_channel_enq() when not all CPUs were online during
initialization and it naturally belongs there.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index e4bb498..a2567a4 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -457,6 +457,8 @@ int hv_synic_alloc(void)
pr_err("Unable to allocate post msg page\n");
goto err;
}
+
+   INIT_LIST_HEAD(_context.percpu_list[cpu]);
}
 
return 0;
@@ -552,8 +554,6 @@ void hv_synic_init(void *arg)
rdmsrl(HV_X64_MSR_VP_INDEX, vp_index);
hv_context.vp_index[cpu] = (u32)vp_index;
 
-   INIT_LIST_HEAD(_context.percpu_list[cpu]);
-
/*
 * Register the per-cpu clockevent source.
 */
-- 
1.7.4.1

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


[PATCH 09/15] hv: change clockevents unbind tactics

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

To get prepared to CPU offlining support we need co change the way how we
unbind clockevent devices. As one CPU may go online/offline multiple times
we need to bind it in hv_synic_init() and unbind it in hv_synic_cleanup().
There is an additional corner case: when we unload the module completely we
need to switch to some other clockevent mechanism before stopping VMBus or
we will hang. We can't call hv_synic_cleanup() before unloading VMBus as
we won't be able to send UNLOAD request and get a response so
hv_synic_clockevents_cleanup() has to live. Luckily, we can always call
clockevents_unbind_device(), even if it wasn't bound before and there is
no issue if we call it twice.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index a2567a4..c11393c 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -575,7 +575,7 @@ void hv_synic_clockevents_cleanup(void)
if (!(ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE))
return;
 
-   for_each_online_cpu(cpu)
+   for_each_present_cpu(cpu)
clockevents_unbind_device(hv_context.clk_evt[cpu], cpu);
 }
 
@@ -594,8 +594,10 @@ void hv_synic_cleanup(void *arg)
return;
 
/* Turn off clockevent device */
-   if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE)
+   if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) {
+   clockevents_unbind_device(hv_context.clk_evt[cpu], cpu);
hv_ce_shutdown(hv_context.clk_evt[cpu]);
+   }
 
rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
-- 
1.7.4.1

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


[PATCH 06/15] hv: acquire vmbus_connection.channel_mutex in vmbus_free_channels()

2016-12-01 Thread kys
From: Vitaly Kuznetsov 

"kernel BUG at drivers/hv/channel_mgmt.c:350!" is observed when hv_vmbus
module is unloaded. BUG_ON() was introduced in commit 85d9aa705184
("Drivers: hv: vmbus: add an API vmbus_hvsock_device_unregister()") as
vmbus_free_channels() codepath was apparently forgotten.

Fixes: 85d9aa705184 ("Drivers: hv: vmbus: add an API 
vmbus_hvsock_device_unregister()")
Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index d83c1ac..e68f06c 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -390,6 +390,7 @@ void vmbus_free_channels(void)
 {
struct vmbus_channel *channel, *tmp;
 
+   mutex_lock(_connection.channel_mutex);
list_for_each_entry_safe(channel, tmp, _connection.chn_list,
listentry) {
/* hv_process_channel_removal() needs this */
@@ -397,6 +398,7 @@ void vmbus_free_channels(void)
 
vmbus_device_unregister(channel->device_obj);
}
+   mutex_unlock(_connection.channel_mutex);
 }
 
 /*
-- 
1.7.4.1

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


[PATCH 00/15] Drivers: hv: CPU management fixes and a new uio driver

2016-12-01 Thread kys
From: K. Y. Srinivasan 

Fixes to handle CPU online/offline. Also included is a new uio
driver for Hyper-V.

Alex Fluter (1):
  Tools: hv: kvp: configurable external scripts path

Haiyang Zhang (2):
  hyperv: Add a function to detect hv_device
  hyperv: Fix spelling of HV_UNKOWN

K. Y. Srinivasan (2):
  Drivers: hv: vmbus: Prevent sending data on a rescinded channel
  Drivers: hv: vmbus: Enhance the rescind callback functionality

Stephen Hemminger (2):
  vmbus: add support for dynamic device id's
  uio-hv-generic: new userspace i/o driver for VMBus

Vitaly Kuznetsov (8):
  Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()
  hv: acquire vmbus_connection.channel_mutex in vmbus_free_channels()
  hv: allocate synic pages for all present CPUs
  hv: init percpu_list in hv_synic_alloc()
  hv: change clockevents unbind tactics
  hv: switch to cpuhp state machine for synic init/cleanup
  hv: make CPU offlining prevention fine-grained
  hv: don't reset hv_context.tsc_page on crash

 MAINTAINERS  |1 +
 drivers/hv/channel.c |   17 ++--
 drivers/hv/channel_mgmt.c|   29 --
 drivers/hv/connection.c  |   18 +++-
 drivers/hv/hv.c  |   65 ++---
 drivers/hv/hyperv_vmbus.h|6 +-
 drivers/hv/ring_buffer.c |3 +
 drivers/hv/vmbus_drv.c   |  208 
 drivers/uio/Kconfig  |9 ++
 drivers/uio/Makefile |1 +
 drivers/uio/uio_hv_generic.c |  218 ++
 include/linux/hyperv.h   |   17 +++-
 tools/hv/hv_kvp_daemon.c |   11 ++-
 13 files changed, 532 insertions(+), 71 deletions(-)
 create mode 100644 drivers/uio/uio_hv_generic.c

-- 
1.7.4.1

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


Re: [PATCH 29/39] Annotate hardware config module parameters in drivers/staging/media/

2016-12-01 Thread Mauro Carvalho Chehab
Em Thu, 01 Dec 2016 14:59:56 +
David Howells  escreveu:

> Mauro Carvalho Chehab  wrote:
> 
> > drivers/staging/media/lirc/lirc_parallel.c:728:19: error: Expected ) in 
> > function declarator  
> 
> Did you apply patch 1 first?  That defines module_param_hw*.

No. Applying it at the media upstream tree can be risky if it ends
by being merged with some changes.

On what tree do you intend patch 1 to be merged?

> 
> David



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


Re: [PATCH 00/13] staging: unisys: Remove POSTCODE macros

2016-12-01 Thread 'Greg KH'
On Thu, Dec 01, 2016 at 11:37:09AM +, Sell, Timothy C wrote:
> > -Original Message-
> > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > Sent: Thursday, December 01, 2016 2:34 AM
> > To: Kershner, David A 
> > Cc: driverdev-devel@linuxdriverproject.org; *S-Par-Maintainer
> > ; jes.soren...@redhat.com
> > Subject: Re: [PATCH 00/13] staging: unisys: Remove POSTCODE macros
> > 
> > On Thu, Dec 01, 2016 at 01:31:02AM -0500, David Kershner wrote:
> > > The s-Par firmware uses POSTCODE macros to get basic health of the
> > > system even when we are not connected to the serial port or have
> > > the ability to obtain the syslog.
> > 
> > If you don't have access to a serial port, or a syslog, how can you get
> > this data as well?
> > 
> 
> On an s-Par platform, the Linux environment where the POSTCODEs
> are issued is just one virtual guest environment of possibly many hosted by
> the s-Par ultravisor (back-end).  POSTCODE data (from ALL guest environments)
> ends up in a consolidated log maintained by our ultravisor.  When our
> customers supply diagnostics to us for ultravisor problems, they supply to us
> what is known as an ldump, which contains this consolidated log file as well
> as other diagnostic information.  Oftentimes we don't get guest log files,
> and because virtual serial ports require some non-trivial setup ahead-of-time,
> we rarely get serial port outputs.
> 
> POSTCODE data in our consolidated log file helps provide the "whole picture"
> in terms of what is going on in s-Par, because the log includes events
> produced by the back-end ultravisor as well as events produced in various
> guest environments.  It's also basically the only diagnostic data we can
> always count on for a customer to supply when a problem occurs.

Ok, but that's only giving you some random data about your specific
drivers, not the whole Linux system.  Why not use the pdata interface
instead to send the logs to your "consolidated log file" so that you now
get all of the kernel's information, not just your tiny driver.

Again, driver-specific logging methods is not ok.  Just look at how many
different driver subsystems we have in the kernel, there's a reason
people unified all of this many many years ago, let's not go backwards.

thanks,

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


Re: [PATCH 29/39] Annotate hardware config module parameters in drivers/staging/media/

2016-12-01 Thread David Howells
Mauro Carvalho Chehab  wrote:

> drivers/staging/media/lirc/lirc_parallel.c:728:19: error: Expected ) in 
> function declarator

Did you apply patch 1 first?  That defines module_param_hw*.

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


Re: [PATCH 29/39] Annotate hardware config module parameters in drivers/staging/media/

2016-12-01 Thread Mauro Carvalho Chehab
Em Thu, 01 Dec 2016 12:33:30 +
David Howells  escreveu:

> When the kernel is running in secure boot mode, we lock down the kernel to
> prevent userspace from modifying the running kernel image.  Whilst this
> includes prohibiting access to things like /dev/mem, it must also prevent
> access by means of configuring driver modules in such a way as to cause a
> device to access or modify the kernel image.
> 
> To this end, annotate module_param* statements that refer to hardware
> configuration and indicate for future reference what type of parameter they
> specify.  The parameter parser in the core sees this information and can
> skip such parameters with an error message if the kernel is locked down.
> The module initialisation then runs as normal, but just sees whatever the
> default values for those parameters is.
> 
> Note that we do still need to do the module initialisation because some
> drivers have viable defaults set in case parameters aren't specified and
> some drivers support automatic configuration (e.g. PNP or PCI) in addition
> to manually coded parameters.
> 
> This patch annotates drivers in drivers/staging/media/.
> 
> Suggested-by: One Thousand Gnomes 
> Signed-off-by: David Howells 
> cc: Mauro Carvalho Chehab 
> cc: Greg Kroah-Hartman 
> cc: linux-me...@vger.kernel.org
> cc: de...@driverdev.osuosl.org

Tried to apply here, but got some errors:


drivers/staging/media/lirc/lirc_parallel.c:728:19: error: Expected ) in 
function declarator
drivers/staging/media/lirc/lirc_parallel.c:728:19: error: got ,
drivers/staging/media/lirc/lirc_parallel.c:731:20: error: Expected ) in 
function declarator
drivers/staging/media/lirc/lirc_parallel.c:731:20: error: got ,
drivers/staging/media/lirc/lirc_sir.c:989:19: error: Expected ) in function 
declarator
drivers/staging/media/lirc/lirc_sir.c:989:19: error: got ,
drivers/staging/media/lirc/lirc_sir.c:992:20: error: Expected ) in function 
declarator
drivers/staging/media/lirc/lirc_sir.c:992:20: error: got ,
drivers/staging/media/lirc/lirc_sir.c:989:21: error: expected ')' before 'int'
 module_param_hw(io, int, ioport, S_IRUGO);
 ^~~
drivers/staging/media/lirc/lirc_sir.c:992:22: error: expected ')' before 'int'
 module_param_hw(irq, int, irq, S_IRUGO);
  ^~~
scripts/Makefile.build:293: recipe for target 
'drivers/staging/media/lirc/lirc_sir.o' failed
make[2]: *** [drivers/staging/media/lirc/lirc_sir.o] Error 1
make[2]: *** Waiting for unfinished jobs
drivers/staging/media/lirc/lirc_parallel.c:728:21: error: expected ')' before 
'int'
 module_param_hw(io, int, ioport, S_IRUGO);
 ^~~
drivers/staging/media/lirc/lirc_parallel.c:731:22: error: expected ')' before 
'int'
 module_param_hw(irq, int, irq, S_IRUGO);
  ^~~
scripts/Makefile.build:293: recipe for target 
'drivers/staging/media/lirc/lirc_parallel.o' failed
make[2]: *** [drivers/staging/media/lirc/lirc_parallel.o] Error 1
scripts/Makefile.build:544: recipe for target 'drivers/staging/media/lirc' 
failed
make[1]: *** [drivers/staging/media/lirc] Error 2
Makefile:1485: recipe for target '_module_drivers/staging/media' failed
make: *** [_module_drivers/staging/media] Error 2



> ---
> 
>  drivers/staging/media/lirc/lirc_parallel.c |4 ++--
>  drivers/staging/media/lirc/lirc_serial.c   |   10 +-

Btw, this got moved to another place, and had some patch getting rid
of those really ugly S_IRUGO & friend macros.

I rebased it to apply over the top of the media tree, but I suspect
it requires some other patch to be applied adding the new macro.

I'm enclosing the rebased patch as reference.

Regards,
Mauro

[PATCH] [media] Annotate hardware config module parameters in 
drivers/staging/media/

From: David Howells 

When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/staging/media/.


[PATCH v2] x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic

2016-12-01 Thread Vitaly Kuznetsov
There is a feature in Hyper-V (Debug-VM --InjectNonMaskableInterrupt) which
injects NMI to the guest. Prior to WS2016 the NMI is injected to all CPUs
of the guest and WS2016 injects it to CPU0 only. When unknown_nmi_panic is
enabled and we'd like to do kdump we need to perform some minimal cleanup
so the kdump kernel will be able to initialize VMBus devices, this cleanup
includes sending CHANNELMSG_UNLOAD to the host waiting for
CHANNELMSG_UNLOAD_RESPONSE to arrive. WS2012R2 always sends the response
to the CPU which was used to send CHANNELMSG_REQUESTOFFERS on VMBus module
load and not to the CPU which is sending CHANNELMSG_UNLOAD. As we can't do
any cross-CPU work reliably on crash we have vmbus_wait_for_unload()
function which tries to read CHANNELMSG_UNLOAD_RESPONSE on all CPUs message
pages and this sometimes works. It was discovered that in case the host
wants to send more than one message to a secondary CPU (not the CPU running
vmbus_wait_for_unload()) we're unable to get it as after reading the first
message we're supposed to do EOMing by doing wrmsrl(HV_X64_MSR_EOM, 0) but
this is per-CPU. I have a feeling that this was working some time ago when
I implemented vmbus_wait_for_unload(), the host was re-trying to deliver a
message even without wrmsrl() but apparently this doesn't work any more.
Unfortunately there is not that much we can do when all CPUs get NMI as
all but the first one are getting blocked with interrupts disabled. What we
can do is limit processing unknown interrupts to the first CPU which gets
it in case we're about to crash.

Signed-off-by: Vitaly Kuznetsov 
Acked-by: K. Y. Srinivasan 
---
Changes since v1:
- Put everything under #ifdef CONFIG_X86_LOCAL_APIC as unknown_nmi_panic is
  otherwise undefined. [kbuild test robot]
- Add KY's Ack (hopefully stands with the above mentioned change)
---
 arch/x86/kernel/cpu/mshyperv.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 8f44c5a..34b29f0 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);
@@ -158,6 +159,26 @@ static unsigned char hv_get_nmi_reason(void)
return 0;
 }
 
+#ifdef CONFIG_X86_LOCAL_APIC
+/*
+ * Prior to WS2016 Debug-VM sends NMIs to all CPUs which makes
+ * it dificult to process CHANNELMSG_UNLOAD in case of crash. Handle
+ * unknown NMI on the first CPU which gets it.
+ */
+static int hv_nmi_unknown(unsigned int val, struct pt_regs *regs)
+{
+   static atomic_t nmi_cpu = ATOMIC_INIT(-1);
+
+   if (!unknown_nmi_panic)
+   return NMI_DONE;
+
+   if (atomic_cmpxchg(_cpu, -1, raw_smp_processor_id()) != -1)
+   return NMI_HANDLED;
+
+   return NMI_DONE;
+}
+#endif
+
 static void __init ms_hyperv_init_platform(void)
 {
/*
@@ -183,6 +204,9 @@ static void __init ms_hyperv_init_platform(void)
pr_info("HyperV: LAPIC Timer Frequency: %#x\n",
lapic_timer_frequency);
}
+
+   register_nmi_handler(NMI_LOCAL, hv_nmi_unknown, NMI_FLAG_FIRST,
+"hv_nmi_unknown");
 #endif
 
if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
-- 
2.9.3

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


Re: [PATCH] x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic

2016-12-01 Thread kbuild test robot
Hi Vitaly,

[auto build test WARNING on tip/x86/core]
[also build test WARNING on v4.9-rc7 next-20161130]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Vitaly-Kuznetsov/x86-hyperv-Handle-unknown-NMIs-on-one-CPU-when-unknown_nmi_panic/20161201-171219
config: i386-randconfig-x0-12011945 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from arch/x86/kernel/cpu/mshyperv.c:13:
   arch/x86/kernel/cpu/mshyperv.c: In function 'hv_nmi_unknown':
   arch/x86/kernel/cpu/mshyperv.c:171:7: error: 'unknown_nmi_panic' undeclared 
(first use in this function)
 if (!unknown_nmi_panic)
  ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> arch/x86/kernel/cpu/mshyperv.c:171:2: note: in expansion of macro 'if'
 if (!unknown_nmi_panic)
 ^~
   arch/x86/kernel/cpu/mshyperv.c:171:7: note: each undeclared identifier is 
reported only once for each function it appears in
 if (!unknown_nmi_panic)
  ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> arch/x86/kernel/cpu/mshyperv.c:171:2: note: in expansion of macro 'if'
 if (!unknown_nmi_panic)
 ^~

vim +/if +171 arch/x86/kernel/cpu/mshyperv.c

 7   * This program is free software; you can redistribute it and/or modify
 8   * it under the terms of the GNU General Public License as published by
 9   * the Free Software Foundation; version 2 of the License.
10   *
11   */
12  
  > 13  #include 
14  #include 
15  #include 
16  #include 
17  #include 
18  #include 
19  #include 
20  #include 
21  #include 
22  #include 
23  #include 
24  #include 
25  #include 
26  #include 
27  #include 
28  #include 
29  #include 
30  #include 
31  #include 
32  #include 
33  #include 
34  #include 
35  
36  struct ms_hyperv_info ms_hyperv;
37  EXPORT_SYMBOL_GPL(ms_hyperv);
38  
39  #if IS_ENABLED(CONFIG_HYPERV)
40  static void (*vmbus_handler)(void);
41  static void (*hv_kexec_handler)(void);
42  static void (*hv_crash_handler)(struct pt_regs *regs);
43  
44  void hyperv_vector_handler(struct pt_regs *regs)
45  {
46  struct pt_regs *old_regs = set_irq_regs(regs);
47  
48  entering_irq();
49  inc_irq_stat(irq_hv_callback_count);
50  if (vmbus_handler)
51  vmbus_handler();
52  
53  exiting_irq();
54  set_irq_regs(old_regs);
55  }
56  
57  void hv_setup_vmbus_irq(void (*handler)(void))
58  {
59  vmbus_handler = handler;
60  /*
61   * Setup the IDT for hypervisor callback. Prevent reallocation
62   * at module reload.
63   */
64  if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
65  alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
66  hyperv_callback_vector);
67  }
68  
69  void hv_remove_vmbus_irq(void)
70  {
71  /* We have no way to deallocate the interrupt gate */
72  vmbus_handler = NULL;
73  }
74  EXPORT_SYMBOL_GPL(hv_setup_vmbus_irq);
75  EXPORT_SYMBOL_GPL(hv_remove_vmbus_irq);
76  
77  void hv_setup_kexec_handler(void (*handler)(void))
78  {
79  hv_kexec_handler = handler;
80  }
81  EXPORT_SYMBOL_GPL(hv_setup_kexec_handler);
82  
83  void hv_remove_kexec_handler(void)
84  {
85  hv_kexec_handler = NULL;
86  }
87  EXPORT_SYMBOL_GPL(hv_remove_kexec_handler);
88  
89  void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs))
90  {
91  hv_crash_handler = handler;
92  }
93  EXPORT_SYMBOL_GPL(hv_setup_crash_handler);
94  
95  void hv_remove_crash_handler(void)
96  {
97  hv_crash_handler = NULL;
98  }
99  EXPORT_SYMBOL_GPL(hv_remove_crash_handler);
   100  
   101  #ifdef CONFIG_KEXEC_CORE
   102  static void hv_machine_shutdown(void)
   103  {
   104  if (kexec_in_progress && hv_kexec_handler)
   105  hv_kexec_handler();
   106  nati

[PATCH 31/39] Annotate hardware config module parameters in drivers/staging/vme/

2016-12-01 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/staging/vme/.

Suggested-by: One Thousand Gnomes 
Signed-off-by: David Howells 
cc: Martyn Welch 
cc: Manohar Vanga 
cc: Greg Kroah-Hartman 
cc: de...@driverdev.osuosl.org
---

 drivers/staging/vme/devices/vme_pio2_core.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_pio2_core.c 
b/drivers/staging/vme/devices/vme_pio2_core.c
index 8e66a520266c..c0e71cb27a6b 100644
--- a/drivers/staging/vme/devices/vme_pio2_core.c
+++ b/drivers/staging/vme/devices/vme_pio2_core.c
@@ -466,16 +466,16 @@ static void __exit pio2_exit(void)
 
 /* These are required for each board */
 MODULE_PARM_DESC(bus, "Enumeration of VMEbus to which the board is connected");
-module_param_array(bus, int, _num, 0444);
+module_param_hw_array(bus, int, other, _num, 0444);
 
 MODULE_PARM_DESC(base, "Base VME address for PIO2 Registers");
-module_param_array(base, long, _num, 0444);
+module_param_hw_array(base, long, other, _num, 0444);
 
 MODULE_PARM_DESC(vector, "VME IRQ Vector (Lower 4 bits masked)");
-module_param_array(vector, int, _num, 0444);
+module_param_hw_array(vector, int, other, _num, 0444);
 
 MODULE_PARM_DESC(level, "VME IRQ Level");
-module_param_array(level, int, _num, 0444);
+module_param_hw_array(level, int, other, _num, 0444);
 
 MODULE_PARM_DESC(variant, "Last 4 characters of PIO2 board variant");
 module_param_array(variant, charp, _num, 0444);

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


[PATCH 30/39] Annotate hardware config module parameters in drivers/staging/speakup/

2016-12-01 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/staging/speakup/.

Suggested-by: One Thousand Gnomes 
Signed-off-by: David Howells 
cc: Greg Kroah-Hartman 
cc: spea...@linux-speakup.org
cc: de...@driverdev.osuosl.org
---

 drivers/staging/speakup/speakup_acntpc.c |2 +-
 drivers/staging/speakup/speakup_dtlk.c   |2 +-
 drivers/staging/speakup/speakup_keypc.c  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/speakup/speakup_acntpc.c 
b/drivers/staging/speakup/speakup_acntpc.c
index efb791bb642b..e7bbc03e4a4f 100644
--- a/drivers/staging/speakup/speakup_acntpc.c
+++ b/drivers/staging/speakup/speakup_acntpc.c
@@ -307,7 +307,7 @@ static void accent_release(void)
speakup_info.port_tts = 0;
 }
 
-module_param_named(port, port_forced, int, S_IRUGO);
+module_param_hw_named(port, port_forced, int, ioport, S_IRUGO);
 module_param_named(start, synth_acntpc.startup, short, S_IRUGO);
 
 MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
diff --git a/drivers/staging/speakup/speakup_dtlk.c 
b/drivers/staging/speakup/speakup_dtlk.c
index 38aa4013bf62..d04aa9e0a147 100644
--- a/drivers/staging/speakup/speakup_dtlk.c
+++ b/drivers/staging/speakup/speakup_dtlk.c
@@ -378,7 +378,7 @@ static void dtlk_release(void)
speakup_info.port_tts = 0;
 }
 
-module_param_named(port, port_forced, int, S_IRUGO);
+module_param_hw_named(port, port_forced, int, ioport, S_IRUGO);
 module_param_named(start, synth_dtlk.startup, short, S_IRUGO);
 
 MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
diff --git a/drivers/staging/speakup/speakup_keypc.c 
b/drivers/staging/speakup/speakup_keypc.c
index 5e2170bf4a8b..d245c7de5ee6 100644
--- a/drivers/staging/speakup/speakup_keypc.c
+++ b/drivers/staging/speakup/speakup_keypc.c
@@ -309,7 +309,7 @@ static void keynote_release(void)
synth_port = 0;
 }
 
-module_param_named(port, port_forced, int, S_IRUGO);
+module_param_hw_named(port, port_forced, int, ioport, S_IRUGO);
 module_param_named(start, synth_keypc.startup, short, S_IRUGO);
 
 MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");

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


[PATCH 29/39] Annotate hardware config module parameters in drivers/staging/media/

2016-12-01 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/staging/media/.

Suggested-by: One Thousand Gnomes 
Signed-off-by: David Howells 
cc: Mauro Carvalho Chehab 
cc: Greg Kroah-Hartman 
cc: linux-me...@vger.kernel.org
cc: de...@driverdev.osuosl.org
---

 drivers/staging/media/lirc/lirc_parallel.c |4 ++--
 drivers/staging/media/lirc/lirc_serial.c   |   10 +-
 drivers/staging/media/lirc/lirc_sir.c  |4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_parallel.c 
b/drivers/staging/media/lirc/lirc_parallel.c
index bfb76a45bfbf..65530e0a6d99 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -725,10 +725,10 @@ MODULE_DESCRIPTION("Infrared receiver driver for parallel 
ports.");
 MODULE_AUTHOR("Christoph Bartelmus");
 MODULE_LICENSE("GPL");
 
-module_param(io, int, S_IRUGO);
+module_param_hw(io, int, ioport, S_IRUGO);
 MODULE_PARM_DESC(io, "I/O address base (0x3bc, 0x378 or 0x278)");
 
-module_param(irq, int, S_IRUGO);
+module_param_hw(irq, int, irq, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (7 or 5)");
 
 module_param(tx_mask, int, S_IRUGO);
diff --git a/drivers/staging/media/lirc/lirc_serial.c 
b/drivers/staging/media/lirc/lirc_serial.c
index b798b311d32c..ea3f735a196d 100644
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ b/drivers/staging/media/lirc/lirc_serial.c
@@ -1094,11 +1094,11 @@ MODULE_PARM_DESC(type, "Hardware type (0 = home-brew, 1 
= IRdeo,"
 " 2 = IRdeo Remote, 3 = AnimaX, 4 = IgorPlug,"
 " 5 = NSLU2 RX:CTS2/TX:GreenLED)");
 
-module_param(io, int, S_IRUGO);
+module_param_hw(io, int, ioport, S_IRUGO);
 MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
 
 /* some architectures (e.g. intel xscale) have memory mapped registers */
-module_param(iommap, bool, S_IRUGO);
+module_param_hw(iommap, bool, other, S_IRUGO);
 MODULE_PARM_DESC(iommap, "physical base for memory mapped I/O"
" (0 = no memory mapped io)");
 
@@ -1107,13 +1107,13 @@ MODULE_PARM_DESC(iommap, "physical base for memory 
mapped I/O"
  * on 32bit word boundaries.
  * See linux-kernel/drivers/tty/serial/8250/8250.c serial_in()/out()
  */
-module_param(ioshift, int, S_IRUGO);
+module_param_hw(ioshift, int, other, S_IRUGO);
 MODULE_PARM_DESC(ioshift, "shift I/O register offset (0 = no shift)");
 
-module_param(irq, int, S_IRUGO);
+module_param_hw(irq, int, irq, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
 
-module_param(share_irq, bool, S_IRUGO);
+module_param_hw (share_irq, bool, other, S_IRUGO);
 MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)");
 
 module_param(sense, int, S_IRUGO);
diff --git a/drivers/staging/media/lirc/lirc_sir.c 
b/drivers/staging/media/lirc/lirc_sir.c
index 4f326e97ad75..e27842e01fba 100644
--- a/drivers/staging/media/lirc/lirc_sir.c
+++ b/drivers/staging/media/lirc/lirc_sir.c
@@ -986,10 +986,10 @@ MODULE_AUTHOR("Milan Pikula");
 #endif
 MODULE_LICENSE("GPL");
 
-module_param(io, int, S_IRUGO);
+module_param_hw(io, int, ioport, S_IRUGO);
 MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
 
-module_param(irq, int, S_IRUGO);
+module_param_hw(irq, int, irq, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
 
 module_param(threshold, int, S_IRUGO);

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


[PATCH 28/39] Annotate hardware config module parameters in drivers/staging/i4l/

2016-12-01 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/staging/i4l/.

Suggested-by: One Thousand Gnomes 
Signed-off-by: David Howells 
cc: Greg Kroah-Hartman 
cc: de...@driverdev.osuosl.org
---

 drivers/staging/i4l/act2000/module.c |6 +++---
 drivers/staging/i4l/icn/icn.c|4 ++--
 drivers/staging/i4l/pcbit/module.c   |4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/i4l/act2000/module.c 
b/drivers/staging/i4l/act2000/module.c
index 99c9c0a1c63e..b3c81e2af7b2 100644
--- a/drivers/staging/i4l/act2000/module.c
+++ b/drivers/staging/i4l/act2000/module.c
@@ -40,9 +40,9 @@ MODULE_PARM_DESC(act_bus, "BusType of first card, 1=ISA, 
2=MCA, 3=PCMCIA, curren
 MODULE_PARM_DESC(act_port, "Base port address of first card");
 MODULE_PARM_DESC(act_irq, "IRQ of first card");
 MODULE_PARM_DESC(act_id, "ID-String of first card");
-module_param(act_bus, int, 0);
-module_param(act_port, int, 0);
-module_param(act_irq, int, 0);
+module_param_hw(act_bus, int, other, 0);
+module_param_hw(act_port, int, ioport, 0);
+module_param_hw(act_irq, int, irq, 0);
 module_param(act_id, charp, 0);
 
 static int act2000_addcard(int, int, int, char *);
diff --git a/drivers/staging/i4l/icn/icn.c b/drivers/staging/i4l/icn/icn.c
index 514bfc2c5b53..cadeee74e9f4 100644
--- a/drivers/staging/i4l/icn/icn.c
+++ b/drivers/staging/i4l/icn/icn.c
@@ -23,9 +23,9 @@ static char *icn_id2 = "\0";
 MODULE_DESCRIPTION("ISDN4Linux: Driver for ICN active ISDN card");
 MODULE_AUTHOR("Fritz Elfert");
 MODULE_LICENSE("GPL");
-module_param(portbase, int, 0);
+module_param_hw(portbase, int, ioport, 0);
 MODULE_PARM_DESC(portbase, "Port address of first card");
-module_param(membase, ulong, 0);
+module_param_hw(membase, ulong, iomem, 0);
 MODULE_PARM_DESC(membase, "Shared memory address of all cards");
 module_param(icn_id, charp, 0);
 MODULE_PARM_DESC(icn_id, "ID-String of first card");
diff --git a/drivers/staging/i4l/pcbit/module.c 
b/drivers/staging/i4l/pcbit/module.c
index 0a59bd0b8210..5a3ea2808351 100644
--- a/drivers/staging/i4l/pcbit/module.c
+++ b/drivers/staging/i4l/pcbit/module.c
@@ -25,8 +25,8 @@ MODULE_LICENSE("GPL");
 static int mem[MAX_PCBIT_CARDS];
 static int irq[MAX_PCBIT_CARDS];
 
-module_param_array(mem, int, NULL, 0);
-module_param_array(irq, int, NULL, 0);
+module_param_hw_array(mem, int, iomem, NULL, 0);
+module_param_hw_array(irq, int, irq, NULL, 0);
 
 static int num_boards;
 struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS];

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


Re: [PATCH v2] staging: most: Eliminate usage of symbolic permissions

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 10:20:47AM +0100, Christian Gromm wrote:
> On Thu, 1 Dec 2016 09:56:11 +0100
> Greg KH  wrote:
> 
> > On Thu, Dec 01, 2016 at 09:50:12AM +0100, Christian Gromm wrote:
> > > On Thu, 1 Dec 2016 08:00:57 +0100
> > > Greg KH  wrote:
> > > 
> > > > On Wed, Nov 30, 2016 at 10:48:32PM -0700, Jason Litzinger wrote:
> > > > > > This is fine, but the fact that the most subsystem feels like it 
> > > > > > has to
> > > > > > have its own attribute type is the big problem with this file, that
> > > > > > should not be needed at all, and hopefully will be fixed up someday 
> > > > > > soon
> > > > > > (i.e. it's a requirement before it can get out of staging...)
> > > 
> > > That's interesting. We still need to set up a strategy to get this driver
> > > out of staging one day, as we decided on the ELCE 2015 in Dublin. A good
> > > starting point would be a list of requirements that need to be met to
> > > achieve this goal.
> > > 
> > > Does this make sense?
> > 
> > Yes, and starting with cleaning up the kobject mess would be a good
> > first item for that list :)
> 
> And what "kobject mess" exactly is it that you're talking about?
> The kobjects to hook things up in sysfs?

Yes, you should never be using "raw" kobjects in a driver subsystem like
this, you should tie into the "real" driver model by being a bus and
driver subsystem.

thanks,

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


RE: [PATCH 00/13] staging: unisys: Remove POSTCODE macros

2016-12-01 Thread Sell, Timothy C
> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, December 01, 2016 2:34 AM
> To: Kershner, David A 
> Cc: driverdev-devel@linuxdriverproject.org; *S-Par-Maintainer
> ; jes.soren...@redhat.com
> Subject: Re: [PATCH 00/13] staging: unisys: Remove POSTCODE macros
> 
> On Thu, Dec 01, 2016 at 01:31:02AM -0500, David Kershner wrote:
> > The s-Par firmware uses POSTCODE macros to get basic health of the
> > system even when we are not connected to the serial port or have
> > the ability to obtain the syslog.
> 
> If you don't have access to a serial port, or a syslog, how can you get
> this data as well?
> 

On an s-Par platform, the Linux environment where the POSTCODEs
are issued is just one virtual guest environment of possibly many hosted by
the s-Par ultravisor (back-end).  POSTCODE data (from ALL guest environments)
ends up in a consolidated log maintained by our ultravisor.  When our
customers supply diagnostics to us for ultravisor problems, they supply to us
what is known as an ldump, which contains this consolidated log file as well
as other diagnostic information.  Oftentimes we don't get guest log files,
and because virtual serial ports require some non-trivial setup ahead-of-time,
we rarely get serial port outputs.

POSTCODE data in our consolidated log file helps provide the "whole picture"
in terms of what is going on in s-Par, because the log includes events
produced by the back-end ultravisor as well as events produced in various
guest environments.  It's also basically the only diagnostic data we can
always count on for a customer to supply when a problem occurs.

- Tim Sell

> > This patch series removes the unsightly postcode macros and creates a
> > simple postcode function to log basic functionality of the controlvm
> > channel.
> 
> It's a lot better, but really, this looks like you are implementing
> ftrace all over again.  Driver subsytems should not have "unique"
> logging solutions, you should use what the kernel provides you and go
> with that.
> 
> If the in-kernel solution doesn't work well for you, then work to change
> that so that the whole kernel benifits (hint, no one usually cares about
> just the logging messages from your tiny drivers, they want to know what
> happened in the overall system.)
> 
> I'll queue up everything but the last patch here, as __LINE__ should
> never be used in a .c file if at all possible (and hint, it usually
> doesn't help you at all as kernel line numbers change all the time
> depending on what distro/version/whatever you are using.)  Worse case,
> put it in a macro, but seriously, it shouldn't be needed at all, you
> should know what is going on by the context of the message itself.
> 
> And finally, you might want to look into the pstore interface if you
> want to write this type of data to something "permanent", but again, the
> default kernel logging system already does this for you, so really, you
> shouldn't have to worry about that either.
> 
> thanks,
> 
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic

2016-12-01 Thread kbuild test robot
Hi Vitaly,

[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.9-rc7 next-20161130]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Vitaly-Kuznetsov/x86-hyperv-Handle-unknown-NMIs-on-one-CPU-when-unknown_nmi_panic/20161201-171219
config: i386-randconfig-x014-201648 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   arch/x86/kernel/cpu/mshyperv.c: In function 'hv_nmi_unknown':
>> arch/x86/kernel/cpu/mshyperv.c:171:7: error: 'unknown_nmi_panic' undeclared 
>> (first use in this function)
 if (!unknown_nmi_panic)
  ^
   arch/x86/kernel/cpu/mshyperv.c:171:7: note: each undeclared identifier is 
reported only once for each function it appears in

vim +/unknown_nmi_panic +171 arch/x86/kernel/cpu/mshyperv.c

   165   * unknown NMI on the first CPU which gets it.
   166   */
   167  static int hv_nmi_unknown(unsigned int val, struct pt_regs *regs)
   168  {
   169  static atomic_t nmi_cpu = ATOMIC_INIT(-1);
   170  
 > 171  if (!unknown_nmi_panic)
   172  return NMI_DONE;
   173  
   174  if (atomic_cmpxchg(_cpu, -1, raw_smp_processor_id()) != -1)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] V4l: omap4iss: Clean up file handle in open() and release().

2016-12-01 Thread Laurent Pinchart
Hi Shailendra,

Thank you for the patch.

On Thursday 01 Dec 2016 10:22:52 Shailendra Verma wrote:
> Both functions initialize the file handle with v4l2_fh_init()
> and thus need to call clean up with v4l2_fh_exit() as appropriate.
> 
> Signed-off-by: Shailendra Verma 

Reviewed-by: Laurent Pinchart 

and applied to my tree for v4.11.

> ---
>  drivers/staging/media/omap4iss/iss_video.c |2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/media/omap4iss/iss_video.c
> b/drivers/staging/media/omap4iss/iss_video.c index c16927a..077c9f8 100644
> --- a/drivers/staging/media/omap4iss/iss_video.c
> +++ b/drivers/staging/media/omap4iss/iss_video.c
> @@ -1141,6 +1141,7 @@ static int iss_video_open(struct file *file)
>  done:
>   if (ret < 0) {
>   v4l2_fh_del(>vfh);
> + v4l2_fh_exit(>vfh);
>   kfree(handle);
>   }
> 
> @@ -1162,6 +1163,7 @@ static int iss_video_release(struct file *file)
>   vb2_queue_release(>queue);
> 
>   v4l2_fh_del(vfh);
> + v4l2_fh_exit(vfh);
>   kfree(handle);
>   file->private_data = NULL;

-- 
Regards,

Laurent Pinchart

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


Re: staging: wilc1000: remove memory allocate failure message

2016-12-01 Thread Markus Böhme
On 12/01/2016 10:44 AM, Amit Kumar Kushwaha wrote:
> This patch fixes the following warning reported by checkpatch.pl
> WARNING: Possible unnecessary 'out of memory' message
> 
> Signed-off-by: Amit Kushwaha 
> ---
>  drivers/staging/wilc1000/host_interface.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/host_interface.c 
> b/drivers/staging/wilc1000/host_interface.c
> index 6ab7443..b7d88bc 100644
> --- a/drivers/staging/wilc1000/host_interface.c
> +++ b/drivers/staging/wilc1000/host_interface.c
> @@ -2322,10 +2322,8 @@ static u32 Handle_ListenStateExpired(struct wilc_vif 
> *vif,
>   wid.size = 2;
>   wid.val = kmalloc(wid.size, GFP_KERNEL);
>  
> - if (!wid.val) {
> - netdev_err(vif->ndev, "Failed to allocate memory\n");
> + if (!wid.val)
>   return -ENOMEM;
> - }
>  
>   wid.val[0] = u8remain_on_chan_flag;
>   wid.val[1] = FALSE_FRMWR_CHANNEL;
> 

Hello Amit,

I cannot apply your patch, because it was sent Base64-encoded. Anyway,
are you sure you are working on a recent kernel tree? This issue has
been fixed already by commit 98b6594844 as of 2016-10-09 in staging-next.

Regards,
Markus

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


staging: wilc1000: remove memory allocate failure message

2016-12-01 Thread Amit Kumar Kushwaha
This patch fixes the following warning reported by checkpatch.pl
WARNING: Possible unnecessary 'out of memory' message

Signed-off-by: Amit Kushwaha 
---
 drivers/staging/wilc1000/host_interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 6ab7443..b7d88bc 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2322,10 +2322,8 @@ static u32 Handle_ListenStateExpired(struct wilc_vif 
*vif,
wid.size = 2;
wid.val = kmalloc(wid.size, GFP_KERNEL);
 
-   if (!wid.val) {
-   netdev_err(vif->ndev, "Failed to allocate memory\n");
+   if (!wid.val)
return -ENOMEM;
-   }
 
wid.val[0] = u8remain_on_chan_flag;
wid.val[1] = FALSE_FRMWR_CHANNEL;
-- 
2.10.2.windows.1___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: most: Eliminate usage of symbolic permissions

2016-12-01 Thread Christian Gromm
On Thu, 1 Dec 2016 09:56:11 +0100
Greg KH  wrote:

> On Thu, Dec 01, 2016 at 09:50:12AM +0100, Christian Gromm wrote:
> > On Thu, 1 Dec 2016 08:00:57 +0100
> > Greg KH  wrote:
> > 
> > > On Wed, Nov 30, 2016 at 10:48:32PM -0700, Jason Litzinger wrote:
> > > > > This is fine, but the fact that the most subsystem feels like it has 
> > > > > to
> > > > > have its own attribute type is the big problem with this file, that
> > > > > should not be needed at all, and hopefully will be fixed up someday 
> > > > > soon
> > > > > (i.e. it's a requirement before it can get out of staging...)
> > 
> > That's interesting. We still need to set up a strategy to get this driver
> > out of staging one day, as we decided on the ELCE 2015 in Dublin. A good
> > starting point would be a list of requirements that need to be met to
> > achieve this goal.
> > 
> > Does this make sense?
> 
> Yes, and starting with cleaning up the kobject mess would be a good
> first item for that list :)

And what "kobject mess" exactly is it that you're talking about?
The kobjects to hook things up in sysfs?

regards,
Chris

> 
> thanks,
> 
> greg k-h

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


Re: [PATCH 1/3] staging: comedi: s626: use preferred kernel type u8

2016-12-01 Thread Greg KH
On Wed, Nov 30, 2016 at 11:06:39PM +0330, Saber Rezvani wrote:
> Fix the checkpatch.pl issue:
> CHECK: Prefer kernel type 'u8' over 'uint8_t'
> 
> Signed-off-by: Saber Rezvani 
> Reviewed-by: Ian Abbott 
> ---
>  drivers/staging/comedi/drivers/s626.c | 30 +++---
>  1 file changed, 15 insertions(+), 15 deletions(-)

Is this a v3 or v4 or some version of a patch?  Please read
Documentation/SubmttingPatches for how to properly version a patch, and
then resend all of them with the correct information.

thanks,

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


Re: [PATCH v2] staging: most: Eliminate usage of symbolic permissions

2016-12-01 Thread Greg KH
On Thu, Dec 01, 2016 at 09:50:12AM +0100, Christian Gromm wrote:
> On Thu, 1 Dec 2016 08:00:57 +0100
> Greg KH  wrote:
> 
> > On Wed, Nov 30, 2016 at 10:48:32PM -0700, Jason Litzinger wrote:
> > > > This is fine, but the fact that the most subsystem feels like it has to
> > > > have its own attribute type is the big problem with this file, that
> > > > should not be needed at all, and hopefully will be fixed up someday soon
> > > > (i.e. it's a requirement before it can get out of staging...)
> 
> That's interesting. We still need to set up a strategy to get this driver
> out of staging one day, as we decided on the ELCE 2015 in Dublin. A good
> starting point would be a list of requirements that need to be met to
> achieve this goal.
> 
> Does this make sense?

Yes, and starting with cleaning up the kobject mess would be a good
first item for that list :)

thanks,

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


Re: [PATCH v2] staging: most: Eliminate usage of symbolic permissions

2016-12-01 Thread Christian Gromm
On Thu, 1 Dec 2016 08:00:57 +0100
Greg KH  wrote:

> On Wed, Nov 30, 2016 at 10:48:32PM -0700, Jason Litzinger wrote:
> > > This is fine, but the fact that the most subsystem feels like it has to
> > > have its own attribute type is the big problem with this file, that
> > > should not be needed at all, and hopefully will be fixed up someday soon
> > > (i.e. it's a requirement before it can get out of staging...)

That's interesting. We still need to set up a strategy to get this driver
out of staging one day, as we decided on the ELCE 2015 in Dublin. A good
starting point would be a list of requirements that need to be met to
achieve this goal.

Does this make sense?

  
> > Ok, couple follow up questions.
> > 
> > Something like struct device/DEVICE_ATTR_* (or something that exists
> > already) to expose the same functionality?
> 
> Yes, that is correct.
> 
> > I'm happy to iterate patches to address this, but, Christian, do you already
> > have a plan/patchset in the works?  I haven't come across a prior
> > discussion of this in the mailing list, but I may have missed it in my
> > search.

Yes, we do have plans to fix this up. I'm just not sure _when_ we are
going to send in patches for this.

> 
> It's a non-trivial change, and it requires you to understand the driver
> model code a bunch to make a new bus type and register devices to it.
> If you have questions about it, let me know.
> 
> good luck!
> 
> greg k-h

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