Hello1

2016-05-12 Thread HH
I hope you and your family are fine. I have a selling proposal that I would 
love to share with you.. Have a nice day as I await to hear your response.

  Thanks and regards

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


[PATCH] staging/lustre/ptlrpc: Removes potential null dereference

2016-05-12 Thread Lidza Louina
The lustre_msg_buf method could return NULL. Subsequent code didn't
check if it's null before using it. This patch adds two checks.

Signed-off-by: Lidza Louina 

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 187fd1d..e6fedc3 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -2195,6 +2195,8 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int 
offset)
    struct ptlrpc_user_desc *pud;
 
    pud = lustre_msg_buf(msg, offset, 0);
+   if (!pud)
+   return -EINVAL;
 
    pud->pud_uid = from_kuid(&init_user_ns, current_uid());
    pud->pud_gid = from_kgid(&init_user_ns, current_gid());
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 37c9f4c..7736aa9 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -542,6 +542,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
 {
    __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
    int alloc_len;
+   int desc;
 
    buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header);
    buflens[PLAIN_PACK_MSG_OFF] = msgsize;
@@ -575,7 +576,10 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
    req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0);
 
    if (req->rq_pack_udesc)
-   sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF);
+   desc = sptlrpc_pack_user_desc(req->rq_reqbuf, 
PLAIN_PACK_USER_OFF);
+   if (!desc){
+   return desc;
+   }
 
    return 0;
 }
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Treat As Urgent

2016-05-12 Thread Mrs Mary Chalmers
Dear Beloved.

Please forgive my intrusion into your privacy; I am a Australia sick
widow admitted in a private hospital here in Spain due to long
time cancer and reference to the doctor’s confirmation that I have
less than three months to live because the cancer has reached a
critical stage.

Now that i am about to end the race like this, without any family
members and no child that will inherit my wealth when I’m no more
alive, I have decided to Donate $8.500.000.00, which I deposited in my
bank for the help of orphans and the less privilege through you for
the work of humanity in the society, you will take 30% of this fund
for your faithful time/commitment and use the rest for the work of
humanity to fulfil my last wish on earth.

Kindly send me your information's as stated below let me attach it to
my authorization letter and forward to my bank now that i have access
to internet to enable them process the transfer to your name. On your
response to this mail I will forward you my valid data for your
reference.

1) Bank Account details, 2) A scanned copy of your international
passport or ID card, 3) Direct telephone number.

My regards
Mrs Mary Chalmers
Email: mary.chalm...@yandex.com

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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


Re: [PATCH net-next 4/5] treewide: replace dev->trans_start update with helper

2016-05-12 Thread Doug Ledford
On 05/03/2016 10:33 AM, Florian Westphal wrote:
> Replace all trans_start updates with netif_trans_update helper.
> change was done via spatch:
> 
> struct net_device *d;
> @@
> - d->trans_start = jiffies
> + netif_trans_update(d)
> 
> Compile tested only.
> 
> Cc: user-mode-linux-de...@lists.sourceforge.net
> Cc: linux-xte...@linux-xtensa.org
> Cc: linux1394-de...@lists.sourceforge.net
> Cc: linux-r...@vger.kernel.org
> Cc: net...@vger.kernel.org
> Cc: mpt-fusionlinux@broadcom.com
> Cc: linux-s...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: linux-par...@vger.kernel.org
> Cc: linux-o...@vger.kernel.org
> Cc: linux-h...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: linux-wirel...@vger.kernel.org
> Cc: linux-s...@vger.kernel.org
> Cc: de...@driverdev.osuosl.org
> Cc: b.a.t.m@lists.open-mesh.org
> Cc: linux-blueto...@vger.kernel.org
> Signed-off-by: Florian Westphal 
> ---
>  Checkpatch complains about whitespace damage, but
>  this extra whitespace already exists before this patch.
> 
>  drivers/infiniband/hw/nes/nes_nic.c| 2 +-
>  drivers/infiniband/ulp/ipoib/ipoib_cm.c| 2 +-
>  drivers/infiniband/ulp/ipoib/ipoib_ib.c| 2 +-

For InfiniBand bits,

Acked-by: Doug Ledford 

-- 
Doug Ledford 
  GPG KeyID: 0E572FDD




signature.asc
Description: OpenPGP digital signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Aw: Re: [PATCH 0/6] hv_netvsc: avoid races on mtu change/set channels

2016-05-12 Thread Lino Sanfilippo

> It's worse: before the patch series we get 'struct hv_device' (as it is
> called from core VMBus code and we simply cannot get to 'struct
> net_device' we need without traveling through 'struct
> netvsc_device'. This structure is removed and re-created by both
> netvsc_set_channels() and netvsc_change_mtu().


Ah ok, I missed that we cant rely on getting a valid netdev from the hv_device 
in 
remove. Thanks for the explanation!

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


Re: [PATCH] MAINTAINERS: add entry for the Sync File Framework

2016-05-12 Thread Emil Velikov
Hi Gustavo,

