[PATCH] staging: lustre: This patch fixes the following sparse warning:

2015-12-11 Thread Jandy Gou
drivers/staging/lustre/lustre/osc/osc_cache.c:622:19: warning: symbol
'osc_extent_find' was not declared. Should it be static?
drivers/staging/lustre/lustre/osc/osc_cache.c:1423:6: warning: symbol
'osc_unreserve_grant' was not declared. Should it be static?

Signed-off-by: Jandy Gou 
---
 drivers/staging/lustre/lustre/osc/osc_cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c 
b/drivers/staging/lustre/lustre/osc/osc_cache.c
index b1d1a87f..62cfca6 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -619,7 +619,7 @@ static inline int overlapped(struct osc_extent *ex1, struct 
osc_extent *ex2)
  * Find or create an extent which includes @index, core function to manage
  * extent tree.
  */
-struct osc_extent *osc_extent_find(const struct lu_env *env,
+static struct osc_extent *osc_extent_find(const struct lu_env *env,
   struct osc_object *obj, pgoff_t index,
   int *grants)
 
@@ -1420,7 +1420,7 @@ static void __osc_unreserve_grant(struct client_obd *cli,
}
 }
 
-void osc_unreserve_grant(struct client_obd *cli,
+static void osc_unreserve_grant(struct client_obd *cli,
 unsigned int reserved, unsigned int unused)
 {
client_obd_list_lock(&cli->cl_loi_list_lock);
-- 
1.9.1


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


Re: [PATCH 1/4] scsi: storvsc: Fix a bug in the layout of the hv_fc_wwn_packet

2015-12-11 Thread Johannes Thumshirn
On Thu, Dec 10, 2015 at 04:14:17PM -0800, K. Y. Srinivasan wrote:
> The hv_fc_wwn_packet is exchanged over vmbus. Make the definition in Linux 
> match
> the Window's definition.
> 
> Signed-off-by: K. Y. Srinivasan 
> Reviewed-by: Long Li 
> Tested-by: Alex Ng 
> ---
>  drivers/scsi/storvsc_drv.c |5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index c41f674..00bb4bd 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -92,9 +92,8 @@ enum vstor_packet_operation {
>   */
>  
>  struct hv_fc_wwn_packet {
> - boolprimary_active;
> - u8  reserved1;
> - u8  reserved2;
> + u8  primary_active;
> + u8  reserved1[3];
>   u8  primary_port_wwn[8];
>   u8  primary_node_wwn[8];
>   u8  secondary_port_wwn[8];
> -- 
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Should this go through stable as well?
If yes:
Fixes: 8b612fa23 '[SCSI] storvsc: Update the storage protocol to win8 level'
Cc: sta...@vger.kernel.org # v3.11+
Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Drivers: hv: vmbus: fix build warning

2015-12-11 Thread Sudip Mukherjee
We were getting build warning about unused variable "tsc_msr" and
"va_tsc" while building for i386 allmodconfig.

Signed-off-by: Sudip Mukherjee 
---
build warning with next-20151211 and build log is at:
https://travis-ci.org/sudipm-mukherjee/parport/jobs/96209206
---

 drivers/hv/hv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 6341be8..ad7fc6d 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -192,9 +192,7 @@ int hv_init(void)
 {
int max_leaf;
union hv_x64_msr_hypercall_contents hypercall_msr;
-   union hv_x64_msr_hypercall_contents tsc_msr;
void *virtaddr = NULL;
-   void *va_tsc = NULL;
 
memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
memset(hv_context.synic_message_page, 0,
@@ -240,6 +238,9 @@ int hv_init(void)
 
 #ifdef CONFIG_X86_64
if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
+   union hv_x64_msr_hypercall_contents tsc_msr;
+   void *va_tsc;
+
va_tsc = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);
if (!va_tsc)
goto cleanup;
-- 
1.9.1

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


Re: [PATCH 2/4] scsi: storvsc: Properly support Fibre Channel devices

2015-12-11 Thread Johannes Thumshirn
On Thu, Dec 10, 2015 at 04:14:18PM -0800, K. Y. Srinivasan wrote:
> For FC devices managed by this driver, atttach the appropriate transport
> template. This will allow us to create the appropriate sysfs files for
> these devices. With this we can publish the wwn for both the port and the 
> node.
> 
> Signed-off-by: K. Y. Srinivasan 
> Reviewed-by: Long Li 
> Tested-by: Alex Ng 
> ---
>  drivers/scsi/storvsc_drv.c |  100 +--
>  1 files changed, 95 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 00bb4bd..b94d471 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -41,6 +41,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /*
>   * All wire protocol details (storage protocol between the guest and the 
> host)
> @@ -397,6 +398,7 @@ static int storvsc_timeout = 180;
>  
>  static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
>  
> +static struct scsi_transport_template *fc_transport_template;
>  
>  static void storvsc_on_channel_callback(void *context);
>  
> @@ -456,6 +458,11 @@ struct storvsc_device {
>   /* Used for vsc/vsp channel reset process */
>   struct storvsc_cmd_request init_request;
>   struct storvsc_cmd_request reset_request;
> + /*
> +  * Currently active port and node names for FC devices.
> +  */
> + u64 node_name;
> + u64 port_name;
>  };
>  
>  struct hv_host_device {
> @@ -695,7 +702,26 @@ static void  handle_multichannel_storage(struct 
> hv_device *device, int max_chns)
>   vmbus_are_subchannels_present(device->channel);
>  }
>  
> -static int storvsc_channel_init(struct hv_device *device)
> +static void cache_wwn(struct storvsc_device *stor_device,
> +   struct vstor_packet *vstor_packet)
> +{
> + /*
> +  * Cache the currently active port and node ww names.
> +  */
> + if (vstor_packet->wwn_packet.primary_active) {
> + stor_device->node_name =
> + wwn_to_u64(vstor_packet->wwn_packet.primary_node_wwn);
> + stor_device->port_name =
> + wwn_to_u64(vstor_packet->wwn_packet.primary_port_wwn);
> + } else {
> + stor_device->node_name =
> + wwn_to_u64(vstor_packet->wwn_packet.secondary_node_wwn);
> + stor_device->port_name =
> + wwn_to_u64(vstor_packet->wwn_packet.secondary_port_wwn);
> + }
> +}
> +
> +static int storvsc_channel_init(struct hv_device *device, bool is_fc)
>  {
>   struct storvsc_device *stor_device;
>   struct storvsc_cmd_request *request;
> @@ -837,6 +863,40 @@ static int storvsc_channel_init(struct hv_device *device)
>   stor_device->max_transfer_bytes =
>   vstor_packet->storage_channel_properties.max_transfer_bytes;
>  
> + if (!is_fc)
> + goto done;
> +
> + memset(vstor_packet, 0, sizeof(struct vstor_packet));
> + vstor_packet->operation = VSTOR_OPERATION_FCHBA_DATA;
> + vstor_packet->flags = REQUEST_COMPLETION_FLAG;
> +
> + ret = vmbus_sendpacket(device->channel, vstor_packet,
> +(sizeof(struct vstor_packet) -
> +vmscsi_size_delta),
> +(unsigned long)request,
> +VM_PKT_DATA_INBAND,
> +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> +
> + if (ret != 0)
> + goto cleanup;
> +
> + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
> + if (t == 0) {
> + ret = -ETIMEDOUT;
> + goto cleanup;
> + }
> +
> + if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
> + vstor_packet->status != 0)
> + goto cleanup;
> +
> + /*
> +  * Cache the currently active port and node ww names.
> +  */
> + cache_wwn(stor_device, vstor_packet);
> +
> +done:
> +

That goto use is a bit weird. I see you did it because of the 80 chars limit
but 
if (is_fc) {
[...]
}

is way more readable IMHO.

>   memset(vstor_packet, 0, sizeof(struct vstor_packet));
>   vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
>   vstor_packet->flags = REQUEST_COMPLETION_FLAG;
> @@ -1076,6 +1136,12 @@ static void storvsc_on_receive(struct hv_device 
> *device,
>   schedule_work(&work->work);
>   break;
>  
> + case VSTOR_OPERATION_FCHBA_DATA:
> + stor_device = get_in_stor_device(device);
> + cache_wwn(stor_device, vstor_packet);
> + fc_host_node_name(stor_device->host) = stor_device->node_name;
> + fc_host_port_name(stor_device->host) = stor_device->port_name;
> + break;
>   default:
>   break;
>   }
> @@ -1131,7 +1197,8 @@ static void storvsc_on_channel_callback(void *context)
>   return;
>  }
>  
> -static int storvsc_connect_to_vsp(struct

Re: [PATCH 3/4] scsi: storvsc: Refactor the code in storvsc_channel_init()

2015-12-11 Thread Johannes Thumshirn
On Thu, Dec 10, 2015 at 04:14:19PM -0800, K. Y. Srinivasan wrote:
> The function storvsc_channel_init() repeatedly interacts with the host to
> extract various channel properties. Refactor this code to eliminate code
> repetition.
> 
> Signed-off-by: K. Y. Srinivasan 
> Reviewed-by: Long Li 
> Tested-by: Alex Ng 
> ---
>  drivers/scsi/storvsc_drv.c |  155 
> 
>  1 files changed, 57 insertions(+), 98 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index b94d471..6f18e94 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -721,29 +721,16 @@ static void cache_wwn(struct storvsc_device 
> *stor_device,
>   }
>  }
>  
> -static int storvsc_channel_init(struct hv_device *device, bool is_fc)
> +static int storvsc_execute_vstor_op(struct hv_device *device,
> + struct storvsc_cmd_request *request,
> + bool status_check)
>  {
> - struct storvsc_device *stor_device;
> - struct storvsc_cmd_request *request;
>   struct vstor_packet *vstor_packet;
> - int ret, t, i;
> - int max_chns;
> - bool process_sub_channels = false;
> -
> - stor_device = get_out_stor_device(device);
> - if (!stor_device)
> - return -ENODEV;
> + int ret, t;
>  
> - request = &stor_device->init_request;
>   vstor_packet = &request->vstor_packet;
>  
> - /*
> -  * Now, initiate the vsc/vsp initialization protocol on the open
> -  * channel
> -  */
> - memset(request, 0, sizeof(struct storvsc_cmd_request));
>   init_completion(&request->wait_event);
> - vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
>   vstor_packet->flags = REQUEST_COMPLETION_FLAG;
>  
>   ret = vmbus_sendpacket(device->channel, vstor_packet,
> @@ -753,27 +740,62 @@ static int storvsc_channel_init(struct hv_device 
> *device, bool is_fc)
>  VM_PKT_DATA_INBAND,
>  VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
>   if (ret != 0)
> - goto cleanup;
> + goto done;
>  
>   t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
>   if (t == 0) {
>   ret = -ETIMEDOUT;
> - goto cleanup;
> + goto done;
>   }
>  
> + if (!status_check)
> + goto done;
> +
>   if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
>   vstor_packet->status != 0) {
>   ret = -EINVAL;
> - goto cleanup;
> + goto done;
>   }
>  
> +done:
> + return ret;
> +}
> +
> +static int storvsc_channel_init(struct hv_device *device, bool is_fc)
> +{
> + struct storvsc_device *stor_device;
> + struct storvsc_cmd_request *request;
> + struct vstor_packet *vstor_packet;
> + int ret, i;
> + int max_chns;
> + bool process_sub_channels = false;
> +
> + stor_device = get_out_stor_device(device);
> + if (!stor_device)
> + return -ENODEV;
> +
> + request = &stor_device->init_request;
> + vstor_packet = &request->vstor_packet;
> +
> + /*
> +  * Now, initiate the vsc/vsp initialization protocol on the open
> +  * channel
> +  */
> + memset(request, 0, sizeof(struct storvsc_cmd_request));
> + vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
> + ret = storvsc_execute_vstor_op(device, request, true);
> + if (ret)
> + goto cleanup;
> +
> + /*
> +  * Query host supported protocol version.
> +  */
>  
>   for (i = 0; i < ARRAY_SIZE(vmstor_protocols); i++) {
>   /* reuse the packet for version range supported */
>   memset(vstor_packet, 0, sizeof(struct vstor_packet));
>   vstor_packet->operation =
>   VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
> - vstor_packet->flags = REQUEST_COMPLETION_FLAG;
>  
>   vstor_packet->version.major_minor =
>   vmstor_protocols[i].protocol_version;
> @@ -783,20 +805,9 @@ static int storvsc_channel_init(struct hv_device 
> *device, bool is_fc)
>*/
>   vstor_packet->version.revision = 0;
>  
> - ret = vmbus_sendpacket(device->channel, vstor_packet,
> -(sizeof(struct vstor_packet) -
> - vmscsi_size_delta),
> -(unsigned long)request,
> -VM_PKT_DATA_INBAND,
> -VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> - if (ret != 0)
> - goto cleanup;
> -
> - t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
> - if (t == 0) {
> - ret = -ETIMEDOUT;
> + ret = storvsc_execute_vstor_op(device, request, false);
> + if (ret)
>

Re: [PATCH 4/4] scsi: storvsc: Tighten up the interrupt path

2015-12-11 Thread Johannes Thumshirn
On Thu, Dec 10, 2015 at 04:14:20PM -0800, K. Y. Srinivasan wrote:
> On the interrupt path, we repeatedly establish the pointer to the
> storvsc_device. Fix this.
> 
> Signed-off-by: K. Y. Srinivasan 
> Reviewed-by: Long Li 
> Tested-by: Alex Ng 
> ---
>  drivers/scsi/storvsc_drv.c |   23 ---
>  1 files changed, 8 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 6f18e94..8ba9908 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -958,19 +958,16 @@ static void storvsc_handle_error(struct vmscsi_request 
> *vm_srb,
>  }
>  
>  
> -static void storvsc_command_completion(struct storvsc_cmd_request 
> *cmd_request)
> +static void storvsc_command_completion(struct storvsc_cmd_request 
> *cmd_request,
> +struct storvsc_device *stor_dev)
>  {
>   struct scsi_cmnd *scmnd = cmd_request->cmd;
> - struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
>   struct scsi_sense_hdr sense_hdr;
>   struct vmscsi_request *vm_srb;
>   struct Scsi_Host *host;
> - struct storvsc_device *stor_dev;
> - struct hv_device *dev = host_dev->dev;
>   u32 payload_sz = cmd_request->payload_sz;
>   void *payload = cmd_request->payload;
>  
> - stor_dev = get_in_stor_device(dev);
>   host = stor_dev->host;
>  
>   vm_srb = &cmd_request->vstor_packet.vm_srb;
> @@ -1000,14 +997,13 @@ static void storvsc_command_completion(struct 
> storvsc_cmd_request *cmd_request)
>   kfree(payload);
>  }
>  
> -static void storvsc_on_io_completion(struct hv_device *device,
> +static void storvsc_on_io_completion(struct storvsc_device *stor_device,
> struct vstor_packet *vstor_packet,
> struct storvsc_cmd_request *request)
>  {
> - struct storvsc_device *stor_device;
>   struct vstor_packet *stor_pkt;
> + struct hv_device *device = stor_device->device;
>  
> - stor_device = hv_get_drvdata(device);
>   stor_pkt = &request->vstor_packet;
>  
>   /*
> @@ -1062,7 +1058,7 @@ static void storvsc_on_io_completion(struct hv_device 
> *device,
>   stor_pkt->vm_srb.data_transfer_length =
>   vstor_packet->vm_srb.data_transfer_length;
>  
> - storvsc_command_completion(request);
> + storvsc_command_completion(request, stor_device);
>  
>   if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
>   stor_device->drain_notify)
> @@ -1071,21 +1067,19 @@ static void storvsc_on_io_completion(struct hv_device 
> *device,
>  
>  }
>  
> -static void storvsc_on_receive(struct hv_device *device,
> +static void storvsc_on_receive(struct storvsc_device *stor_device,
>struct vstor_packet *vstor_packet,
>struct storvsc_cmd_request *request)
>  {
>   struct storvsc_scan_work *work;
> - struct storvsc_device *stor_device;
>  
>   switch (vstor_packet->operation) {
>   case VSTOR_OPERATION_COMPLETE_IO:
> - storvsc_on_io_completion(device, vstor_packet, request);
> + storvsc_on_io_completion(stor_device, vstor_packet, request);
>   break;
>  
>   case VSTOR_OPERATION_REMOVE_DEVICE:
>   case VSTOR_OPERATION_ENUMERATE_BUS:
> - stor_device = get_in_stor_device(device);
>   work = kmalloc(sizeof(struct storvsc_scan_work), GFP_ATOMIC);
>   if (!work)
>   return;
> @@ -1096,7 +1090,6 @@ static void storvsc_on_receive(struct hv_device *device,
>   break;
>  
>   case VSTOR_OPERATION_FCHBA_DATA:
> - stor_device = get_in_stor_device(device);
>   cache_wwn(stor_device, vstor_packet);
>   fc_host_node_name(stor_device->host) = stor_device->node_name;
>   fc_host_port_name(stor_device->host) = stor_device->port_name;
> @@ -1144,7 +1137,7 @@ static void storvsc_on_channel_callback(void *context)
>   vmscsi_size_delta));
>   complete(&request->wait_event);
>   } else {
> - storvsc_on_receive(device,
> + storvsc_on_receive(stor_device,
>   (struct vstor_packet *)packet,
>   request);
>   }
> -- 
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284

[PATCH v3] staging: gdm72xx: add userspace data struct

2015-12-11 Thread Wim de With
This fixes the sparse warnings about dereferencing a userspace pointer.

Once I updated the sparse annotations, I noticed a bug in
gdm_wimax_ioctl() where we pass a user space pointer to gdm_update_fsm()
which dereferences it. I fixed this.

Signed-off-by: Wim de With 
---
 drivers/staging/gdm72xx/gdm_wimax.c | 12 
 drivers/staging/gdm72xx/wm_ioctl.h  |  7 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/gdm72xx/gdm_wimax.c 
b/drivers/staging/gdm72xx/gdm_wimax.c
index d9ddced..5da9ad9 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -368,7 +368,7 @@ static void kdelete(void **buf)
}
 }
 
-static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
+static int gdm_wimax_ioctl_get_data(struct udata_s *dst, struct data_s *src)
 {
int size;
 
@@ -384,7 +384,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, 
struct data_s *src)
return 0;
 }
 
-static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)
+static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct udata_s *src)
 {
if (!src->size) {
dst->size = 0;
@@ -460,6 +460,7 @@ static int gdm_wimax_ioctl(struct net_device *dev, struct 
ifreq *ifr, int cmd)
struct wm_req_s *req = (struct wm_req_s *)ifr;
struct nic *nic = netdev_priv(dev);
int ret;
+   struct fsm_s fsm_buf;
 
if (cmd != SIOCWMIOCTL)
return -EOPNOTSUPP;
@@ -482,8 +483,11 @@ static int gdm_wimax_ioctl(struct net_device *dev, struct 
ifreq *ifr, int cmd)
/* NOTE: gdm_update_fsm should be called
 * before gdm_wimax_ioctl_set_data is called.
 */
-   gdm_update_fsm(dev,
-  req->data.buf);
+   if (copy_from_user(&fsm_buf, req->data.buf,
+  sizeof(struct fsm_s)))
+   return -EFAULT;
+
+   gdm_update_fsm(dev, &fsm_buf);
}
ret = gdm_wimax_ioctl_set_data(
&nic->sdk_data[req->data_id], &req->data);
diff --git a/drivers/staging/gdm72xx/wm_ioctl.h 
b/drivers/staging/gdm72xx/wm_ioctl.h
index ed8f649..631cb1d 100644
--- a/drivers/staging/gdm72xx/wm_ioctl.h
+++ b/drivers/staging/gdm72xx/wm_ioctl.h
@@ -78,13 +78,18 @@ struct data_s {
void*buf;
 };
 
+struct udata_s {
+   int size;
+   void __user *buf;
+};
+
 struct wm_req_s {
union {
char ifrn_name[IFNAMSIZ];
} ifr_ifrn;
unsigned short  cmd;
unsigned short  data_id;
-   struct data_s   data;
+   struct udata_s  data;
 
 /* NOTE: sizeof(struct wm_req_s) must be less than sizeof(struct ifreq). */
 };
-- 
2.6.3

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


Re: [PATCH 0/2] staging: COMEDI: checkpatch.pl cleanups in comedi.h

2015-12-11 Thread Ian Abbott

On 10/12/15 14:57, Moritz König wrote:

This patchset fixes all the warnings and legitimate checks of
checkpatch.pl in comedi.h.

The following warnings were fixed:
  * WARNING: Block comments use * on subsequent lines
  * WARNING: Block comments use a trailing */ on a separate line
The following checks were fixed:
  * CHECK: spaces preferred around that '<<' (ctx:VxV)
  * CHECK: spaces preferred around that '>>' (ctx:VxV)
  * CHECK: spaces preferred around that '|' (ctx:VxV)

The following checks are not legitimate here and were not fixed:
  * CHECK: spaces preferred around that '&' (ctx:VxV)
This '&' is not a binary operator, but a referencing.
  * CHECK: Prefer using the BIT macro
The author defined a BIT macro here.
  * CHECK: Avoid CamelCase: 
This refers to the unit 'milli ampere'.

Moritz König (2):
   staging: COMEDI: Fixed the format of comments
   staging: COMEDI: Added missing spaces at binary operators

  drivers/staging/comedi/comedi.h | 232 +++-
  1 file changed, 131 insertions(+), 101 deletions(-)



Thanks.  There's an outstanding patch by Daniel H. Hemmingsen that also 
fixes these issues:


http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2015-November/081778.html

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/4] scsi: storvsc: Properly support Fibre Channel devices

2015-12-11 Thread Dan Carpenter
On Thu, Dec 10, 2015 at 04:14:18PM -0800, K. Y. Srinivasan wrote:
> + ret = vmbus_sendpacket(device->channel, vstor_packet,
> +(sizeof(struct vstor_packet) -
> +vmscsi_size_delta),
> +(unsigned long)request,
> +VM_PKT_DATA_INBAND,
> +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> +
> + if (ret != 0)
> + goto cleanup;
> +
> + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
> + if (t == 0) {
> + ret = -ETIMEDOUT;
> + goto cleanup;
> + }
> +
> + if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
> + vstor_packet->status != 0)
> + goto cleanup;

"cleanup" is a misleading name because it doesn't clean up anything.
Do nothing gotos are a pain in the butt and they always introduce bugs.
For example, you appear to have forgotten to set the error code.  But
because it's a do-nothing goto it's ambiguous so perhaps returning
success was intended.

Empirically this style of coding causes bugs.  It does not prevent them.
It is a bad style if you believe in measuring, evidence and science.

regards,
dan carpenter

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


Re: [PATCH] staging: gdm72xx: fix address space parse warnings

2015-12-11 Thread Okash Khawaja
Thanks, that's a cleaner approach. Apologies for delayed reply as I'm in middle 
of a house move. I'll send an updated patch soon.

Okash

> On 2 Dec 2015, at 13:17, Dan Carpenter  wrote:
> 
> Probably it's better to create a different struct:
> 
> struct udata_s {
>unsigned int size;
>void __user *buf;
> };
> 
> regards,
> dan carpenter
> 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/4] scsi: storvsc: Refactor the code in storvsc_channel_init()

2015-12-11 Thread Dan Carpenter
On Thu, Dec 10, 2015 at 04:14:19PM -0800, K. Y. Srinivasan wrote:
> @@ -753,27 +740,62 @@ static int storvsc_channel_init(struct hv_device 
> *device, bool is_fc)
>  VM_PKT_DATA_INBAND,
>  VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
>   if (ret != 0)
> - goto cleanup;
> + goto done;
>  
>   t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
>   if (t == 0) {
>   ret = -ETIMEDOUT;
> - goto cleanup;
> + goto done;
>   }
>  
> + if (!status_check)
> + goto done;

See?  This goto looks exactly the same as the earlier buggy goto but
it's actually correct.  Meanwhile if you just used an explicit
"return 0;" then it would be easy to understand.

I rant about this all the time but it's because it's bad deliberately.
It's normal to have bugs, but this deliberate stuff really I can't
understand it...

> +
>   if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
>   vstor_packet->status != 0) {
>   ret = -EINVAL;
> - goto cleanup;
> + goto done;
>   }
>  
> +done:
> + return ret;
> +}
> +
> +static int storvsc_channel_init(struct hv_device *device, bool is_fc)
> +{
> + struct storvsc_device *stor_device;
> + struct storvsc_cmd_request *request;
> + struct vstor_packet *vstor_packet;
> + int ret, i;
> + int max_chns;
> + bool process_sub_channels = false;
> +
> + stor_device = get_out_stor_device(device);
> + if (!stor_device)
> + return -ENODEV;
> +
> + request = &stor_device->init_request;
> + vstor_packet = &request->vstor_packet;
> +
> + /*
> +  * Now, initiate the vsc/vsp initialization protocol on the open
> +  * channel
> +  */
> + memset(request, 0, sizeof(struct storvsc_cmd_request));
> + vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
> + ret = storvsc_execute_vstor_op(device, request, true);
> + if (ret)
> + goto cleanup;

10 lines earlier there is an explicit "return -ENODEV" so it's not as if
writing explicit returns will kill you.

regards,
dan carpenter

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


Re: [PATCH] staging: gdm72xx: fix address space parse warnings

2015-12-11 Thread Dan Carpenter
On Fri, Dec 11, 2015 at 10:33:13AM +, Okash Khawaja wrote:
> Thanks, that's a cleaner approach. Apologies for delayed reply as I'm in 
> middle of a house move. I'll send an updated patch soon.
> 

Someone already fixed it.  Thanks.

regards,
dan carpenter

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


Re: [PATCH] staging: gdm72xx: fix address space parse warnings

2015-12-11 Thread Okash Khawaja

> On 11 Dec 2015, at 10:52, Dan Carpenter  wrote:
> 
>> On Fri, Dec 11, 2015 at 10:33:13AM +, Okash Khawaja wrote:
>> Thanks, that's a cleaner approach. Apologies for delayed reply as I'm in 
>> middle of a house move. I'll send an updated patch soon.
> 
> Someone already fixed it.  Thanks.
> 
> regards,
> dan carpenter
> 

It seems like it's still there: 
https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/staging/+/staging-next/drivers/staging/gdm72xx/gdm_wimax.c
 

Am I looking in the wrong place?

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


[PATCH] staging: gdm72xx: Code cleanups

2015-12-11 Thread Sanidhya Solanki
>From c07c57f3e045865b0acae498c631189f24aeda0b Mon Sep 17 00:00:00 2001
From: Sanidhya Solanki 
Date: Thu, 10 Dec 2015 21:13:10 -0500
Subject: [PATCH] staging: gdm72xx: Code cleanups

Code cleanups as per the TODO file.

Signed-off-by: Sanidhya Solanki 
---
 drivers/staging/gdm72xx/gdm_qos.c   | 54 +++
 drivers/staging/gdm72xx/gdm_sdio.c  |  4 +--
 drivers/staging/gdm72xx/gdm_usb.c   |  3 +-
 drivers/staging/gdm72xx/gdm_usb.h   |  4 +--
 drivers/staging/gdm72xx/gdm_wimax.c | 18 +--
 drivers/staging/gdm72xx/hci.h   | 11 +++
 drivers/staging/gdm72xx/netlink_k.c |  8 ++---
 drivers/staging/gdm72xx/sdio_boot.c |  2 +-
 drivers/staging/gdm72xx/usb_boot.c  | 10 +++---
 drivers/staging/gdm72xx/usb_ids.h   | 64 ++---
 10 files changed, 88 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/gdm72xx/gdm_qos.c 
b/drivers/staging/gdm72xx/gdm_qos.c
index 81feffa..c03204b 100644
--- a/drivers/staging/gdm72xx/gdm_qos.c
+++ b/drivers/staging/gdm72xx/gdm_qos.c
@@ -101,7 +101,7 @@ void gdm_qos_init(void *nic_ptr)
}
 
qcb->qos_list_cnt = 0;
-   qcb->qos_null_idx = QOS_MAX-1;
+   qcb->qos_null_idx = QOS_MAX - 1;
qcb->qos_limit_size = 255;
 
spin_lock_init(&qcb->qos_lock);
@@ -128,7 +128,7 @@ void gdm_qos_release_list(void *nic_ptr)
}
 
qcb->qos_list_cnt = 0;
-   qcb->qos_null_idx = QOS_MAX-1;
+   qcb->qos_null_idx = QOS_MAX - 1;
 
for (i = 0; i < QOS_MAX; i++) {
list_for_each_entry_safe(entry, n, &qcb->qos_list[i], list) {
@@ -143,18 +143,18 @@ static int chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 
*stream, u8 *port)
 {
int i;
 
-   if (csr->classifier_rule_en&IPTYPEOFSERVICE) {
+   if (csr->classifier_rule_en & IPTYPEOFSERVICE) {
if (((stream[1] & csr->ip2s_mask) < csr->ip2s_lo) ||
((stream[1] & csr->ip2s_mask) > csr->ip2s_hi))
return 1;
}
 
-   if (csr->classifier_rule_en&PROTOCOL) {
+   if (csr->classifier_rule_en & PROTOCOL) {
if (stream[9] != csr->protocol)
return 1;
}
 
-   if (csr->classifier_rule_en&IPMASKEDSRCADDRESS) {
+   if (csr->classifier_rule_en & IPMASKEDSRCADDRESS) {
for (i = 0; i < 4; i++) {
if ((stream[12 + i] & csr->ipsrc_addrmask[i]) !=
(csr->ipsrc_addr[i] & csr->ipsrc_addrmask[i]))
@@ -162,7 +162,7 @@ static int chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 
*stream, u8 *port)
}
}
 
-   if (csr->classifier_rule_en&IPMASKEDDSTADDRESS) {
+   if (csr->classifier_rule_en & IPMASKEDDSTADDRESS) {
for (i = 0; i < 4; i++) {
if ((stream[16 + i] & csr->ipdst_addrmask[i]) !=
(csr->ipdst_addr[i] & csr->ipdst_addrmask[i]))
@@ -170,14 +170,14 @@ static int chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 
*stream, u8 *port)
}
}
 
-   if (csr->classifier_rule_en&PROTOCOLSRCPORTRANGE) {
-   i = ((port[0]<<8)&0xff00)+port[1];
+   if (csr->classifier_rule_en & PROTOCOLSRCPORTRANGE) {
+   i = ((port[0] << 8) & 0xff00) + port[1];
if ((i < csr->srcport_lo) || (i > csr->srcport_hi))
return 1;
}
 
-   if (csr->classifier_rule_en&PROTOCOLDSTPORTRANGE) {
-   i = ((port[2]<<8)&0xff00)+port[3];
+   if (csr->classifier_rule_en & PROTOCOLDSTPORTRANGE) {
+   i = ((port[2] << 8) & 0xff00) + port[3];
if ((i < csr->dstport_lo) || (i > csr->dstport_hi))
return 1;
}
@@ -193,7 +193,7 @@ static int get_qos_index(struct nic *nic, u8 *iph, u8 
*tcpudph)
if (!iph || !tcpudph)
return -1;
 
-   ip_ver = (iph[0]>>4)&0xf;
+   ip_ver = (iph[0] >> 4) & 0xf;
 
if (ip_ver != 4)
return -1;
@@ -261,7 +261,7 @@ int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct 
net_device *dev)
struct list_head send_list;
int ret = 0;
 
-   tcph = (struct tcphdr *)iph + iph->ihl*4;
+   tcph = (struct tcphdr *)iph + iph->ihl * 4;
 
if (ethh->h_proto == cpu_to_be16(ETH_P_IP)) {
if (qcb->qos_list_cnt && !qos_free_list.cnt) {
@@ -342,17 +342,17 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int 
size)
if (sub_cmd_evt == QOS_REPORT) {
spin_lock_irqsave(&qcb->qos_lock, flags);
for (i = 0; i < qcb->qos_list_cnt; i++) {
-   sfid = ((buf[(i*5)+6]<<24)&0xff00);
-   sfid += ((buf[(i*5)+7]<<16)&0xff);
-   sfid += ((buf[(i*5)+8]<<8)&0xff00);
-   sfid += (buf[(i*5)+9]);
+   sfid = ((buf[(i * 5) + 6] << 24) & 0xff00);
+   sfid += ((buf[(i * 5) + 7] <<

[PATCH 02/13] staging/android/sync: add sync_fence_create_dma

2015-12-11 Thread John . C . Harrison
From: Maarten Lankhorst 

This allows users of dma fences to create a android fence.

v2: Added kerneldoc. (Tvrtko Ursulin).

v4: Updated comments from review feedback my Maarten.

Signed-off-by: Maarten Lankhorst 
Signed-off-by: Tvrtko Ursulin 
Cc: Maarten Lankhorst 
Cc: Daniel Vetter 
Cc: Jesse Barnes 
Cc: de...@driverdev.osuosl.org
Cc: Riley Andrews 
Cc: Greg Kroah-Hartman 
Cc: Arve Hjønnevåg 
---
 drivers/staging/android/sync.c | 13 +
 drivers/staging/android/sync.h | 10 ++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index f83e00c..7f0e919 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -188,7 +188,7 @@ static void fence_check_cb_func(struct fence *f, struct 
fence_cb *cb)
 }
 
 /* TODO: implement a create which takes more that one sync_pt */
-struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
 {
struct sync_fence *fence;
 
@@ -199,16 +199,21 @@ struct sync_fence *sync_fence_create(const char *name, 
struct sync_pt *pt)
fence->num_fences = 1;
atomic_set(&fence->status, 1);
 
-   fence->cbs[0].sync_pt = &pt->base;
+   fence->cbs[0].sync_pt = pt;
fence->cbs[0].fence = fence;
-   if (fence_add_callback(&pt->base, &fence->cbs[0].cb,
-  fence_check_cb_func))
+   if (fence_add_callback(pt, &fence->cbs[0].cb, fence_check_cb_func))
atomic_dec(&fence->status);
 
sync_fence_debug_add(fence);
 
return fence;
 }
+EXPORT_SYMBOL(sync_fence_create_dma);
+
+struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+{
+   return sync_fence_create_dma(name, &pt->base);
+}
 EXPORT_SYMBOL(sync_fence_create);
 
 struct sync_fence *sync_fence_fdget(int fd)
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 61f8a3a..afa0752 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -254,6 +254,16 @@ void sync_pt_free(struct sync_pt *pt);
  */
 struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt);
 
+/**
+ * sync_fence_create_dma() - creates a sync fence from dma-fence
+ * @name:  name of fence to create
+ * @pt:dma-fence to add to the fence
+ *
+ * Creates a fence containg @pt.  Once this is called, the fence takes
+ * ownership of @pt.
+ */
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt);
+
 /*
  * API for sync_fence consumers
  */
-- 
1.9.1

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


[PATCH 01/13] staging/android/sync: Support sync points created from dma-fences

2015-12-11 Thread John . C . Harrison
From: Maarten Lankhorst 

Debug output assumes all sync points are built on top of Android sync points
and when we start creating them from dma-fences will NULL ptr deref unless
taught about this.

v4: Corrected patch ownership.

Signed-off-by: Maarten Lankhorst 
Signed-off-by: Tvrtko Ursulin 
Cc: Maarten Lankhorst 
Cc: de...@driverdev.osuosl.org
Cc: Riley Andrews 
Cc: Greg Kroah-Hartman 
Cc: Arve Hjønnevåg 
---
 drivers/staging/android/sync_debug.c | 42 +++-
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/android/sync_debug.c 
b/drivers/staging/android/sync_debug.c
index 91ed2c4..f45d13c 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -82,36 +82,42 @@ static const char *sync_status_str(int status)
return "error";
 }
 
-static void sync_print_pt(struct seq_file *s, struct sync_pt *pt, bool fence)
+static void sync_print_pt(struct seq_file *s, struct fence *pt, bool fence)
 {
int status = 1;
-   struct sync_timeline *parent = sync_pt_parent(pt);
 
-   if (fence_is_signaled_locked(&pt->base))
-   status = pt->base.status;
+   if (fence_is_signaled_locked(pt))
+   status = pt->status;
 
seq_printf(s, "  %s%spt %s",
-  fence ? parent->name : "",
+  fence && pt->ops->get_timeline_name ?
+  pt->ops->get_timeline_name(pt) : "",
   fence ? "_" : "",
   sync_status_str(status));
 
if (status <= 0) {
struct timespec64 ts64 =
-   ktime_to_timespec64(pt->base.timestamp);
+   ktime_to_timespec64(pt->timestamp);
 
seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec);
}
 
-   if (parent->ops->timeline_value_str &&
-   parent->ops->pt_value_str) {
+   if ((!fence || pt->ops->timeline_value_str) &&
+   pt->ops->fence_value_str) {
char value[64];
+   bool success;
 
-   parent->ops->pt_value_str(pt, value, sizeof(value));
-   seq_printf(s, ": %s", value);
-   if (fence) {
-   parent->ops->timeline_value_str(parent, value,
-   sizeof(value));
-   seq_printf(s, " / %s", value);
+   pt->ops->fence_value_str(pt, value, sizeof(value));
+   success = strlen(value);
+
+   if (success)
+   seq_printf(s, ": %s", value);
+
+   if (success && fence) {
+   pt->ops->timeline_value_str(pt, value, sizeof(value));
+
+   if (strlen(value))
+   seq_printf(s, " / %s", value);
}
}
 
@@ -138,7 +144,7 @@ static void sync_print_obj(struct seq_file *s, struct 
sync_timeline *obj)
list_for_each(pos, &obj->child_list_head) {
struct sync_pt *pt =
container_of(pos, struct sync_pt, child_list);
-   sync_print_pt(s, pt, false);
+   sync_print_pt(s, &pt->base, false);
}
spin_unlock_irqrestore(&obj->child_list_lock, flags);
 }
@@ -153,11 +159,7 @@ static void sync_print_fence(struct seq_file *s, struct 
sync_fence *fence)
   sync_status_str(atomic_read(&fence->status)));
 
for (i = 0; i < fence->num_fences; ++i) {
-   struct sync_pt *pt =
-   container_of(fence->cbs[i].sync_pt,
-struct sync_pt, base);
-
-   sync_print_pt(s, pt, true);
+   sync_print_pt(s, fence->cbs[i].sync_pt, true);
}
 
spin_lock_irqsave(&fence->wq.lock, flags);
-- 
1.9.1

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


[PATCH] staging: dgnc: Patch includes the checkpatch fixes

2015-12-11 Thread Sanidhya Solanki
>From 1dbe78ce98037da5467d817a9db838d678b338ae Mon Sep 17 00:00:00 2001
From: Sanidhya Solanki 
Date: Fri, 11 Dec 2015 03:08:53 -0500
Subject: [PATCH] staging: dgnc: Patch includes the checkpatch fixes

Patch contains the checkpatch fixes as asked by the TODO.
TODO file is updated as well.

Signed-off-by: Sanidhya Solanki 
---
 drivers/staging/dgnc/TODO  |   1 -
 drivers/staging/dgnc/dgnc_cls.c|   4 +-
 drivers/staging/dgnc/dgnc_driver.c |  56 -
 drivers/staging/dgnc/dgnc_driver.h |  33 +++---
 drivers/staging/dgnc/dgnc_mgmt.c   |  28 ++---
 drivers/staging/dgnc/dgnc_neo.c| 229 ++---
 drivers/staging/dgnc/dgnc_neo.h|  22 ++--
 drivers/staging/dgnc/dgnc_pci.h|   1 -
 drivers/staging/dgnc/dgnc_sysfs.c  | 163 +-
 drivers/staging/dgnc/dgnc_tty.c| 197 +++
 drivers/staging/dgnc/digi.h|  44 +++
 11 files changed, 464 insertions(+), 314 deletions(-)

diff --git a/drivers/staging/dgnc/TODO b/drivers/staging/dgnc/TODO
index 0e0825b..0bdfd26 100644
--- a/drivers/staging/dgnc/TODO
+++ b/drivers/staging/dgnc/TODO
@@ -1,4 +1,3 @@
-* checkpatch fixes
 * remove unnecessary comments
 * remove unnecessary error messages. Example kzalloc() has its
   own error message. Adding an extra one is useless.
diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 75040da..d312d35 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -1168,8 +1168,8 @@ static void cls_uart_init(struct channel_t *ch)
/* Clear out UART and FIFO */
readb(&ch->ch_cls_uart->txrx);
 
-   writeb((UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|UART_FCR_CLEAR_XMIT),
-  &ch->ch_cls_uart->isr_fcr);
+   writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
+  UART_FCR_CLEAR_XMIT), &ch->ch_cls_uart->isr_fcr);
udelay(10);
 
ch->ch_flags |= (CH_FIFO_ENABLED | CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index fc6d298..37fb8f9 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -48,7 +48,7 @@ static void   dgnc_do_remap(struct dgnc_board *brd);
 /*
  * File operations permitted on Control/Management major.
  */
-static const struct file_operations dgnc_BoardFops = {
+static const struct file_operations dgnc_board_fops = {
.owner  =   THIS_MODULE,
.unlocked_ioctl =   dgnc_mgmt_ioctl,
.open   =   dgnc_mgmt_open,
@@ -58,11 +58,11 @@ static const struct file_operations dgnc_BoardFops = {
 /*
  * Globals
  */
-uint   dgnc_NumBoards;
-struct dgnc_board  *dgnc_Board[MAXBOARDS];
+uint   dgnc_num_boards;
+struct dgnc_board  *dgnc_board[MAXBOARDS];
 DEFINE_SPINLOCK(dgnc_global_lock);
 DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
-uint   dgnc_Major;
+uint   dgnc_major;
 intdgnc_poll_tick = 20;/* Poll interval - 20 ms */
 
 /*
@@ -92,7 +92,7 @@ struct board_id {
unsigned int is_pci_express;
 };
 
-static struct board_id dgnc_Ids[] = {
+static struct board_id dgnc_ids[] = {
{   PCI_DEVICE_CLASSIC_4_PCI_NAME,  4,  0   },
{   PCI_DEVICE_CLASSIC_4_422_PCI_NAME,  4,  0   },
{   PCI_DEVICE_CLASSIC_8_PCI_NAME,  8,  0   },
@@ -144,19 +144,19 @@ static void dgnc_cleanup_module(void)
 
dgnc_remove_driver_sysfiles(&dgnc_driver);
 
-   device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
class_destroy(dgnc_class);
-   unregister_chrdev(dgnc_Major, "dgnc");
+   unregister_chrdev(dgnc_major, "dgnc");
 
-   for (i = 0; i < dgnc_NumBoards; ++i) {
-   dgnc_remove_ports_sysfiles(dgnc_Board[i]);
-   dgnc_tty_uninit(dgnc_Board[i]);
-   dgnc_cleanup_board(dgnc_Board[i]);
+   for (i = 0; i < dgnc_num_boards; ++i) {
+   dgnc_remove_ports_sysfiles(dgnc_board[i]);
+   dgnc_tty_uninit(dgnc_board[i]);
+   dgnc_cleanup_board(dgnc_board[i]);
}
 
dgnc_tty_post_uninit();
 
-   if (dgnc_NumBoards)
+   if (dgnc_num_boards)
pci_unregister_driver(&dgnc_driver);
 }
 
@@ -187,7 +187,7 @@ static int __init dgnc_init_module(void)
 */
if (rc < 0) {
/* Only unregister if it was actually registered. */
-   if (dgnc_NumBoards)
+   if (dgnc_num_boards)
pci_unregister_driver(&dgnc_driver);
else
pr_warn("WARNING: dgnc driver load failed.  No Digi Neo 
or Classic boards found.\n");
@@ -222,12 +222,12 @@ static int dgnc_start(void)
 *
 * Register management/d

Re: [PATCH net-next] hv_netvsc: Fix race condition on Multi-Send Data field

2015-12-11 Thread Vitaly Kuznetsov
Haiyang Zhang  writes:

> In commit 2a04ae8acb14 ("hv_netvsc: remove locking in netvsc_send()"), the
> locking for MSD (Multi-Send Data) field was removed. This could cause a
> race condition between RNDIS control messages and data packets processing,
> because these two types of traffic are not synchronized.
> This patch fixes this issue by sending control messages out directly
> without reading MSD field.
>
> Signed-off-by: Haiyang Zhang 
> Reviewed-by: K. Y. Srinivasan 
> ---
>  drivers/net/hyperv/netvsc.c |9 +
>  1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index 02bab9a..059fc52 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c
> @@ -867,6 +867,14 @@ int netvsc_send(struct hv_device *device,
>   packet->send_buf_index = NETVSC_INVALID_INDEX;
>   packet->cp_partial = false;
>  
> + /* Send control message directly without accessing msd (Multi-Send
> +  * Data) field which may be changed during data packet processing.
> +  */
> + if (!skb) {
> + cur_send = packet;
> + goto send_now;
> + }
> +

Is is supposed to be applied on top of some other patches? It doesn't
compile on top of current net-next:

drivers/net/hyperv/netvsc.c: In function ‘netvsc_send’:
drivers/net/hyperv/netvsc.c:865:7: error: ‘skb’ undeclared (first use in
this function)
  if (!skb) {
 ^
 
Did you mean to check rndis_msg instead (as skb is not defined here)?

>   msdp = &net_device->msd[q_idx];
>  
>   /* batch packets in send buffer if possible */
> @@ -939,6 +947,7 @@ int netvsc_send(struct hv_device *device,
>   }
>   }
>  
> +send_now:
>   if (cur_send)
>   ret = netvsc_send_pkt(cur_send, net_device, pb, skb);

I suppose we untangle these two pathes completely: let
rndis_filter_send_request() call netvsc_send_pkt() directly. Please see
my patch attached (note: it should be split in 3 patches if
submitted). If you like the idea I can send it.

-- 
  Vitaly

commit b2784f827d2b7b19d3af6025bbe8be5b1450b88c
Author: Vitaly Kuznetsov 
Date:   Fri Dec 11 13:29:40 2015 +0100

netvsc: untangle rndis_filter_send_request and netvsc_send

Signed-off-by: Vitaly Kuznetsov 

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index f5b2145..03da20c 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -189,6 +189,8 @@ int netvsc_device_remove(struct hv_device *device);
 int netvsc_send(struct hv_device *device,
 		struct hv_netvsc_packet *packet,
 		struct rndis_message *rndis_msg);
+int netvsc_send_pkt(struct hv_netvsc_packet *packet,
+		struct netvsc_device *net_device);
 void netvsc_linkstatus_callback(struct hv_device *device_obj,
 struct rndis_message *resp);
 void netvsc_xmit_completion(void *context);
@@ -211,6 +213,8 @@ int rndis_filter_receive(struct hv_device *dev,
 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
 int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
 
+struct netvsc_device *netvsc_outbound_net_device(struct hv_device *device);
+
 #define NVSP_INVALID_PROTOCOL_VERSION	((u32)0x)
 
 #define NVSP_PROTOCOL_VERSION_1		2
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 081f14f..eadbb03 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -67,7 +67,7 @@ static void free_netvsc_device(struct netvsc_device *nvdev)
 	kfree(nvdev);
 }
 
-static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
+struct netvsc_device *netvsc_outbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
 
@@ -226,7 +226,7 @@ static int netvsc_init_buf(struct hv_device *device)
 	struct net_device *ndev;
 	int node;
 
-	net_device = get_outbound_net_device(device);
+	net_device = netvsc_outbound_net_device(device);
 	if (!net_device)
 		return -ENODEV;
 	ndev = net_device->ndev;
@@ -478,7 +478,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
 		NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 };
 	int i, num_ver = 4; /* number of different NVSP versions */
 
-	net_device = get_outbound_net_device(device);
+	net_device = netvsc_outbound_net_device(device);
 	if (!net_device)
 		return -ENODEV;
 	ndev = net_device->ndev;
@@ -740,7 +740,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
 	return msg_size;
 }
 
-static inline int netvsc_send_pkt(
+int netvsc_send_pkt(
 	struct hv_netvsc_packet *packet,
 	struct netvsc_device *net_device)
 {
@@ -850,7 +850,7 @@ int netvsc_send(struct hv_device *device,
 	struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL;
 	bool try_batch;
 
-	net_device = get_outbound_net_device(device);
+	net_device = netvsc_outbound_net_device(device);
 	if (!net_device)
 		return -ENODEV;
 
@@ -1063,7 +1063,7 @@ static void netvsc_send_table(

Re: [PATCH] staging: dgnc: Patch includes the checkpatch fixes

2015-12-11 Thread Dan Carpenter
On Fri, Dec 11, 2015 at 03:21:49AM -0500, Sanidhya Solanki wrote:
> >From 1dbe78ce98037da5467d817a9db838d678b338ae Mon Sep 17 00:00:00 2001
> From: Sanidhya Solanki 
> Date: Fri, 11 Dec 2015 03:08:53 -0500
> Subject: [PATCH] staging: dgnc: Patch includes the checkpatch fixes


Don't include this stuff.

> 
> Patch contains the checkpatch fixes as asked by the TODO.
> TODO file is updated as well.

Fix one type of warning at a time.  This will be a series of patches.

> 
> Signed-off-by: Sanidhya Solanki 
> @@ -110,7 +98,16 @@ static ssize_t dgnc_vpd_show(struct device *p, struct 
> device_attribute *attr,
>   int count = 0;
>   int i = 0;
>  
> - DGNC_VERIFY_BOARD(p, bd);
> + do {
> + if (!p)
> + return 0;
> +
> + bd = dev_get_drvdata(p);
> + if (!bd || bd->magic != DGNC_BOARD_MAGIC)
> + return 0;
> + if (bd->state != BOARD_READY)
> + return 0;
> + } while (0);

Google about why do while(0) loops are used in macros and then redo
this.  Mostly the patch isn't bad, but I suspect I'm going to complain
about how you split up some of the long lines.

regards,
dan carpenter

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


[PATCH 01/13] staging/android/sync: Support sync points created from dma-fences

2015-12-11 Thread John . C . Harrison
From: Maarten Lankhorst 

Debug output assumes all sync points are built on top of Android sync points
and when we start creating them from dma-fences will NULL ptr deref unless
taught about this.

v4: Corrected patch ownership.

Signed-off-by: Maarten Lankhorst 
Signed-off-by: Tvrtko Ursulin 
Cc: Maarten Lankhorst 
Cc: de...@driverdev.osuosl.org
Cc: Riley Andrews 
Cc: Greg Kroah-Hartman 
Cc: Arve Hjønnevåg 
---
 drivers/staging/android/sync_debug.c | 42 +++-
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/android/sync_debug.c 
b/drivers/staging/android/sync_debug.c
index 91ed2c4..f45d13c 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -82,36 +82,42 @@ static const char *sync_status_str(int status)
return "error";
 }
 
-static void sync_print_pt(struct seq_file *s, struct sync_pt *pt, bool fence)
+static void sync_print_pt(struct seq_file *s, struct fence *pt, bool fence)
 {
int status = 1;
-   struct sync_timeline *parent = sync_pt_parent(pt);
 
-   if (fence_is_signaled_locked(&pt->base))
-   status = pt->base.status;
+   if (fence_is_signaled_locked(pt))
+   status = pt->status;
 
seq_printf(s, "  %s%spt %s",
-  fence ? parent->name : "",
+  fence && pt->ops->get_timeline_name ?
+  pt->ops->get_timeline_name(pt) : "",
   fence ? "_" : "",
   sync_status_str(status));
 
if (status <= 0) {
struct timespec64 ts64 =
-   ktime_to_timespec64(pt->base.timestamp);
+   ktime_to_timespec64(pt->timestamp);
 
seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec);
}
 
-   if (parent->ops->timeline_value_str &&
-   parent->ops->pt_value_str) {
+   if ((!fence || pt->ops->timeline_value_str) &&
+   pt->ops->fence_value_str) {
char value[64];
+   bool success;
 
-   parent->ops->pt_value_str(pt, value, sizeof(value));
-   seq_printf(s, ": %s", value);
-   if (fence) {
-   parent->ops->timeline_value_str(parent, value,
-   sizeof(value));
-   seq_printf(s, " / %s", value);
+   pt->ops->fence_value_str(pt, value, sizeof(value));
+   success = strlen(value);
+
+   if (success)
+   seq_printf(s, ": %s", value);
+
+   if (success && fence) {
+   pt->ops->timeline_value_str(pt, value, sizeof(value));
+
+   if (strlen(value))
+   seq_printf(s, " / %s", value);
}
}
 
@@ -138,7 +144,7 @@ static void sync_print_obj(struct seq_file *s, struct 
sync_timeline *obj)
list_for_each(pos, &obj->child_list_head) {
struct sync_pt *pt =
container_of(pos, struct sync_pt, child_list);
-   sync_print_pt(s, pt, false);
+   sync_print_pt(s, &pt->base, false);
}
spin_unlock_irqrestore(&obj->child_list_lock, flags);
 }
@@ -153,11 +159,7 @@ static void sync_print_fence(struct seq_file *s, struct 
sync_fence *fence)
   sync_status_str(atomic_read(&fence->status)));
 
for (i = 0; i < fence->num_fences; ++i) {
-   struct sync_pt *pt =
-   container_of(fence->cbs[i].sync_pt,
-struct sync_pt, base);
-
-   sync_print_pt(s, pt, true);
+   sync_print_pt(s, fence->cbs[i].sync_pt, true);
}
 
spin_lock_irqsave(&fence->wq.lock, flags);
-- 
1.9.1

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


[PATCH 02/13] staging/android/sync: add sync_fence_create_dma

2015-12-11 Thread John . C . Harrison
From: Maarten Lankhorst 

This allows users of dma fences to create a android fence.

v2: Added kerneldoc. (Tvrtko Ursulin).

v4: Updated comments from review feedback my Maarten.

Signed-off-by: Maarten Lankhorst 
Signed-off-by: Tvrtko Ursulin 
Cc: Maarten Lankhorst 
Cc: Daniel Vetter 
Cc: Jesse Barnes 
Cc: de...@driverdev.osuosl.org
Cc: Riley Andrews 
Cc: Greg Kroah-Hartman 
Cc: Arve Hjønnevåg 
---
 drivers/staging/android/sync.c | 13 +
 drivers/staging/android/sync.h | 10 ++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index f83e00c..7f0e919 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -188,7 +188,7 @@ static void fence_check_cb_func(struct fence *f, struct 
fence_cb *cb)
 }
 
 /* TODO: implement a create which takes more that one sync_pt */
-struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
 {
struct sync_fence *fence;
 
@@ -199,16 +199,21 @@ struct sync_fence *sync_fence_create(const char *name, 
struct sync_pt *pt)
fence->num_fences = 1;
atomic_set(&fence->status, 1);
 
-   fence->cbs[0].sync_pt = &pt->base;
+   fence->cbs[0].sync_pt = pt;
fence->cbs[0].fence = fence;
-   if (fence_add_callback(&pt->base, &fence->cbs[0].cb,
-  fence_check_cb_func))
+   if (fence_add_callback(pt, &fence->cbs[0].cb, fence_check_cb_func))
atomic_dec(&fence->status);
 
sync_fence_debug_add(fence);
 
return fence;
 }
+EXPORT_SYMBOL(sync_fence_create_dma);
+
+struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+{
+   return sync_fence_create_dma(name, &pt->base);
+}
 EXPORT_SYMBOL(sync_fence_create);
 
 struct sync_fence *sync_fence_fdget(int fd)
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 61f8a3a..afa0752 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -254,6 +254,16 @@ void sync_pt_free(struct sync_pt *pt);
  */
 struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt);
 
+/**
+ * sync_fence_create_dma() - creates a sync fence from dma-fence
+ * @name:  name of fence to create
+ * @pt:dma-fence to add to the fence
+ *
+ * Creates a fence containg @pt.  Once this is called, the fence takes
+ * ownership of @pt.
+ */
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt);
+
 /*
  * API for sync_fence consumers
  */
-- 
1.9.1

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


[PATCH 03/10] media framework: rename pads init function to media_entity_pads_init()

2015-12-11 Thread Mauro Carvalho Chehab
With the MC next gen rework, what's left for media_entity_init()
is to just initialize the PADs. However, certain devices, like
a FLASH led/light doesn't have any input or output PAD.

So, there's no reason why calling media_entity_init() would be
mandatory. Also, despite its name, what this function actually
does is to initialize the PADs data. So, rename it to
media_entity_pads_init() in order to reflect that.

The media entity actual init happens during entity register,
at media_device_register_entity(). We should move init of
num_links and num_backlinks to it.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media-framework.txt  | 18 +++---
 Documentation/video4linux/v4l2-framework.txt   |  8 
 Documentation/zh_CN/video4linux/v4l2-framework.txt |  8 
 drivers/media/dvb-core/dvbdev.c|  4 ++--
 drivers/media/dvb-frontends/au8522_decoder.c   |  2 +-
 drivers/media/i2c/ad9389b.c|  2 +-
 drivers/media/i2c/adp1653.c|  2 +-
 drivers/media/i2c/adv7180.c|  2 +-
 drivers/media/i2c/adv7511.c|  2 +-
 drivers/media/i2c/adv7604.c|  2 +-
 drivers/media/i2c/adv7842.c|  2 +-
 drivers/media/i2c/as3645a.c|  2 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |  2 +-
 drivers/media/i2c/lm3560.c |  2 +-
 drivers/media/i2c/lm3646.c |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |  2 +-
 drivers/media/i2c/mt9m032.c|  2 +-
 drivers/media/i2c/mt9p031.c|  2 +-
 drivers/media/i2c/mt9t001.c|  2 +-
 drivers/media/i2c/mt9v032.c|  2 +-
 drivers/media/i2c/noon010pc30.c|  2 +-
 drivers/media/i2c/ov2659.c |  2 +-
 drivers/media/i2c/ov9650.c |  2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  4 ++--
 drivers/media/i2c/s5k4ecgx.c   |  2 +-
 drivers/media/i2c/s5k5baf.c|  4 ++--
 drivers/media/i2c/s5k6a3.c |  2 +-
 drivers/media/i2c/s5k6aa.c |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  6 +++---
 drivers/media/i2c/tc358743.c   |  2 +-
 drivers/media/i2c/tvp514x.c|  2 +-
 drivers/media/i2c/tvp7002.c|  2 +-
 drivers/media/media-device.c   |  2 ++
 drivers/media/media-entity.c   | 11 ---
 drivers/media/platform/exynos4-is/fimc-capture.c   |  4 ++--
 drivers/media/platform/exynos4-is/fimc-isp-video.c |  2 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  2 +-
 drivers/media/platform/exynos4-is/fimc-lite.c  |  4 ++--
 drivers/media/platform/exynos4-is/fimc-m2m.c   |  2 +-
 drivers/media/platform/exynos4-is/mipi-csis.c  |  2 +-
 drivers/media/platform/omap3isp/ispccdc.c  |  2 +-
 drivers/media/platform/omap3isp/ispccp2.c  |  2 +-
 drivers/media/platform/omap3isp/ispcsi2.c  |  2 +-
 drivers/media/platform/omap3isp/isppreview.c   |  2 +-
 drivers/media/platform/omap3isp/ispresizer.c   |  2 +-
 drivers/media/platform/omap3isp/ispstat.c  |  2 +-
 drivers/media/platform/omap3isp/ispvideo.c |  2 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  4 ++--
 drivers/media/platform/vsp1/vsp1_entity.c  |  2 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  2 +-
 drivers/media/platform/xilinx/xilinx-dma.c |  2 +-
 drivers/media/platform/xilinx/xilinx-tpg.c |  2 +-
 drivers/media/usb/au0828/au0828-video.c|  6 +++---
 drivers/media/usb/cx231xx/cx231xx-video.c  |  4 ++--
 drivers/media/usb/uvc/uvc_entity.c |  4 ++--
 drivers/media/v4l2-core/tuner-core.c   |  2 +-
 drivers/media/v4l2-core/v4l2-flash-led-class.c |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  2 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  6 +++---
 drivers/staging/media/davinci_vpfe/vpfe_video.c|  2 +-
 drivers/staging/media/omap4iss/iss_csi2.c  |  2 +-
 drivers/staging/media/omap4iss/iss_ipipe.c |  2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  2 +-
 drivers/staging/media/omap4iss/iss_resizer.c   |  2 +-
 drivers/staging/media/omap4iss/iss_video.c |  2 +-
 include/media/media-entity.h   |  2 +-
 68 files changed, 102 insertions(+), 99 deletions(-)

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index b424de6c3bb3..7fbfe4bd1f47 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/m

[PATCH] staging/rdma/hfi1: Change num_rcv_contexts to num_user_contexts and its meaning

2015-12-11 Thread Mike Marciniszyn
From: Sebastian Sanchez 

num_rcv_contexts sets the number of user contexts, both receive and send.
Renaming it to num_user_contexts makes sense to reflect its true meaning.
When num_rcv_contexts is 0, the default behavior is the number of CPU
cores instead of 0 contexts. This commit changes the variable
num_rcv_contexts to num_user_contexts, and it also makes any negative
value for this variable default to the number of CPU cores, so if
num_user_contexts is set >= 0, the value will number of contexts.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Sebastian Sanchez 
---
 drivers/staging/rdma/hfi1/chip.c |9 +++--
 drivers/staging/rdma/hfi1/hfi.h  |2 +-
 drivers/staging/rdma/hfi1/init.c |6 +++---
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index dc69159..510e5f6 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -9197,7 +9197,6 @@ fail:
 static int set_up_context_variables(struct hfi1_devdata *dd)
 {
int num_kernel_contexts;
-   int num_user_contexts;
int total_contexts;
int ret;
unsigned ngroups;
@@ -9234,12 +9233,10 @@ static int set_up_context_variables(struct hfi1_devdata 
*dd)
}
/*
 * User contexts: (to be fixed later)
-*  - set to num_rcv_contexts if non-zero
-*  - default to 1 user context per CPU
+*  - default to 1 user context per CPU if num_user_contexts is
+*negative
 */
-   if (num_rcv_contexts)
-   num_user_contexts = num_rcv_contexts;
-   else
+   if (num_user_contexts < 0)
num_user_contexts = num_online_cpus();
 
total_contexts = num_kernel_contexts + num_user_contexts;
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 54ed6b3..434a89b 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1629,7 +1629,7 @@ void update_sge(struct hfi1_sge_state *ss, u32 length);
 extern unsigned int hfi1_max_mtu;
 extern unsigned int hfi1_cu;
 extern unsigned int user_credit_return_threshold;
-extern uint num_rcv_contexts;
+extern int num_user_contexts;
 extern unsigned n_krcvqs;
 extern u8 krcvqs[];
 extern int krcvqsset;
diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 1c8286f..a091b6c 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -82,10 +82,10 @@
  * Number of user receive contexts we are configured to use (to allow for more
  * pio buffers per ctxt, etc.)  Zero means use one user context per CPU.
  */
-uint num_rcv_contexts;
-module_param_named(num_rcv_contexts, num_rcv_contexts, uint, S_IRUGO);
+int num_user_contexts = -1;
+module_param_named(num_user_contexts, num_user_contexts, uint, S_IRUGO);
 MODULE_PARM_DESC(
-   num_rcv_contexts, "Set max number of user receive contexts to use");
+   num_user_contexts, "Set max number of user contexts to use");
 
 u8 krcvqs[RXE_NUM_DATA_VL];
 int krcvqsset;

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


Re: [PATCH net-next] hv_netvsc: Fix race condition on Multi-Send Data field

2015-12-11 Thread Vitaly Kuznetsov
Vitaly Kuznetsov  writes:

> Haiyang Zhang  writes:
>
>> In commit 2a04ae8acb14 ("hv_netvsc: remove locking in netvsc_send()"), the
>> locking for MSD (Multi-Send Data) field was removed. This could cause a
>> race condition between RNDIS control messages and data packets processing,
>> because these two types of traffic are not synchronized.
>> This patch fixes this issue by sending control messages out directly
>> without reading MSD field.
>>
>> Signed-off-by: Haiyang Zhang 
>> Reviewed-by: K. Y. Srinivasan 
>> ---
>>  drivers/net/hyperv/netvsc.c |9 +
>>  1 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
>> index 02bab9a..059fc52 100644
>> --- a/drivers/net/hyperv/netvsc.c
>> +++ b/drivers/net/hyperv/netvsc.c
>> @@ -867,6 +867,14 @@ int netvsc_send(struct hv_device *device,
>>  packet->send_buf_index = NETVSC_INVALID_INDEX;
>>  packet->cp_partial = false;
>>  
>> +/* Send control message directly without accessing msd (Multi-Send
>> + * Data) field which may be changed during data packet processing.
>> + */
>> +if (!skb) {
>> +cur_send = packet;
>> +goto send_now;
>> +}
>> +
>
> Is is supposed to be applied on top of some other patches? It doesn't
> compile on top of current net-next:
>
> drivers/net/hyperv/netvsc.c: In function ‘netvsc_send’:
> drivers/net/hyperv/netvsc.c:865:7: error: ‘skb’ undeclared (first use in
> this function)
>   if (!skb) {
>  ^
>
> Did you mean to check rndis_msg instead (as skb is not defined here)?

Oh, my bad, it was me who was looking at the wrong branch... Sorry for
the noise.

>
>>  msdp = &net_device->msd[q_idx];
>>  
>>  /* batch packets in send buffer if possible */
>> @@ -939,6 +947,7 @@ int netvsc_send(struct hv_device *device,
>>  }
>>  }
>>  
>> +send_now:
>>  if (cur_send)
>>  ret = netvsc_send_pkt(cur_send, net_device, pb, skb);
>
> I suppose we untangle these two pathes completely: let
> rndis_filter_send_request() call netvsc_send_pkt() directly. Please see
> my patch attached (note: it should be split in 3 patches if
> submitted). If you like the idea I can send it.

This patch will need some changes but the suggestion still stands: let's
untangle sending data and control messages.

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


Re: [PATCH v4 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Boris Brezillon
Hi Brian,

On Thu, 10 Dec 2015 16:40:08 -0800
Brian Norris  wrote:

> On Thu, Dec 10, 2015 at 08:59:45AM +0100, Boris Brezillon wrote:
> > Unregister the NAND device from the NAND subsystem when removing a denali
> > NAND controller, otherwise the MTD attached to the NAND device is still
> > exposed by the MTD layer, and accesses to this device will likely crash
> > the system.
> > 
> > Signed-off-by: Boris Brezillon 
> > Cc:  #3.8+
> 
> Does this follow these rules, from
> Documentation/stable_kernel_rules.txt?
> 
>  - It must be obviously correct and tested.
> 
>  - It must fix a real bug that bothers people (not a, "This could be a
>problem..." type thing).

As you wish, I'll remove those Cc and Fixes tags, or just drop the
patch if you think it's useless...
I just noticed the bug while reworking this series, and thought it
would be useful to fix it, but I honestly don't care if it's applied
or not (I don't use this platform).

> 
> > Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer")
> > ---
> >  drivers/mtd/nand/denali.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> > index 67eb2be..8feece3 100644
> > --- a/drivers/mtd/nand/denali.c
> > +++ b/drivers/mtd/nand/denali.c
> > @@ -1622,6 +1622,7 @@ EXPORT_SYMBOL(denali_init);
> >  /* driver exit point */
> >  void denali_remove(struct denali_nand_info *denali)
> >  {
> > +   nand_release(&denali->mtd);
> > denali_irq_cleanup(denali->irq, denali);
> > dma_unmap_single(denali->dev, denali->buf.dma_buf,
> >  denali->mtd.writesize + denali->mtd.oobsize,
> 
> It feels a bit odd to allow usage of MTD fields after it has been
> unregistered. Maybe precompute this before the nand_release()?

nand_realease() is not releasing the mtd instance or re-initialazing
its field, so it should be safe, but I agree that pre-computing the DMA
buffer size is more future-proof.

I'll fix that, send a v5 and let you decide whether it's needed or not.

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Boris Brezillon
Unregister the NAND device from the NAND subsystem when removing a denali
NAND controller, otherwise the MTD attached to the NAND device is still
exposed by the MTD layer, and accesses to this device will likely crash
the system.

Signed-off-by: Boris Brezillon 
---
Changes since v4:
- remove Cc stable and fixes tags
- calculate the dma buffer size before calling nand_release()

 drivers/mtd/nand/denali.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index 67eb2be..fdfea05 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -1622,9 +1622,11 @@ EXPORT_SYMBOL(denali_init);
 /* driver exit point */
 void denali_remove(struct denali_nand_info *denali)
 {
+   int bufsize = denali->mtd.writesize + denali->mtd.oobsize;
+
+   nand_release(&denali->mtd);
denali_irq_cleanup(denali->irq, denali);
-   dma_unmap_single(denali->dev, denali->buf.dma_buf,
-denali->mtd.writesize + denali->mtd.oobsize,
+   dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize,
 DMA_BIDIRECTIONAL);
 }
 EXPORT_SYMBOL(denali_remove);
-- 
2.1.4

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


[PATCH v5 41/58] mtd: nand: socrates: use the mtd instance embedded in struct nand_chip

2015-12-11 Thread Boris Brezillon
struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon 
---
Changes since v4:
- fix build error

---
Changes generated with the following coccinelle script

--->8---
virtual patch

@fix1@
identifier __chipfield, __mtdfield;
type __type;
@@
(
__type {
...
struct nand_chip __chipfield;
...
-   struct mtd_info __mtdfield;
...
};
|
__type {
...
-   struct mtd_info __mtdfield;
...
struct nand_chip __chipfield;
...
};
)

@fix2 depends on fix1@
identifier fix1.__chipfield, fix1.__mtdfield;
identifier __subfield;
type fix1.__type;
__type *__priv;
@@
(
-   __priv->__mtdfield.__subfield
+   nand_to_mtd(&__priv->__chipfield)->__subfield
|
-   &(__priv->__mtdfield)
+   nand_to_mtd(&__priv->__chipfield)
)
--->8---
---
 drivers/mtd/nand/socrates_nand.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
index 2dfb1e0..925761c 100644
--- a/drivers/mtd/nand/socrates_nand.c
+++ b/drivers/mtd/nand/socrates_nand.c
@@ -30,7 +30,6 @@
 
 struct socrates_nand_host {
struct nand_chipnand_chip;
-   struct mtd_info mtd;
void __iomem*io_base;
struct device   *dev;
 };
@@ -159,8 +158,8 @@ static int socrates_nand_probe(struct platform_device 
*ofdev)
return -EIO;
}
 
-   mtd = &host->mtd;
nand_chip = &host->nand_chip;
+   mtd = nand_to_mtd(nand_chip);
host->dev = &ofdev->dev;
 
nand_chip->priv = host; /* link the private data structures */
@@ -216,7 +215,7 @@ out:
 static int socrates_nand_remove(struct platform_device *ofdev)
 {
struct socrates_nand_host *host = dev_get_drvdata(&ofdev->dev);
-   struct mtd_info *mtd = &host->mtd;
+   struct mtd_info *mtd = nand_to_mtd(&host->nand_chip);
 
nand_release(mtd);
 
-- 
2.1.4

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


[PATCH v5 15/58] mtd: nand: denali: use the mtd instance embedded in struct nand_chip

2015-12-11 Thread Boris Brezillon
struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon 
---
Changes since v4:
- fix conflict after changes brought in v5 of patch 1

---
Changes generated with the following coccinelle script

--->8---
virtual patch

@fix1@
identifier __chipfield, __mtdfield;
type __type;
@@
(
__type {
...
struct nand_chip __chipfield;
...
-   struct mtd_info __mtdfield;
...
};
|
__type {
...
-   struct mtd_info __mtdfield;
...
struct nand_chip __chipfield;
...
};
)

@fix2 depends on fix1@
identifier fix1.__chipfield, fix1.__mtdfield;
identifier __subfield;
type fix1.__type;
__type *__priv;
@@
(
-   __priv->__mtdfield.__subfield
+   nand_to_mtd(&__priv->__chipfield)->__subfield
|
-   &(__priv->__mtdfield)
+   nand_to_mtd(&__priv->__chipfield)
)
--->8---

Conflicts:
drivers/mtd/nand/denali.c
---
 drivers/mtd/nand/denali.c | 69 ++-
 drivers/mtd/nand/denali.h |  1 -
 2 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index fdfea05..ccab8bc 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -75,7 +75,10 @@ MODULE_PARM_DESC(onfi_timing_mode,
  * this macro allows us to convert from an MTD structure to our own
  * device context (denali) structure.
  */
-#define mtd_to_denali(m) container_of(m, struct denali_nand_info, mtd)
+static inline struct denali_nand_info *mtd_to_denali(struct mtd_info *mtd)
+{
+   return container_of(mtd_to_nand(mtd), struct denali_nand_info, nand);
+}
 
 /*
  * These constants are defined by the driver to enable common driver
@@ -986,6 +989,8 @@ static bool handle_ecc(struct denali_nand_info *denali, 
uint8_t *buf,
 * than one NAND connected.
 */
if (err_byte < ECC_SECTOR_SIZE) {
+   struct mtd_info *mtd =
+   nand_to_mtd(&denali->nand);
int offset;
 
offset = (err_sector *
@@ -995,7 +1000,7 @@ static bool handle_ecc(struct denali_nand_info *denali, 
uint8_t *buf,
err_device;
/* correct the ECC error */
buf[offset] ^= err_correction_value;
-   denali->mtd.ecc_stats.corrected++;
+   mtd->ecc_stats.corrected++;
bitflips++;
}
} else {
@@ -1062,7 +1067,7 @@ static int write_page(struct mtd_info *mtd, struct 
nand_chip *chip,
 {
struct denali_nand_info *denali = mtd_to_denali(mtd);
dma_addr_t addr = denali->buf.dma_buf;
-   size_t size = denali->mtd.writesize + denali->mtd.oobsize;
+   size_t size = mtd->writesize + mtd->oobsize;
uint32_t irq_status;
uint32_t irq_mask = INTR_STATUS__DMA_CMD_COMP |
INTR_STATUS__PROGRAM_FAIL;
@@ -1160,7 +1165,7 @@ static int denali_read_page(struct mtd_info *mtd, struct 
nand_chip *chip,
struct denali_nand_info *denali = mtd_to_denali(mtd);
 
dma_addr_t addr = denali->buf.dma_buf;
-   size_t size = denali->mtd.writesize + denali->mtd.oobsize;
+   size_t size = mtd->writesize + mtd->oobsize;
 
uint32_t irq_status;
uint32_t irq_mask = INTR_STATUS__ECC_TRANSACTION_DONE |
@@ -1193,14 +1198,14 @@ static int denali_read_page(struct mtd_info *mtd, 
struct nand_chip *chip,
denali_enable_dma(denali, false);
 
if (check_erased_page) {
-   read_oob_data(&denali->mtd, chip->oob_poi, denali->page);
+   read_oob_data(mtd, chip->oob_poi, denali->page);
 
/* check ECC failures that may have occurred on erased pages */
if (check_erased_page) {
-   if (!is_erased(buf, denali->mtd.writesize))
-   denali->mtd.ecc_stats.failed++;
-   if (!is_erased(buf, denali->mtd.oobsize))
-   denali->mtd.ecc_stats.failed++;
+   if (!is_erased(buf, mtd->writesize))
+   mtd->ecc_stats.failed++;
+   if (!is_erased(buf, mtd->oobsize))
+   mtd->ecc_stats.failed++;
}
}
return max_bitflips;
@@ -1211,7 +1216,7 @@ static int denali_read_page_raw(struct mtd_info *mtd, 
struct nand_chip *chip,
 {
struct denali_nand_info *denali = mtd_to_denali(mtd);
d

Re: [PATCH] staging: dgnc: Patch includes the checkpatch fixes

2015-12-11 Thread Sanidhya Solanki
On Fri, 11 Dec 2015 16:02:33 +0300
Dan Carpenter  wrote:

> > Signed-off-by: Sanidhya Solanki 
> > @@ -110,7 +98,16 @@ static ssize_t dgnc_vpd_show(struct device *p, struct 
> > device_attribute *attr,
> > int count = 0;
> > int i = 0;
> >  
> > -   DGNC_VERIFY_BOARD(p, bd);
> > +   do {
> > +   if (!p)
> > +   return 0;
> > +
> > +   bd = dev_get_drvdata(p);
> > +   if (!bd || bd->magic != DGNC_BOARD_MAGIC)
> > +   return 0;
> > +   if (bd->state != BOARD_READY)
> > +   return 0;
> > +   } while (0);
> 
> Google about why do while(0) loops are used in macros and then redo
> this.  Mostly the patch isn't bad, but I suspect I'm going to complain
> about how you split up some of the long lines.

Let me just be completely sure that you and I are on the same page here. The 
macro was used to replace the do-while loop, I replaced all instances of the 
macro with the the actual loop. Both pieces were originally part of the code, 
just using macros in place of do-while statements. Do you still want me to 
change it? Maybe the original author did it for a specific reason.

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


Re: [PATCH 03/10] media framework: rename pads init function to media_entity_pads_init()

2015-12-11 Thread Jacek Anaszewski

On 12/11/2015 02:34 PM, Mauro Carvalho Chehab wrote:

With the MC next gen rework, what's left for media_entity_init()
is to just initialize the PADs. However, certain devices, like
a FLASH led/light doesn't have any input or output PAD.

So, there's no reason why calling media_entity_init() would be
mandatory. Also, despite its name, what this function actually
does is to initialize the PADs data. So, rename it to
media_entity_pads_init() in order to reflect that.

The media entity actual init happens during entity register,
at media_device_register_entity(). We should move init of
num_links and num_backlinks to it.

Signed-off-by: Mauro Carvalho Chehab 

[...]

diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c 
b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index 5c686a24712b..13d5a36bc5d8 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -651,7 +651,7 @@ struct v4l2_flash *v4l2_flash_init(
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
strlcpy(sd->name, config->dev_name, sizeof(sd->name));

-   ret = media_entity_init(&sd->entity, 0, NULL);
+   ret = media_entity_pads_init(&sd->entity, 0, NULL);
if (ret < 0)
return ERR_PTR(ret);



For this part:

Acked-by: Jacek Anaszewski 

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


Re: [PATCH] staging: dgnc: Patch includes the checkpatch fixes

2015-12-11 Thread Dan Carpenter
On Fri, Dec 11, 2015 at 05:10:43AM -0500, Sanidhya Solanki wrote:
> On Fri, 11 Dec 2015 16:02:33 +0300
> Dan Carpenter  wrote:
> 
> > > Signed-off-by: Sanidhya Solanki 
> > > @@ -110,7 +98,16 @@ static ssize_t dgnc_vpd_show(struct device *p, struct 
> > > device_attribute *attr,
> > >   int count = 0;
> > >   int i = 0;
> > >  
> > > - DGNC_VERIFY_BOARD(p, bd);
> > > + do {
> > > + if (!p)
> > > + return 0;
> > > +
> > > + bd = dev_get_drvdata(p);
> > > + if (!bd || bd->magic != DGNC_BOARD_MAGIC)
> > > + return 0;
> > > + if (bd->state != BOARD_READY)
> > > + return 0;
> > > + } while (0);
> > 
> > Google about why do while(0) loops are used in macros and then redo
> > this.  Mostly the patch isn't bad, but I suspect I'm going to complain
> > about how you split up some of the long lines.
> 
> Let me just be completely sure that you and I are on the same page
> here. The macro was used to replace the do-while loop, I replaced all
> instances of the macro with the the actual loop. Both pieces were
> originally part of the code, just using macros in place of do-while
> statements. Do you still want me to change it? Maybe the original
> author did it for a specific reason.
> 

https://www.quora.com/What-is-the-purpose-of-using-do-while-0-in-macros

Do while(0) is used to make a macro look like a function.  Since we have
deleted the macro we don't need the do while.

regards,
dan carpenter

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


[PATCH] media: use unsigned for pad index

2015-12-11 Thread Mauro Carvalho Chehab
The pad index is unsigned. Replace the occurences of it where
pertinent.

Suggested-by: Laurent Pinchart 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/platform/omap3isp/ispccdc.c  | 2 +-
 drivers/media/platform/omap3isp/ispccp2.c  | 2 +-
 drivers/media/platform/omap3isp/ispcsi2.c  | 2 +-
 drivers/media/platform/omap3isp/isppreview.c   | 2 +-
 drivers/media/platform/omap3isp/ispresizer.c   | 2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c| 2 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c | 2 +-
 drivers/staging/media/omap4iss/iss_csi2.c  | 2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c   | 2 +-
 drivers/staging/media/omap4iss/iss_resizer.c   | 2 +-
 11 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispccdc.c 
b/drivers/media/platform/omap3isp/ispccdc.c
index dae674cd3f74..749462c1af8e 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -2513,7 +2513,7 @@ static int ccdc_link_setup(struct media_entity *entity,
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
struct isp_device *isp = to_isp_device(ccdc);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/media/platform/omap3isp/ispccp2.c 
b/drivers/media/platform/omap3isp/ispccp2.c
index 0c790b25f6f9..59686dd1bb0a 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -956,7 +956,7 @@ static int ccp2_link_setup(struct media_entity *entity,
 {
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c 
b/drivers/media/platform/omap3isp/ispcsi2.c
index f50f6b305204..886f148755b0 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -1144,7 +1144,7 @@ static int csi2_link_setup(struct media_entity *entity,
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
struct isp_csi2_ctrl_cfg *ctrl = &csi2->ctrl;
-   int index = local->index;
+   unsigned int index = local->index;
 
/*
 * The ISP core doesn't support pipelines with multiple video outputs.
diff --git a/drivers/media/platform/omap3isp/isppreview.c 
b/drivers/media/platform/omap3isp/isppreview.c
index c300cb7219e9..e15ad4133632 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -2144,7 +2144,7 @@ static int preview_link_setup(struct media_entity *entity,
 {
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/media/platform/omap3isp/ispresizer.c 
b/drivers/media/platform/omap3isp/ispresizer.c
index cd0a9f6e1fed..20b98d876d7e 100644
--- a/drivers/media/platform/omap3isp/ispresizer.c
+++ b/drivers/media/platform/omap3isp/ispresizer.c
@@ -1623,7 +1623,7 @@ static int resizer_link_setup(struct media_entity *entity,
 {
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct isp_res_device *res = v4l2_get_subdevdata(sd);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
index a54c60fce3d5..633d6456fdce 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
@@ -885,7 +885,7 @@ ipipeif_link_setup(struct media_entity *entity, const 
struct media_pad *local,
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
struct vpfe_device *vpfe = to_vpfe_device(ipipeif);
-   int index = local->index;
+   unsigned int index = local->index;
 
/* FIXME: this is actually a hack! */
if (is_media_entity_v4l2_subdev(remote->entity))
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c 
b/drivers/staging/media/davinci_vpfe/dm365_isif.c
i

[PATCH] Staging: rtl8192u: Fix block comment formatting

2015-12-11 Thread Gavin Thomas Claugus
Change block comments to comply with checkpatch style
guidelines.

Signed-off-by: Gavin Thomas Claugus 
---
 drivers/staging/rtl8192u/r8190_rtl8256.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c 
b/drivers/staging/rtl8192u/r8190_rtl8256.c
index e000329..5c3bb3b 100644
--- a/drivers/staging/rtl8192u/r8190_rtl8256.c
+++ b/drivers/staging/rtl8192u/r8190_rtl8256.c
@@ -1,12 +1,11 @@
 /*
-  This is part of the rtl8192 driver
-  released under the GPL (See file COPYING for details).
-
-  This files contains programming code for the rtl8256
-  radio frontend.
-
-  *Many* thanks to Realtek Corp. for their great support!
-
+* This is part of the rtl8192 driver
+* released under the GPL (See file COPYING for details).
+*
+* This files contains programming code for the rtl8256
+* radio frontend.
+*
+* *Many* thanks to Realtek Corp. for their great support!
 */
 
 #include "r8192U.h"
@@ -22,7 +21,8 @@
  * Output:  NONE
  * Return:  NONE
  * Note:   8226 support both 20M  and 40 MHz
- *---*/
+ *--
+ */
 void PHY_SetRF8256Bandwidth(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth)
 {
u8  eRFPath;
@@ -83,7 +83,8 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev, 
HT_CHANNEL_WIDTH Bandwidth)
  * Input:   struct net_device* dev
  * Output:  NONE
  * Return:  NONE
- *---*/
+ *--
+ */
 void PHY_RF8256_Config(struct net_device *dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -100,7 +101,8 @@ void PHY_RF8256_Config(struct net_device *dev)
  * Input:   struct net_device* dev
  * Output:  NONE
  * Return:  NONE
- *---*/
+ *--
+ */
 void phy_RF8256_Config_ParaFile(struct net_device *dev)
 {
u32 u4RegValue = 0;
-- 
2.6.4

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


Re: [PATCH v4 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Dan Carpenter
On Fri, Dec 11, 2015 at 02:53:20PM +0100, Boris Brezillon wrote:
> Hi Brian,
> 
> On Thu, 10 Dec 2015 16:40:08 -0800
> Brian Norris  wrote:
> 
> > On Thu, Dec 10, 2015 at 08:59:45AM +0100, Boris Brezillon wrote:
> > > Unregister the NAND device from the NAND subsystem when removing a denali
> > > NAND controller, otherwise the MTD attached to the NAND device is still
> > > exposed by the MTD layer, and accesses to this device will likely crash
> > > the system.
> > > 
> > > Signed-off-by: Boris Brezillon 
> > > Cc:  #3.8+
> > 
> > Does this follow these rules, from
> > Documentation/stable_kernel_rules.txt?
> > 
> >  - It must be obviously correct and tested.
> > 
> >  - It must fix a real bug that bothers people (not a, "This could be a
> >problem..." type thing).
> 
> As you wish, I'll remove those Cc and Fixes tags, or just drop the
> patch if you think it's useless...

The fixes tag is a separate thing from CCing stable.  It's useful on by
itself.  I always put the person who wrote the original patch in the To:
header so they can review and comment if I have made a mistake.

regards,
dan carpenter

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


Re: [PATCH v5 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Boris Brezillon
+ Dinh (who made commit 2a0a288ec258)

Also added back the Fixes tag.

On Fri, 11 Dec 2015 15:02:34 +0100
Boris Brezillon  wrote:

> Unregister the NAND device from the NAND subsystem when removing a denali
> NAND controller, otherwise the MTD attached to the NAND device is still
> exposed by the MTD layer, and accesses to this device will likely crash
> the system.
> 
> Signed-off-by: Boris Brezillon 

Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer")

> ---
> Changes since v4:
> - remove Cc stable and fixes tags
> - calculate the dma buffer size before calling nand_release()
> 
>  drivers/mtd/nand/denali.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> index 67eb2be..fdfea05 100644
> --- a/drivers/mtd/nand/denali.c
> +++ b/drivers/mtd/nand/denali.c
> @@ -1622,9 +1622,11 @@ EXPORT_SYMBOL(denali_init);
>  /* driver exit point */
>  void denali_remove(struct denali_nand_info *denali)
>  {
> + int bufsize = denali->mtd.writesize + denali->mtd.oobsize;
> +
> + nand_release(&denali->mtd);
>   denali_irq_cleanup(denali->irq, denali);
> - dma_unmap_single(denali->dev, denali->buf.dma_buf,
> -  denali->mtd.writesize + denali->mtd.oobsize,
> + dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize,
>DMA_BIDIRECTIONAL);
>  }
>  EXPORT_SYMBOL(denali_remove);



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Boris Brezillon
Hi Dan,

On Fri, 11 Dec 2015 17:39:47 +0300
Dan Carpenter  wrote:

> On Fri, Dec 11, 2015 at 02:53:20PM +0100, Boris Brezillon wrote:
> > Hi Brian,
> > 
> > On Thu, 10 Dec 2015 16:40:08 -0800
> > Brian Norris  wrote:
> > 
> > > On Thu, Dec 10, 2015 at 08:59:45AM +0100, Boris Brezillon wrote:
> > > > Unregister the NAND device from the NAND subsystem when removing a 
> > > > denali
> > > > NAND controller, otherwise the MTD attached to the NAND device is still
> > > > exposed by the MTD layer, and accesses to this device will likely crash
> > > > the system.
> > > > 
> > > > Signed-off-by: Boris Brezillon 
> > > > Cc:  #3.8+
> > > 
> > > Does this follow these rules, from
> > > Documentation/stable_kernel_rules.txt?
> > > 
> > >  - It must be obviously correct and tested.
> > > 
> > >  - It must fix a real bug that bothers people (not a, "This could be a
> > >problem..." type thing).
> > 
> > As you wish, I'll remove those Cc and Fixes tags, or just drop the
> > patch if you think it's useless...
> 
> The fixes tag is a separate thing from CCing stable.  It's useful on by
> itself.  I always put the person who wrote the original patch in the To:
> header so they can review and comment if I have made a mistake.

Noted. I added back the Fixes tag and added Dinh Nguyen (the commit
author) in the loop.

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH net-next] hv_netvsc: Fix race condition on Multi-Send Data field

2015-12-11 Thread Haiyang Zhang


> -Original Message-
> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com]
> Sent: Friday, December 11, 2015 8:53 AM
> To: Haiyang Zhang 
> Cc: da...@davemloft.net; net...@vger.kernel.org; o...@aepfle.de;
> jasow...@redhat.com; driverdev-devel@linuxdriverproject.org; linux-
> ker...@vger.kernel.org
> Subject: Re: [PATCH net-next] hv_netvsc: Fix race condition on Multi-
> Send Data field
> 
> Vitaly Kuznetsov  writes:
> 
> > Haiyang Zhang  writes:
> >
> >> In commit 2a04ae8acb14 ("hv_netvsc: remove locking in netvsc_send()"),
> the
> >> locking for MSD (Multi-Send Data) field was removed. This could cause
> a
> >> race condition between RNDIS control messages and data packets
> processing,
> >> because these two types of traffic are not synchronized.
> >> This patch fixes this issue by sending control messages out directly
> >> without reading MSD field.
> >>
> >> Signed-off-by: Haiyang Zhang 
> >> Reviewed-by: K. Y. Srinivasan 
> >> ---
> >>  drivers/net/hyperv/netvsc.c |9 +
> >>  1 files changed, 9 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/drivers/net/hyperv/netvsc.c
> b/drivers/net/hyperv/netvsc.c
> >> index 02bab9a..059fc52 100644
> >> --- a/drivers/net/hyperv/netvsc.c
> >> +++ b/drivers/net/hyperv/netvsc.c
> >> @@ -867,6 +867,14 @@ int netvsc_send(struct hv_device *device,
> >>packet->send_buf_index = NETVSC_INVALID_INDEX;
> >>packet->cp_partial = false;
> >>
> >> +  /* Send control message directly without accessing msd (Multi-Send
> >> +   * Data) field which may be changed during data packet processing.
> >> +   */
> >> +  if (!skb) {
> >> +  cur_send = packet;
> >> +  goto send_now;
> >> +  }
> >> +
> >
> > Is is supposed to be applied on top of some other patches? It doesn't
> > compile on top of current net-next:
> >
> > drivers/net/hyperv/netvsc.c: In function ‘netvsc_send’:
> > drivers/net/hyperv/netvsc.c:865:7: error: ‘skb’ undeclared (first use
> in
> > this function)
> >   if (!skb) {
> >  ^
> >
> > Did you mean to check rndis_msg instead (as skb is not defined here)?
> 
> Oh, my bad, it was me who was looking at the wrong branch... Sorry for
> the noise.
> 
> >
> >>msdp = &net_device->msd[q_idx];
> >>
> >>/* batch packets in send buffer if possible */
> >> @@ -939,6 +947,7 @@ int netvsc_send(struct hv_device *device,
> >>}
> >>}
> >>
> >> +send_now:
> >>if (cur_send)
> >>ret = netvsc_send_pkt(cur_send, net_device, pb, skb);
> >
> > I suppose we untangle these two pathes completely: let
> > rndis_filter_send_request() call netvsc_send_pkt() directly. Please
> see
> > my patch attached (note: it should be split in 3 patches if
> > submitted). If you like the idea I can send it.
> 
> This patch will need some changes but the suggestion still stands: let's
> untangle sending data and control messages.

Thanks for the suggestion.
I still prefer fixing this bug in the netvsc_send(), and keep the common
entry point for sending data & control packets. So, the total lines of
code is smaller. And, when we add more pre-processing steps for send in 
the future, we won't need to change multiple places.

Thanks,
- Haiyang

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


RE: [PATCH net-next] hv_netvsc: Fix race condition on Multi-Send Data field

2015-12-11 Thread KY Srinivasan


> -Original Message-
> From: devel [mailto:driverdev-devel-boun...@linuxdriverproject.org] On
> Behalf Of Vitaly Kuznetsov
> Sent: Friday, December 11, 2015 5:53 AM
> To: Haiyang Zhang 
> Cc: o...@aepfle.de; net...@vger.kernel.org; jasow...@redhat.com;
> driverdev-devel@linuxdriverproject.org; linux-ker...@vger.kernel.org;
> da...@davemloft.net
> Subject: Re: [PATCH net-next] hv_netvsc: Fix race condition on Multi-Send
> Data field
> 
> Vitaly Kuznetsov  writes:
> 
> > Haiyang Zhang  writes:
> >
> >> In commit 2a04ae8acb14 ("hv_netvsc: remove locking in netvsc_send()"),
> the
> >> locking for MSD (Multi-Send Data) field was removed. This could cause a
> >> race condition between RNDIS control messages and data packets
> processing,
> >> because these two types of traffic are not synchronized.
> >> This patch fixes this issue by sending control messages out directly
> >> without reading MSD field.
> >>
> >> Signed-off-by: Haiyang Zhang 
> >> Reviewed-by: K. Y. Srinivasan 
> >> ---
> >>  drivers/net/hyperv/netvsc.c |9 +
> >>  1 files changed, 9 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> >> index 02bab9a..059fc52 100644
> >> --- a/drivers/net/hyperv/netvsc.c
> >> +++ b/drivers/net/hyperv/netvsc.c
> >> @@ -867,6 +867,14 @@ int netvsc_send(struct hv_device *device,
> >>packet->send_buf_index = NETVSC_INVALID_INDEX;
> >>packet->cp_partial = false;
> >>
> >> +  /* Send control message directly without accessing msd (Multi-Send
> >> +   * Data) field which may be changed during data packet processing.
> >> +   */
> >> +  if (!skb) {
> >> +  cur_send = packet;
> >> +  goto send_now;
> >> +  }
> >> +
> >
> > Is is supposed to be applied on top of some other patches? It doesn't
> > compile on top of current net-next:
> >
> > drivers/net/hyperv/netvsc.c: In function ‘netvsc_send’:
> > drivers/net/hyperv/netvsc.c:865:7: error: ‘skb’ undeclared (first use in
> > this function)
> >   if (!skb) {
> >  ^
> >
> > Did you mean to check rndis_msg instead (as skb is not defined here)?
> 
> Oh, my bad, it was me who was looking at the wrong branch... Sorry for
> the noise.
> 
> >
> >>msdp = &net_device->msd[q_idx];
> >>
> >>/* batch packets in send buffer if possible */
> >> @@ -939,6 +947,7 @@ int netvsc_send(struct hv_device *device,
> >>}
> >>}
> >>
> >> +send_now:
> >>if (cur_send)
> >>ret = netvsc_send_pkt(cur_send, net_device, pb, skb);
> >
> > I suppose we untangle these two pathes completely: let
> > rndis_filter_send_request() call netvsc_send_pkt() directly. Please see
> > my patch attached (note: it should be split in 3 patches if
> > submitted). If you like the idea I can send it.
> 
> This patch will need some changes but the suggestion still stands: let's
> untangle sending data and control messages.

Control messages will have skb set to NULL and that is what Haiyang is doing
to distinguish control packets.

K. Y
> 
> --
>   Vitaly
> ___
> devel mailing list
> de...@linuxdriverproject.org
> https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fdriverde
> v.linuxdriverproject.org%2fmailman%2flistinfo%2fdriverdev-
> devel%0a&data=01%7c01%7ckys%40microsoft.com%7c741026ba8cbb47a993
> 2c08d3023257b7%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=VdQiM
> NOzCtlRcsN5%2b%2faf%2bGrPNDHPmrvo2TuUs1T%2frlQ%3d
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Dinh Nguyen
Hi Boris,

On Fri, Dec 11, 2015 at 9:10 AM, Boris Brezillon
 wrote:
> + Dinh (who made commit 2a0a288ec258)
>
> Also added back the Fixes tag.
>
> On Fri, 11 Dec 2015 15:02:34 +0100
> Boris Brezillon  wrote:
>
>> Unregister the NAND device from the NAND subsystem when removing a denali
>> NAND controller, otherwise the MTD attached to the NAND device is still
>> exposed by the MTD layer, and accesses to this device will likely crash
>> the system.
>>
>> Signed-off-by: Boris Brezillon 
>
> Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer")
>
>> ---
>> Changes since v4:
>> - remove Cc stable and fixes tags
>> - calculate the dma buffer size before calling nand_release()
>>
>>  drivers/mtd/nand/denali.c | 6 --
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
>> index 67eb2be..fdfea05 100644
>> --- a/drivers/mtd/nand/denali.c
>> +++ b/drivers/mtd/nand/denali.c
>> @@ -1622,9 +1622,11 @@ EXPORT_SYMBOL(denali_init);
>>  /* driver exit point */
>>  void denali_remove(struct denali_nand_info *denali)
>>  {
>> + int bufsize = denali->mtd.writesize + denali->mtd.oobsize;
>> +
>> + nand_release(&denali->mtd);
>>   denali_irq_cleanup(denali->irq, denali);
>> - dma_unmap_single(denali->dev, denali->buf.dma_buf,
>> -  denali->mtd.writesize + denali->mtd.oobsize,
>> + dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize,
>>DMA_BIDIRECTIONAL);

Not sure what is the need to add bufsize here, but the commit message
doesn't reflect the change.

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


Re: [PATCH v5 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Boris Brezillon
Hi Dinh,

On Fri, 11 Dec 2015 10:50:21 -0600
Dinh Nguyen  wrote:

> Hi Boris,
> 
> On Fri, Dec 11, 2015 at 9:10 AM, Boris Brezillon
>  wrote:
> > + Dinh (who made commit 2a0a288ec258)
> >
> > Also added back the Fixes tag.
> >
> > On Fri, 11 Dec 2015 15:02:34 +0100
> > Boris Brezillon  wrote:
> >
> >> Unregister the NAND device from the NAND subsystem when removing a denali
> >> NAND controller, otherwise the MTD attached to the NAND device is still
> >> exposed by the MTD layer, and accesses to this device will likely crash
> >> the system.
> >>
> >> Signed-off-by: Boris Brezillon 
> >
> > Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer")
> >
> >> ---
> >> Changes since v4:
> >> - remove Cc stable and fixes tags
> >> - calculate the dma buffer size before calling nand_release()
> >>
> >>  drivers/mtd/nand/denali.c | 6 --
> >>  1 file changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> >> index 67eb2be..fdfea05 100644
> >> --- a/drivers/mtd/nand/denali.c
> >> +++ b/drivers/mtd/nand/denali.c
> >> @@ -1622,9 +1622,11 @@ EXPORT_SYMBOL(denali_init);
> >>  /* driver exit point */
> >>  void denali_remove(struct denali_nand_info *denali)
> >>  {
> >> + int bufsize = denali->mtd.writesize + denali->mtd.oobsize;
> >> +
> >> + nand_release(&denali->mtd);
> >>   denali_irq_cleanup(denali->irq, denali);
> >> - dma_unmap_single(denali->dev, denali->buf.dma_buf,
> >> -  denali->mtd.writesize + denali->mtd.oobsize,
> >> + dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize,
> >>DMA_BIDIRECTIONAL);
> 
> Not sure what is the need to add bufsize here, but the commit message
> doesn't reflect the change.

You were not in Cc of the first version (my fault), but Brian pointed
that the mtd fields could be in an unknown state after the
nand_release() call (this is currently not the case, but it change in
the future). The idea is to pre-compute the DMA buffer size before
releasing the mtd/nand device to prevent any future issues.

I don't think it is worth mentioning this in the commit message,
because these are just implementation details, but I can add the
following comment before the bufsize declaration:

/*
 * Pre-compute DMA buffer size to avoid any problems in case
 * nand_release() ever changes in a way that mtd->writesize and
 * mtd->oobsize are not reliable after this call.
 */

What do you think?

Best Regards,

Boris

> 
> Dinh



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Dinh Nguyen
On Fri, Dec 11, 2015 at 11:08 AM, Boris Brezillon
 wrote:
> Hi Dinh,
>
> On Fri, 11 Dec 2015 10:50:21 -0600
> Dinh Nguyen  wrote:
>
>> Hi Boris,
>>
>> On Fri, Dec 11, 2015 at 9:10 AM, Boris Brezillon
>>  wrote:
>> > + Dinh (who made commit 2a0a288ec258)
>> >
>> > Also added back the Fixes tag.
>> >
>> > On Fri, 11 Dec 2015 15:02:34 +0100
>> > Boris Brezillon  wrote:
>> >
>> >> Unregister the NAND device from the NAND subsystem when removing a denali
>> >> NAND controller, otherwise the MTD attached to the NAND device is still
>> >> exposed by the MTD layer, and accesses to this device will likely crash
>> >> the system.
>> >>
>> >> Signed-off-by: Boris Brezillon 
>> >
>> > Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer")
>> >
>> >> ---
>> >> Changes since v4:
>> >> - remove Cc stable and fixes tags
>> >> - calculate the dma buffer size before calling nand_release()
>> >>
>> >>  drivers/mtd/nand/denali.c | 6 --
>> >>  1 file changed, 4 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
>> >> index 67eb2be..fdfea05 100644
>> >> --- a/drivers/mtd/nand/denali.c
>> >> +++ b/drivers/mtd/nand/denali.c
>> >> @@ -1622,9 +1622,11 @@ EXPORT_SYMBOL(denali_init);
>> >>  /* driver exit point */
>> >>  void denali_remove(struct denali_nand_info *denali)
>> >>  {
>> >> + int bufsize = denali->mtd.writesize + denali->mtd.oobsize;
>> >> +
>> >> + nand_release(&denali->mtd);
>> >>   denali_irq_cleanup(denali->irq, denali);
>> >> - dma_unmap_single(denali->dev, denali->buf.dma_buf,
>> >> -  denali->mtd.writesize + denali->mtd.oobsize,
>> >> + dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize,
>> >>DMA_BIDIRECTIONAL);
>>
>> Not sure what is the need to add bufsize here, but the commit message
>> doesn't reflect the change.
>
> You were not in Cc of the first version (my fault), but Brian pointed
> that the mtd fields could be in an unknown state after the
> nand_release() call (this is currently not the case, but it change in
> the future). The idea is to pre-compute the DMA buffer size before
> releasing the mtd/nand device to prevent any future issues.
>
> I don't think it is worth mentioning this in the commit message,
> because these are just implementation details, but I can add the
> following comment before the bufsize declaration:
>
> /*
>  * Pre-compute DMA buffer size to avoid any problems in case
>  * nand_release() ever changes in a way that mtd->writesize and
>  * mtd->oobsize are not reliable after this call.
>  */
>
> What do you think?
>

Ah, perfect! With the updated comment,

Acked-by: Dinh Nguyen 

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


[PATCH v2] staging: gdm72xx: fix address space warnings

2015-12-11 Thread Okash Khawaja
copy_to_user() and copy_from_user() functions expect the user space
pointers to be marked with __user. Sparse throws following warnings.

For copy_to_user():

warning: incorrect type in argument 1 (different address spaces)
expected void [noderef] *to
got void *buf

For copy_from_user():

warning: incorrect type in argument 2 (different address spaces)
expected void const [noderef] *from
got void *buf

This creates a separate `struct udata_s` which is user space counterpart
of `struct data_s`. This patch also alters function signatures where
data transfer between user and kernel space occurs, in order to make the
distinction explicit. Finally, it explicitly casts the argument passed
to `gdm_update_fsm()` using __force to avoid the warning "cast removes
address space of expression".

Signed-off-by: Okash Khawaja 
---
 drivers/staging/gdm72xx/gdm_wimax.c | 7 ---
 drivers/staging/gdm72xx/wm_ioctl.h  | 7 ++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gdm72xx/gdm_wimax.c 
b/drivers/staging/gdm72xx/gdm_wimax.c
index b8eea21..c61ce92 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -363,7 +363,7 @@ static void kdelete(void **buf)
}
 }
 
-static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
+static int gdm_wimax_ioctl_get_data(struct udata_s *dst, struct data_s *src)
 {
int size;
 
@@ -379,7 +379,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, 
struct data_s *src)
return 0;
 }
 
-static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)
+static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct udata_s *src)
 {
if (!src->size) {
dst->size = 0;
@@ -478,7 +478,8 @@ static int gdm_wimax_ioctl(struct net_device *dev, struct 
ifreq *ifr, int cmd)
 * before gdm_wimax_ioctl_set_data is called.
 */
gdm_update_fsm(dev,
-  req->data.buf);
+   (__force struct fsm_s *)
+   req->data.buf);
}
ret = gdm_wimax_ioctl_set_data(
&nic->sdk_data[req->data_id], &req->data);
diff --git a/drivers/staging/gdm72xx/wm_ioctl.h 
b/drivers/staging/gdm72xx/wm_ioctl.h
index ed8f649..7dc8f6f 100644
--- a/drivers/staging/gdm72xx/wm_ioctl.h
+++ b/drivers/staging/gdm72xx/wm_ioctl.h
@@ -78,13 +78,18 @@ struct data_s {
void*buf;
 };
 
+struct udata_s {
+   unsigned int size;
+   void __user *buf;
+};
+
 struct wm_req_s {
union {
char ifrn_name[IFNAMSIZ];
} ifr_ifrn;
unsigned short  cmd;
unsigned short  data_id;
-   struct data_s   data;
+   struct udata_s  data;
 
 /* NOTE: sizeof(struct wm_req_s) must be less than sizeof(struct ifreq). */
 };
-- 
2.5.2

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


[PATCH v4 01/11] irqdomain: Added domain bus token DOMAIN_BUS_FSL_MC_MSI

2015-12-11 Thread J. German Rivera
Since an FSL-MC bus is a new bus type that is neither PCI nor
PLATFORM, we need a new domain bus token to disambiguate the
IRQ domain for FSL-MC MSIs.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2: none

 include/linux/irqdomain.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d5e5c5b..c0cb5d1 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -73,6 +73,7 @@ enum irq_domain_bus_token {
DOMAIN_BUS_PCI_MSI,
DOMAIN_BUS_PLATFORM_MSI,
DOMAIN_BUS_NEXUS,
+   DOMAIN_BUS_FSL_MC_MSI,
 };

 /**
--
2.3.3

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


[PATCH v4 03/11] staging: fsl-mc: Added generic MSI support for FSL-MC devices

2015-12-11 Thread J. German Rivera
Created an MSI domain for the fsl-mc bus-- including functions
to create a domain, find a domain, alloc/free domain irqs, and
bus specific overrides for domain and irq_chip ops.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4:
- Addressed comments from Marc Zyngier:
  * Re-implemented fsl_mc_find_msi_domain() using of_msi_get_domain()

Changes in v3:
- Addressed comments from Marc Zyngier:
  * Added WARN_ON in fsl_mc_msi_set_desc to check that caller does
not set set_desc
  * Changed type of paddr in irq_cfg to be phys_addr_t
  * Added WARN_ON in fsl_mc_msi_update_chip_op() to check that caller
does not set irq_write_msi_msg

Changes in v2: none

 drivers/staging/fsl-mc/bus/Kconfig  |   1 +
 drivers/staging/fsl-mc/bus/Makefile |   1 +
 drivers/staging/fsl-mc/bus/mc-msi.c | 276 
 drivers/staging/fsl-mc/include/dprc.h   |   2 +-
 drivers/staging/fsl-mc/include/mc-private.h |  17 ++
 drivers/staging/fsl-mc/include/mc.h |  17 ++
 6 files changed, 313 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/mc-msi.c

diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 0d779d9..c498ac6 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -9,6 +9,7 @@
 config FSL_MC_BUS
tristate "Freescale Management Complex (MC) bus driver"
depends on OF && ARM64
+   select GENERIC_MSI_IRQ_DOMAIN
help
  Driver to enable the bus infrastructure for the Freescale
   QorIQ Management Complex (fsl-mc). The fsl-mc is a hardware
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index 25433a9..a5f2ba4 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -13,5 +13,6 @@ mc-bus-driver-objs := mc-bus.o \
  dpmng.o \
  dprc-driver.o \
  mc-allocator.o \
+ mc-msi.o \
  dpmcp.o \
  dpbp.o
diff --git a/drivers/staging/fsl-mc/bus/mc-msi.c 
b/drivers/staging/fsl-mc/bus/mc-msi.c
new file mode 100644
index 000..3a8258f
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-msi.c
@@ -0,0 +1,276 @@
+/*
+ * Freescale Management Complex (MC) bus driver MSI support
+ *
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Author: German Rivera 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include "../include/mc-private.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../include/mc-sys.h"
+#include "dprc-cmd.h"
+
+static void fsl_mc_msi_set_desc(msi_alloc_info_t *arg,
+   struct msi_desc *desc)
+{
+   arg->desc = desc;
+   arg->hwirq = (irq_hw_number_t)desc->fsl_mc.msi_index;
+}
+
+static void fsl_mc_msi_update_dom_ops(struct msi_domain_info *info)
+{
+   struct msi_domain_ops *ops = info->ops;
+
+   if (WARN_ON(!ops))
+   return;
+
+   /*
+* set_desc should not be set by the caller
+*/
+   if (WARN_ON(ops->set_desc))
+   return;
+
+   ops->set_desc = fsl_mc_msi_set_desc;
+}
+
+static void __fsl_mc_msi_write_msg(struct fsl_mc_device *mc_bus_dev,
+  struct fsl_mc_device_irq *mc_dev_irq)
+{
+   int error;
+   struct fsl_mc_device *owner_mc_dev = mc_dev_irq->mc_dev;
+   struct msi_desc *msi_desc = mc_dev_irq->msi_desc;
+   struct dprc_irq_cfg irq_cfg;
+
+   /*
+* msi_desc->msg.address is 0x0 when this function is invoked in
+* the free_irq() code path. In this case, for the MC, we don't
+* really need to "unprogram" the MSI, so we just return.
+*/
+   if (msi_desc->msg.address_lo == 0x0 && msi_desc->msg.address_hi == 0x0)
+   return;
+
+   if (WARN_ON(!owner_mc_dev))
+   return;
+
+   irq_cfg.paddr = ((u64)msi_desc->msg.address_hi << 32) |
+   msi_desc->msg.address_lo;
+   irq_cfg.val = msi_desc->msg.data;
+   irq_cfg.user_irq_id = msi_desc->irq;
+
+   if (owner_mc_dev == mc_bus_dev) {
+   /*
+* IRQ is for the mc_bus_dev's DPRC itself
+*/
+   error = dprc_set_irq(mc_bus_dev->mc_io,
+MC_CMD_FLAG_INTR_DIS | MC_CMD_FLAG_PRI,
+mc_bus_dev->mc_handle,
+mc_dev_irq->dev_irq_index,
+&irq_cfg);
+   if (error < 0) {
+   dev_err(&owner_mc_dev->dev,
+   "dprc_set_irq() failed: %d\n", error);
+   }
+   } else {
+   /*
+   

[PATCH v4 10/11] staging: fsl-mc: Added DPRC interrupt handler

2015-12-11 Thread J. German Rivera
The interrupt handler for DPRC IRQs is added. DPRC IRQs are
generated for hot plug events related to DPAA2 objects in a given
DPRC. These events include, creating/destroying DPAA2 objects in
the DPRC, changing the "plugged" state of DPAA2 objects and moving
objects between DPRCs.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2: none

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

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 42b2494..52c6fce 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "dprc-cmd.h"

 struct dprc_child_objs {
@@ -386,6 +387,230 @@ error:
 EXPORT_SYMBOL_GPL(dprc_scan_container);

 /**
+ * dprc_irq0_handler - Regular ISR for DPRC interrupt 0
+ *
+ * @irq: IRQ number of the interrupt being handled
+ * @arg: Pointer to device structure
+ */
+static irqreturn_t dprc_irq0_handler(int irq_num, void *arg)
+{
+   return IRQ_WAKE_THREAD;
+}
+
+/**
+ * dprc_irq0_handler_thread - Handler thread function for DPRC interrupt 0
+ *
+ * @irq: IRQ number of the interrupt being handled
+ * @arg: Pointer to device structure
+ */
+static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg)
+{
+   int error;
+   u32 status;
+   struct device *dev = (struct device *)arg;
+   struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
+   struct fsl_mc_io *mc_io = mc_dev->mc_io;
+   struct msi_desc *msi_desc = mc_dev->irqs[0]->msi_desc;
+
+   dev_dbg(dev, "DPRC IRQ %d triggered on CPU %u\n",
+   irq_num, smp_processor_id());
+
+   if (WARN_ON(!(mc_dev->flags & FSL_MC_IS_DPRC)))
+   return IRQ_HANDLED;
+
+   mutex_lock(&mc_bus->scan_mutex);
+   if (WARN_ON(!msi_desc || msi_desc->irq != (u32)irq_num))
+   goto out;
+
+   error = dprc_get_irq_status(mc_io, 0, mc_dev->mc_handle, 0,
+   &status);
+   if (error < 0) {
+   dev_err(dev,
+   "dprc_get_irq_status() failed: %d\n", error);
+   goto out;
+   }
+
+   error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0,
+ status);
+   if (error < 0) {
+   dev_err(dev,
+   "dprc_clear_irq_status() failed: %d\n", error);
+   goto out;
+   }
+
+   if (status & (DPRC_IRQ_EVENT_OBJ_ADDED |
+ DPRC_IRQ_EVENT_OBJ_REMOVED |
+ DPRC_IRQ_EVENT_CONTAINER_DESTROYED |
+ DPRC_IRQ_EVENT_OBJ_DESTROYED |
+ DPRC_IRQ_EVENT_OBJ_CREATED)) {
+   unsigned int irq_count;
+
+   error = dprc_scan_objects(mc_dev, &irq_count);
+   if (error < 0) {
+   /*
+* If the error is -ENXIO, we ignore it, as it indicates
+* that the object scan was aborted, as we detected that
+* an object was removed from the DPRC in the MC, while
+* we were scanning the DPRC.
+*/
+   if (error != -ENXIO) {
+   dev_err(dev, "dprc_scan_objects() failed: %d\n",
+   error);
+   }
+
+   goto out;
+   }
+
+   if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
+   dev_warn(dev,
+"IRQs needed (%u) exceed IRQs preallocated 
(%u)\n",
+irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
+   }
+   }
+
+out:
+   mutex_unlock(&mc_bus->scan_mutex);
+   return IRQ_HANDLED;
+}
+
+/*
+ * Disable and clear interrupt for a given DPRC object
+ */
+static int disable_dprc_irq(struct fsl_mc_device *mc_dev)
+{
+   int error;
+   struct fsl_mc_io *mc_io = mc_dev->mc_io;
+
+   WARN_ON(mc_dev->obj_desc.irq_count != 1);
+
+   /*
+* Disable generation of interrupt, while we configure it:
+*/
+   error = dprc_set_irq_enable(mc_io, 0, mc_dev->mc_handle, 0, 0);
+   if (error < 0) {
+   dev_err(&mc_dev->dev,
+   "Disabling DPRC IRQ failed: dprc_set_irq_enable() 
failed: %d\n",
+   error);
+   return error;
+   }
+
+   /*
+* Disable all interrupt causes for the interrupt:
+*/
+   error = dprc_set_irq_mask(mc_io, 0, mc_dev->mc_handle, 0, 0x0);
+   if (error < 0) {
+   dev_err(&mc_dev->dev,
+   "Disabling DPRC IRQ failed: dprc_set_irq_mask() failed: 
%d\n",
+  

[PATCH v4 00/11] staging: fsl-mc: MC bus MSI support

2015-12-11 Thread J. German Rivera
This patch series addresses the following item from the TODO list
for the MC bus driver to exit staging:

* Interrupt support. For meaningful driver support we need
  interrupts, and thus need message interrupt support by the bus
  driver.

MC Bus MSI Support Architecture
===
A new IRQ domain bus token is added for the FSL-MC bus.
An MSI IRQ domain is created for each top-level (root) data-path
resource container (DPRC), based on its msi-parent in the device
tree (which is the GIC-ITS). Child DPRCs inherit the MSI IRQ
domain form their parent DPRC.

MC Bus MSI Allocation
-
Given the way in which the GIC-ITS works, we need to pre-allocate
a block of MSIs in the GIC-ITS for the IRQs of all the DPAA2 objects
in the same data-path resource container (DPRC) and for the IRQ of
the DPRC iself.

This is due to the fact that all the IRQs for DPAA2 objects in the
same DPRC (and the DPRC's own IRQ) must use the same "device Id" in
the GIC-ITS. Thus, all these IRQs must share the same ITT table in
the GIC-ITS, and therefore must be allocated in the GIC-ITS as
a block of MSIs for the same "device Id".

This is because all the DPAA2 objects in the same DPRC (and the
DPRC itself) use the DPRC's SMMU stream ID as their device Id for
the GIC-ITS.
The DPAA2 Management Complex (MC) firmware does not assign a separate
SMMU stream ID to each DPAA2 object. The MC only assigns SMMU stream
IDs to DPRCs. In MC terms, the stream ID assigned to a DPRC is known
as the DPRC's Isolation Context ID (ICID).

As a consequence of having to pre-allocate a block of MSIs in
the GIC-ITS, the object allocator of the MC bus driver needs to be
extended to provide IRQ allocation services to DPAA2 device drivers
and to the DPRC driver. For a given DPAA2 object, MSIs are allocated
from the corresponding DPRC's pool of pre-allocated MSIs. The MSI
for the DPRC itself is also allocated from this pool.

The following are the patches in this series:

Patch 1: Added domain bus token DOMAIN_BUS_FSL_MC_MSI
Patch 2: Added Added FSL-MC-specific member to the msi_desc's union
Patch 3: Added generic MSI support for FSL-MC devices
Patch 4: Added GICv3-ITS support for FSL-MC MSIs
Patch 5: Extended MC bus allocator to include IRQs
Patch 6: Changed DPRC built-in portal's mc_io to be atomic
Patch 7: Populate the IRQ pool for an MC bus instance
Patch 8: Set MSI domain for DPRC objects
Patch 9: Fixed bug in dprc_probe() error path
Patch 10: Added DPRC interrupt handler
Patch 11: Added MSI support to the MC bus driver

CHANGE HISTORY

Changes in v4:
- Addressed comments from Marc Zyngier for patches 3, 4, 8.
  See details in each patch.

Changes in v3:
- Addressed comments from Marc Zyngier for patch 3.
  See details in patch 3.

Changes in v2:
- Addressed comment from Jiang Liu in patch 2
  See details in patch 2.
- Addressed comment from Dan Carpenter in patch 9
  See details in patch 9.

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


[PATCH v4 08/11] staging: fsl-mc: set MSI domain for DPRC objects

2015-12-11 Thread J. German Rivera
THE MSI domain associated with a root DPRC object is
obtained form the device tree. Child DPRCs inherit
the parent DPRC MSI domain.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4:
- Addressed comments from Marc Zyngier:
  * Changed call to fsl_mc_find_msi_domain() to match new
signature changed in patch 3.

Changes in v3: none

Changes in v2: none

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

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index ef1bb93..38fc404 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -13,6 +13,7 @@
 #include "../include/mc-sys.h"
 #include 
 #include 
+#include 
 #include "dprc-cmd.h"

 struct dprc_child_objs {
@@ -398,11 +399,16 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 {
int error;
size_t region_size;
+   struct device *parent_dev = mc_dev->dev.parent;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
+   bool msi_domain_set = false;

if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
return -EINVAL;

+   if (WARN_ON(dev_get_msi_domain(&mc_dev->dev)))
+   return -EINVAL;
+
if (!mc_dev->mc_io) {
/*
 * This is a child DPRC:
@@ -421,6 +427,30 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 &mc_dev->mc_io);
if (error < 0)
return error;
+   /*
+* Inherit parent MSI domain:
+*/
+   dev_set_msi_domain(&mc_dev->dev,
+  dev_get_msi_domain(parent_dev));
+   msi_domain_set = true;
+   } else {
+   /*
+* This is a root DPRC
+*/
+   struct irq_domain *mc_msi_domain;
+
+   if (WARN_ON(parent_dev->bus == &fsl_mc_bus_type))
+   return -EINVAL;
+
+   error = fsl_mc_find_msi_domain(parent_dev,
+  &mc_msi_domain);
+   if (error < 0) {
+   dev_warn(&mc_dev->dev,
+"WARNING: MC bus without interrupt support\n");
+   } else {
+   dev_set_msi_domain(&mc_dev->dev, mc_msi_domain);
+   msi_domain_set = true;
+   }
}

error = dprc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id,
@@ -446,6 +476,9 @@ error_cleanup_open:
(void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);

 error_cleanup_mc_io:
+   if (msi_domain_set)
+   dev_set_msi_domain(&mc_dev->dev, NULL);
+
fsl_destroy_mc_io(mc_dev->mc_io);
return error;
 }
@@ -463,6 +496,7 @@ error_cleanup_mc_io:
 static int dprc_remove(struct fsl_mc_device *mc_dev)
 {
int error;
+   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);

if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
return -EINVAL;
@@ -475,6 +509,11 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
if (error < 0)
dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);

+   if (dev_get_msi_domain(&mc_dev->dev)) {
+   fsl_mc_cleanup_irq_pool(mc_bus);
+   dev_set_msi_domain(&mc_dev->dev, NULL);
+   }
+
dev_info(&mc_dev->dev, "DPRC device unbound from driver");
return 0;
 }
--
2.3.3

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


[PATCH v4 11/11] staging: fsl-mc: Added MSI support to the MC bus driver

2015-12-11 Thread J. German Rivera
Initialize/Cleanup ITS-MSI support for the MC bus driver at driver
init/exit time. Associate an MSI domain with each DPAA2 child device.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2: none

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

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index d34f1af..9317561 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "../include/dpmng.h"
 #include "../include/mc-sys.h"
 #include "dprc-cmd.h"
@@ -472,6 +474,8 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
mc_dev->icid = parent_mc_dev->icid;
mc_dev->dma_mask = FSL_MC_DEFAULT_DMA_MASK;
mc_dev->dev.dma_mask = &mc_dev->dma_mask;
+   dev_set_msi_domain(&mc_dev->dev,
+  dev_get_msi_domain(&parent_mc_dev->dev));
}

/*
@@ -833,8 +837,15 @@ static int __init fsl_mc_bus_driver_init(void)
if (error < 0)
goto error_cleanup_dprc_driver;

+   error = its_fsl_mc_msi_init();
+   if (error < 0)
+   goto error_cleanup_mc_allocator;
+
return 0;

+error_cleanup_mc_allocator:
+   fsl_mc_allocator_driver_exit();
+
 error_cleanup_dprc_driver:
dprc_driver_exit();

@@ -856,6 +867,7 @@ static void __exit fsl_mc_bus_driver_exit(void)
if (WARN_ON(!mc_dev_cache))
return;

+   its_fsl_mc_msi_cleanup();
fsl_mc_allocator_driver_exit();
dprc_driver_exit();
platform_driver_unregister(&fsl_mc_bus_driver);
--
2.3.3

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


[PATCH v4 02/11] fsl-mc: msi: Added FSL-MC-specific member to the msi_desc's union

2015-12-11 Thread J. German Rivera
FSL-MC is a bus type different from PCI and platform, so it needs
its own member in the msi_desc's union.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2:
- Addressed comment from Jiang Liu
  * Added a dedicated structure for FSL-MC in struct msi_desc

 include/linux/msi.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/msi.h b/include/linux/msi.h
index f71a25e..152e51a 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -33,6 +33,14 @@ struct platform_msi_desc {
 };

 /**
+ * fsl_mc_msi_desc - FSL-MC device specific msi descriptor data
+ * @msi_index: The index of the MSI descriptor
+ */
+struct fsl_mc_msi_desc {
+   u16 msi_index;
+};
+
+/**
  * struct msi_desc - Descriptor structure for MSI based interrupts
  * @list:  List head for management
  * @irq:   The base interrupt number
@@ -87,6 +95,7 @@ struct msi_desc {
 * tree wide cleanup.
 */
struct platform_msi_desc platform;
+   struct fsl_mc_msi_desc fsl_mc;
};
 };

--
2.3.3

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


[PATCH v4 06/11] staging: fsl-mc: Changed DPRC built-in portal's mc_io to be atomic

2015-12-11 Thread J. German Rivera
The DPRC built-in portal's mc_io is used to send commands to the MC
to program MSIs for MC objects. This is done by the
fsl_mc_msi_write_msg() callback, which is invoked by the generic MSI
layer with interrupts disabled. As a result, the mc_io used in
fsl_mc_msi_write_msg needs to be an atomic mc_io.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2: none

 drivers/staging/fsl-mc/bus/dprc-driver.c | 4 +++-
 drivers/staging/fsl-mc/bus/mc-bus.c  | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 2c4cd70..767d437 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -396,7 +396,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
error = fsl_create_mc_io(&mc_dev->dev,
 mc_dev->regions[0].start,
 region_size,
-NULL, 0, &mc_dev->mc_io);
+NULL,
+FSL_MC_IO_ATOMIC_CONTEXT_PORTAL,
+&mc_dev->mc_io);
if (error < 0)
return error;
}
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 84db55b..d34f1af 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -702,7 +702,8 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
mc_portal_phys_addr = res.start;
mc_portal_size = resource_size(&res);
error = fsl_create_mc_io(&pdev->dev, mc_portal_phys_addr,
-mc_portal_size, NULL, 0, &mc_io);
+mc_portal_size, NULL,
+FSL_MC_IO_ATOMIC_CONTEXT_PORTAL, &mc_io);
if (error < 0)
return error;

--
2.3.3

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


[PATCH v4 07/11] staging: fsl-mc: Populate the IRQ pool for an MC bus instance

2015-12-11 Thread J. German Rivera
Scan the corresponding DPRC container to get total count
of IRQs needed by all its child DPAA2 objects. Then,
preallocate a set of MSI IRQs with the DPRC's ICID
(GIT-ITS device Id) to populate the the DPRC's IRQ pool.
Each child DPAA2 object in the DPRC and the DPRC object itself
will allocate their necessary MSI IRQs from the DPRC's IRQ pool,
in their driver probe function.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2: none

 drivers/staging/fsl-mc/bus/dprc-driver.c| 24 ++--
 drivers/staging/fsl-mc/include/mc-private.h |  3 ++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 767d437..ef1bb93 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -241,6 +241,7 @@ static void dprc_cleanup_all_resource_pools(struct 
fsl_mc_device *mc_bus_dev)
  * dprc_scan_objects - Discover objects in a DPRC
  *
  * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
+ * @total_irq_count: total number of IRQs needed by objects in the DPRC.
  *
  * Detects objects added and removed from a DPRC and synchronizes the
  * state of the Linux bus driver, MC by adding and removing
@@ -254,11 +255,13 @@ static void dprc_cleanup_all_resource_pools(struct 
fsl_mc_device *mc_bus_dev)
  * populated before they can get allocation requests from probe callbacks
  * of the device drivers for the non-allocatable devices.
  */
-int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev)
+int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
+ unsigned int *total_irq_count)
 {
int num_child_objects;
int dprc_get_obj_failures;
int error;
+   unsigned int irq_count = mc_bus_dev->obj_desc.irq_count;
struct dprc_obj_desc *child_obj_desc_array = NULL;

error = dprc_get_obj_count(mc_bus_dev->mc_io,
@@ -307,6 +310,7 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev)
continue;
}

+   irq_count += obj_desc->irq_count;
dev_dbg(&mc_bus_dev->dev,
"Discovered object: type %s, id %d\n",
obj_desc->type, obj_desc->id);
@@ -319,6 +323,7 @@ int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev)
}
}

+   *total_irq_count = irq_count;
dprc_remove_devices(mc_bus_dev, child_obj_desc_array,
num_child_objects);

@@ -344,6 +349,7 @@ EXPORT_SYMBOL_GPL(dprc_scan_objects);
 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
 {
int error;
+   unsigned int irq_count;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);

dprc_init_all_resource_pools(mc_bus_dev);
@@ -352,11 +358,25 @@ int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
 * Discover objects in the DPRC:
 */
mutex_lock(&mc_bus->scan_mutex);
-   error = dprc_scan_objects(mc_bus_dev);
+   error = dprc_scan_objects(mc_bus_dev, &irq_count);
mutex_unlock(&mc_bus->scan_mutex);
if (error < 0)
goto error;

+   if (dev_get_msi_domain(&mc_bus_dev->dev) && !mc_bus->irq_resources) {
+   if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
+   dev_warn(&mc_bus_dev->dev,
+"IRQs needed (%u) exceed IRQs preallocated 
(%u)\n",
+irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
+   }
+
+   error = fsl_mc_populate_irq_pool(
+   mc_bus,
+   FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
+   if (error < 0)
+   goto error;
+   }
+
return 0;
 error:
dprc_cleanup_all_resource_pools(mc_bus_dev);
diff --git a/drivers/staging/fsl-mc/include/mc-private.h 
b/drivers/staging/fsl-mc/include/mc-private.h
index 3babe92..be72a44 100644
--- a/drivers/staging/fsl-mc/include/mc-private.h
+++ b/drivers/staging/fsl-mc/include/mc-private.h
@@ -114,7 +114,8 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);

 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev);

-int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev);
+int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
+ unsigned int *total_irq_count);

 int __init dprc_driver_init(void);

--
2.3.3

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


[PATCH v4 04/11] staging: fsl-mc: Added GICv3-ITS support for FSL-MC MSIs

2015-12-11 Thread J. German Rivera
Added platform-specific MSI support layer for FSL-MC devices.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4:
- Addressed comments from Marc Zyngier:
  * Moved bus type check earlier in its_fsl_mc_msi_prepare()
  * Removed its_dev_id variable
  * Changed some assignments to keep both sides on the same line

Changes in v3: none

Changes in v2: none

 drivers/staging/fsl-mc/bus/Makefile|   1 +
 .../staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c | 127 +
 drivers/staging/fsl-mc/include/mc-private.h|   4 +
 3 files changed, 132 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c

diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index a5f2ba4..e731517 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -14,5 +14,6 @@ mc-bus-driver-objs := mc-bus.o \
  dprc-driver.o \
  mc-allocator.o \
  mc-msi.o \
+ irq-gic-v3-its-fsl-mc-msi.o \
  dpmcp.o \
  dpbp.o
diff --git a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c 
b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
new file mode 100644
index 000..4e8e822
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
@@ -0,0 +1,127 @@
+/*
+ * Freescale Management Complex (MC) bus driver MSI support
+ *
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Author: German Rivera 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include "../include/mc-private.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../include/mc-sys.h"
+#include "dprc-cmd.h"
+
+static struct irq_chip its_msi_irq_chip = {
+   .name = "fsl-mc-bus-msi",
+   .irq_mask = irq_chip_mask_parent,
+   .irq_unmask = irq_chip_unmask_parent,
+   .irq_eoi = irq_chip_eoi_parent,
+   .irq_set_affinity = msi_domain_set_affinity
+};
+
+static int its_fsl_mc_msi_prepare(struct irq_domain *msi_domain,
+ struct device *dev,
+ int nvec, msi_alloc_info_t *info)
+{
+   struct fsl_mc_device *mc_bus_dev;
+   struct msi_domain_info *msi_info;
+
+   if (WARN_ON(dev->bus != &fsl_mc_bus_type))
+   return -EINVAL;
+
+   mc_bus_dev = to_fsl_mc_device(dev);
+   if (WARN_ON(!(mc_bus_dev->flags & FSL_MC_IS_DPRC)))
+   return -EINVAL;
+
+   /*
+* Set the device Id to be passed to the GIC-ITS:
+*
+* NOTE: This device id corresponds to the IOMMU stream ID
+* associated with the DPRC object (ICID).
+*/
+   info->scratchpad[0].ul = mc_bus_dev->icid;
+   msi_info = msi_get_domain_info(msi_domain->parent);
+   return msi_info->ops->msi_prepare(msi_domain->parent, dev, nvec, info);
+}
+
+static struct msi_domain_ops its_fsl_mc_msi_ops = {
+   .msi_prepare = its_fsl_mc_msi_prepare,
+};
+
+static struct msi_domain_info its_fsl_mc_msi_domain_info = {
+   .flags  = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS),
+   .ops= &its_fsl_mc_msi_ops,
+   .chip   = &its_msi_irq_chip,
+};
+
+static const struct of_device_id its_device_id[] = {
+   {   .compatible = "arm,gic-v3-its", },
+   {},
+};
+
+int __init its_fsl_mc_msi_init(void)
+{
+   struct device_node *np;
+   struct irq_domain *parent;
+   struct irq_domain *mc_msi_domain;
+
+   for (np = of_find_matching_node(NULL, its_device_id); np;
+np = of_find_matching_node(np, its_device_id)) {
+   if (!of_property_read_bool(np, "msi-controller"))
+   continue;
+
+   parent = irq_find_matching_host(np, DOMAIN_BUS_NEXUS);
+   if (!parent || !msi_get_domain_info(parent)) {
+   pr_err("%s: unable to locate ITS domain\n",
+  np->full_name);
+   continue;
+   }
+
+   mc_msi_domain = fsl_mc_msi_create_irq_domain(
+of_node_to_fwnode(np),
+&its_fsl_mc_msi_domain_info,
+parent);
+   if (!mc_msi_domain) {
+   pr_err("%s: unable to create fsl-mc domain\n",
+  np->full_name);
+   continue;
+   }
+
+   WARN_ON(mc_msi_domain->
+   host_data != &its_fsl_mc_msi_domain_info);
+
+   pr_info("fsl-mc MSI: %s domain created\n", np->full_name);
+   }
+
+   return 0;
+}
+
+void its_fsl_mc_msi_cleanup(void)
+{

[PATCH v4 05/11] staging: fsl-mc: Extended MC bus allocator to include IRQs

2015-12-11 Thread J. German Rivera
All the IRQs for DPAA2 objects in the same DPRC must use
the ICID of that DPRC, as their device Id in the GIC-ITS.
Thus, all these IRQs must share the same ITT table in the GIC.
As a result, a pool of IRQs with the same device Id must be
preallocated per DPRC (fsl-mc bus instance). So, the fsl-mc
bus object allocator is extended to also provide services
to allocate IRQs to DPAA2 devices, from their parent fsl-mc bus
IRQ pool.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2: none

 drivers/staging/fsl-mc/bus/mc-allocator.c   | 199 
 drivers/staging/fsl-mc/include/mc-private.h |  15 +++
 drivers/staging/fsl-mc/include/mc.h |   9 ++
 3 files changed, 223 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c 
b/drivers/staging/fsl-mc/bus/mc-allocator.c
index 88d1857..c5fa628 100644
--- a/drivers/staging/fsl-mc/bus/mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
@@ -15,6 +15,7 @@
 #include "../include/dpcon-cmd.h"
 #include "dpmcp-cmd.h"
 #include "dpmcp.h"
+#include 

 /**
  * fsl_mc_resource_pool_add_device - add allocatable device to a resource
@@ -160,6 +161,7 @@ static const char *const fsl_mc_pool_type_strings[] = {
[FSL_MC_POOL_DPMCP] = "dpmcp",
[FSL_MC_POOL_DPBP] = "dpbp",
[FSL_MC_POOL_DPCON] = "dpcon",
+   [FSL_MC_POOL_IRQ] = "irq",
 };

 static int __must_check object_type_to_pool_type(const char *object_type,
@@ -465,6 +467,203 @@ void fsl_mc_object_free(struct fsl_mc_device *mc_adev)
 }
 EXPORT_SYMBOL_GPL(fsl_mc_object_free);

+/*
+ * Initialize the interrupt pool associated with a MC bus.
+ * It allocates a block of IRQs from the GIC-ITS
+ */
+int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
+unsigned int irq_count)
+{
+   unsigned int i;
+   struct msi_desc *msi_desc;
+   struct fsl_mc_device_irq *irq_resources;
+   struct fsl_mc_device_irq *mc_dev_irq;
+   int error;
+   struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
+   struct fsl_mc_resource_pool *res_pool =
+   &mc_bus->resource_pools[FSL_MC_POOL_IRQ];
+
+   if (WARN_ON(irq_count == 0 ||
+   irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS))
+   return -EINVAL;
+
+   error = fsl_mc_msi_domain_alloc_irqs(&mc_bus_dev->dev, irq_count);
+   if (error < 0)
+   return error;
+
+   irq_resources = devm_kzalloc(&mc_bus_dev->dev,
+sizeof(*irq_resources) * irq_count,
+GFP_KERNEL);
+   if (!irq_resources) {
+   error = -ENOMEM;
+   goto cleanup_msi_irqs;
+   }
+
+   for (i = 0; i < irq_count; i++) {
+   mc_dev_irq = &irq_resources[i];
+
+   /*
+* NOTE: This mc_dev_irq's MSI addr/value pair will be set
+* by the fsl_mc_msi_write_msg() callback
+*/
+   mc_dev_irq->resource.type = res_pool->type;
+   mc_dev_irq->resource.data = mc_dev_irq;
+   mc_dev_irq->resource.parent_pool = res_pool;
+   INIT_LIST_HEAD(&mc_dev_irq->resource.node);
+   list_add_tail(&mc_dev_irq->resource.node, &res_pool->free_list);
+   }
+
+   for_each_msi_entry(msi_desc, &mc_bus_dev->dev) {
+   mc_dev_irq = &irq_resources[msi_desc->fsl_mc.msi_index];
+   mc_dev_irq->msi_desc = msi_desc;
+   mc_dev_irq->resource.id = msi_desc->irq;
+   }
+
+   res_pool->max_count = irq_count;
+   res_pool->free_count = irq_count;
+   mc_bus->irq_resources = irq_resources;
+   return 0;
+
+cleanup_msi_irqs:
+   fsl_mc_msi_domain_free_irqs(&mc_bus_dev->dev);
+   return error;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_populate_irq_pool);
+
+/**
+ * Teardown the interrupt pool associated with an MC bus.
+ * It frees the IRQs that were allocated to the pool, back to the GIC-ITS.
+ */
+void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus)
+{
+   struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
+   struct fsl_mc_resource_pool *res_pool =
+   &mc_bus->resource_pools[FSL_MC_POOL_IRQ];
+
+   if (WARN_ON(!mc_bus->irq_resources))
+   return;
+
+   if (WARN_ON(res_pool->max_count == 0))
+   return;
+
+   if (WARN_ON(res_pool->free_count != res_pool->max_count))
+   return;
+
+   INIT_LIST_HEAD(&res_pool->free_list);
+   res_pool->max_count = 0;
+   res_pool->free_count = 0;
+   mc_bus->irq_resources = NULL;
+   fsl_mc_msi_domain_free_irqs(&mc_bus_dev->dev);
+}
+EXPORT_SYMBOL_GPL(fsl_mc_cleanup_irq_pool);
+
+/**
+ * It allocates the IRQs required by a given MC object device. The
+ * IRQs are allocated from the interrupt pool associated with the
+ * MC bus that contains the device, if the device is not a DPRC device.
+ * Otherwise, the 

[PATCH v4 09/11] staging: fsl-mc: Fixed bug in dprc_probe() error path

2015-12-11 Thread J. German Rivera
Destroy mc_io in error path in dprc_probe() only if the mc_io was
created in this function.

Signed-off-by: J. German Rivera 
---
CHANGE HISTORY

Changes in v4: none

Changes in v3: none

Changes in v2:
- Addressed comment from Dan Carpenter:
  * Renamed goto error labels to indicate what the goto does

 drivers/staging/fsl-mc/bus/dprc-driver.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 38fc404..42b2494 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -401,6 +401,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
size_t region_size;
struct device *parent_dev = mc_dev->dev.parent;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
+   bool mc_io_created = false;
bool msi_domain_set = false;

if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
@@ -413,6 +414,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
/*
 * This is a child DPRC:
 */
+   if (WARN_ON(parent_dev->bus != &fsl_mc_bus_type))
+   return -EINVAL;
+
if (WARN_ON(mc_dev->obj_desc.region_count == 0))
return -EINVAL;

@@ -427,6 +431,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 &mc_dev->mc_io);
if (error < 0)
return error;
+
+   mc_io_created = true;
+
/*
 * Inherit parent MSI domain:
 */
@@ -457,7 +464,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
  &mc_dev->mc_handle);
if (error < 0) {
dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
-   goto error_cleanup_mc_io;
+   goto error_cleanup_msi_domain;
}

mutex_init(&mc_bus->scan_mutex);
@@ -475,11 +482,15 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 error_cleanup_open:
(void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);

-error_cleanup_mc_io:
+error_cleanup_msi_domain:
if (msi_domain_set)
dev_set_msi_domain(&mc_dev->dev, NULL);

-   fsl_destroy_mc_io(mc_dev->mc_io);
+   if (mc_io_created) {
+   fsl_destroy_mc_io(mc_dev->mc_io);
+   mc_dev->mc_io = NULL;
+   }
+
return error;
 }

--
2.3.3

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


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

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

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

diff --git a/Documentation/ABI/testing/sysfs-bus-fsl-mc 
b/Documentation/ABI/testing/sysfs-bus-fsl-mc
new file mode 100644
index 000..3fa747c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-fsl-mc
@@ -0,0 +1,11 @@
+What:  /sys/bus/fsl-mc/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+Description:
+   Writing a non-zero value to this attribute will
+   force a rescan of fsl-mc bus in the system, and
+   add/remove previously added/removed objects in
+   Management Complex firmwarer, i.e., synchronize
+   the objects under fsl-mc bus and Management Complex
+   firmware. For example:
+   # echo 1 > /sys/bus/fsl-mc/rescan
-- 
2.3.3

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


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

2015-12-11 Thread Lijun Pan
The kernel support for the restool (a user space resource management
tool) is a driver for the /dev/dprc.N device file.
Its purpose is to provide an ioctl interface,
which the restool uses to interact with the MC bus driver
and with the MC firmware.
We allocate a dpmcp at driver initialization,
and keep that dpmcp until driver exit.
We use that dpmcp by default.
If that dpmcp is in use, we create another portal at run time
and destroy the newly created portal after use.
The ioctl RESTOOL_SEND_MC_COMMAND sends user space command to fsl-mc
bus and utilizes the fsl-mc bus to communicate with MC firmware.
The ioctl RESTOOL_DPRC_SYNC request the mc-bus launch
objects scan under root dprc.
In order to support multiple root dprc, we utilize the bus notify
mechanism to scan fsl_mc_bus_type for the newly added root dprc.
After discovering the root dprc, it creates a miscdevice
/dev/dprc.N to associate with this root dprc.

Signed-off-by: Lijun Pan 
---
v2:
remove verbose printk
improve error handling
synchronize misc_list access
reserve ioctl range in Documentation/ioctl/ioctl-number.txt
remove ioctl sync command
flip if(!...) to make them fit in 80 columns
change if(x==NULL) to if(!x)
change ("int error = 0;" initialization) to (int error;)


 Documentation/ioctl/ioctl-number.txt|   1 +
 drivers/staging/fsl-mc/bus/Kconfig  |   7 +-
 drivers/staging/fsl-mc/bus/Makefile |   3 +
 drivers/staging/fsl-mc/bus/mc-ioctl.h   |  22 ++
 drivers/staging/fsl-mc/bus/mc-restool.c | 392 
 5 files changed, 424 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-mc/bus/mc-ioctl.h
 create mode 100644 drivers/staging/fsl-mc/bus/mc-restool.c

diff --git a/Documentation/ioctl/ioctl-number.txt 
b/Documentation/ioctl/ioctl-number.txt
index df1b25e..3e83fe9 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -166,6 +166,7 @@ Code  Seq#(hex) Include FileComments
 'R'00-1F   linux/random.h  conflict!
 'R'01  linux/rfkill.h  conflict!
 'R'C0-DF   net/bluetooth/rfcomm.h
+'R'E0-EF   drivers/staging/fsl-mc/bus/mc-ioctl.h
 'S'all linux/cdrom.h   conflict!
 'S'80-81   scsi/scsi_ioctl.h   conflict!
 'S'82-FF   scsi/scsi.h conflict!
diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 0d779d9..39c6ef9 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -21,4 +21,9 @@ config FSL_MC_BUS
  Only enable this option when building the kernel for
  Freescale QorQIQ LS2 SoCs.
 
-
+config FSL_MC_RESTOOL
+tristate "Freescale Management Complex (MC) restool driver"
+depends on FSL_MC_BUS
+help
+  Driver that provides kernel support for the Freescale Management
+ Complex resource manager user-space tool.
diff --git a/drivers/staging/fsl-mc/bus/Makefile 
b/drivers/staging/fsl-mc/bus/Makefile
index 25433a9..28b5fc0 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -15,3 +15,6 @@ mc-bus-driver-objs := mc-bus.o \
  mc-allocator.o \
  dpmcp.o \
  dpbp.o
+
+# MC restool kernel support
+obj-$(CONFIG_FSL_MC_RESTOOL) += mc-restool.o
diff --git a/drivers/staging/fsl-mc/bus/mc-ioctl.h 
b/drivers/staging/fsl-mc/bus/mc-ioctl.h
new file mode 100644
index 000..8ac502a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-ioctl.h
@@ -0,0 +1,22 @@
+/*
+ * Freescale Management Complex (MC) ioclt interface
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#ifndef _FSL_MC_IOCTL_H_
+#define _FSL_MC_IOCTL_H_
+
+#include 
+#include "../include/mc-sys.h"
+
+#define RESTOOL_IOCTL_TYPE   'R'
+
+#define RESTOOL_SEND_MC_COMMAND \
+   _IOWR(RESTOOL_IOCTL_TYPE, 0xE0, struct mc_command)
+
+#endif /* _FSL_MC_IOCTL_H_ */
diff --git a/drivers/staging/fsl-mc/bus/mc-restool.c 
b/drivers/staging/fsl-mc/bus/mc-restool.c
new file mode 100644
index 000..57f059a
--- /dev/null
+++ b/drivers/staging/fsl-mc/bus/mc-restool.c
@@ -0,0 +1,392 @@
+/*
+ * Freescale Management Complex (MC) restool driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: Lijun Pan 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include "../include/mc-private.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mc-ioctl.h"
+#include "../include/mc-sys.h"
+#include "../include/mc-cmd.h"
+#include "../includ

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

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

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

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

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

Lijun Pan (8):
  staging: fsl-mc: static inline function to differentiate root dprc
  staging: fsl-mc: add sysfs rescan attribute in TODO
  staging: fsl-mc: dprc device's sysfs rescan documentation
  staging: fsl-mc: root dprc rescan attribute to sync kernel with MC
  staging: fsl-mc: fsl-mc bus's sysfs rescan documentation
  staging: fsl-mc: bus rescan attribute to sync kernel with MC
  staging: fsl-mc: update TODO and README for restool driver
  staging: fsl-mc: Management Complex restool driver

 Documentation/ABI/testing/sysfs-bus-fsl-mc   |  11 +
 Documentation/ABI/testing/sysfs-devices-dprc |  13 +
 Documentation/ioctl/ioctl-number.txt |   1 +
 drivers/staging/fsl-mc/README.txt|  11 +-
 drivers/staging/fsl-mc/TODO  |  24 +-
 drivers/staging/fsl-mc/bus/Kconfig   |   7 +-
 drivers/staging/fsl-mc/bus/Makefile  |   3 +
 drivers/staging/fsl-mc/bus/mc-bus.c  | 112 ++--
 drivers/staging/fsl-mc/bus/mc-ioctl.h|  22 ++
 drivers/staging/fsl-mc/bus/mc-restool.c  | 392 +++
 drivers/staging/fsl-mc/include/mc.h  |  14 +
 11 files changed, 587 insertions(+), 23 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsl-mc
 create mode 100644 Documentation/ABI/testing/sysfs-devices-dprc
 create mode 100644 drivers/staging/fsl-mc/bus/mc-ioctl.h
 create mode 100644 drivers/staging/fsl-mc/bus/mc-restool.c

-- 
2.3.3

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


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

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

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

diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 3894368..5065821 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -1,3 +1,9 @@
+* Add sysfs rescan attribute for fsl-mc bus, and dprc device. The rescan will
+  trigger the fsl-mc bus, dprc driver to re-discover the objects under fsl-mc
+  bus and dprc.X container. Hence this feature actually verifies the
+  functionality of fsl-mc bus, and dprc driver, and it helps moving
+  fsl-mc bus out of staging.
+
 * Decide if multiple root fsl-mc buses will be supported per Linux instance,
   and if so add support for this.
 
-- 
2.3.3

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


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

2015-12-11 Thread Lijun Pan
Introduce the rescan attribute as a bus attribute to
synchronize the fsl-mc bus objects and the MC firmware.

To rescan the fsl-mc bus, e.g.,
echo 1 > /sys/bus/fsl-mc/rescan

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

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 61d44fd..f9ee5fe 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -142,11 +142,57 @@ static const struct attribute_group *fsl_mc_dev_groups[] 
= {
NULL,
 };
 
+static int scan_fsl_mc_bus(struct device *dev, void *data)
+{
+   struct fsl_mc_device *root_mc_dev;
+   struct fsl_mc_bus *root_mc_bus;
+
+   if (is_root_dprc(dev)) {
+   root_mc_dev = to_fsl_mc_device(dev);
+   root_mc_bus = to_fsl_mc_bus(root_mc_dev);
+   mutex_lock(&root_mc_bus->scan_mutex);
+   dprc_scan_objects(root_mc_dev);
+   mutex_unlock(&root_mc_bus->scan_mutex);
+   }
+
+   return 0;
+}
+
+static ssize_t bus_rescan_store(struct bus_type *bus,
+   const char *buf, size_t count)
+{
+   unsigned long val;
+
+   if (kstrtoul(buf, 0, &val) < 0)
+   return -EINVAL;
+
+   if (val)
+   bus_for_each_dev(bus, NULL, NULL, scan_fsl_mc_bus);
+
+   return count;
+}
+static BUS_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, bus_rescan_store);
+
+static struct attribute *fsl_mc_bus_attrs[] = {
+   &bus_attr_rescan.attr,
+   NULL,
+};
+
+static const struct attribute_group fsl_mc_bus_group = {
+   .attrs = fsl_mc_bus_attrs,
+};
+
+static const struct attribute_group *fsl_mc_bus_groups[] = {
+   &fsl_mc_bus_group,
+   NULL,
+};
+
 struct bus_type fsl_mc_bus_type = {
.name = "fsl-mc",
.match = fsl_mc_bus_match,
.uevent = fsl_mc_bus_uevent,
.dev_groups = fsl_mc_dev_groups,
+   .bus_groups = fsl_mc_bus_groups,
 };
 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
 
-- 
2.3.3

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


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

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

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

diff --git a/Documentation/ABI/testing/sysfs-devices-dprc 
b/Documentation/ABI/testing/sysfs-devices-dprc
new file mode 100644
index 000..3c5d725
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-dprc
@@ -0,0 +1,13 @@
+What:  /sys/devices/.../dprc.X/rescan
+Date:  October 2015
+Contact:   Lijun Pan 
+Description:
+   Writing a non-zero value to this attribute will
+   force a rescan of dprc.X container in the system, and
+   add/remove previously added/removed objects in
+   Management Complex firmwarer, i.e., synchronize
+   the objects under dprc.X and Management Complex
+   firmware. For example:
+   # echo 1 > /sys/devices/platform/80c00.fsl-mc/dprc.1/rescan
+
+
-- 
2.3.3

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


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

2015-12-11 Thread Lijun Pan
Add more introduction of restool driver and state why
restool driver is needed in helping moving fsl-mc bus
out of staging tree.

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

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/README.txt
index 8214102..e9ec507 100644
--- a/drivers/staging/fsl-mc/README.txt
+++ b/drivers/staging/fsl-mc/README.txt
@@ -130,7 +130,16 @@ the objects involved in creating a network interfaces.
 via a config file passed to the MC when firmware starts
 it.  There is also a Linux user space tool called "restool"
 that can be used to create/destroy containers and objects
-dynamically.
+dynamically. The kernel side restool driver communicates with
+user space restool via ioctl. Restool relies on allocator driver
+to allocate dpmcp resources, enumerates fsl-mc bus to find root dprc
+objects of interest. When the user space restool program sends a request
+to restool driver to create a dp* objects in MC firmware, an interrupt
+will be triggered by MC firmware and the dprc driver's interrupt handler
+shall process the interrupt (synchronizing the objects in MC firmware and
+objects in Linux kernel). Though small, restool driver helps verify all
+the functionality of fsl-mc bus, dprc driver, allocator driver,
+and MC flib API.
 
 -DPAA2 Objects for an Ethernet Network Interface
 
diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
index 5065821..4892eb6 100644
--- a/drivers/staging/fsl-mc/TODO
+++ b/drivers/staging/fsl-mc/TODO
@@ -5,10 +5,24 @@
   fsl-mc bus out of staging.
 
 * Decide if multiple root fsl-mc buses will be supported per Linux instance,
-  and if so add support for this.
+  and if so add support for this. No matter fsl-mc bus support multiple root
+  dprc or not, restool driver is designed to support multiple root if fsl-mc
+  bus is ready some day later. If there is only one root dprc, restool driver
+  works fine.
+
+* Add at least one driver utilizing fsl-mc bus. Restool driver is a very
+  small and simple driver, which interacts with fsl-mc bus, dprc driver,
+  allocator driver. Restool relies on allocator driver to allocate
+  dpmcp resources, enumerates fsl-mc bus to find root dprc objects of interest.
+  When the user space restool program sends a request to restool driver to
+  create a dp* objects in MC firmware, an interrupt will be triggered by
+  MC firmware and the dprc driver's interrupt handler shall process the
+  interrupt. Though small, restool driver helps verify all the functionality
+  of fsl-mc bus, dprc driver, allocator driver, and MC flib API. Restool
+  driver helps in moving fsl-mc bus out of staging branch.
 
 * Add at least one device driver for a DPAA2 object (child device of the
-  fsl-mc bus).  Most likely candidate for this is adding DPAA2 Ethernet
+  fsl-mc bus). Most likely candidate for this is adding DPAA2 Ethernet
   driver support, which depends on drivers for several objects: DPNI,
   DPIO, DPMAC.  Other pre-requisites include:
 
-- 
2.3.3

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


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

2015-12-11 Thread Lijun Pan
Introduce the rescan attribute as a device attribute to
synchronize the fsl-mc bus objects and the MC firmware.

To rescan the root dprc only, e.g.
echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan

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

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 25e205421..61d44fd 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -100,10 +100,53 @@ static int fsl_mc_bus_uevent(struct device *dev, struct 
kobj_uevent_env *env)
return 0;
 }
 
+static ssize_t rescan_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   unsigned long val;
+   struct fsl_mc_device *root_mc_dev;
+   struct fsl_mc_bus *root_mc_bus;
+
+   if (!is_root_dprc(dev))
+   return -EINVAL;
+
+   root_mc_dev = to_fsl_mc_device(dev);
+   root_mc_bus = to_fsl_mc_bus(root_mc_dev);
+
+   if (kstrtoul(buf, 0, &val) < 0)
+   return -EINVAL;
+
+   if (val) {
+   mutex_lock(&root_mc_bus->scan_mutex);
+   dprc_scan_objects(root_mc_dev);
+   mutex_unlock(&root_mc_bus->scan_mutex);
+   }
+
+   return count;
+}
+
+static DEVICE_ATTR_WO(rescan);
+
+static struct attribute *fsl_mc_dev_attrs[] = {
+   &dev_attr_rescan.attr,
+   NULL,
+};
+
+static const struct attribute_group fsl_mc_dev_group = {
+   .attrs = fsl_mc_dev_attrs,
+};
+
+static const struct attribute_group *fsl_mc_dev_groups[] = {
+   &fsl_mc_dev_group,
+   NULL,
+};
+
 struct bus_type fsl_mc_bus_type = {
.name = "fsl-mc",
.match = fsl_mc_bus_match,
.uevent = fsl_mc_bus_uevent,
+   .dev_groups = fsl_mc_dev_groups,
 };
 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
 
-- 
2.3.3

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


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

2015-12-11 Thread Lijun Pan
Define a static inline function is_root_dprc(dev) to tell whether
a device is root dprc or not via platform_bus_type.
Remove fsl_mc_is_root_dprc() because is_root_dprc() is simpler
and easier to understand.

Signed-off-by: Lijun Pan 
---
v2: use static inline function instead of macro
replace the fsl_mc_is_root_dprc with is_root_dprc

 drivers/staging/fsl-mc/bus/mc-bus.c | 22 +++---
 drivers/staging/fsl-mc/include/mc.h | 14 ++
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 84db55b..25e205421 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -22,8 +22,6 @@
 
 static struct kmem_cache *mc_dev_cache;
 
-static bool fsl_mc_is_root_dprc(struct device *dev);
-
 /**
  * fsl_mc_bus_match - device to driver matching callback
  * @dev: the MC object device structure to match against
@@ -52,7 +50,7 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
 * Only exception is the root DPRC, which is a special case.
 */
if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0 &&
-   !fsl_mc_is_root_dprc(&mc_dev->dev))
+   !is_root_dprc(&mc_dev->dev))
goto out;
 
/*
@@ -236,20 +234,6 @@ static void fsl_mc_get_root_dprc(struct device *dev,
}
 }
 
-/**
- * fsl_mc_is_root_dprc - function to check if a given device is a root dprc
- */
-static bool fsl_mc_is_root_dprc(struct device *dev)
-{
-   struct device *root_dprc_dev;
-
-   fsl_mc_get_root_dprc(dev, &root_dprc_dev);
-   if (!root_dprc_dev)
-   return false;
-   else
-   return dev == root_dprc_dev;
-}
-
 static int get_dprc_icid(struct fsl_mc_io *mc_io,
 int container_id, u16 *icid)
 {
@@ -541,7 +525,7 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
mc_dev->mc_io = NULL;
}
 
-   if (fsl_mc_is_root_dprc(&mc_dev->dev)) {
+   if (is_root_dprc(&mc_dev->dev)) {
if (atomic_read(&root_dprc_count) > 0)
atomic_dec(&root_dprc_count);
else
@@ -772,7 +756,7 @@ static int fsl_mc_bus_remove(struct platform_device *pdev)
 {
struct fsl_mc *mc = platform_get_drvdata(pdev);
 
-   if (WARN_ON(!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev)))
+   if (WARN_ON(!is_root_dprc(&mc->root_mc_bus_dev->dev)))
return -EINVAL;
 
fsl_mc_device_remove(mc->root_mc_bus_dev);
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index a933291..6051955 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "../include/dprc.h"
 
 #define FSL_MC_VENDOR_FREESCALE0x1957
@@ -200,4 +201,17 @@ void fsl_mc_object_free(struct fsl_mc_device *mc_adev);
 
 extern struct bus_type fsl_mc_bus_type;
 
+/**
+  * is_root_dprc - tell whether dev is root dprc or not.
+  * root dprc's parent is a platform device,
+  * that platform device's bus type is platform_bus_type.
+  * @dev: MC object device
+  * return 1 on root dprc, 0 otherwise
+  */
+static inline bool is_root_dprc(struct device *dev)
+{
+   return ((to_fsl_mc_device(dev)->flags & FSL_MC_IS_DPRC) &&
+   ((dev)->bus == &fsl_mc_bus_type) &&
+   ((dev)->parent->bus == &platform_bus_type));
+}
 #endif /* _FSL_MC_H_ */
-- 
2.3.3

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


Re: [PATCH] staging: goldfish: Coding Style Fix Comparison to NULL could

2015-12-11 Thread Benjamin Young
On Fri, Dec 11, 2015 at 12:14:17PM +0530, Sudip Mukherjee wrote:
> On Thu, Dec 10, 2015 at 06:31:09PM -0500, Benjamin Young wrote:
> > From 4b8ce6b3bd7effdfff2c95fbeb4a20cb93d5e9e5 Mon Sep 17 00:00:00 2001
> > From: Benjamin Young 
> > Date: Thu, 10 Dec 2015 17:31:00 -0500
> > Subject: [PATCH] staging: goldfish: Coding Style Fix - spaces preferred 
> > around
> >  that '+'
> 
> Regarding all the three patches: The above header information should not
> be here.
> 
> Regarding this patch: This is a repeat of the previous patch with the
> subject of the next patch.
> 
> regards
> sudip

Sorry about the duplicate emails with one having the wrong subject line.  My 
fingers betrayed me and hit
Enter before I was done editing

As for the header information, i will remove it and send out the patches

Thank you again for being so pacient, since i am a noobie to kernel development

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


[PATCH] staging: goldfish: Coding Style Fix - spaces preferred around that '+'

2015-12-11 Thread Benjamin Young
Helped improve coding style to make arithemethic easier to read

Signed-off-by: Benjamin Young 
---
 drivers/staging/goldfish/goldfish_audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/goldfish/goldfish_audio.c 
b/drivers/staging/goldfish/goldfish_audio.c
index b0927e4..f1e1838 100644
--- a/drivers/staging/goldfish/goldfish_audio.c
+++ b/drivers/staging/goldfish/goldfish_audio.c
@@ -63,7 +63,7 @@ struct goldfish_audio {
 #define AUDIO_READ(data, addr) (readl(data->reg_base + addr))
 #define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr))
 #define AUDIO_WRITE64(data, addr, addr2, x)\
-   (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base+addr2))
+   (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base + addr2))
 
 /*
  *  temporary variable used between goldfish_audio_probe() and
-- 
2.5.0

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


[PATCH] staging: goldfish: Coding Style Fix Comparison to NULL could be written "!r"

2015-12-11 Thread Benjamin Young
Fixed coding style for null comparisons in goldfish_audio.c to be more 
consistant
with the rest of the kernel coding style

Signed-off-by: Benjamin Young 
---
 drivers/staging/goldfish/goldfish_audio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/goldfish/goldfish_audio.c 
b/drivers/staging/goldfish/goldfish_audio.c
index f1e1838..364fdcd 100644
--- a/drivers/staging/goldfish/goldfish_audio.c
+++ b/drivers/staging/goldfish/goldfish_audio.c
@@ -280,12 +280,12 @@ static int goldfish_audio_probe(struct platform_device 
*pdev)
platform_set_drvdata(pdev, data);
 
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (r == NULL) {
+   if (!r) {
dev_err(&pdev->dev, "platform_get_resource failed\n");
return -ENODEV;
}
data->reg_base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
-   if (data->reg_base == NULL)
+   if (!data->reg_base)
return -ENOMEM;
 
data->irq = platform_get_irq(pdev, 0);
@@ -295,7 +295,7 @@ static int goldfish_audio_probe(struct platform_device 
*pdev)
}
data->buffer_virt = dmam_alloc_coherent(&pdev->dev,
COMBINED_BUFFER_SIZE, &buf_addr, GFP_KERNEL);
-   if (data->buffer_virt == NULL) {
+   if (!data->buffer_virt) {
dev_err(&pdev->dev, "allocate buffer failed\n");
return -ENOMEM;
}
-- 
2.5.0

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


Re: [PATCH v4 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Boris Brezillon
Hi Brian,

On Thu, 10 Dec 2015 16:40:08 -0800
Brian Norris  wrote:

> On Thu, Dec 10, 2015 at 08:59:45AM +0100, Boris Brezillon wrote:
> > Unregister the NAND device from the NAND subsystem when removing a denali
> > NAND controller, otherwise the MTD attached to the NAND device is still
> > exposed by the MTD layer, and accesses to this device will likely crash
> > the system.
> > 
> > Signed-off-by: Boris Brezillon 
> > Cc:  #3.8+
> 
> Does this follow these rules, from
> Documentation/stable_kernel_rules.txt?
> 
>  - It must be obviously correct and tested.
> 
>  - It must fix a real bug that bothers people (not a, "This could be a
>problem..." type thing).

Sorry to bring the "stable or not stable (that is the question :-))"
debate back, but after thinking a bit more about the implications of
this missing nand_release() call, I think it is worth backporting the
fix to all stable kernels.
The reason is, it can potentially introduce a security hole, because if
the mtd device is not unregister but the underlying mtd object is freed
and the kernel reuses the same memory region for a different object,
the MTD layer will possibly call one of the mtd->_method() function,
and this field might point to another completely different function.

You'll say that denali devices are probably never removed and this is
the reason why people have never seen this problem before, which would
be a good reason to not bother backporting the patch.
But, given that the driver can be compiled as a module (the user can
possibly load/unload it, which will in turn create/destroy the
NAND/MTD device), and that the denali controller can be exposed through
a PCI bus (which, AFAIK is hotpluggable), I really think this fix
should be sent to stable.

Best Regards,

Boris

> 
> > Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer")
> > ---
> >  drivers/mtd/nand/denali.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> > index 67eb2be..8feece3 100644
> > --- a/drivers/mtd/nand/denali.c
> > +++ b/drivers/mtd/nand/denali.c
> > @@ -1622,6 +1622,7 @@ EXPORT_SYMBOL(denali_init);
> >  /* driver exit point */
> >  void denali_remove(struct denali_nand_info *denali)
> >  {
> > +   nand_release(&denali->mtd);
> > denali_irq_cleanup(denali->irq, denali);
> > dma_unmap_single(denali->dev, denali->buf.dma_buf,
> >  denali->mtd.writesize + denali->mtd.oobsize,
> 
> It feels a bit odd to allow usage of MTD fields after it has been
> unregistered. Maybe precompute this before the nand_release()?
> 
> Brian



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 01/58] mtd: nand: denali: add missing nand_release() call in denali_remove()

2015-12-11 Thread Brian Norris
Hi Boris,

On Fri, Dec 11, 2015 at 11:03:05PM +0100, Boris Brezillon wrote:
> On Thu, 10 Dec 2015 16:40:08 -0800
> Brian Norris  wrote:
> > On Thu, Dec 10, 2015 at 08:59:45AM +0100, Boris Brezillon wrote:
> > > Unregister the NAND device from the NAND subsystem when removing a denali
> > > NAND controller, otherwise the MTD attached to the NAND device is still
> > > exposed by the MTD layer, and accesses to this device will likely crash
> > > the system.
> > > 
> > > Signed-off-by: Boris Brezillon 
> > > Cc:  #3.8+
> > 
> > Does this follow these rules, from
> > Documentation/stable_kernel_rules.txt?
> > 
> >  - It must be obviously correct and tested.
> > 
> >  - It must fix a real bug that bothers people (not a, "This could be a
> >problem..." type thing).
> 
> Sorry to bring the "stable or not stable (that is the question :-))"
> debate back, but after thinking a bit more about the implications of
> this missing nand_release() call, I think it is worth backporting the
> fix to all stable kernels.
> The reason is, it can potentially introduce a security hole, because if
> the mtd device is not unregister but the underlying mtd object is freed
> and the kernel reuses the same memory region for a different object,
> the MTD layer will possibly call one of the mtd->_method() function,
> and this field might point to another completely different function.
> 
> You'll say that denali devices are probably never removed and this is
> the reason why people have never seen this problem before, which would
> be a good reason to not bother backporting the patch.
> But, given that the driver can be compiled as a module (the user can
> possibly load/unload it, which will in turn create/destroy the
> NAND/MTD device), and that the denali controller can be exposed through
> a PCI bus (which, AFAIK is hotpluggable), I really think this fix
> should be sent to stable.

That's all well and good, but still nobody has told me they've tested
this.

I've pushed your v5 (+ comments, + ack) to l2-mtd.git. If it gets
testing and this request is made again at that point, we can easily send
it to stable after it hits Linus' tree. See option 2 in
Documentation/stable_kernel_rules.txt. You can even send the email
yourself, just CC me and anyone else relevant. I'll ack it if it's been
tested.

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


very urgent business proposal

2015-12-11 Thread Mr. Akinwumi Godson Fanimokun
Mr. Akinwumi Godson Fanimokun
Group Executive, Technology & Services
First Bank of Nigerian Plc


Dearest,

My name is Mr. Akinwumi Godson Fanimokun,Group Executive, Technology & Services 
 First Bank of Nigerian Plc. based in Nigeria.  I am  writing in respect of a 
foreign customer of our Financial Firm with Deposit Code: XXMD-908-14-255-114 
whose name is  Eng. Ahmed Mohd Elshami, an Egyptian citizen and a Federal 
Contractor with the Federal Governments of Nigeria and  Egypt.

My client lost his life along with his wife, daughter and several others in a 
tragic air accident in Abuja - Nigeria.  Since the death of this customer, I 
personally have watched with keen interest to see the next of kin but all has 
proved abortive as no one has come to claim his funds of US$25,500,000.00 
(Twenty Five Million, Five Hundred Thousand US Dollars) which  has been with 
our branch for a very long time.

On this note, I decided to seek for whom his name shall be used as the Next of 
Kin as no one has come up as his next of kin.  In view of this I got your 
contact through a trade journal on my quest for a foreign business partner, who 
will be presented to the financial firm as the next of kin to the deceased 
client to enable them release the fund in your favour.

For your assistant I am willing to give you 40% of the total amount, 10% to 
cover all expenses and 50% for me and my family.  Upon the receipt of your 
response, I will send you by fax the letter of application which you will type 
sign and send to the First Bank of Nigerian Plc to enable us start the 
processing of this claim.  I will not fail to bring to your notice that this 
business is problem free process and shall be carried out under legitimate 
procedure without breaching any of the International Law, in other words, you 
should not entertain any fear as all modality for the smooth and easy transfer 
of this fund has been finalized.

Please take note my wife is the only one that I have discussed this business 
with and we both agreed to do it with you, I will give you more explanation on 
this transaction, feel free to send email to me.

When you receive this letter, kindly send me an email for more explanation, 
please include your private Tel/Fax numbers in your correspondence to 
facilitate communication.

Yours Sincerely,

Mr. Akinwumi Godson Fanimokun
Group Executive, Technology & Services
First Bank of Nigerian Plc.

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


RE: [PATCH V2 02/10] Drivers: hv: utils: run polling callback always in interrupt context

2015-12-11 Thread KY Srinivasan


> -Original Message-
> From: Dexuan Cui
> Sent: Thursday, December 10, 2015 11:33 PM
> To: KY Srinivasan ; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; vkuzn...@redhat.com; jasow...@redhat.com
> Subject: RE: [PATCH V2 02/10] Drivers: hv: utils: run polling callback always 
> in
> interrupt context
> 
> > -Original Message-
> > From: KY Srinivasan
> > Sent: Friday, December 11, 2015 7:23
> > > It looks the patch has not been Greg's tree yet.
> > >
> > > I have 2 questions about the patch:
> > >
> > > 1. hv_poll_channel() is invoked in fcopy_handle_handshake(), but not in
> > > vss_handle_handshake() and kvp_handle_handshake().
> > > Why -- I guess we missed the vss/kvp cases somehow?
> > I will fix this.
> 
> Thanks, KY!
> BTW, I fixed another small issue by https://lkml.org/lkml/2015/12/10/50
> (The mail is attached for your convenience)

I will pick this up.

> 
> > > 2.  With the patch, hv_fcopy_onchannelcallback() can be invoked in the
> > > tasklet (i.e., vmbus_on_event(). NB: local irq is enabled), and in the
> > > hard irq handler(the IPI handler, e.g.,
> > > fcopy_poll_wrapper() -> fcopy_poll_wrapper()).
> > >
> > > Can the former be interrupted by the latter?
> > > e.g., when the callback is running in the tasklet on vCPU0,
> > > fcopy_timeout_func() or fcopy_on_msg() could send the IPI to
> > > vCPU0 from another vCPU.
> >
> > Keep in mind that when the poll function is run, the state will not be
> > HVUTIL_READY. The state will be set to HVUTIL_READY in the IPI
> > handler. So, it is ok if the tasklet is interrupted by the IPI handler.
> >
> > K. Y
> 
> Got it.
> 
> BTW, in fcopy_handle_handshake(), IMO the line
> fcopy_transaction.state = HVUTIL_READY;
> just before
> hv_poll_channel(fcopy_transaction.recv_channel, fcopy_poll_wrapper);
> should be removed? Because in fcopy_poll_wrapper() we always have
> the same line.
> 
> Ditto for kvp/vss.
> 
> Thanks,

I will fix this and resend.

Thanks,

K. Y
> -- Dexuan

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


[PATCH v2 1/6] staging/lustre: Silence warning about 'inline'

2015-12-11 Thread Valdis Kletnieks
Low-hanging fruit first:

  CC [M]  drivers/staging/lustre/lustre/fid/fid_request.o
In file included from 
drivers/staging/lustre/lustre/fid/../include/lustre_net.h:66:0,
 from 
drivers/staging/lustre/lustre/fid/../include/lustre_lib.h:64,
 from drivers/staging/lustre/lustre/fid/../include/obd.h:52,
 from drivers/staging/lustre/lustre/fid/fid_request.c:48:
drivers/staging/lustre/lustre/fid/../include/lu_object.h:765:1: warning: 
'inline' is not at beginning of declaration [-Wold-style-declaration]
 static const inline struct lu_device_operations *
 ^

So we just swap inline and const.  272 warnings gone. :)

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/lustre/lustre/include/lu_object.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/include/lu_object.h 
b/drivers/staging/lustre/lustre/include/lu_object.h
index fa78689748a9..176724f60c1b 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -756,7 +756,7 @@ static inline const struct lu_fid *lu_object_fid(const 
struct lu_object *o)
 /**
  * return device operations vector for this object
  */
-static const inline struct lu_device_operations *
+static inline const struct lu_device_operations *
 lu_object_ops(const struct lu_object *o)
 {
return o->lo_dev->ld_ops;
-- 
2.6.3

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


[PATCH v2 4/6] Fix another C compiler whine: set but not used

2015-12-11 Thread Valdis Kletnieks
  CC [M]  drivers/staging/lustre/lustre/libcfs/module.o
drivers/staging/lustre/lustre/libcfs/module.c: In function 
'lustre_insert_debugfs':
drivers/staging/lustre/lustre/libcfs/module.c:670:17: warning: variable 'entry' 
set but not used [-Wunused-but-set-variable]
  struct dentry *entry;
 ^

Just ignore the dentry returned, and add a comment that we *know*
we're not really leaking the dentry because something else will be able
to reap it via recursion.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/lustre/lustre/libcfs/module.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/module.c 
b/drivers/staging/lustre/lustre/libcfs/module.c
index 96d9d4651a51..4438dc426b54 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -667,8 +667,6 @@ static const struct file_operations 
lnet_debugfs_file_operations = {
 void lustre_insert_debugfs(struct ctl_table *table,
   const struct lnet_debugfs_symlink_def *symlinks)
 {
-   struct dentry *entry;
-
if (lnet_debugfs_root == NULL)
lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
 
@@ -676,15 +674,17 @@ void lustre_insert_debugfs(struct ctl_table *table,
if (IS_ERR_OR_NULL(lnet_debugfs_root))
return;
 
+   /* We don't save the dentry returned in next two calls, because
+* we don't call debugfs_remove() but rather remove_recursive()
+*/
for (; table->procname; table++)
-   entry = debugfs_create_file(table->procname, table->mode,
-   lnet_debugfs_root, table,
-   &lnet_debugfs_file_operations);
+   debugfs_create_file(table->procname, table->mode,
+   lnet_debugfs_root, table,
+   &lnet_debugfs_file_operations);
 
for (; symlinks && symlinks->name; symlinks++)
-   entry = debugfs_create_symlink(symlinks->name,
-  lnet_debugfs_root,
-  symlinks->target);
+   debugfs_create_symlink(symlinks->name, lnet_debugfs_root,
+  symlinks->target);
 
 }
 EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
-- 
2.6.3

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


[PATCH v2 2/6] Fix set-but-unused whinge.

2015-12-11 Thread Valdis Kletnieks
drivers/staging/lustre/lustre/fid/lproc_fid.c: In function 
'ldebugfs_fid_write_common':
drivers/staging/lustre/lustre/fid/lproc_fid.c:67:6: warning: variable 'rc' set 
but not used [-Wunused-but-set-variable]
  int rc;

We fix it by *using* the return code to help bulletproof it.  It says it's
test code - it should be *more* bulletproof than production, not less.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/lustre/lustre/fid/lproc_fid.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c 
b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index ce90c1c54a63..eff011f30fa5 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -85,6 +85,8 @@ ldebugfs_fid_write_common(const char __user *buffer, size_t 
count,
rc = sscanf(kernbuf, "[%llx - %llx]\n",
(unsigned long long *)&tmp.lsr_start,
(unsigned long long *)&tmp.lsr_end);
+   if (rc != 2)
+   return -EINVAL;
if (!range_is_sane(&tmp) || range_is_zero(&tmp) ||
tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end)
return -EINVAL;
-- 
2.6.3

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


[PATCH v2 5/6] Nuke an unsigned >= 0 assert

2015-12-11 Thread Valdis Kletnieks
Writing asserts for almost-never-can-happen things can be valuable.
Writing an assert that tests that an "unsigned int" hasn't gone negative
isn't.

And it generates an *ugly* message:

drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of 
unsigned expression >= 0 is always true [-Wtype-limits]
  LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
^
include/linux/compiler.h:137:45: note: in definition of macro 'unlikely'
 #  define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 
0))
 ^
drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 
'LASSERTF'
  LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
  ^
drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of 
unsigned expression >= 0 is always true [-Wtype-limits]
  LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
^
include/linux/compiler.h:137:53: note: in definition of macro 'unlikely'
 #  define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 
0))
 ^
drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 
'LASSERTF'
  LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
  ^
drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of 
unsigned expression >= 0 is always true [-Wtype-limits]
  LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
^
include/linux/compiler.h:110:47: note: in definition of macro 'likely_notrace'
 #define likely_notrace(x) __builtin_expect(!!(x), 1)
   ^
include/linux/compiler.h:137:58: note: in expansion of macro '__branch_check__'
 #  define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 
0))
  ^
drivers/staging/lustre/lustre/llite/../include/linux/../../../include/linux/libcfs/libcfs_private.h:58:6:
 note: in expansion of macro 'unlikely'
  if (unlikely(!(cond))) { \
  ^
drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 
'LASSERTF'
  LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
  ^

Umm, thank you, GCC.  We'll delete the problem line so we never see that spew 
again.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/lustre/lustre/llite/rw.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/llite/rw.c 
b/drivers/staging/lustre/lustre/llite/rw.c
index f79193fa2fb7..39390aab9da2 100644
--- a/drivers/staging/lustre/lustre/llite/rw.c
+++ b/drivers/staging/lustre/lustre/llite/rw.c
@@ -764,7 +764,6 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io,
ret = ll_read_ahead_pages(env, io, queue,
  ria, &reserved, mapping, &ra_end);
 
-   LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
if (reserved != 0)
ll_ra_count_put(ll_i2sbi(inode), reserved);
 
-- 
2.6.3

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


[PATCH v2 0/6] Patch series to make lustre safe(r) for W=1 compiles

2015-12-11 Thread Valdis Kletnieks
Start of a batch series to clean up the Lustre tree. Other people have
done some sparse and checkpatch cleanups, but I found a bunch of
stuff building with W=1. There's probably more, but this was the
really low-hanging obvious fruit.

Valdis Kletnieks (6):
  staging/lustre: Silence warning about 'inline'
  staging/lustre: Fix set-but-unused whinge.
  staging/lustre: Clean up another C warnining: set but not used
  staging/lustre: Fix another C compiler whine: set but not used
  staging/lustre: Nuke an unsigned >= 0 assert
  staging/lustre: Nuke another unsigned >= 0 assert

 drivers/staging/lustre/lustre/fid/lproc_fid.c  |  1 +
 drivers/staging/lustre/lustre/include/lu_object.h  |  2 +-
 drivers/staging/lustre/lustre/include/lustre_cfg.h |  4 --
 drivers/staging/lustre/lustre/libcfs/module.c  | 15 
 drivers/staging/lustre/lustre/llite/rw.c   |  1 -
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c|  1 -
 6 files changed, 9 insertions(+), 15 deletions(-)

-- 
2.6.3

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


[PATCH v2 6/6] Nuke another unsigned >= 0 assert

2015-12-11 Thread Valdis Kletnieks
Clean up another case of the compiler remininding the programmer they
are an idiot:

drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c:308:34: warning: comparison of 
unsigned expression >= 0 is always true [-Wtype-limits]
  LASSERT(page_pools.epp_waitqlen >= 0);

Just lose the assert, and save a page of compiler spew.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index cd8a9987f7ac..1f326673f089 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
@@ -304,7 +304,6 @@ static unsigned long enc_pools_cleanup(struct page 
***pools, int npools)
 static inline void enc_pools_wakeup(void)
 {
assert_spin_locked(&page_pools.epp_lock);
-   LASSERT(page_pools.epp_waitqlen >= 0);
 
if (unlikely(page_pools.epp_waitqlen)) {
LASSERT(waitqueue_active(&page_pools.epp_waitq));
-- 
2.6.3

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


[PATCH v2 3/6] Clean up another C warnining: set but not used

2015-12-11 Thread Valdis Kletnieks
drivers/staging/lustre/lustre/fid/../include/lustre_cfg.h: In function 
'lustre_cfg_free':
drivers/staging/lustre/lustre/fid/../include/lustre_cfg.h:253:6: warning: 
variable 'len' set but not used [-Wunused-but-set-variable]
  int len;

Yep, we're just gonna call kfree, no need to calculate len. Bye-bye.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/lustre/lustre/include/lustre_cfg.h |  4 --
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h 
b/drivers/staging/lustre/lustre/include/lustre_cfg.h
index eb6b292b7b25..d30d8b054c92 100644
--- a/drivers/staging/lustre/lustre/include/lustre_cfg.h
+++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h
@@ -252,10 +252,6 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd,
 
 static inline void lustre_cfg_free(struct lustre_cfg *lcfg)
 {
-   int len;
-
-   len = lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens);
-
kfree(lcfg);
return;
 }
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 00/27] Drivers: hv: Miscellaneous fixes.

2015-12-11 Thread K. Y. Srinivasan
Most of the patches in this set are being resent.

Andrey Smetanin (2):
  drivers/hv: cleanup synic msrs if vmbus connect failed
  drivers/hv: correct tsc page sequence invalid value

Dexuan Cui (6):
  Drivers: hv: vmbus: serialize process_chn_event() and
vmbus_close_internal()
  Drivers: hv: vmbus: do sanity check of channel state in
vmbus_close_internal()
  Drivers: hv: vmbus: fix rescind-offer handling for device without a
driver
  Drivers: hv: vmbus: release relid on error in vmbus_process_offer()
  Drivers: hv: vmbus: channge vmbus_connection.channel_lock to mutex
  tools: hv: vss: fix the write()'s argument: error -> vss_msg

Jake Oshins (4):
  drivers:hv: Export a function that maps Linux CPU num onto Hyper-V
proc num
  drivers:hv: Export the API to invoke a hypercall on Hyper-V
  drivers:hv: Define the channel type for Hyper-V PCI Express
pass-through
  drivers:hv: Allow for MMIO claims that span ACPI _CRS records

K. Y. Srinivasan (8):
  Drivers: hv: util: Increase the timeout for util services
  Drivers: hv: vmbus: Use uuid_le type consistently
  Drivers: hv: vmbus: Use uuid_le_cmp() for comparing GUIDs
  Drivers: hv: vmbus: Get rid of the unused macro
  Drivers: hv: vmbus: Get rid of the unused irq variable
  Drivers: hv: vmbus: Fix a Host signaling bug
  Drivers: hv: vmbus: Force all channel messages to be delivered on CPU
0
  Drivers: hv: utils: Invoke the poll function after handshake

Kamal Mostafa (1):
  tools/hv: Use include/uapi with __EXPORTED_HEADERS__

Olaf Hering (6):
  Drivers: hv: utils: run polling callback always in interrupt context
  tools: hv: report ENOSPC errors in hv_fcopy_daemon
  tools: hv: remove repeated HV_FCOPY string
  Drivers: hv: util: catch allocation errors
  Drivers: hv: utils: use memdup_user in hvt_op_write
  Drivers: hv: vss: run only on supported host versions

 drivers/hv/channel.c|   57 +++---
 drivers/hv/channel_mgmt.c   |   45 +-
 drivers/hv/connection.c |   18 +++---
 drivers/hv/hv.c |   24 
 drivers/hv/hv_fcopy.c   |   37 +---
 drivers/hv/hv_kvp.c |   33 --
 drivers/hv/hv_snapshot.c|   36 +--
 drivers/hv/hv_utils_transport.c |   18 +++---
 drivers/hv/hyperv_vmbus.h   |   15 +++--
 drivers/hv/vmbus_drv.c  |   82 +++--
 include/linux/hyperv.h  |  123 ++-
 include/linux/mod_devicetable.h |2 +-
 include/uapi/linux/hyperv.h |1 +
 scripts/mod/file2alias.c|2 +-
 tools/hv/Makefile   |2 +
 tools/hv/hv_fcopy_daemon.c  |   24 ++--
 tools/hv/hv_vss_daemon.c|2 +-
 17 files changed, 292 insertions(+), 229 deletions(-)

-- 
1.7.4.1

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


[PATCH RESEND 01/27] Drivers: hv: util: Increase the timeout for util services

2015-12-11 Thread K. Y. Srinivasan
Util services such as KVP and FCOPY need assistance from daemon's running
in user space. Increase the timeout so we don't prematurely terminate
the transaction in the kernel. Host sets up a 60 second timeout for
all util driver transactions. The host will retry the transaction if it
times out. Set the guest timeout at 30 seconds.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_fcopy.c |3 ++-
 drivers/hv/hv_kvp.c   |3 ++-
 drivers/hv/hyperv_vmbus.h |5 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
index db4b887..bbdec50 100644
--- a/drivers/hv/hv_fcopy.c
+++ b/drivers/hv/hv_fcopy.c
@@ -275,7 +275,8 @@ void hv_fcopy_onchannelcallback(void *context)
 * Send the information to the user-level daemon.
 */
schedule_work(&fcopy_send_work);
-   schedule_delayed_work(&fcopy_timeout_work, 5*HZ);
+   schedule_delayed_work(&fcopy_timeout_work,
+ HV_UTIL_TIMEOUT * HZ);
return;
}
icmsghdr->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE;
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index 74c38a9..e6aa33a 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -668,7 +668,8 @@ void hv_kvp_onchannelcallback(void *context)
 * user-mode not responding.
 */
schedule_work(&kvp_sendkey_work);
-   schedule_delayed_work(&kvp_timeout_work, 5*HZ);
+   schedule_delayed_work(&kvp_timeout_work,
+ HV_UTIL_TIMEOUT * HZ);
 
return;
 
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 3782636..225b96b 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -31,6 +31,11 @@
 #include 
 
 /*
+ * Timeout for services such as KVP and fcopy.
+ */
+#define HV_UTIL_TIMEOUT 30
+
+/*
  * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
  * is set by CPUID(HVCPUID_VERSION_FEATURES).
  */
-- 
1.7.4.1

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


[PATCH RESEND 03/27] tools: hv: report ENOSPC errors in hv_fcopy_daemon

2015-12-11 Thread K. Y. Srinivasan
From: Olaf Hering 

Currently some "Unspecified error 0x80004005" is reported on the Windows
side if something fails. Handle the ENOSPC case and return
ERROR_DISK_FULL, which allows at least Copy-VMFile to report a meaning
full error.

Signed-off-by: Olaf Hering 
Signed-off-by: K. Y. Srinivasan 
---
 include/uapi/linux/hyperv.h |1 +
 tools/hv/hv_fcopy_daemon.c  |   20 +---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h
index e4c0a35..e347b24 100644
--- a/include/uapi/linux/hyperv.h
+++ b/include/uapi/linux/hyperv.h
@@ -313,6 +313,7 @@ enum hv_kvp_exchg_pool {
 #define HV_INVALIDARG  0x80070057
 #define HV_GUID_NOTFOUND   0x80041002
 #define HV_ERROR_ALREADY_EXISTS0x80070050
+#define HV_ERROR_DISK_FULL 0x80070070
 
 #define ADDR_FAMILY_NONE   0x00
 #define ADDR_FAMILY_IPV4   0x01
diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index 5480e4e..f1d7426 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -37,12 +37,14 @@
 
 static int target_fd;
 static char target_fname[W_MAX_PATH];
+static unsigned long long filesize;
 
 static int hv_start_fcopy(struct hv_start_fcopy *smsg)
 {
int error = HV_E_FAIL;
char *q, *p;
 
+   filesize = 0;
p = (char *)smsg->path_name;
snprintf(target_fname, sizeof(target_fname), "%s/%s",
 (char *)smsg->path_name, (char *)smsg->file_name);
@@ -98,14 +100,26 @@ done:
 static int hv_copy_data(struct hv_do_fcopy *cpmsg)
 {
ssize_t bytes_written;
+   int ret = 0;
 
bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size,
cpmsg->offset);
 
-   if (bytes_written != cpmsg->size)
-   return HV_E_FAIL;
+   filesize += cpmsg->size;
+   if (bytes_written != cpmsg->size) {
+   switch (errno) {
+   case ENOSPC:
+   ret = HV_ERROR_DISK_FULL;
+   break;
+   default:
+   ret = HV_E_FAIL;
+   break;
+   }
+   syslog(LOG_ERR, "pwrite failed to write %llu bytes: %ld (%s)",
+  filesize, (long)bytes_written, strerror(errno));
+   }
 
-   return 0;
+   return ret;
 }
 
 static int hv_copy_finished(void)
-- 
1.7.4.1

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


[PATCH RESEND 15/27] Drivers: hv: vmbus: Get rid of the unused irq variable

2015-12-11 Thread K. Y. Srinivasan
The irq we extract from ACPI is not used - we deliver hypervisor
interrupts on a special vector. Make the necessary adjustments.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/vmbus_drv.c |   16 +++-
 1 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 9e0e25c..ab888a1 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -47,7 +47,6 @@ static struct acpi_device  *hv_acpi_dev;
 
 static struct tasklet_struct msg_dpc;
 static struct completion probe_event;
-static int irq;
 
 
 static void hyperv_report_panic(struct pt_regs *regs)
@@ -835,10 +834,9 @@ static void vmbus_isr(void)
  * Here, we
  * - initialize the vmbus driver context
  * - invoke the vmbus hv main init routine
- * - get the irq resource
  * - retrieve the channel offers
  */
-static int vmbus_bus_init(int irq)
+static int vmbus_bus_init(void)
 {
int ret;
 
@@ -1033,9 +1031,6 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *ctx)
struct resource **prev_res = NULL;
 
switch (res->type) {
-   case ACPI_RESOURCE_TYPE_IRQ:
-   irq = res->data.irq.interrupts[0];
-   return AE_OK;
 
/*
 * "Address" descriptors are for bus windows. Ignore
@@ -1294,7 +1289,7 @@ static int __init hv_acpi_init(void)
init_completion(&probe_event);
 
/*
-* Get irq resources first.
+* Get ACPI resources first.
 */
ret = acpi_bus_register_driver(&vmbus_acpi_driver);
 
@@ -1307,12 +1302,7 @@ static int __init hv_acpi_init(void)
goto cleanup;
}
 
-   if (irq <= 0) {
-   ret = -ENODEV;
-   goto cleanup;
-   }
-
-   ret = vmbus_bus_init(irq);
+   ret = vmbus_bus_init();
if (ret)
goto cleanup;
 
-- 
1.7.4.1

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


[PATCH RESEND 04/27] tools: hv: remove repeated HV_FCOPY string

2015-12-11 Thread K. Y. Srinivasan
From: Olaf Hering 

HV_FCOPY is already used as identifier in syslog.

Signed-off-by: Olaf Hering 
Signed-off-by: K. Y. Srinivasan 
---
 tools/hv/hv_fcopy_daemon.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index f1d7426..fdc9ca4 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -179,7 +179,7 @@ int main(int argc, char *argv[])
}
 
openlog("HV_FCOPY", 0, LOG_USER);
-   syslog(LOG_INFO, "HV_FCOPY starting; pid is:%d", getpid());
+   syslog(LOG_INFO, "starting; pid is:%d", getpid());
 
fcopy_fd = open("/dev/vmbus/hv_fcopy", O_RDWR);
 
@@ -215,7 +215,7 @@ int main(int argc, char *argv[])
}
kernel_modver = *(__u32 *)buffer;
in_handshake = 0;
-   syslog(LOG_INFO, "HV_FCOPY: kernel module version: %d",
+   syslog(LOG_INFO, "kernel module version: %d",
   kernel_modver);
continue;
}
-- 
1.7.4.1

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


[PATCH RESEND 05/27] Drivers: hv: util: catch allocation errors

2015-12-11 Thread K. Y. Srinivasan
From: Olaf Hering 

Catch allocation errors in hvutil_transport_send.

Fixes: 14b50f80c32d ('Drivers: hv: util: introduce hv_utils_transport 
abstraction')

Signed-off-by: Olaf Hering 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_utils_transport.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 6a9d80a..1505ee6 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -204,9 +204,12 @@ int hvutil_transport_send(struct hvutil_transport *hvt, 
void *msg, int len)
goto out_unlock;
}
hvt->outmsg = kzalloc(len, GFP_KERNEL);
-   memcpy(hvt->outmsg, msg, len);
-   hvt->outmsg_len = len;
-   wake_up_interruptible(&hvt->outmsg_q);
+   if (hvt->outmsg) {
+   memcpy(hvt->outmsg, msg, len);
+   hvt->outmsg_len = len;
+   wake_up_interruptible(&hvt->outmsg_q);
+   } else
+   ret = -ENOMEM;
 out_unlock:
mutex_unlock(&hvt->outmsg_lock);
return ret;
-- 
1.7.4.1

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


[PATCH RESEND 17/27] Drivers: hv: vmbus: do sanity check of channel state in vmbus_close_internal()

2015-12-11 Thread K. Y. Srinivasan
From: Dexuan Cui 

This fixes an incorrect assumption of channel state in the function.

Signed-off-by: Dexuan Cui 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index f7f3d5c..00e1be7 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -512,6 +512,18 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
tasklet = hv_context.event_dpc[channel->target_cpu];
tasklet_disable(tasklet);
 
+   /*
+* In case a device driver's probe() fails (e.g.,
+* util_probe() -> vmbus_open() returns -ENOMEM) and the device is
+* rescinded later (e.g., we dynamically disble an Integrated Service
+* in Hyper-V Manager), the driver's remove() invokes vmbus_close():
+* here we should skip most of the below cleanup work.
+*/
+   if (channel->state != CHANNEL_OPENED_STATE) {
+   ret = -EINVAL;
+   goto out;
+   }
+
channel->state = CHANNEL_OPEN_STATE;
channel->sc_creation_callback = NULL;
/* Stop callback and cancel the timer asap */
-- 
1.7.4.1

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


[PATCH RESEND 02/27] Drivers: hv: utils: run polling callback always in interrupt context

2015-12-11 Thread K. Y. Srinivasan
From: Olaf Hering 

All channel interrupts are bound to specific VCPUs in the guest
at the point channel is created. While currently, we invoke the
polling function on the correct CPU (the CPU to which the channel
is bound to) in some cases we may run the polling function in
a non-interrupt context. This  potentially can cause an issue as the
polling function can be interrupted by the channel callback function.
Fix the issue by running the polling function on the appropriate CPU
at interrupt level. Additional details of the issue being addressed by
this patch are given below:

Currently hv_fcopy_onchannelcallback is called from interrupts and also
via the ->write function of hv_utils. Since the used global variables to
maintain state are not thread safe the state can get out of sync.
This affects the variable state as well as the channel inbound buffer.

As suggested by KY adjust hv_poll_channel to always run the given
callback on the cpu which the channel is bound to. This avoids the need
for locking because all the util services are single threaded and only
one transaction is active at any given point in time.

Additionally, remove the context variable, they will always be the same as
recv_channel.

Signed-off-by: Olaf Hering 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_fcopy.c |   34 --
 drivers/hv/hv_kvp.c   |   28 ++--
 drivers/hv/hv_snapshot.c  |   29 +++--
 drivers/hv/hyperv_vmbus.h |6 +-
 4 files changed, 34 insertions(+), 63 deletions(-)

diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
index bbdec50..c37a71e 100644
--- a/drivers/hv/hv_fcopy.c
+++ b/drivers/hv/hv_fcopy.c
@@ -51,7 +51,6 @@ static struct {
struct hv_fcopy_hdr  *fcopy_msg; /* current message */
struct vmbus_channel *recv_channel; /* chn we got the request */
u64 recv_req_id; /* request ID. */
-   void *fcopy_context; /* for the channel callback */
 } fcopy_transaction;
 
 static void fcopy_respond_to_host(int error);
@@ -67,6 +66,13 @@ static struct hvutil_transport *hvt;
  */
 static int dm_reg_value;
 
+static void fcopy_poll_wrapper(void *channel)
+{
+   /* Transaction is finished, reset the state here to avoid races. */
+   fcopy_transaction.state = HVUTIL_READY;
+   hv_fcopy_onchannelcallback(channel);
+}
+
 static void fcopy_timeout_func(struct work_struct *dummy)
 {
/*
@@ -74,13 +80,7 @@ static void fcopy_timeout_func(struct work_struct *dummy)
 * process the pending transaction.
 */
fcopy_respond_to_host(HV_E_FAIL);
-
-   /* Transaction is finished, reset the state. */
-   if (fcopy_transaction.state > HVUTIL_READY)
-   fcopy_transaction.state = HVUTIL_READY;
-
-   hv_poll_channel(fcopy_transaction.fcopy_context,
-   hv_fcopy_onchannelcallback);
+   hv_poll_channel(fcopy_transaction.recv_channel, fcopy_poll_wrapper);
 }
 
 static int fcopy_handle_handshake(u32 version)
@@ -108,9 +108,7 @@ static int fcopy_handle_handshake(u32 version)
return -EINVAL;
}
pr_debug("FCP: userspace daemon ver. %d registered\n", version);
-   fcopy_transaction.state = HVUTIL_READY;
-   hv_poll_channel(fcopy_transaction.fcopy_context,
-   hv_fcopy_onchannelcallback);
+   hv_poll_channel(fcopy_transaction.recv_channel, fcopy_poll_wrapper);
return 0;
 }
 
@@ -227,15 +225,8 @@ void hv_fcopy_onchannelcallback(void *context)
int util_fw_version;
int fcopy_srv_version;
 
-   if (fcopy_transaction.state > HVUTIL_READY) {
-   /*
-* We will defer processing this callback once
-* the current transaction is complete.
-*/
-   fcopy_transaction.fcopy_context = context;
+   if (fcopy_transaction.state > HVUTIL_READY)
return;
-   }
-   fcopy_transaction.fcopy_context = NULL;
 
vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen,
 &requestid);
@@ -305,9 +296,8 @@ static int fcopy_on_msg(void *msg, int len)
if (cancel_delayed_work_sync(&fcopy_timeout_work)) {
fcopy_transaction.state = HVUTIL_USERSPACE_RECV;
fcopy_respond_to_host(*val);
-   fcopy_transaction.state = HVUTIL_READY;
-   hv_poll_channel(fcopy_transaction.fcopy_context,
-   hv_fcopy_onchannelcallback);
+   hv_poll_channel(fcopy_transaction.recv_channel,
+   fcopy_poll_wrapper);
}
 
return 0;
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index e6aa33a..2a3420c 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -66,7 +66,6 @@ static struct {
struct hv_kvp_msg  *kvp_msg; /* current message */
struct vmbus_channel *recv_channel; /* chn we got the request */
u64

[PATCH RESEND 06/27] Drivers: hv: utils: use memdup_user in hvt_op_write

2015-12-11 Thread K. Y. Srinivasan
From: Olaf Hering 

Use memdup_user to handle OOM.

Fixes: 14b50f80c32d ('Drivers: hv: util: introduce hv_utils_transport 
abstraction')

Signed-off-by: Olaf Hering 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_utils_transport.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 1505ee6..24b2766 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -80,11 +80,10 @@ static ssize_t hvt_op_write(struct file *file, const char 
__user *buf,
 
hvt = container_of(file->f_op, struct hvutil_transport, fops);
 
-   inmsg = kzalloc(count, GFP_KERNEL);
-   if (copy_from_user(inmsg, buf, count)) {
-   kfree(inmsg);
-   return -EFAULT;
-   }
+   inmsg = memdup_user(buf, count);
+   if (IS_ERR(inmsg))
+   return PTR_ERR(inmsg);
+
if (hvt->on_msg(inmsg, count))
return -EFAULT;
kfree(inmsg);
-- 
1.7.4.1

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


[PATCH RESEND 14/27] Drivers: hv: vmbus: Get rid of the unused macro

2015-12-11 Thread K. Y. Srinivasan
The macro VMBUS_DEVICE() is unused; get rid of it.

Signed-off-by: K. Y. Srinivasan 
---
 include/linux/hyperv.h |   13 -
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index b9f3bb2..f773a68 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -986,19 +986,6 @@ int vmbus_allocate_mmio(struct resource **new, struct 
hv_device *device_obj,
 int vmbus_cpu_number_to_vp_number(int cpu_number);
 u64 hv_do_hypercall(u64 control, void *input, void *output);
 
-/**
- * VMBUS_DEVICE - macro used to describe a specific hyperv vmbus device
- *
- * This macro is used to create a struct hv_vmbus_device_id that matches a
- * specific device.
- */
-#define VMBUS_DEVICE(g0, g1, g2, g3, g4, g5, g6, g7,   \
-g8, g9, ga, gb, gc, gd, ge, gf)\
-   .guid = { g0, g1, g2, g3, g4, g5, g6, g7,   \
- g8, g9, ga, gb, gc, gd, ge, gf },
-
-
-
 /*
  * GUID definitions of various offer types - services offered to the guest.
  */
-- 
1.7.4.1

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


[PATCH 27/27] tools: hv: vss: fix the write()'s argument: error -> vss_msg

2015-12-11 Thread K. Y. Srinivasan
From: Dexuan Cui 

Fix the write()'s argument in the daemon code.

Cc: Vitaly Kuznetsov 
Cc: "K. Y. Srinivasan" 
Signed-off-by: Dexuan Cui 
Cc: sta...@vger.kernel.org
Signed-off-by: K. Y. Srinivasan 
---
 tools/hv/hv_vss_daemon.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 96234b6..5d51d6f 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -254,7 +254,7 @@ int main(int argc, char *argv[])
syslog(LOG_ERR, "Illegal op:%d\n", op);
}
vss_msg->error = error;
-   len = write(vss_fd, &error, sizeof(struct hv_vss_msg));
+   len = write(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
if (len != sizeof(struct hv_vss_msg)) {
syslog(LOG_ERR, "write failed; error: %d %s", errno,
   strerror(errno));
-- 
1.7.4.1

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


[PATCH RESEND 19/27] Drivers: hv: vmbus: release relid on error in vmbus_process_offer()

2015-12-11 Thread K. Y. Srinivasan
From: Dexuan Cui 

We want to simplify vmbus_onoffer_rescind() by not invoking
hv_process_channel_removal(NULL, ...).

Signed-off-by: Dexuan Cui 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |   21 +++--
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 7903acc..9c9da3a 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -177,19 +177,22 @@ static void percpu_channel_deq(void *arg)
 }
 
 
-void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
+static void vmbus_release_relid(u32 relid)
 {
struct vmbus_channel_relid_released msg;
-   unsigned long flags;
-   struct vmbus_channel *primary_channel;
 
memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
msg.child_relid = relid;
msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released));
+}
 
-   if (channel == NULL)
-   return;
+void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
+{
+   unsigned long flags;
+   struct vmbus_channel *primary_channel;
+
+   vmbus_release_relid(relid);
 
BUG_ON(!channel->rescind);
 
@@ -336,6 +339,8 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
return;
 
 err_deq_chan:
+   vmbus_release_relid(newchannel->offermsg.child_relid);
+
spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
list_del(&newchannel->listentry);
spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
@@ -587,7 +592,11 @@ static void vmbus_onoffer_rescind(struct 
vmbus_channel_message_header *hdr)
channel = relid2channel(rescind->child_relid);
 
if (channel == NULL) {
-   hv_process_channel_removal(NULL, rescind->child_relid);
+   /*
+* This is very impossible, because in
+* vmbus_process_offer(), we have already invoked
+* vmbus_release_relid() on error.
+*/
return;
}
 
-- 
1.7.4.1

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


[PATCH RESEND 12/27] Drivers: hv: vmbus: Use uuid_le type consistently

2015-12-11 Thread K. Y. Srinivasan
Consistently use uuid_le type in the Hyper-V driver code.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c   |2 +-
 drivers/hv/vmbus_drv.c  |   10 ++--
 include/linux/hyperv.h  |   92 +-
 include/linux/mod_devicetable.h |2 +-
 scripts/mod/file2alias.c|2 +-
 5 files changed, 40 insertions(+), 68 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index a77646b..38470aa 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -408,7 +408,7 @@ static void init_vp_index(struct vmbus_channel *channel, 
const uuid_le *type_gui
struct cpumask *alloced_mask;
 
for (i = IDE; i < MAX_PERF_CHN; i++) {
-   if (!memcmp(type_guid->b, hp_devs[i].guid,
+   if (!memcmp(type_guid->b, &hp_devs[i].guid,
 sizeof(uuid_le))) {
perf_chn = true;
break;
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index c01b689..7078b5f 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -531,7 +531,7 @@ static int vmbus_uevent(struct device *device, struct 
kobj_uevent_env *env)
 
 static const uuid_le null_guid;
 
-static inline bool is_null_guid(const __u8 *guid)
+static inline bool is_null_guid(const uuid_le *guid)
 {
if (memcmp(guid, &null_guid, sizeof(uuid_le)))
return false;
@@ -544,9 +544,9 @@ static inline bool is_null_guid(const __u8 *guid)
  */
 static const struct hv_vmbus_device_id *hv_vmbus_get_id(
const struct hv_vmbus_device_id *id,
-   const __u8 *guid)
+   const uuid_le *guid)
 {
-   for (; !is_null_guid(id->guid); id++)
+   for (; !is_null_guid(&id->guid); id++)
if (!memcmp(&id->guid, guid, sizeof(uuid_le)))
return id;
 
@@ -563,7 +563,7 @@ static int vmbus_match(struct device *device, struct 
device_driver *driver)
struct hv_driver *drv = drv_to_hv_drv(driver);
struct hv_device *hv_dev = device_to_hv_device(device);
 
-   if (hv_vmbus_get_id(drv->id_table, hv_dev->dev_type.b))
+   if (hv_vmbus_get_id(drv->id_table, &hv_dev->dev_type))
return 1;
 
return 0;
@@ -580,7 +580,7 @@ static int vmbus_probe(struct device *child_device)
struct hv_device *dev = device_to_hv_device(child_device);
const struct hv_vmbus_device_id *dev_id;
 
-   dev_id = hv_vmbus_get_id(drv->id_table, dev->dev_type.b);
+   dev_id = hv_vmbus_get_id(drv->id_table, &dev->dev_type);
if (drv->probe) {
ret = drv->probe(dev, dev_id);
if (ret != 0)
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index c9a9eed..b9f3bb2 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -997,6 +997,8 @@ u64 hv_do_hypercall(u64 control, void *input, void *output);
.guid = { g0, g1, g2, g3, g4, g5, g6, g7,   \
  g8, g9, ga, gb, gc, gd, ge, gf },
 
+
+
 /*
  * GUID definitions of various offer types - services offered to the guest.
  */
@@ -1006,118 +1008,94 @@ u64 hv_do_hypercall(u64 control, void *input, void 
*output);
  * {f8615163-df3e-46c5-913f-f2d2f965ed0e}
  */
 #define HV_NIC_GUID \
-   .guid = { \
-   0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46, \
-   0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e \
-   }
+   .guid = UUID_LE(0xf8615163, 0xdf3e, 0x46c5, 0x91, 0x3f, \
+   0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e)
 
 /*
  * IDE GUID
  * {32412632-86cb-44a2-9b5c-50d1417354f5}
  */
 #define HV_IDE_GUID \
-   .guid = { \
-   0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, \
-   0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 \
-   }
+   .guid = UUID_LE(0x32412632, 0x86cb, 0x44a2, 0x9b, 0x5c, \
+   0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5)
 
 /*
  * SCSI GUID
  * {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}
  */
 #define HV_SCSI_GUID \
-   .guid = { \
-   0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, \
-   0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f \
-   }
+   .guid = UUID_LE(0xba6163d9, 0x04a1, 0x4d29, 0xb6, 0x05, \
+   0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f)
 
 /*
  * Shutdown GUID
  * {0e0b6031-5213-4934-818b-38d90ced39db}
  */
 #define HV_SHUTDOWN_GUID \
-   .guid = { \
-   0x31, 0x60, 0x0b, 0x0e, 0x13, 0x52, 0x34, 0x49, \
-   0x81, 0x8b, 0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb \
-   }
+   .guid = UUID_LE(0x0e0b6031, 0x5213, 0x4934, 0x81, 0x8b, \
+   0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb)
 
 /*
  * Time Synch GUID
  * {9527E630-D0AE-497b-ADCE-E80AB0175CAF}
  

[PATCH RESEND 23/27] Drivers: hv: vmbus: Fix a Host signaling bug

2015-12-11 Thread K. Y. Srinivasan
Currently we have two policies for deciding when to signal the host:
One based on the ring buffer state and the other based on what the
VMBUS client driver wants to do. Consider the case when the client
wants to explicitly control when to signal the host. In this case,
if the client were to defer signaling, we will not be able to signal
the host subsequently when the client does want to signal since the
ring buffer state will prevent the signaling. Implement logic to
have only one signaling policy in force for a given channel.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
Tested-by: Haiyang Zhang 
Cc:  # v4.2+
---
 drivers/hv/channel.c   |   18 ++
 include/linux/hyperv.h |   18 ++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 77d2579..2889d97 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -653,10 +653,19 @@ int vmbus_sendpacket_ctl(struct vmbus_channel *channel, 
void *buffer,
 *on the ring. We will not signal if more data is
 *to be placed.
 *
+* Based on the channel signal state, we will decide
+* which signaling policy will be applied.
+*
 * If we cannot write to the ring-buffer; signal the host
 * even if we may not have written anything. This is a rare
 * enough condition that it should not matter.
 */
+
+   if (channel->signal_policy)
+   signal = true;
+   else
+   kick_q = true;
+
if (((ret == 0) && kick_q && signal) || (ret))
vmbus_setevent(channel);
 
@@ -756,10 +765,19 @@ int vmbus_sendpacket_pagebuffer_ctl(struct vmbus_channel 
*channel,
 *on the ring. We will not signal if more data is
 *to be placed.
 *
+* Based on the channel signal state, we will decide
+* which signaling policy will be applied.
+*
 * If we cannot write to the ring-buffer; signal the host
 * even if we may not have written anything. This is a rare
 * enough condition that it should not matter.
 */
+
+   if (channel->signal_policy)
+   signal = true;
+   else
+   kick_q = true;
+
if (((ret == 0) && kick_q && signal) || (ret))
vmbus_setevent(channel);
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index f773a68..acd995b 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -630,6 +630,11 @@ struct hv_input_signal_event_buffer {
struct hv_input_signal_event event;
 };
 
+enum hv_signal_policy {
+   HV_SIGNAL_POLICY_DEFAULT = 0,
+   HV_SIGNAL_POLICY_EXPLICIT,
+};
+
 struct vmbus_channel {
/* Unique channel id */
int id;
@@ -757,8 +762,21 @@ struct vmbus_channel {
 * link up channels based on their CPU affinity.
 */
struct list_head percpu_list;
+   /*
+* Host signaling policy: The default policy will be
+* based on the ring buffer state. We will also support
+* a policy where the client driver can have explicit
+* signaling control.
+*/
+   enum hv_signal_policy  signal_policy;
 };
 
+static inline void set_channel_signal_state(struct vmbus_channel *c,
+   enum hv_signal_policy policy)
+{
+   c->signal_policy = policy;
+}
+
 static inline void set_channel_read_state(struct vmbus_channel *c, bool state)
 {
c->batched_reading = state;
-- 
1.7.4.1

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


[PATCH RESEND 10/27] drivers:hv: Define the channel type for Hyper-V PCI Express pass-through

2015-12-11 Thread K. Y. Srinivasan
From: Jake Oshins 

This defines the channel type for PCI front-ends in Hyper-V VMs.

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

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 652afd1..a77646b 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -358,6 +358,7 @@ enum {
SCSI,
NIC,
ND_NIC,
+   PCIE,
MAX_PERF_CHN,
 };
 
@@ -375,6 +376,8 @@ static const struct hv_vmbus_device_id hp_devs[] = {
{ HV_NIC_GUID, },
/* NetworkDirect Guest RDMA */
{ HV_ND_GUID, },
+   /* PCI Express Pass Through */
+   { HV_PCIE_GUID, },
 };
 
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 24d0b65..c9a9eed 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1141,6 +1141,17 @@ u64 hv_do_hypercall(u64 control, void *input, void 
*output);
}
 
 /*
+ * PCI Express Pass Through
+ * {44C4F61D--4400-9D52-802E27EDE19F}
+ */
+
+#define HV_PCIE_GUID \
+   .guid = { \
+   0x1D, 0xF6, 0xC4, 0x44, 0x44, 0x44, 0x00, 0x44, \
+   0x9D, 0x52, 0x80, 0x2E, 0x27, 0xED, 0xE1, 0x9F \
+   }
+
+/*
  * Common header for Hyper-V ICs
  */
 
-- 
1.7.4.1

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


[PATCH 25/27] Drivers: hv: vmbus: Force all channel messages to be delivered on CPU 0

2015-12-11 Thread K. Y. Srinivasan
Force all channel messages to be delivered on CPU0. These messages are not
performance critical and are used during the setup and teardown of the
channel.

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

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 521f48e..3dc5a9c 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -83,10 +83,13 @@ static int vmbus_negotiate_version(struct 
vmbus_channel_msginfo *msginfo,
msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages[0]);
msg->monitor_page2 = virt_to_phys(vmbus_connection.monitor_pages[1]);
-   if (version >= VERSION_WIN8_1) {
-   msg->target_vcpu = hv_context.vp_index[get_cpu()];
-   put_cpu();
-   }
+   /*
+* We want all channel messages to be delivered on CPU 0.
+* This has been the behavior pre-win8. This is not
+* perf issue and having all channel messages delivered on CPU 0
+* would be ok.
+*/
+   msg->target_vcpu = 0;
 
/*
 * Add to list before we send the request since we may
-- 
1.7.4.1

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


[PATCH 26/27] Drivers: hv: utils: Invoke the poll function after handshake

2015-12-11 Thread K. Y. Srinivasan
When the handshake with daemon is complete, we should poll the channel since
during the handshake, we will not be processing any messages. This is a
potential bug if the host is waiting for a response from the guest.
I would like to thank Dexuan for pointing this out.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_kvp.c  |2 +-
 drivers/hv/hv_snapshot.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index 2a3420c..d4ab81b 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -154,7 +154,7 @@ static int kvp_handle_handshake(struct hv_kvp_msg *msg)
pr_debug("KVP: userspace daemon ver. %d registered\n",
 KVP_OP_REGISTER);
kvp_register(dm_reg_value);
-   kvp_transaction.state = HVUTIL_READY;
+   hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper);
 
return 0;
 }
diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
index 81882d4..67def4a 100644
--- a/drivers/hv/hv_snapshot.c
+++ b/drivers/hv/hv_snapshot.c
@@ -113,7 +113,7 @@ static int vss_handle_handshake(struct hv_vss_msg *vss_msg)
default:
return -EINVAL;
}
-   vss_transaction.state = HVUTIL_READY;
+   hv_poll_channel(vss_transaction.recv_channel, vss_poll_wrapper);
pr_debug("VSS: userspace daemon ver. %d registered\n", dm_reg_value);
return 0;
 }
-- 
1.7.4.1

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


[PATCH RESEND 21/27] drivers:hv: Allow for MMIO claims that span ACPI _CRS records

2015-12-11 Thread K. Y. Srinivasan
From: Jake Oshins 

This patch makes 16GB GPUs work in Hyper-V VMs, since, for
compatibility reasons, the Hyper-V BIOS lists MMIO ranges in 2GB
chunks in its root bus's _CRS object.

Signed-off-by: Jake Oshins 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/vmbus_drv.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index f123bca..328e4c3 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1063,12 +1063,28 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *ctx)
new_res->start = start;
new_res->end = end;
 
+   /*
+* Stick ranges from higher in address space at the front of the list.
+* If two ranges are adjacent, merge them.
+*/
do {
if (!*old_res) {
*old_res = new_res;
break;
}
 
+   if (((*old_res)->end + 1) == new_res->start) {
+   (*old_res)->end = new_res->end;
+   kfree(new_res);
+   break;
+   }
+
+   if ((*old_res)->start == new_res->end + 1) {
+   (*old_res)->start = new_res->start;
+   kfree(new_res);
+   break;
+   }
+
if ((*old_res)->end < new_res->start) {
new_res->sibling = *old_res;
if (prev_res)
-- 
1.7.4.1

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


[PATCH RESEND 18/27] Drivers: hv: vmbus: fix rescind-offer handling for device without a driver

2015-12-11 Thread K. Y. Srinivasan
From: Dexuan Cui 

In the path vmbus_onoffer_rescind() -> vmbus_device_unregister()  ->
device_unregister() -> ... -> __device_release_driver(), we can see for a
device without a driver loaded: dev->driver is NULL, so
dev->bus->remove(dev), namely vmbus_remove(), isn't invoked.

As a result, vmbus_remove() -> hv_process_channel_removal() isn't invoked
and some cleanups(like sending a CHANNELMSG_RELID_RELEASED message to the
host) aren't done.

We can demo the issue this way:
1. rmmod hv_utils;
2. disable the Heartbeat Integration Service in Hyper-V Manager and lsvmbus
shows the device disappears.
3. re-enable the Heartbeat in Hyper-V Manager and modprobe hv_utils, but
lsvmbus shows the device can't appear again.
This is because, the host thinks the VM hasn't released the relid, so can't
re-offer the device to the VM.

We can fix the issue by moving hv_process_channel_removal()
from vmbus_close_internal() to vmbus_device_release(), since the latter is
always invoked on device_unregister(), whether or not the dev has a driver
loaded.

Signed-off-by: Dexuan Cui 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |6 --
 drivers/hv/channel_mgmt.c |6 +++---
 drivers/hv/vmbus_drv.c|   15 +++
 3 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 00e1be7..77d2579 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -575,12 +575,6 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
free_pages((unsigned long)channel->ringbuffer_pages,
get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
 
-   /*
-* If the channel has been rescinded; process device removal.
-*/
-   if (channel->rescind)
-   hv_process_channel_removal(channel,
-  channel->offermsg.child_relid);
 out:
tasklet_enable(tasklet);
 
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index dc4fb0b..7903acc 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -191,6 +191,8 @@ void hv_process_channel_removal(struct vmbus_channel 
*channel, u32 relid)
if (channel == NULL)
return;
 
+   BUG_ON(!channel->rescind);
+
if (channel->target_cpu != get_cpu()) {
put_cpu();
smp_call_function_single(channel->target_cpu,
@@ -230,9 +232,7 @@ void vmbus_free_channels(void)
 
list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
listentry) {
-   /* if we don't set rescind to true, vmbus_close_internal()
-* won't invoke hv_process_channel_removal().
-*/
+   /* hv_process_channel_removal() needs this */
channel->rescind = true;
 
vmbus_device_unregister(channel->device_obj);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index ab888a1..f123bca 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -601,23 +601,11 @@ static int vmbus_remove(struct device *child_device)
 {
struct hv_driver *drv;
struct hv_device *dev = device_to_hv_device(child_device);
-   u32 relid = dev->channel->offermsg.child_relid;
 
if (child_device->driver) {
drv = drv_to_hv_drv(child_device->driver);
if (drv->remove)
drv->remove(dev);
-   else {
-   hv_process_channel_removal(dev->channel, relid);
-   pr_err("remove not set for driver %s\n",
-   dev_name(child_device));
-   }
-   } else {
-   /*
-* We don't have a driver for this device; deal with the
-* rescind message by removing the channel.
-*/
-   hv_process_channel_removal(dev->channel, relid);
}
 
return 0;
@@ -652,7 +640,10 @@ static void vmbus_shutdown(struct device *child_device)
 static void vmbus_device_release(struct device *device)
 {
struct hv_device *hv_dev = device_to_hv_device(device);
+   struct vmbus_channel *channel = hv_dev->channel;
 
+   hv_process_channel_removal(channel,
+  channel->offermsg.child_relid);
kfree(hv_dev);
 
 }
-- 
1.7.4.1

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


[PATCH RESEND 24/27] drivers/hv: correct tsc page sequence invalid value

2015-12-11 Thread K. Y. Srinivasan
From: Andrey Smetanin 

Hypervisor Top Level Functional Specification v3/4 says
that TSC page sequence value = -1(0x) is used to
indicate that TSC page no longer reliable source of reference
timer. Unfortunately, we found that Windows Hyper-V guest
side implementation uses sequence value = 0 to indicate
that Tsc page no longer valid. This is clearly visible
inside Windows 2012R2 ntoskrnl.exe HvlGetReferenceTime()
function dissassembly:

HvlGetReferenceTime proc near
 xchgax, ax
loc_1401C3132:
 mov rax, cs:HvlpReferenceTscPage
 mov r9d, [rax]
 testr9d, r9d
 jz  short loc_1401C3176
 rdtsc
 mov rcx, cs:HvlpReferenceTscPage
 shl rdx, 20h
 or  rdx, rax
 mov rax, [rcx+8]
 mov rcx, cs:HvlpReferenceTscPage
 mov r8, [rcx+10h]
 mul rdx
 mov rax, cs:HvlpReferenceTscPage
 add rdx, r8
 mov ecx, [rax]
 cmp ecx, r9d
 jnz short loc_1401C3132
 jmp short loc_1401C3184
loc_1401C3176:
 mov ecx, 4020h
 rdmsr
 shl rdx, 20h
 or  rdx, rax
loc_1401C3184:
 mov rax, rdx
 retn
HvlGetReferenceTime endp

This patch aligns Tsc page invalid sequence value with
Windows Hyper-V guest implementation which is more
compatible with both Hyper-V hypervisor and KVM hypervisor.

Signed-off-by: Andrey Smetanin 
Signed-off-by: Denis V. Lunev 
CC: "K. Y. Srinivasan" 
CC: Haiyang Zhang 
CC: Vitaly Kuznetsov 

Signed-off-by: Denis V. Lunev 
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 7a06933..1db9556 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -140,7 +140,7 @@ static cycle_t read_hv_clock_tsc(struct clocksource *arg)
cycle_t current_tick;
struct ms_hyperv_tsc_page *tsc_pg = hv_context.tsc_page;
 
-   if (tsc_pg->tsc_sequence != -1) {
+   if (tsc_pg->tsc_sequence != 0) {
/*
 * Use the tsc page to compute the value.
 */
@@ -162,7 +162,7 @@ static cycle_t read_hv_clock_tsc(struct clocksource *arg)
if (tsc_pg->tsc_sequence == sequence)
return current_tick;
 
-   if (tsc_pg->tsc_sequence != -1)
+   if (tsc_pg->tsc_sequence != 0)
continue;
/*
 * Fallback using MSR method.
-- 
1.7.4.1

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


[PATCH RESEND 11/27] Drivers: hv: vss: run only on supported host versions

2015-12-11 Thread K. Y. Srinivasan
From: Olaf Hering 

The Backup integration service on WS2012 has appearently trouble to
negotiate with a guest which does not support the provided util version.
Currently the VSS driver supports only version 5/0. A WS2012 offers only
version 1/x and 3/x, and vmbus_prep_negotiate_resp correctly returns an
empty icframe_vercnt/icmsg_vercnt. But the host ignores that and
continues to send ICMSGTYPE_NEGOTIATE messages. The result are weird
errors during boot and general misbehaviour.

Check the Windows version to work around the host bug, skip hv_vss_init
on WS2012 and older.

Signed-off-by: Olaf Hering 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_snapshot.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
index a548ae4..81882d4 100644
--- a/drivers/hv/hv_snapshot.c
+++ b/drivers/hv/hv_snapshot.c
@@ -331,6 +331,11 @@ static void vss_on_reset(void)
 int
 hv_vss_init(struct hv_util_service *srv)
 {
+   if (vmbus_proto_version < VERSION_WIN8_1) {
+   pr_warn("Integration service 'Backup (volume snapshot)'"
+   " not supported on this host version.\n");
+   return -ENOTSUPP;
+   }
recv_buffer = srv->recv_buffer;
 
/*
-- 
1.7.4.1

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


[PATCH RESEND 16/27] Drivers: hv: vmbus: serialize process_chn_event() and vmbus_close_internal()

2015-12-11 Thread K. Y. Srinivasan
From: Dexuan Cui 

process_chn_event(), running in the tasklet, can race with
vmbus_close_internal() in the case of SMP guest, e.g., when the former is
accessing channel->inbound.ring_buffer, the latter could be freeing the
ring_buffer pages.

To resolve the race, we can serialize them by disabling the tasklet when
the latter is running here.

Signed-off-by: Dexuan Cui 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c |   21 +++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index c4dcab0..f7f3d5c 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "hyperv_vmbus.h"
 
@@ -496,8 +497,21 @@ static void reset_channel_cb(void *arg)
 static int vmbus_close_internal(struct vmbus_channel *channel)
 {
struct vmbus_channel_close_channel *msg;
+   struct tasklet_struct *tasklet;
int ret;
 
+   /*
+* process_chn_event(), running in the tasklet, can race
+* with vmbus_close_internal() in the case of SMP guest, e.g., when
+* the former is accessing channel->inbound.ring_buffer, the latter
+* could be freeing the ring_buffer pages.
+*
+* To resolve the race, we can serialize them by disabling the
+* tasklet when the latter is running here.
+*/
+   tasklet = hv_context.event_dpc[channel->target_cpu];
+   tasklet_disable(tasklet);
+
channel->state = CHANNEL_OPEN_STATE;
channel->sc_creation_callback = NULL;
/* Stop callback and cancel the timer asap */
@@ -525,7 +539,7 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
 * If we failed to post the close msg,
 * it is perhaps better to leak memory.
 */
-   return ret;
+   goto out;
}
 
/* Tear down the gpadl for the channel's ring buffer */
@@ -538,7 +552,7 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
 * If we failed to teardown gpadl,
 * it is perhaps better to leak memory.
 */
-   return ret;
+   goto out;
}
}
 
@@ -555,6 +569,9 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
if (channel->rescind)
hv_process_channel_removal(channel,
   channel->offermsg.child_relid);
+out:
+   tasklet_enable(tasklet);
+
return ret;
 }
 
-- 
1.7.4.1

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


[PATCH RESEND 13/27] Drivers: hv: vmbus: Use uuid_le_cmp() for comparing GUIDs

2015-12-11 Thread K. Y. Srinivasan
Use uuid_le_cmp() for comparing GUIDs.

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

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 38470aa..dc4fb0b 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -408,8 +408,7 @@ static void init_vp_index(struct vmbus_channel *channel, 
const uuid_le *type_gui
struct cpumask *alloced_mask;
 
for (i = IDE; i < MAX_PERF_CHN; i++) {
-   if (!memcmp(type_guid->b, &hp_devs[i].guid,
-sizeof(uuid_le))) {
+   if (!uuid_le_cmp(*type_guid, hp_devs[i].guid)) {
perf_chn = true;
break;
}
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 7078b5f..9e0e25c 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -533,7 +533,7 @@ static const uuid_le null_guid;
 
 static inline bool is_null_guid(const uuid_le *guid)
 {
-   if (memcmp(guid, &null_guid, sizeof(uuid_le)))
+   if (uuid_le_cmp(*guid, null_guid))
return false;
return true;
 }
@@ -547,7 +547,7 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(
const uuid_le *guid)
 {
for (; !is_null_guid(&id->guid); id++)
-   if (!memcmp(&id->guid, guid, sizeof(uuid_le)))
+   if (!uuid_le_cmp(id->guid, *guid))
return id;
 
return NULL;
-- 
1.7.4.1

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


  1   2   >