On 11 May 2016 at 14:45, Gustavo Padovan  wrote:
> From: Gustavo Padovan 
>
> Add Gustavo as maintainer for the Sync File Framework. Sumit is
> co-maintainer as he maintains drivers/dma-buf/. It also uses Sumit's
> tree as base.
>
> Cc: Sumit Semwal 
> Signed-off-by: Gustavo Padovan 
> ---
>  MAINTAINERS | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8c10b4c..0abc9c3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3677,6 +3677,16 @@ F:   include/linux/*fence.h
>  F: Documentation/dma-buf-sharing.txt
>  T: git git://git.linaro.org/people/sumitsemwal/linux-dma-buf.git
>
> +SYNC FILE FRAMEWORK
> +M: Gustavo Padovan 
> +S: Maintained
> +L: linux-me...@vger.kernel.org
> +L: dri-de...@lists.freedesktop.org
> +F: drivers/dma-buf/sync_file.c
> +F: include/linux/sync_file.h
> +F: Documentation/sync_file.txt
> +T: git git://git.linaro.org/people/sumitsemwal/linux-dma-buf.git
> +
Do you have commit access to that tree/repo ? If not I'd suggest
dropping/updating the line.

Or you are thinking about being a 'designated' reviewer while Sumit
still handling maintainership/pull requests ? In which case add Sumit
as M: and yourself as R:

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


Re: Aw: [PATCH 0/6] hv_netvsc: avoid races on mtu change/set channels

2016-05-12 Thread Vitaly Kuznetsov
"Lino Sanfilippo"  writes:

> Hi,
>
>>
>> MTU change and set channels operations are implemented as netvsc device
>> re-creation destroying internal structures (struct net_device stays). This
>> is really unfortunate but there is no support from Hyper-V host to do it
>> in a different way. Such re-creation is unsurprisingly racy, Haiyang
>> reported a crash when netvsc_change_mtu() is racing with
>> netvsc_link_change() but I was able to identify additional races upon
>> investigation. Both netvsc_set_channels() and netvsc_change_mtu() race
>> against:
>> 1) netvsc_link_change()
>> 2) netvsc_remove()
>> 3) netvsc_send()
>> 
>
> after having a look into this driver I got the impression that you are 
> working around an
> unfortunate implementation of the shutdown sequence in the remove function:
> If you do unregister_netdev() first instead of resource cleanup then neither 
> set_channels()
> nor change_mtu() can race with remove(). This is since after 
> unregister_netdev() returns
> the netdev is not longer available from userspace and thus neither 
> set_channels nor
> change_mtu can be called anymore (note that all of these functions are 
> protected by the 
> rtnl_lock).

It's worse: before the patch series we get 'struct hv_device' (as it is
called from core VMBus code and we simply cannot get to 'struct
net_device' we need without traveling through 'struct
netvsc_device'. This structure is removed and re-created by both
netvsc_set_channels() and netvsc_change_mtu().

>
> To avoid the race between netvsc_change_mtu()/netvsc_set_channels() and 
> netvsc_link_change()
> you have to stop the concerning worker thread (dwork) before you call 
> netvsc_close() and
> restart it once the device is up again.

Yes, but we also need to guarantee this won't get rescheduled so we need
a flag for that. The appropriate flag is start_remove but only after we
move it from a structure we remove.

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


Aw: [PATCH 0/6] hv_netvsc: avoid races on mtu change/set channels

2016-05-12 Thread Lino Sanfilippo
Hi,

>
> MTU change and set channels operations are implemented as netvsc device
> re-creation destroying internal structures (struct net_device stays). This
> is really unfortunate but there is no support from Hyper-V host to do it
> in a different way. Such re-creation is unsurprisingly racy, Haiyang
> reported a crash when netvsc_change_mtu() is racing with
> netvsc_link_change() but I was able to identify additional races upon
> investigation. Both netvsc_set_channels() and netvsc_change_mtu() race
> against:
> 1) netvsc_link_change()
> 2) netvsc_remove()
> 3) netvsc_send()
> 

after having a look into this driver I got the impression that you are working 
around an
unfortunate implementation of the shutdown sequence in the remove function:
If you do unregister_netdev() first instead of resource cleanup then neither 
set_channels()
nor change_mtu() can race with remove(). This is since after 
unregister_netdev() returns
the netdev is not longer available from userspace and thus neither set_channels 
nor
change_mtu can be called anymore (note that all of these functions are 
protected by the 
rtnl_lock).

To avoid the race between netvsc_change_mtu()/netvsc_set_channels() and 
netvsc_link_change()
you have to stop the concerning worker thread (dwork) before you call 
netvsc_close() and
restart it once the device is up again.

Regards,
Lino

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


[PATCH 8/9] staging: unisys: visorhba: return 0 literal

2016-05-12 Thread David Kershner
From: David Binder 

Returns 0 instead of variable rc in visorhba_init().

Signed-off-by: David Binder 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index 11985bb..5ef1d30 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -1204,7 +1204,7 @@ static int visorhba_init(void)
if (rc)
goto cleanup_debugfs;
 
-   return rc;
+   return 0;
 
 cleanup_debugfs:
debugfs_remove_recursive(visorhba_debugfs_dir);
-- 
1.9.1

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


[PATCH 4/9] staging: unisys: visorhba: simplify and enhance debugfs interface

2016-05-12 Thread David Kershner
From: Tim Sell 

debugfs info for each visorhba device is now presented by a file named of
the following form within the debugfs tree:

visorhba/vbus:dev/info

where  is the vbus number, and  is the relative device number.

Also, the debugfs presentation function was converted to use the seq_file
interface, so that it could access the device context without resorting to
a global array.  This also simplified the function.

Signed-off-by: Tim Sell 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 136 +++-
 1 file changed, 65 insertions(+), 71 deletions(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index 5ea6bb2..6a21514 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -51,14 +52,7 @@ static int visorhba_pause(struct visor_device *dev,
 static int visorhba_resume(struct visor_device *dev,
   visorbus_state_complete_func complete_func);
 
-static ssize_t info_debugfs_read(struct file *file, char __user *buf,
-size_t len, loff_t *offset);
-static int set_no_disk_inquiry_result(unsigned char *buf,
- size_t len, bool is_lun0);
 static struct dentry *visorhba_debugfs_dir;
-static const struct file_operations debugfs_info_fops = {
-   .read = info_debugfs_read,
-};
 
 /* GUIDS for HBA channel type supported by this driver */
 static struct visor_channeltype_descriptor visorhba_channel_types[] = {
@@ -132,6 +126,9 @@ struct visorhba_devdata {
 * iovm, instead of raw pointers
 */
struct idr idr;
+
+   struct dentry *debugfs_dir;
+   struct dentry *debugfs_info;
 };
 
 struct visorhba_devices_open {
@@ -667,66 +664,49 @@ static struct scsi_host_template visorhba_driver_template 
= {
 };
 
 /**
- * info_debugfs_read - debugfs interface to dump visorhba states
- * @file: Debug file
- * @buf: buffer to send back to user
- * @len: len that can be written to buf
- * @offset: offset into buf
+ * info_debugfs_show - debugfs interface to dump visorhba states
  *
- * Dumps information about the visorhba driver and devices
- * TODO: Make this per vhba
- * Returns bytes_read
+ *  This presents a file in the debugfs tree named:
+ *  /visorhba/vbus:dev/info
  */
-static ssize_t info_debugfs_read(struct file *file, char __user *buf,
-size_t len, loff_t *offset)
+static int info_debugfs_show(struct seq_file *seq, void *v)
 {
-   ssize_t bytes_read = 0;
-   int str_pos = 0;
-   u64 phys_flags_addr;
-   int i;
-   struct visorhba_devdata *devdata;
-   char *vbuf;
-
-   if (len > MAX_BUF)
-   len = MAX_BUF;
-   vbuf = kzalloc(len, GFP_KERNEL);
-   if (!vbuf)
-   return -ENOMEM;
-
-   for (i = 0; i < VISORHBA_OPEN_MAX; i++) {
-   if (!visorhbas_open[i].devdata)
-   continue;
-
-   devdata = visorhbas_open[i].devdata;
-
-   str_pos += scnprintf(vbuf + str_pos,
-   len - str_pos, "max_buff_len:%u\n",
-   devdata->max_buff_len);
-
-   str_pos += scnprintf(vbuf + str_pos, len - str_pos,
-   "\ninterrupts_rcvd = %llu, interrupts_disabled 
= %llu\n",
-   devdata->interrupts_rcvd,
-   devdata->interrupts_disabled);
-   str_pos += scnprintf(vbuf + str_pos,
-   len - str_pos, "\ninterrupts_notme = %llu,\n",
-   devdata->interrupts_notme);
-   phys_flags_addr = virt_to_phys((__force  void *)
-  devdata->flags_addr);
-   str_pos += scnprintf(vbuf + str_pos, len - str_pos,
-   "flags_addr = %p, phys_flags_addr=0x%016llx, 
FeatureFlags=%llu\n",
-   devdata->flags_addr, phys_flags_addr,
-   (__le64)readq(devdata->flags_addr));
-   str_pos += scnprintf(vbuf + str_pos,
-   len - str_pos, "acquire_failed_cnt:%llu\n",
-   devdata->acquire_failed_cnt);
-   str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n");
+   struct visorhba_devdata *devdata = seq->private;
+
+   seq_printf(seq, "max_buff_len = %u\n", devdata->max_buff_len);
+   seq_printf(seq, "interrupts_rcvd = %llu\n", devdata->interrupts_rcvd);
+   seq_printf(seq, "interrupts_disabled = %llu\n",
+  devdata->interrupts_disabled);
+   seq_printf(seq, "interrupts_notme = %llu\n",
+  devdata->interrupts_not

[PATCH 7/9] staging: unisys: visornic: cleanup error handling

2016-05-12 Thread David Kershner
From: David Binder 

Adjusts goto labels to prevent attempts to free unallocated resources.

Signed-off-by: David Binder 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visornic/visornic_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index 992543a..f556100 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -1796,7 +1796,7 @@ static int visornic_probe(struct visor_device *dev)
  sizeof(struct sk_buff *), GFP_KERNEL);
if (!devdata->rcvbuf) {
err = -ENOMEM;
-   goto cleanup_rcvbuf;
+   goto cleanup_netdev;
}
 
/* set the net_xmit outstanding threshold */
@@ -1817,12 +1817,12 @@ static int visornic_probe(struct visor_device *dev)
devdata->cmdrsp_rcv = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
if (!devdata->cmdrsp_rcv) {
err = -ENOMEM;
-   goto cleanup_cmdrsp_rcv;
+   goto cleanup_rcvbuf;
}
devdata->xmit_cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
if (!devdata->xmit_cmdrsp) {
err = -ENOMEM;
-   goto cleanup_xmit_cmdrsp;
+   goto cleanup_cmdrsp_rcv;
}
INIT_WORK(&devdata->timeout_reset, visornic_timeout_reset);
devdata->server_down = false;
-- 
1.9.1

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


[PATCH 6/9] staging: unisys: visornic: simplify visornic if statements

2016-05-12 Thread David Kershner
From: David Binder 

Changes the conditional logic by looking for the absence of work
to do, instead of the opposite.

Signed-off-by: David Binder 
Reviewed-by: Tim Sell 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visornic/visornic_main.c | 41 +
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index fd7c9a6..992543a 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -1000,25 +1000,28 @@ visornic_set_multi(struct net_device *netdev)
struct uiscmdrsp *cmdrsp;
struct visornic_devdata *devdata = netdev_priv(netdev);
 
-   /* any filtering changes */
-   if (devdata->old_flags != netdev->flags) {
-   if ((netdev->flags & IFF_PROMISC) !=
-   (devdata->old_flags & IFF_PROMISC)) {
-   cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
-   if (!cmdrsp)
-   return;
-   cmdrsp->cmdtype = CMD_NET_TYPE;
-   cmdrsp->net.type = NET_RCV_PROMISC;
-   cmdrsp->net.enbdis.context = netdev;
-   cmdrsp->net.enbdis.enable =
-   netdev->flags & IFF_PROMISC;
-   visorchannel_signalinsert(devdata->dev->visorchannel,
- IOCHAN_TO_IOPART,
- cmdrsp);
-   kfree(cmdrsp);
-   }
-   devdata->old_flags = netdev->flags;
-   }
+   if (devdata->old_flags == netdev->flags)
+   return;
+
+   if ((netdev->flags & IFF_PROMISC) ==
+   (devdata->old_flags & IFF_PROMISC))
+   goto out_save_flags;
+
+   cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
+   if (!cmdrsp)
+   return;
+   cmdrsp->cmdtype = CMD_NET_TYPE;
+   cmdrsp->net.type = NET_RCV_PROMISC;
+   cmdrsp->net.enbdis.context = netdev;
+   cmdrsp->net.enbdis.enable =
+   netdev->flags & IFF_PROMISC;
+   visorchannel_signalinsert(devdata->dev->visorchannel,
+ IOCHAN_TO_IOPART,
+ cmdrsp);
+   kfree(cmdrsp);
+
+out_save_flags:
+   devdata->old_flags = netdev->flags;
 }
 
 /**
-- 
1.9.1

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


[PATCH 2/9] staging: unisys: visorhba: correct scsi task mgmt completion handling

2016-05-12 Thread David Kershner
From: Tim Sell 

This patch is necessary to enable ANY task mgmt command to complete
successfully via visorhba.

When issuing a task mgmt command (CMD_SCSITASKMGMT_TYPE) to the IO
partition (back-end), forward_taskmgmt_command() includes pointers
within the command area that will be used to wake up the issuing
process and provide the result when the command completes:

cmdrsp->scsitaskmgmt.notify_handle = (u64)¬ifyevent;
cmdrsp->scsitaskmgmt.notifyresult_handle = (u64)¬ifyresult;

'notify_handle' is a pointer to a 'wait_queue_head_t' variable, and
'notifyresult' is a pointer to an int.  Both of these are just local
stack variables in the issuing process.

The way it's supposed to happen is that when the IO partition completes
the command, in our completion handling we get copies of those pointers
back from the IO partition, where we stash the result of the command at
'*notifyresult' (which should not be 0x, because that is the initial
value that the caller is looking to see a change in), and wake up the
wait queue at '*notify_handle'.  There are several places we do that dance,
but prior to this patch, we always do it WRONG, like:

cmdrsp->scsitaskmgmt.notifyresult_handle = TASK_MGMT_FAILED;
wake_up_all((wait_queue_head_t *)cmdrsp->scsitaskmgmt.notify_handle);

The wake_up_all() part is correct (albeit with the help of the sloppy
pointer casting, but that's irrelevant to the bug), but the assignment of
'notifyresult_handle' is WRONG, and SHOULD read:

*(int *)(cmdrsp->scsitaskmgmt.notifyresult_handle) = TASK_MGMT_FAILED;

Without this change, the caller is NEVER going to notice a change in his
local value of 'notifyresult' when he does the:

if (!wait_event_timeout(notifyevent, notifyresult != 0x,
msecs_to_jiffies(45000)))

and hence will be timing out EVERY taskmgmt command.

This patch also eliminates the need for sloppy casting of pointers
back-and-forth between u64 values, with the help of idr_alloc() to provide
handles for us.  It is the generated int handles we pass to the IO
partition to denote our completion context, and these are validated and
converted back to the required pointers when the task mgmt commands are
returned back to us by the IO partition.

== Testing ==

You must enable dynamic debugging in visorhba (build kernel with
'CONFIG_DYNAMIC_DEBUG=y', provide kernel parameter 'visorhba.dyndbg=+p')
to see kernel messages involved with visorhba scsi task mgmt commands,
which were added in this patch in the form of a few dev_dbg() / pr_debug()
messages.

In order to inject faults necessary to get visorhba to actully issue scsi
task mgmt commands, you will need to compile a kernel with
CONFIG_FAIL_IO_TIMEOUT and friends, in the "Kernel hacking" section:
* Enable "Fault-injection framework"
  * Enable "Fault-injection capability for disk IO"
  * Enable "Fault-injection capability for faking disk interrupts"
* Enable "Debugfs entries for fault-injection capabilities"

When running a kernel with those options, you can manually inject a fault
that will force a scsi task mgmt command to be issued like this:

# mount -t debugfs nodev /sys/kernel/debug
# cd /sys/kernel/debug/fail_io_timeout
# cat interval
1
# cat probability
0
# cat times
1
# echo 100 >probability
# cd /sys/block/sda
# l | grep fail
-rw-r--r--  1 root root 4096 May  5 10:53 io-timeout-fail
-rw-r--r--  1 root root 4096 May  5 10:54 make-it-fail
# echo 1 >io-timeout-fail
# echo 1 >make-it-fail

To test this patch, after performing the above steps, I did something to
force a block device i/o, then shortly afterwards examined the kernel log.
There I found evidence that visorhba had successfully issued a task mgmt
command, and that it completed successfully:

[  333.352612] FAULT_INJECTION: forcing a failure.
name fail_io_timeout, interval 1, probability 100, space 0, times 1
[  333.352617] CPU: 0 PID: 295 Comm: vhba_incoming Tainted: G C
   4.6.0-rc3-ARCH+ #2
[  333.352619] Hardware name: Dell Inc. PowerEdge T110/ ,
   BIOS 1.23 12/15/2009
[  333.352620]   88001d1a7dd0 8125beeb
818507c0
[  333.352623]  0064 88001d1a7df0 8128047a
8800113462b0
[  333.352625]  88000e523000 88001d1a7e00 81241c79
88001d1a7e18
[  333.352627] Call Trace:
[  333.352634]  [] dump_stack+0x4d/0x72
[  333.352637]  [] should_fail+0x11a/0x120
[  333.352641]  [] blk_should_fake_timeout+0x29/0x30
[  333.352643]  [] blk_complete_request+0x16/0x30
[  333.352654]  [] scsi_done+0x26/0x80 [scsi_mod]
[  333.352657]  [] process_incoming_rsps+0x2bc/0x770
 [visorhba]
[  333.352661]  [] ? wait_woken+0x80/0x80
[  333.352663]  [] ? add_scsipending_entry+0x100/0x100

[PATCH 3/9] staging: unisys: visorhba: remove unused (and broken) logic

2016-05-12 Thread David Kershner
From: Tim Sell 

The handling of CMD_NOTIFYGUEST_TYPE messages from the IO partition appears
to be only partially implemented, but fortunately it is never used in our
current environment.  This patch deletes the unused code.

Signed-off-by: Tim Sell 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 78 ++---
 1 file changed, 4 insertions(+), 74 deletions(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index c4a9f32..5ea6bb2 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -100,14 +100,6 @@ struct scsipending {
char cmdtype;   /* Type of pointer that is being stored */
 };
 
-/* Work Data for dar_work_queue */
-struct diskaddremove {
-   u8 add; /* 0-remove, 1-add */
-   struct Scsi_Host *shost; /* Scsi Host for this visorhba instance */
-   u32 channel, id, lun;   /* Disk Path */
-   struct diskaddremove *next;
-};
-
 /* Each scsi_host has a host_data area that contains this struct. */
 struct visorhba_devdata {
struct Scsi_Host *scsihost;
@@ -967,62 +959,6 @@ complete_scsi_command(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
scsicmd->scsi_done(scsicmd);
 }
 
-static struct work_struct dar_work_queue;
-static struct diskaddremove *dar_work_queue_head;
-static spinlock_t dar_work_queue_lock; /* Lock to protet dar_work_queue_head */
-static unsigned short dar_work_queue_sched;
-
-/**
- * queue_disk_add_remove - IOSP has sent us a add/remove request
- * @dar: disk add/remove request
- *
- * Queue the work needed to add/remove a disk.
- * Returns void
- */
-static inline void queue_disk_add_remove(struct diskaddremove *dar)
-{
-   unsigned long flags;
-
-   spin_lock_irqsave(&dar_work_queue_lock, flags);
-   if (!dar_work_queue_head) {
-   dar_work_queue_head = dar;
-   dar->next = NULL;
-   } else {
-   dar->next = dar_work_queue_head;
-   dar_work_queue_head = dar;
-   }
-   if (!dar_work_queue_sched) {
-   schedule_work(&dar_work_queue);
-   dar_work_queue_sched = 1;
-   }
-   spin_unlock_irqrestore(&dar_work_queue_lock, flags);
-}
-
-/**
- * process_disk_notify - IOSP has sent a process disk notify event
- * @shost: Scsi hot
- * @cmdrsp: Response from the IOSP
- *
- * Queue it to the work queue.
- * Return void.
- */
-static void process_disk_notify(struct Scsi_Host *shost,
-   struct uiscmdrsp *cmdrsp)
-{
-   struct diskaddremove *dar;
-
-   dar = kzalloc(sizeof(*dar), GFP_ATOMIC);
-   if (!dar)
-   return;
-
-   dar->add = cmdrsp->disknotify.add;
-   dar->shost = shost;
-   dar->channel = cmdrsp->disknotify.channel;
-   dar->id = cmdrsp->disknotify.id;
-   dar->lun = cmdrsp->disknotify.lun;
-   queue_disk_add_remove(dar);
-}
-
 /**
  * drain_queue - pull responses out of iochannel
  * @cmdrsp: Response from the IOSP
@@ -1035,7 +971,6 @@ static void
 drain_queue(struct uiscmdrsp *cmdrsp, struct visorhba_devdata *devdata)
 {
struct scsi_cmnd *scsicmd;
-   struct Scsi_Host *shost = devdata->scsihost;
 
while (1) {
if (!visorchannel_signalremove(devdata->dev->visorchannel,
@@ -1059,15 +994,10 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct 
visorhba_devdata *devdata)
break;
complete_taskmgmt_command(&devdata->idr, cmdrsp,
  cmdrsp->scsitaskmgmt.result);
-   } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE) {
-   /* The vHba pointer has no meaning in a
-* guest partition. Let's be safe and set it
-* to NULL now. Do not use it here!
-*/
-   cmdrsp->disknotify.v_hba = NULL;
-   process_disk_notify(shost, cmdrsp);
-   }
-   /* cmdrsp is now available for resuse */
+   } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE)
+   dev_err_once(&devdata->dev->device,
+"ignoring unsupported NOTIFYGUEST\n");
+   /* cmdrsp is now available for re-use */
}
 }
 
-- 
1.9.1

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


[PATCH 1/9] staging: unisys: visorhba: delete processing of vdiskmgmt commands

2016-05-12 Thread David Kershner
From: Tim Sell 

We never issue SCSI commands of type CMD_VDISKMGMT_TYPE, so there is no
need to have code that processes their completions.

Signed-off-by: Tim Sell 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 22 --
 1 file changed, 22 deletions(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index 6a4570d..085d782 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -706,13 +706,6 @@ static void visorhba_serverdown_complete(struct 
visorhba_devdata *devdata)
wake_up_all((wait_queue_head_t *)
cmdrsp->scsitaskmgmt.notify_handle);
break;
-   case CMD_VDISKMGMT_TYPE:
-   cmdrsp = pendingdel->sent;
-   cmdrsp->vdiskmgmt.notifyresult_handle
-   = VDISK_MGMT_FAILED;
-   wake_up_all((wait_queue_head_t *)
-   cmdrsp->vdiskmgmt.notify_handle);
-   break;
default:
break;
}
@@ -878,16 +871,6 @@ complete_scsi_command(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
scsicmd->scsi_done(scsicmd);
 }
 
-/* DELETE VDISK TASK MGMT COMMANDS */
-static inline void complete_vdiskmgmt_command(struct uiscmdrsp *cmdrsp)
-{
-   /* copy the result of the taskmgmt and
-* wake up the error handler that is waiting for this
-*/
-   cmdrsp->vdiskmgmt.notifyresult_handle = cmdrsp->vdiskmgmt.result;
-   wake_up_all((wait_queue_head_t *)cmdrsp->vdiskmgmt.notify_handle);
-}
-
 /**
  * complete_taskmgmt_command - complete task management
  * @cmdrsp: Response from the IOVM
@@ -1003,11 +986,6 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct 
visorhba_devdata *devdata)
 */
cmdrsp->disknotify.v_hba = NULL;
process_disk_notify(shost, cmdrsp);
-   } else if (cmdrsp->cmdtype == CMD_VDISKMGMT_TYPE) {
-   if (!del_scsipending_ent(devdata,
-cmdrsp->vdiskmgmt.handle))
-   break;
-   complete_vdiskmgmt_command(cmdrsp);
}
/* cmdrsp is now available for resuse */
}
-- 
1.9.1

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


[PATCH 5/9] staging: unisys: visorhba: visorhbas_open[] no longer used, so deleted

2016-05-12 Thread David Kershner
From: Tim Sell 

The prior patch which simplified the visorhba debugfs interface made it so
visorhbas_open[] and VISORHBA_OPEN_MAX were no longer needed, so they have
now been deleted.

Signed-off-by: Tim Sell 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index 6a21514..11985bb 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -35,7 +35,6 @@
 #define MAX_BUF8192
 #define MAX_PENDING_REQUESTS   (MIN_NUMSIGNALS * 2)
 #define VISORHBA_ERROR_COUNT   30
-#define VISORHBA_OPEN_MAX  1
 
 static int visorhba_queue_command_lck(struct scsi_cmnd *scsicmd,
  void (*visorhba_cmnd_done)
@@ -135,8 +134,6 @@ struct visorhba_devices_open {
struct visorhba_devdata *devdata;
 };
 
-static struct visorhba_devices_open visorhbas_open[VISORHBA_OPEN_MAX];
-
 #define for_each_vdisk_match(iter, list, match)  \
for (iter = &list->head; iter->next; iter = iter->next) \
if ((iter->channel == match->channel) &&  \
@@ -1075,7 +1072,7 @@ static int visorhba_probe(struct visor_device *dev)
struct Scsi_Host *scsihost;
struct vhba_config_max max;
struct visorhba_devdata *devdata = NULL;
-   int i, err, channel_offset;
+   int err, channel_offset;
u64 features;
 
scsihost = scsi_host_alloc(&visorhba_driver_template,
@@ -1104,13 +1101,6 @@ static int visorhba_probe(struct visor_device *dev)
goto err_scsi_host_put;
 
devdata = (struct visorhba_devdata *)scsihost->hostdata;
-   for (i = 0; i < VISORHBA_OPEN_MAX; i++) {
-   if (!visorhbas_open[i].devdata) {
-   visorhbas_open[i].devdata = devdata;
-   break;
-   }
-   }
-
devdata->dev = dev;
dev_set_drvdata(&dev->device, devdata);
 
-- 
1.9.1

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


[PATCH 9/9] staging: unisys: visornic: check for error instead of success

2016-05-12 Thread David Kershner
From: David Binder 

Changes the conditional logic to check for an error code instead
of a success code.

Signed-off-by: David Binder 
Signed-off-by: David Kershner 
---
 drivers/staging/unisys/visornic/visornic_main.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index f556100..af81d31 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -2091,8 +2091,10 @@ static int visornic_init(void)
goto cleanup_debugfs;
 
err = visorbus_register_visor_driver(&visornic_driver);
-   if (!err)
-   return 0;
+   if (err)
+   goto cleanup_debugfs;
+
+   return 0;
 
 cleanup_debugfs:
debugfs_remove_recursive(visornic_debugfs_dir);
-- 
1.9.1

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


[PATCH 0/9] staging: unisys: visorhba: fix scsi task mgmt completion handling and other cleanups

2016-05-12 Thread David Kershner
On 5/2 Dan Carpenter pointed out some sloppy u64 <--> pointer casting we
were doing in visorhba, but this turned out to be the tip of an iceberg.
Our handling of scsi task mgmt completions turned out to be buggy. 

This patchset switches visorhba to use idr_alloc() / idr_find() so that we
can cleanly pass handles back-and-forth from/to the IO partition instead
of raw pointers.

This patchset simplifies and enhances the visorhba debugfs interface, and
deletes a global array made no-longer-necessary by the cleanup.


David Binder (4):
  staging: unisys: visornic: simplify visornic if statements
  staging: unisys: visornic: cleanup error handling
  staging: unisys: visorhba: return 0 literal
  staging: unisys: visornic: check for error instead of success

Tim Sell (5):
  staging: unisys: visorhba: delete processing of vdiskmgmt commands
  staging: unisys: visorhba: correct scsi task mgmt completion handling
  staging: unisys: visorhba: remove unused (and broken) logic
  staging: unisys: visorhba: simplify and enhance debugfs interface
  staging: unisys: visorhba: visorhbas_open[] no longer used, so deleted

 drivers/staging/unisys/visorhba/visorhba_main.c | 384 +++-
 drivers/staging/unisys/visornic/visornic_main.c |  53 ++--
 2 files changed, 209 insertions(+), 228 deletions(-)

-- 
1.9.1

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


[PATCH 6/6] hv_netvsc: set nvdev link after populating chn_table

2016-05-12 Thread Vitaly Kuznetsov
Crash in netvsc_send() is observed when netvsc device is re-created on
mtu change/set channels. The crash is caused by dereferencing of NULL
channel pointer which comes from chn_table. The root cause is a mixture
of two facts:
- we set nvdev pointer in net_device_context in alloc_net_device()
  before we populate chn_table.
- we populate chn_table[0] only.

The issue could be papered over by checking channel != NULL in
netvsc_send() but populating the whole chn_table and writing the
nvdev pointer afterwards seems more appropriate.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/net/hyperv/netvsc.c | 29 ++---
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index f755b03..5049346 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -34,11 +34,9 @@
 #include "hyperv_net.h"
 
 
-static struct netvsc_device *alloc_net_device(struct hv_device *device)
+static struct netvsc_device *alloc_net_device(void)
 {
struct netvsc_device *net_device;
-   struct net_device *ndev = hv_get_drvdata(device);
-   struct net_device_context *net_device_ctx = netdev_priv(ndev);
 
net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
if (!net_device)
@@ -55,8 +53,6 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
 
-   net_device_ctx->nvdev = net_device;
-
return net_device;
 }
 
@@ -1209,20 +1205,19 @@ void netvsc_channel_cb(void *context)
  */
 int netvsc_device_add(struct hv_device *device, void *additional_info)
 {
-   int ret = 0;
+   int i, ret = 0;
int ring_size =
((struct netvsc_device_info *)additional_info)->ring_size;
struct netvsc_device *net_device;
-   struct net_device *ndev;
+   struct net_device *ndev = hv_get_drvdata(device);
+   struct net_device_context *net_device_ctx = netdev_priv(ndev);
 
-   net_device = alloc_net_device(device);
+   net_device = alloc_net_device();
if (!net_device)
return -ENOMEM;
 
net_device->ring_size = ring_size;
 
-   ndev = hv_get_drvdata(device);
-
/* Initialize the NetVSC channel extension */
init_completion(&net_device->channel_init_wait);
 
@@ -1241,7 +1236,19 @@ int netvsc_device_add(struct hv_device *device, void 
*additional_info)
/* Channel is opened */
pr_info("hv_netvsc channel opened successfully\n");
 
-   net_device->chn_table[0] = device->channel;
+   /* If we're reopening the device we may have multiple queues, fill the
+* chn_table with the default channel to use it before subchannels are
+* opened.
+*/
+   for (i = 0; i < VRSS_CHANNEL_MAX; i++)
+   net_device->chn_table[i] = device->channel;
+
+   /* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is
+* populated.
+*/
+   wmb();
+
+   net_device_ctx->nvdev = net_device;
 
/* Connect with the NetVsp */
ret = netvsc_connect_vsp(device);
-- 
2.5.5

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


[PATCH 3/6] hv_netvsc: untangle the pointer mess

2016-05-12 Thread Vitaly Kuznetsov
We have the following structures keeping netvsc adapter state:
- struct net_device
- struct net_device_context
- struct netvsc_device
- struct rndis_device
- struct hv_device
and there are pointers/dependencies between them:
- struct net_device_context is contained in struct net_device
- struct hv_device has driver_data pointer which points to
  'struct net_device' OR 'struct netvsc_device' depending on driver's
  state (!).
- struct net_device_context has a pointer to 'struct hv_device'.
- struct netvsc_device has pointers to 'struct hv_device' and
  'struct net_device_context'.
- struct rndis_device has a pointer to 'struct netvsc_device'.

Different functions get different structures as parameters and use these
pointers for traveling. The problem is (in addition to keeping in mind
this complex graph) that some of these structures (struct netvsc_device
and struct rndis_device) are being removed and re-created on mtu change
(as we implement it as re-creation of hyper-v device) so our travel using
these pointers is dangerous.

Simplify this to a the following:
- add struct netvsc_device pointer to struct net_device_context (which is
  a part of struct net_device and thus never disappears)
- remove struct hv_device and struct net_device_context pointers from
  struct netvsc_device
- replace pointer to 'struct netvsc_device' with pointer to
  'struct net_device'.
- always keep 'struct net_device' in hv_device driver_data.

We'll end up with the following 'circular' structure:

net_device:
 [net_device_context] -> netvsc_device -> rndis_device -> net_device
  -> hv_device -> net_device

On MTU change we'll be removing the 'netvsc_device -> rndis_device'
branch and re-creating it making the synchronization easier.

There is one additional redundant pointer left, it is struct net_device
link in struct netvsc_device, it is going to be removed in a separate
commit.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/net/hyperv/hyperv_net.h   |  9 ++---
 drivers/net/hyperv/netvsc.c   | 78 +++
 drivers/net/hyperv/netvsc_drv.c   | 48 ++--
 drivers/net/hyperv/rndis_filter.c | 78 ---
 4 files changed, 93 insertions(+), 120 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 3f08132..6edc55f 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -158,7 +158,7 @@ enum rndis_device_state {
 };
 
 struct rndis_device {
-   struct netvsc_device *net_dev;
+   struct net_device *ndev;
 
enum rndis_device_state state;
bool link_state;
@@ -645,6 +645,8 @@ struct netvsc_reconfig {
 struct net_device_context {
/* point back to our device context */
struct hv_device *device_ctx;
+   /* netvsc_device */
+   struct netvsc_device *nvdev;
/* reconfigure work */
struct delayed_work dwork;
/* last reconfig time */
@@ -670,8 +672,6 @@ struct net_device_context {
 
 /* Per netvsc device */
 struct netvsc_device {
-   struct hv_device *dev;
-
u32 nvsp_version;
 
atomic_t num_outstanding_sends;
@@ -725,9 +725,6 @@ struct netvsc_device {
u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
u32 pkt_align; /* alignment bytes, e.g. 8 */
 
-   /* The net device context */
-   struct net_device_context *nd_ctx;
-
/* 1: allocated, serial number is valid. 0: not allocated */
u32 vf_alloc;
/* Serial number of the VF to team with */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index ba6b304..cc0af6a 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -38,6 +38,7 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
 {
struct netvsc_device *net_device;
struct net_device *ndev = hv_get_drvdata(device);
+   struct net_device_context *net_device_ctx = netdev_priv(ndev);
 
net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
if (!net_device)
@@ -51,12 +52,12 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
 
init_waitqueue_head(&net_device->wait_drain);
net_device->destroy = false;
-   net_device->dev = device;
net_device->ndev = ndev;
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
 
-   hv_set_drvdata(device, net_device);
+   net_device_ctx->nvdev = net_device;
+
return net_device;
 }
 
@@ -68,9 +69,10 @@ static void free_netvsc_device(struct netvsc_device *nvdev)
 
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
-   struct netvsc_device *net_device;
+   struct net_device *ndev = hv_get_drvdata(device);
+   struct net_device_context *net_device_ctx = netdev_priv(ndev);
+   struct netvsc_device *net_device = net_device_ctx->nvd

[PATCH 2/6] hv_netvsc: use start_remove flag to protect netvsc_link_change()

2016-05-12 Thread Vitaly Kuznetsov
netvsc_link_change() can race with netvsc_change_mtu() or
netvsc_set_channels() as these functions destroy struct netvsc_device and
rndis filter. Use start_remove flag for syncronization. As
netvsc_change_mtu()/netvsc_set_channels() are called with rtnl lock held
we need to take it before checking start_remove value in
netvsc_link_change().

Reported-by: Haiyang Zhang 
Signed-off-by: Vitaly Kuznetsov 
---
 drivers/net/hyperv/netvsc_drv.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 48dc81c..9a46b3d 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -787,6 +787,8 @@ static int netvsc_set_channels(struct net_device *net,
  out:
netvsc_open(net);
net_device_ctx->start_remove = false;
+   /* We may have missed link change notifications */
+   schedule_delayed_work(&net_device_ctx->dwork, 0);
 
return ret;
 
@@ -895,6 +897,9 @@ out:
netvsc_open(ndev);
ndevctx->start_remove = false;
 
+   /* We may have missed link change notifications */
+   schedule_delayed_work(&ndevctx->dwork, 0);
+
return ret;
 }
 
@@ -1015,6 +1020,11 @@ static void netvsc_link_change(struct work_struct *w)
unsigned long flags, next_reconfig, delay;
 
ndev_ctx = container_of(w, struct net_device_context, dwork.work);
+
+   rtnl_lock();
+   if (ndev_ctx->start_remove)
+   goto out_unlock;
+
net_device = hv_get_drvdata(ndev_ctx->device_ctx);
rdev = net_device->extension;
net = net_device->ndev;
@@ -1028,7 +1038,7 @@ static void netvsc_link_change(struct work_struct *w)
delay = next_reconfig - jiffies;
delay = delay < LINKCHANGE_INT ? delay : LINKCHANGE_INT;
schedule_delayed_work(&ndev_ctx->dwork, delay);
-   return;
+   goto out_unlock;
}
ndev_ctx->last_reconfig = jiffies;
 
@@ -1042,9 +1052,7 @@ static void netvsc_link_change(struct work_struct *w)
spin_unlock_irqrestore(&ndev_ctx->lock, flags);
 
if (!event)
-   return;
-
-   rtnl_lock();
+   goto out_unlock;
 
switch (event->event) {
/* Only the following events are possible due to the check in
@@ -1093,6 +1101,11 @@ static void netvsc_link_change(struct work_struct *w)
 */
if (reschedule)
schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT);
+
+   return;
+
+out_unlock:
+   rtnl_unlock();
 }
 
 static void netvsc_free_netdev(struct net_device *netdev)
-- 
2.5.5

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


[PATCH 5/6] hv_netvsc: synchronize netvsc_change_mtu()/netvsc_set_channels() with netvsc_remove()

2016-05-12 Thread Vitaly Kuznetsov
When netvsc device is removed during mtu change or channels setup we get
into troubles as both paths are trying to remove the device. Synchronize
them with start_remove flag and rtnl lock.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/net/hyperv/netvsc_drv.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 393403a..71b9125 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -707,7 +707,7 @@ static int netvsc_set_channels(struct net_device *net,
int ret = 0;
bool recovering = false;
 
-   if (!nvdev || nvdev->destroy)
+   if (net_device_ctx->start_remove || !nvdev || nvdev->destroy)
return -ENODEV;
 
num_chn = nvdev->num_chn;
@@ -855,7 +855,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int 
mtu)
u32 num_chn;
int ret = 0;
 
-   if (nvdev == NULL || nvdev->destroy)
+   if (ndevctx->start_remove || !nvdev || nvdev->destroy)
return -ENODEV;
 
if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
@@ -1206,7 +1206,12 @@ static int netvsc_remove(struct hv_device *dev)
ndev_ctx = netdev_priv(net);
net_device = ndev_ctx->nvdev;
 
+   /* Avoid racing with netvsc_change_mtu()/netvsc_set_channels()
+* removing the device.
+*/
+   rtnl_lock();
ndev_ctx->start_remove = true;
+   rtnl_unlock();
 
cancel_delayed_work_sync(&ndev_ctx->dwork);
cancel_work_sync(&ndev_ctx->work);
-- 
2.5.5

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


[PATCH 4/6] hv_netvsc: get rid of struct net_device pointer in struct netvsc_device

2016-05-12 Thread Vitaly Kuznetsov
Simplify netvsvc pointer graph by getting rid of the redundant ndev
pointer. We can always get a pointer to struct net_device from somewhere
else.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/net/hyperv/hyperv_net.h   |  2 --
 drivers/net/hyperv/netvsc.c   | 30 --
 drivers/net/hyperv/netvsc_drv.c   | 18 +-
 drivers/net/hyperv/rndis_filter.c |  4 ++--
 4 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 6edc55f..16d22b3 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -701,8 +701,6 @@ struct netvsc_device {
struct nvsp_message revoke_packet;
/* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
 
-   struct net_device *ndev;
-
struct vmbus_channel *chn_table[VRSS_CHANNEL_MAX];
u32 send_table[VRSS_SEND_TAB_SIZE];
u32 max_chn;
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index cc0af6a..f755b03 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -52,7 +52,6 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
 
init_waitqueue_head(&net_device->wait_drain);
net_device->destroy = false;
-   net_device->ndev = ndev;
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
 
@@ -232,7 +231,7 @@ static int netvsc_init_buf(struct hv_device *device)
net_device = get_outbound_net_device(device);
if (!net_device)
return -ENODEV;
-   ndev = net_device->ndev;
+   ndev = hv_get_drvdata(device);
 
node = cpu_to_node(device->channel->target_cpu);
net_device->recv_buf = vzalloc_node(net_device->recv_buf_size, node);
@@ -422,6 +421,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
  struct nvsp_message *init_packet,
  u32 nvsp_ver)
 {
+   struct net_device *ndev = hv_get_drvdata(device);
int ret;
unsigned long t;
 
@@ -455,8 +455,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
/* NVSPv2 or later: Send NDIS config */
memset(init_packet, 0, sizeof(struct nvsp_message));
init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG;
-   init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu +
-  ETH_HLEN;
+   init_packet->msg.v2_msg.send_ndis_config.mtu = ndev->mtu + ETH_HLEN;
init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1;
 
if (nvsp_ver >= NVSP_PROTOCOL_VERSION_5)
@@ -476,7 +475,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
struct netvsc_device *net_device;
struct nvsp_message *init_packet;
int ndis_version;
-   struct net_device *ndev;
u32 ver_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 };
int i, num_ver = 4; /* number of different NVSP versions */
@@ -484,7 +482,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
net_device = get_outbound_net_device(device);
if (!net_device)
return -ENODEV;
-   ndev = net_device->ndev;
 
init_packet = &net_device->channel_init_pkt;
 
@@ -737,6 +734,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
 }
 
 static inline int netvsc_send_pkt(
+   struct hv_device *device,
struct hv_netvsc_packet *packet,
struct netvsc_device *net_device,
struct hv_page_buffer **pb,
@@ -745,7 +743,7 @@ static inline int netvsc_send_pkt(
struct nvsp_message nvmsg;
u16 q_idx = packet->q_idx;
struct vmbus_channel *out_channel = net_device->chn_table[q_idx];
-   struct net_device *ndev = net_device->ndev;
+   struct net_device *ndev = hv_get_drvdata(device);
u64 req_id;
int ret;
struct hv_page_buffer *pgbuf;
@@ -940,7 +938,8 @@ int netvsc_send(struct hv_device *device,
}
 
if (msd_send) {
-   m_ret = netvsc_send_pkt(msd_send, net_device, NULL, msd_skb);
+   m_ret = netvsc_send_pkt(device, msd_send, net_device,
+   NULL, msd_skb);
 
if (m_ret != 0) {
netvsc_free_send_slot(net_device,
@@ -951,7 +950,7 @@ int netvsc_send(struct hv_device *device,
 
 send_now:
if (cur_send)
-   ret = netvsc_send_pkt(cur_send, net_device, pb, skb);
+   ret = netvsc_send_pkt(device, cur_send, net_device, pb, skb);
 
if (ret != 0 && section_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, section_index);
@@ -967,9 +966,7 @@ static void netvsc_send_recv_completion(struct hv_device 
*device,
struct nvsp_message recvcompMes

[PATCH 0/6] hv_netvsc: avoid races on mtu change/set channels

2016-05-12 Thread Vitaly Kuznetsov
MTU change and set channels operations are implemented as netvsc device
re-creation destroying internal structures (struct net_device stays). This
is really unfortunate but there is no support from Hyper-V host to do it
in a different way. Such re-creation is unsurprisingly racy, Haiyang
reported a crash when netvsc_change_mtu() is racing with
netvsc_link_change() but I was able to identify additional races upon
investigation. Both netvsc_set_channels() and netvsc_change_mtu() race
against:
1) netvsc_link_change()
2) netvsc_remove()
3) netvsc_send()

To solve these issues without introducing new locks some refactoring is
required. We need to get rid of very complex link graph in all the
internal structures and avoid traveling through structures which are being
removed.

Vitaly Kuznetsov (6):
  hv_netvsc: move start_remove flag to net_device_context
  hv_netvsc: use start_remove flag to protect netvsc_link_change()
  hv_netvsc: untangle the pointer mess
  hv_netvsc: get rid of struct net_device pointer in struct
netvsc_device
  hv_netvsc: synchronize netvsc_change_mtu()/netvsc_set_channels() with
netvsc_remove()
  hv_netvsc: set nvdev link after populating chn_table

 drivers/net/hyperv/hyperv_net.h   |  15 ++---
 drivers/net/hyperv/netvsc.c   | 130 --
 drivers/net/hyperv/netvsc_drv.c   | 104 +-
 drivers/net/hyperv/rndis_filter.c |  82 
 4 files changed, 164 insertions(+), 167 deletions(-)

-- 
2.5.5

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


[PATCH 1/6] hv_netvsc: move start_remove flag to net_device_context

2016-05-12 Thread Vitaly Kuznetsov
struct netvsc_device is destroyed on mtu change so keeping the
protection flag there is not a good idea. Move it to struct
net_device_context which is preserved.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/net/hyperv/hyperv_net.h |  4 +++-
 drivers/net/hyperv/netvsc.c |  3 +--
 drivers/net/hyperv/netvsc_drv.c | 12 +---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 8b3bd8e..3f08132 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -663,6 +663,9 @@ struct net_device_context {
/* Ethtool settings */
u8 duplex;
u32 speed;
+
+   /* the device is going away */
+   bool start_remove;
 };
 
 /* Per netvsc device */
@@ -673,7 +676,6 @@ struct netvsc_device {
 
atomic_t num_outstanding_sends;
wait_queue_head_t wait_drain;
-   bool start_remove;
bool destroy;
 
/* Receive buffer allocated by us but manages by NetVSP */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index ec313fc..ba6b304 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -50,7 +50,6 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
}
 
init_waitqueue_head(&net_device->wait_drain);
-   net_device->start_remove = false;
net_device->destroy = false;
net_device->dev = device;
net_device->ndev = ndev;
@@ -662,7 +661,7 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
wake_up(&net_device->wait_drain);
 
if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) &&
-   !net_device->start_remove &&
+   !net_device->nd_ctx->start_remove &&
(hv_ringbuf_avail_percent(&channel->outbound) >
 RING_AVAIL_PERCENT_HIWATER || queue_sends < 1))
netif_tx_wake_queue(netdev_get_tx_queue(
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index b8121eb..48dc81c 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -742,7 +742,7 @@ static int netvsc_set_channels(struct net_device *net,
goto out;
 
  do_set:
-   nvdev->start_remove = true;
+   net_device_ctx->start_remove = true;
rndis_filter_device_remove(dev);
 
nvdev->num_chn = channels->combined_count;
@@ -786,6 +786,7 @@ static int netvsc_set_channels(struct net_device *net,
 
  out:
netvsc_open(net);
+   net_device_ctx->start_remove = false;
 
return ret;
 
@@ -876,7 +877,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int 
mtu)
 
num_chn = nvdev->num_chn;
 
-   nvdev->start_remove = true;
+   ndevctx->start_remove = true;
rndis_filter_device_remove(hdev);
 
ndev->mtu = mtu;
@@ -892,6 +893,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int 
mtu)
 
 out:
netvsc_open(ndev);
+   ndevctx->start_remove = false;
 
return ret;
 }
@@ -1138,6 +1140,9 @@ static int netvsc_probe(struct hv_device *dev,
}
 
hv_set_drvdata(dev, net);
+
+   net_device_ctx->start_remove = false;
+
INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
INIT_WORK(&net_device_ctx->work, do_set_multicast);
 
@@ -1198,9 +1203,10 @@ static int netvsc_remove(struct hv_device *dev)
return 0;
}
 
-   net_device->start_remove = true;
 
ndev_ctx = netdev_priv(net);
+   ndev_ctx->start_remove = true;
+
cancel_delayed_work_sync(&ndev_ctx->dwork);
cancel_work_sync(&ndev_ctx->work);
 
-- 
2.5.5

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


Re: [PATCH] MAINTAINERS: add entry for the Sync File Framework

2016-05-12 Thread Maarten Lankhorst
Op 11-05-16 om 15:45 schreef Gustavo Padovan:
> From: Gustavo Padovan 
>
> Add Gustavo as maintainer for the Sync File Framework. Sumit is
> co-maintainer as he maintains drivers/dma-buf/. It also uses Sumit's
> tree as base.
>
> Cc: Sumit Semwal 
> Signed-off-by: Gustavo Padovan 
Acked-by: Maarten Lankhorst 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: dgnc: removes redundant null check and change

2016-05-12 Thread Daeseok Youn
The dgnc_set_modem_info() used only channel_t variable.
Any other variables were used only for checking NULL.

So fist parameter changed from "tty_struct" to "channel_t" and
useless NULL checks and variables are removed.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_tty.c | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 5119bcb..51c37ee 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -100,7 +100,7 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty);
 static void dgnc_tty_flush_chars(struct tty_struct *tty);
 static void dgnc_tty_flush_buffer(struct tty_struct *tty);
 static void dgnc_tty_hangup(struct tty_struct *tty);
-static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command,
+static int dgnc_set_modem_info(struct channel_t *ch, unsigned int command,
   unsigned int __user *value);
 static int dgnc_get_modem_info(struct channel_t *ch,
   unsigned int __user *value);
@@ -2015,32 +2015,14 @@ static int dgnc_get_modem_info(struct channel_t *ch,
  *
  * Set modem signals, called by ld.
  */
-static int dgnc_set_modem_info(struct tty_struct *tty,
+static int dgnc_set_modem_info(struct channel_t *ch,
   unsigned int command,
   unsigned int __user *value)
 {
-   struct dgnc_board *bd;
-   struct channel_t *ch;
-   struct un_t *un;
int ret = -ENXIO;
unsigned int arg = 0;
unsigned long flags;
 
-   if (!tty || tty->magic != TTY_MAGIC)
-   return ret;
-
-   un = tty->driver_data;
-   if (!un || un->magic != DGNC_UNIT_MAGIC)
-   return ret;
-
-   ch = un->un_ch;
-   if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
-   return ret;
-
-   bd = ch->ch_bd;
-   if (!bd || bd->magic != DGNC_BOARD_MAGIC)
-   return ret;
-
ret = get_user(arg, value);
if (ret)
return ret;
@@ -2607,7 +2589,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
case TIOCMBIC:
case TIOCMSET:
spin_unlock_irqrestore(&ch->ch_lock, flags);
-   return dgnc_set_modem_info(tty, cmd, uarg);
+   return dgnc_set_modem_info(ch, cmd, uarg);
 
/*
 * Here are any additional ioctl's that we want to implement
-- 
2.8.2

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


[PATCH 2/3] staging: dgnc: remove redundant variable null check

2016-05-12 Thread Daeseok Youn
The unit struct(un_t) was not used in dgnc_tty_hangup().

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_tty.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 52a1613..5119bcb 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1294,15 +1294,9 @@ static int dgnc_block_til_ready(struct tty_struct *tty,
  */
 static void dgnc_tty_hangup(struct tty_struct *tty)
 {
-   struct un_t *un;
-
if (!tty || tty->magic != TTY_MAGIC)
return;
 
-   un = tty->driver_data;
-   if (!un || un->magic != DGNC_UNIT_MAGIC)
-   return;
-
/* flush the transmit queues */
dgnc_tty_flush_buffer(tty);
 }
-- 
2.8.2

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


[PATCH 1/3] staging: dgnc: remove redundant local variable for

2016-05-12 Thread Daeseok Youn
The local variable "bd" was not used in dgnc_carrier() function.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_tty.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a505775..52a1613 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -640,19 +640,12 @@ exit_unlock:
  /
 void dgnc_carrier(struct channel_t *ch)
 {
-   struct dgnc_board *bd;
-
int virt_carrier = 0;
int phys_carrier = 0;
 
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return;
 
-   bd = ch->ch_bd;
-
-   if (!bd || bd->magic != DGNC_BOARD_MAGIC)
-   return;
-
if (ch->ch_mistat & UART_MSR_DCD)
phys_carrier = 1;
 
-- 
2.8.2

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


Re: [PATCH 0/6] Intel Secure Guard Extensions

2016-05-12 Thread Dr. Greg Wettstein
On Mon, May 09, 2016 at 08:27:04AM +0200, Thomas Gleixner wrote:

Good morning.

> > On Fri, 6 May 2016, Jarkko Sakkinen wrote:
> > I fully understand if you (and others) want to keep this standpoint but
> > what if we could get it to staging after I've revised it with suggested
> >
> This should not go to staging at all. Either this is going to be a
> real useful driver or we just keep it out of tree.
> >
> > changes and internal changes in my TODO? Then it would not pollute the
> > mainline kernel but still would be easily available for experimentation.

> How are we supposed to experiment with that if there is no launch
> enclave for Linux available?

Build one in a simulator where an independent root enclave key can be
established.  At least thats the approach we are working on with
Jarkko's patches.

Intel does have an instruction accurate simulator, Microsoft used it
for the work which was reported in the Haven paper.  I believe the Air
Force academy used that simulator for their work on SGX as well.

As with other issues SGX related it is unclear why access to the
simulator was/is restricted.  Given that Gen6 hardware is now emerging
there would seem to be even less reason to not have the simulator
generically available to allow implementations to be tested.

> Thanks,
> 
>   tglx

Have a good day.

As always,
Dr. G.W. Wettstein, Ph.D.   Enjellic Systems Development, LLC.
4206 N. 19th Ave.   Specializing in information infra-structure
Fargo, ND  58102development.
PH: 701-281-1686
FAX: 701-281-3949   EMAIL: g...@enjellic.com
--
"Everything should be made as simple as possible, but not simpler."
-- Albert Einstein
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] Staging: comedi: fix type issue in s626.c

2016-05-12 Thread Ravishankar Karkala Mallikarjunayya
This is a patch to the s626.c file that fixes up a type issues
found by the checkpatch.pl tool.

i.e Prefer kernel type 'u8' over 'uint8_t'
Prefer kernel type 'u16' over 'uint16_t'
Prefer kernel type 'u32' over 'uint32_t'
Prefer kernel type 's16' over 'int16_t'
Prefer kernel type 's32' over 'int32_t'

Signed-off-by: Ravishankar Karkala Mallikarjunayya 
---
 drivers/staging/comedi/drivers/s626.c | 150 +-
 1 file changed, 75 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index 13f302d..fb27089 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
 */
@@ -83,22 +83,22 @@ struct s626_private {
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
 */
-   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
 * 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
 */
-   uint16_t dacpol;/* image of DAC polarity register */
-   uint8_t trim_setpoint[12];  /* images of TrimDAC setpoints */
-   uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
+   u16 dacpol; /* image of DAC polarity register */
+   u8 trim_setpoint[12];   /* images of TrimDAC setpoints */
+   u32 i2c_adrs;   /* I2C device address for onboard EEPROM
 * (board rev dependent)
 */
 };
@@ -311,10 +311,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
 };
 
@@ -523,12 +523,12 @@ 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;
-   uint32_t ws_image;
-   uint32_t val;
+   u16 signmask;
+   u32 ws_image;
+   u32 val;
 
/*
 * Adjust DAC data polarity and set up Polarity Control Register image.
@@ -592,10 +592,10 @@ 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, uint8_t 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
@@ -643,7 +643,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. */
@@ -696,7 +696,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;
+

[PATCH 4/4] Staging: comedi: fix line over 80 characters issue in s626.c

2016-05-12 Thread Ravishankar Karkala Mallikarjunayya
This is a patch to the s626.c file that fixes up a  line over
80 characters issues found by the checkpatch.pl tool.

Signed-off-by: Ravishankar Karkala Mallikarjunayya 
---
 drivers/staging/comedi/drivers/s626.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index fb27089..fb1a190 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -2510,7 +2510,8 @@ static int s626_initialize(struct comedi_device *dev)
for (i = 0; i < 2; i++) {
writel(S626_I2C_CLKSEL, dev->mmio + S626_P_I2CSTAT);
s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2);
-   ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 
0);
+   ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc,
+0);
if (ret)
return ret;
}
-- 
1.9.1

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


[PATCH 1/4] Staging: comedi: Fix WARNING issue in s626.c

2016-05-12 Thread Ravishankar Karkala Mallikarjunayya
This is a patch to the s626.c file that fixes up a Block comments
issues found by the checkpatch.pl tool.

i.e. Block comments use a trailing */ on a separate line

Signed-off-by: Ravishankar Karkala Mallikarjunayya 
---
 drivers/staging/comedi/drivers/s626.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index c5e0863..43ab2e4 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -77,23 +77,30 @@ struct s626_buffer_dma {
 struct s626_private {
uint8_t ai_cmd_running; /* ai_cmd is running */
unsigned int ai_sample_timer;   /* time between samples in
-* units of the timer */
+* units of the timer
+*/
int ai_convert_count;   /* conversion counter */
unsigned int ai_convert_timer;  /* time between conversion in
-* units of the timer */
+* units of the timer
+*/
uint16_t counter_int_enabs; /* counter interrupt enable mask
-* for MISC2 register */
+* for MISC2 register
+*/
uint8_t adc_items;  /* number of items in ADC poll list */
struct s626_buffer_dma rps_buf; /* DMA buffer used to hold ADC (RPS1)
-* program */
+* program
+*/
struct s626_buffer_dma ana_buf; /* DMA buffer used to receive ADC data
-* and hold DAC data */
+* and hold DAC data
+*/
uint32_t *dac_wbuf; /* pointer to logical adrs of DMA buffer
-* used to hold DAC data */
+* used to hold DAC data
+*/
uint16_t dacpol;/* image of DAC polarity register */
uint8_t trim_setpoint[12];  /* images of TrimDAC setpoints */
uint32_t i2c_adrs;  /* I2C device address for onboard EEPROM
-* (board rev dependent) */
+* (board rev dependent)
+*/
 };
 
 /* Counter overflow/index event flag masks for RDMISC2. */
@@ -572,11 +579,14 @@ static int s626_set_dac(struct comedi_device *dev,
 * running after the packet has been sent to the target DAC.
 */
val = 0x0F00;   /* Continue clock after target DAC data
-* (write to non-existent trimdac). */
+* (write to non-existent trimdac).
+*/
val |= 0x4000;  /* Address the two main dual-DAC devices
-* (TSL's chip select enables target device). */
+* (TSL's chip select enables target device).
+*/
val |= ((uint32_t)(chan & 1) << 15);/* Address the DAC channel
-* within the device. */
+* within the device.
+*/
val |= (uint32_t)dacdata;   /* Include DAC setpoint data. */
return s626_send_dac(dev, val);
 }
-- 
1.9.1

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


[PATCH 2/4] Staging: comedi:Fix checkpatch issue in s626.c

2016-05-12 Thread Ravishankar Karkala Mallikarjunayya
This is a patch to the s626.c file that fixes up a
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
found by the checkpatch.pl tool

Signed-off-by: Ravishankar Karkala Mallikarjunayya 
---
 drivers/staging/comedi/drivers/s626.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index 43ab2e4..13f302d 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -718,7 +718,7 @@ static uint16_t s626_get_mode_a(struct comedi_device *dev,
uint16_t cra;
uint16_t crb;
uint16_t setup;
-   unsigned cntsrc, clkmult, clkpol, encmode;
+   unsigned int cntsrc, clkmult, clkpol, encmode;
 
/* Fetch CRA and CRB register images. */
cra = s626_debi_read(dev, S626_LP_CRA(chan));
@@ -773,7 +773,7 @@ static uint16_t s626_get_mode_b(struct comedi_device *dev,
uint16_t cra;
uint16_t crb;
uint16_t setup;
-   unsigned cntsrc, clkmult, clkpol, encmode;
+   unsigned int cntsrc, clkmult, clkpol, encmode;
 
/* Fetch CRA and CRB register images. */
cra = s626_debi_read(dev, S626_LP_CRA(chan));
@@ -848,7 +848,7 @@ static void s626_set_mode_a(struct comedi_device *dev,
struct s626_private *devpriv = dev->private;
uint16_t cra;
uint16_t crb;
-   unsigned cntsrc, clkmult, clkpol;
+   unsigned int cntsrc, clkmult, clkpol;
 
/* Initialize CRA and CRB images. */
/* Preload trigger is passed through. */
@@ -926,7 +926,7 @@ static void s626_set_mode_b(struct comedi_device *dev,
struct s626_private *devpriv = dev->private;
uint16_t cra;
uint16_t crb;
-   unsigned cntsrc, clkmult, clkpol;
+   unsigned int cntsrc, clkmult, clkpol;
 
/* Initialize CRA and CRB images. */
/* IndexSrc is passed through. */
-- 
1.9.1

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