[PATCH] staging: ks7010: replace kmalloc() + memcpy() with kmemdup()

2018-04-05 Thread Ji-Hun Kim
Use kmemdup rather than duplicating its implementation.

Signed-off-by: Ji-Hun Kim 
---
 drivers/staging/ks7010/ks7010_sdio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a1..c8eb55b 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -589,11 +589,10 @@ static int ks7010_sdio_update_index(struct 
ks_wlan_private *priv, u32 index)
int ret;
unsigned char *data_buf;
 
-   data_buf = kmalloc(sizeof(u32), GFP_KERNEL);
+   data_buf = kmemdup(&index, sizeof(u32), GFP_KERNEL);
if (!data_buf)
return -ENOMEM;
 
-   memcpy(data_buf, &index, sizeof(index));
ret = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index));
if (ret)
goto err_free_data_buf;
-- 
1.9.1

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


Re: [PATCH 0/4] hv_netvsc: Fix shutdown issues on older Windows hosts

2018-04-05 Thread David Miller
From: Mohammed Gamal 
Date: Thu,  5 Apr 2018 21:09:17 +0200

> Guests running on WS2012 hosts would not shutdown when changing network
> interface setting (e.g. Number of channels, MTU ... etc). 
> 
> This patch series addresses these shutdown issues we enecountered with WS2012
> hosts. It's essentialy a rework of the series sent in 
> https://lkml.org/lkml/2018/1/23/111 on top of latest upstream
> 
> Fixes: 0ef58b0a05c1 ("hv_netvsc: change GPAD teardown order on older 
> versions")

Series applied, thank you.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next] hv_netvsc: Add NetVSP v6 into version negotiation

2018-04-05 Thread David Miller
From: Haiyang Zhang 
Date: Thu,  5 Apr 2018 11:42:22 -0700

> From: Haiyang Zhang 
> 
> This patch adds the NetVSP v6 message structures, and includes this
> version into NetVSC/NetVSP version negotiation process.
> 
> Signed-off-by: Haiyang Zhang 

The net-next tree is closed, please resubmit this when the net-next
tree reopens.

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


Re: [PATCH v2 17/19] media: omap4iss: make it build with COMPILE_TEST

2018-04-05 Thread Laurent Pinchart
Hi Mauro,

Thank you for the patch.

On Thursday, 5 April 2018 23:29:44 EEST Mauro Carvalho Chehab wrote:
> This driver compile as-is with COMPILE_TEST.
> 
> Signed-off-by: Mauro Carvalho Chehab 

Acked-by: Laurent Pinchart 

I don't have patches pending for the omap4iss driver, could you merge this 
patch as part of the whole series ?

> ---
>  drivers/staging/media/omap4iss/Kconfig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/omap4iss/Kconfig
> b/drivers/staging/media/omap4iss/Kconfig index 46183464ee79..192ba0829128
> 100644
> --- a/drivers/staging/media/omap4iss/Kconfig
> +++ b/drivers/staging/media/omap4iss/Kconfig
> @@ -1,6 +1,7 @@
>  config VIDEO_OMAP4
>   tristate "OMAP 4 Camera support"
> - depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4
> + depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C
> + depends on ARCH_OMAP4 || COMPILE_TEST
>   depends on HAS_DMA
>   select MFD_SYSCON
>   select VIDEOBUF2_DMA_CONTIG


-- 
Regards,

Laurent Pinchart



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


[PATCH v2 17/19] media: omap4iss: make it build with COMPILE_TEST

2018-04-05 Thread Mauro Carvalho Chehab
This driver compile as-is with COMPILE_TEST.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/omap4iss/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/omap4iss/Kconfig 
b/drivers/staging/media/omap4iss/Kconfig
index 46183464ee79..192ba0829128 100644
--- a/drivers/staging/media/omap4iss/Kconfig
+++ b/drivers/staging/media/omap4iss/Kconfig
@@ -1,6 +1,7 @@
 config VIDEO_OMAP4
tristate "OMAP 4 Camera support"
-   depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4
+   depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C
+   depends on ARCH_OMAP4 || COMPILE_TEST
depends on HAS_DMA
select MFD_SYSCON
select VIDEOBUF2_DMA_CONTIG
-- 
2.14.3

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


[PATCH v2 19/19] media: staging: davinci_vpfe: allow building with COMPILE_TEST

2018-04-05 Thread Mauro Carvalho Chehab
This is a little bit hashish, but this driver is at staging,
so it won't become worse.

With this small change at Makefile, we can now build it with
COMPILE_TEST.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/davinci_vpfe/Kconfig  | 3 ++-
 drivers/staging/media/davinci_vpfe/Makefile | 5 +
 drivers/staging/media/davinci_vpfe/TODO | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/davinci_vpfe/Kconfig 
b/drivers/staging/media/davinci_vpfe/Kconfig
index f40a06954a92..bcba9a64c514 100644
--- a/drivers/staging/media/davinci_vpfe/Kconfig
+++ b/drivers/staging/media/davinci_vpfe/Kconfig
@@ -1,6 +1,7 @@
 config VIDEO_DM365_VPFE
tristate "DM365 VPFE Media Controller Capture Driver"
-   depends on VIDEO_V4L2 && ARCH_DAVINCI_DM365 && !VIDEO_DM365_ISIF
+   depends on VIDEO_V4L2
+   depends on (ARCH_DAVINCI_DM365 && !VIDEO_DM365_ISIF) || COMPILE_TEST
depends on HAS_DMA
depends on VIDEO_V4L2_SUBDEV_API
depends on VIDEO_DAVINCI_VPBE_DISPLAY
diff --git a/drivers/staging/media/davinci_vpfe/Makefile 
b/drivers/staging/media/davinci_vpfe/Makefile
index 3019c9ecd548..9c57042c877d 100644
--- a/drivers/staging/media/davinci_vpfe/Makefile
+++ b/drivers/staging/media/davinci_vpfe/Makefile
@@ -3,3 +3,8 @@ obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci-vfpe.o
 davinci-vfpe-objs := \
dm365_isif.o dm365_ipipe_hw.o dm365_ipipe.o \
dm365_resizer.o dm365_ipipeif.o vpfe_mc_capture.o vpfe_video.o
+
+# Allow building it with COMPILE_TEST on other archs
+ifndef CONFIG_ARCH_DAVINCI
+ccflags-y += -Iarch/arm/mach-davinci/include/
+endif
diff --git a/drivers/staging/media/davinci_vpfe/TODO 
b/drivers/staging/media/davinci_vpfe/TODO
index 3e5477e8cfa5..cc8bd9306f2a 100644
--- a/drivers/staging/media/davinci_vpfe/TODO
+++ b/drivers/staging/media/davinci_vpfe/TODO
@@ -20,6 +20,7 @@ TODO (general):
 - While replacing the older driver in media folder, provide a compatibility
   layer and compatibility tests that warrants (using the libv4l's LD_PRELOAD
   approach) there is no regression for the users using the older driver.
+- make it independent of arch-specific APIs (mach/mux.h).
 
 Building of uImage and Applications:
 ==
-- 
2.14.3

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


[PATCH 4/4] hv_netvsc: Pass net_device parameter to revoke and teardown functions

2018-04-05 Thread Mohammed Gamal
The callers to netvsc_revoke_*_buf() and netvsc_teardown_*_gpadl()
already have their net_device instances. Pass them as a paramaeter to
the function instead of obtaining them from netvsc_device struct
everytime

Signed-off-by: Mohammed Gamal 
---
 drivers/net/hyperv/netvsc.c | 37 ++---
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index df92c2f..04f611e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -110,9 +110,9 @@ static void free_netvsc_device_rcu(struct netvsc_device 
*nvdev)
 }
 
 static void netvsc_revoke_recv_buf(struct hv_device *device,
-  struct netvsc_device *net_device)
+  struct netvsc_device *net_device,
+  struct net_device *ndev)
 {
-   struct net_device *ndev = hv_get_drvdata(device);
struct nvsp_message *revoke_packet;
int ret;
 
@@ -160,9 +160,9 @@ static void netvsc_revoke_recv_buf(struct hv_device *device,
 }
 
 static void netvsc_revoke_send_buf(struct hv_device *device,
-  struct netvsc_device *net_device)
+  struct netvsc_device *net_device,
+  struct net_device *ndev)
 {
-   struct net_device *ndev = hv_get_drvdata(device);
struct nvsp_message *revoke_packet;
int ret;
 
@@ -211,9 +211,9 @@ static void netvsc_revoke_send_buf(struct hv_device *device,
 }
 
 static void netvsc_teardown_recv_gpadl(struct hv_device *device,
-  struct netvsc_device *net_device)
+  struct netvsc_device *net_device,
+  struct net_device *ndev)
 {
-   struct net_device *ndev = hv_get_drvdata(device);
int ret;
 
if (net_device->recv_buf_gpadl_handle) {
@@ -233,9 +233,9 @@ static void netvsc_teardown_recv_gpadl(struct hv_device 
*device,
 }
 
 static void netvsc_teardown_send_gpadl(struct hv_device *device,
-  struct netvsc_device *net_device)
+  struct netvsc_device *net_device,
+  struct net_device *ndev)
 {
-   struct net_device *ndev = hv_get_drvdata(device);
int ret;
 
if (net_device->send_buf_gpadl_handle) {
@@ -452,10 +452,10 @@ static int netvsc_init_buf(struct hv_device *device,
goto exit;
 
 cleanup:
-   netvsc_revoke_recv_buf(device, net_device);
-   netvsc_revoke_send_buf(device, net_device);
-   netvsc_teardown_recv_gpadl(device, net_device);
-   netvsc_teardown_send_gpadl(device, net_device);
+   netvsc_revoke_recv_buf(device, net_device, ndev);
+   netvsc_revoke_send_buf(device, net_device, ndev);
+   netvsc_teardown_recv_gpadl(device, net_device, ndev);
+   netvsc_teardown_send_gpadl(device, net_device, ndev);
 
 exit:
return ret;
@@ -474,7 +474,6 @@ static int negotiate_nvsp_ver(struct hv_device *device,
init_packet->hdr.msg_type = NVSP_MSG_TYPE_INIT;
init_packet->msg.init_msg.init.min_protocol_ver = nvsp_ver;
init_packet->msg.init_msg.init.max_protocol_ver = nvsp_ver;
-
trace_nvsp_send(ndev, init_packet);
 
/* Send the init request */
@@ -596,13 +595,13 @@ void netvsc_device_remove(struct hv_device *device)
 * Revoke receive buffer. If host is pre-Win2016 then tear down
 * receive buffer GPADL. Do the same for send buffer.
 */
-   netvsc_revoke_recv_buf(device, net_device);
+   netvsc_revoke_recv_buf(device, net_device, ndev);
if (vmbus_proto_version < VERSION_WIN10)
-   netvsc_teardown_recv_gpadl(device, net_device);
+   netvsc_teardown_recv_gpadl(device, net_device, ndev);
 
-   netvsc_revoke_send_buf(device, net_device);
+   netvsc_revoke_send_buf(device, net_device, ndev);
if (vmbus_proto_version < VERSION_WIN10)
-   netvsc_teardown_send_gpadl(device, net_device);
+   netvsc_teardown_send_gpadl(device, net_device, ndev);
 
RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
 
@@ -624,8 +623,8 @@ void netvsc_device_remove(struct hv_device *device)
 * here after VMBus is closed.
*/
if (vmbus_proto_version >= VERSION_WIN10) {
-   netvsc_teardown_recv_gpadl(device, net_device);
-   netvsc_teardown_send_gpadl(device, net_device);
+   netvsc_teardown_recv_gpadl(device, net_device, ndev);
+   netvsc_teardown_send_gpadl(device, net_device, ndev);
}
 
/* Release all resources */
-- 
1.8.3.1

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


[PATCH 0/4] hv_netvsc: Fix shutdown issues on older Windows hosts

2018-04-05 Thread Mohammed Gamal
Guests running on WS2012 hosts would not shutdown when changing network
interface setting (e.g. Number of channels, MTU ... etc). 

This patch series addresses these shutdown issues we enecountered with WS2012
hosts. It's essentialy a rework of the series sent in 
https://lkml.org/lkml/2018/1/23/111 on top of latest upstream

Fixes: 0ef58b0a05c1 ("hv_netvsc: change GPAD teardown order on older versions")

Mohammed Gamal (4):
  hv_netvsc: Use Windows version instead of NVSP version on GPAD
teardown
  hv_netvsc: Split netvsc_revoke_buf() and netvsc_teardown_gpadl()
  hv_netvsc: Ensure correct teardown message sequence order
  hv_netvsc: Pass net_device parameter to revoke and teardown functions

 drivers/net/hyperv/netvsc.c | 60 +
 1 file changed, 44 insertions(+), 16 deletions(-)

-- 
1.8.3.1

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


[PATCH 3/4] hv_netvsc: Ensure correct teardown message sequence order

2018-04-05 Thread Mohammed Gamal
Prior to commit 0cf737808ae7 ("hv_netvsc: netvsc_teardown_gpadl() split")
the call sequence in netvsc_device_remove() was as follows (as
implemented in netvsc_destroy_buf()):
1- Send NVSP_MSG1_TYPE_REVOKE_RECV_BUF message
2- Teardown receive buffer GPADL
3- Send NVSP_MSG1_TYPE_REVOKE_SEND_BUF message
4- Teardown send buffer GPADL
5- Close vmbus

This didn't work for WS2016 hosts. Commit 0cf737808ae7
("hv_netvsc: netvsc_teardown_gpadl() split") rearranged the
teardown sequence as follows:
1- Send NVSP_MSG1_TYPE_REVOKE_RECV_BUF message
2- Send NVSP_MSG1_TYPE_REVOKE_SEND_BUF message
3- Close vmbus
4- Teardown receive buffer GPADL
5- Teardown send buffer GPADL

That worked well for WS2016 hosts, but it prevented guests on older hosts from
shutting down after changing network settings. Commit 0ef58b0a05c1
("hv_netvsc: change GPAD teardown order on older versions") ensured the
following message sequence for older hosts
1- Send NVSP_MSG1_TYPE_REVOKE_RECV_BUF message
2- Send NVSP_MSG1_TYPE_REVOKE_SEND_BUF message
3- Teardown receive buffer GPADL
4- Teardown send buffer GPADL
5- Close vmbus

However, with this sequence calling `ip link set eth0 mtu 1000` hangs and the
process becomes uninterruptible. On futher analysis it turns out that on tearing
down the receive buffer GPADL the kernel is waiting indefinitely
in vmbus_teardown_gpadl() for a completion to be signaled.

Here is a snippet of where this occurs:
int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
{
struct vmbus_channel_gpadl_teardown *msg;
struct vmbus_channel_msginfo *info;
unsigned long flags;
int ret;

info = kmalloc(sizeof(*info) +
   sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
if (!info)
return -ENOMEM;

init_completion(&info->waitevent);
info->waiting_channel = channel;
[]
ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown),
 true);

if (ret)
goto post_msg_err;

wait_for_completion(&info->waitevent);
[]
}

The completion is signaled from vmbus_ongpadl_torndown(), which gets called when
the corresponding message is received from the host, which apparently never 
happens
in that case.
This patch works around the issue by restoring the first mentioned message 
sequence
for older hosts

Fixes: 0ef58b0a05c1 ("hv_netvsc: change GPAD teardown order on older versions")

Signed-off-by: Mohammed Gamal 
---
 drivers/net/hyperv/netvsc.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index f4df5de..df92c2f 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -592,8 +592,17 @@ void netvsc_device_remove(struct hv_device *device)
= rtnl_dereference(net_device_ctx->nvdev);
int i;
 
+   /*
+* Revoke receive buffer. If host is pre-Win2016 then tear down
+* receive buffer GPADL. Do the same for send buffer.
+*/
netvsc_revoke_recv_buf(device, net_device);
+   if (vmbus_proto_version < VERSION_WIN10)
+   netvsc_teardown_recv_gpadl(device, net_device);
+
netvsc_revoke_send_buf(device, net_device);
+   if (vmbus_proto_version < VERSION_WIN10)
+   netvsc_teardown_send_gpadl(device, net_device);
 
RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
 
@@ -607,15 +616,13 @@ void netvsc_device_remove(struct hv_device *device)
 */
netdev_dbg(ndev, "net device safe to remove\n");
 
-   /* older versions require that buffer be revoked before close */
-   if (vmbus_proto_version < VERSION_WIN10) {
-   netvsc_teardown_recv_gpadl(device, net_device);
-   netvsc_teardown_send_gpadl(device, net_device);
-   }
-
/* Now, we can close the channel safely */
vmbus_close(device->channel);
 
+   /*
+* If host is Win2016 or higher then we do the GPADL tear down
+* here after VMBus is closed.
+   */
if (vmbus_proto_version >= VERSION_WIN10) {
netvsc_teardown_recv_gpadl(device, net_device);
netvsc_teardown_send_gpadl(device, net_device);
-- 
1.8.3.1

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


[PATCH 2/4] hv_netvsc: Split netvsc_revoke_buf() and netvsc_teardown_gpadl()

2018-04-05 Thread Mohammed Gamal
Split each of the functions into two for each of send/recv buffers.
This will be needed in order to implement a fine-grained messaging
sequence to the host so tht we accommodate the requirements of
different Windows versions

Fixes: 0ef58b0a05c12 ("hv_netvsc: change GPAD teardown order on older versions")

Signed-off-by: Mohammed Gamal 
---
 drivers/net/hyperv/netvsc.c | 46 +
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index d65b7fc..f4df5de 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -109,11 +109,11 @@ static void free_netvsc_device_rcu(struct netvsc_device 
*nvdev)
call_rcu(&nvdev->rcu, free_netvsc_device);
 }
 
-static void netvsc_revoke_buf(struct hv_device *device,
- struct netvsc_device *net_device)
+static void netvsc_revoke_recv_buf(struct hv_device *device,
+  struct netvsc_device *net_device)
 {
-   struct nvsp_message *revoke_packet;
struct net_device *ndev = hv_get_drvdata(device);
+   struct nvsp_message *revoke_packet;
int ret;
 
/*
@@ -157,6 +157,14 @@ static void netvsc_revoke_buf(struct hv_device *device,
}
net_device->recv_section_cnt = 0;
}
+}
+
+static void netvsc_revoke_send_buf(struct hv_device *device,
+  struct netvsc_device *net_device)
+{
+   struct net_device *ndev = hv_get_drvdata(device);
+   struct nvsp_message *revoke_packet;
+   int ret;
 
/* Deal with the send buffer we may have setup.
 * If we got a  send section size, it means we received a
@@ -202,8 +210,8 @@ static void netvsc_revoke_buf(struct hv_device *device,
}
 }
 
-static void netvsc_teardown_gpadl(struct hv_device *device,
- struct netvsc_device *net_device)
+static void netvsc_teardown_recv_gpadl(struct hv_device *device,
+  struct netvsc_device *net_device)
 {
struct net_device *ndev = hv_get_drvdata(device);
int ret;
@@ -222,6 +230,13 @@ static void netvsc_teardown_gpadl(struct hv_device *device,
}
net_device->recv_buf_gpadl_handle = 0;
}
+}
+
+static void netvsc_teardown_send_gpadl(struct hv_device *device,
+  struct netvsc_device *net_device)
+{
+   struct net_device *ndev = hv_get_drvdata(device);
+   int ret;
 
if (net_device->send_buf_gpadl_handle) {
ret = vmbus_teardown_gpadl(device->channel,
@@ -437,8 +452,10 @@ static int netvsc_init_buf(struct hv_device *device,
goto exit;
 
 cleanup:
-   netvsc_revoke_buf(device, net_device);
-   netvsc_teardown_gpadl(device, net_device);
+   netvsc_revoke_recv_buf(device, net_device);
+   netvsc_revoke_send_buf(device, net_device);
+   netvsc_teardown_recv_gpadl(device, net_device);
+   netvsc_teardown_send_gpadl(device, net_device);
 
 exit:
return ret;
@@ -575,7 +592,8 @@ void netvsc_device_remove(struct hv_device *device)
= rtnl_dereference(net_device_ctx->nvdev);
int i;
 
-   netvsc_revoke_buf(device, net_device);
+   netvsc_revoke_recv_buf(device, net_device);
+   netvsc_revoke_send_buf(device, net_device);
 
RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
 
@@ -590,14 +608,18 @@ void netvsc_device_remove(struct hv_device *device)
netdev_dbg(ndev, "net device safe to remove\n");
 
/* older versions require that buffer be revoked before close */
-   if (vmbus_proto_version < VERSION_WIN10)
-   netvsc_teardown_gpadl(device, net_device);
+   if (vmbus_proto_version < VERSION_WIN10) {
+   netvsc_teardown_recv_gpadl(device, net_device);
+   netvsc_teardown_send_gpadl(device, net_device);
+   }
 
/* Now, we can close the channel safely */
vmbus_close(device->channel);
 
-   if (vmbus_proto_version >= VERSION_WIN10)
-   netvsc_teardown_gpadl(device, net_device);
+   if (vmbus_proto_version >= VERSION_WIN10) {
+   netvsc_teardown_recv_gpadl(device, net_device);
+   netvsc_teardown_send_gpadl(device, net_device);
+   }
 
/* Release all resources */
free_netvsc_device_rcu(net_device);
-- 
1.8.3.1

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


[PATCH 1/4] hv_netvsc: Use Windows version instead of NVSP version on GPAD teardown

2018-04-05 Thread Mohammed Gamal
When changing network interface settings, Windows guests
older than WS2016 can no longer shutdown. This was addressed
by commit 0ef58b0a05c12 ("hv_netvsc: change GPAD teardown order
on older versions"), however the issue also occurs on WS2012
guests that share NVSP protocol versions with WS2016 guests.
Hence we use Windows version directly to differentiate them.

Fixes: 0ef58b0a05c12 ("hv_netvsc: change GPAD teardown order on older versions")

Signed-off-by: Mohammed Gamal 
---
 drivers/net/hyperv/netvsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index c9910c3..d65b7fc 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -590,13 +590,13 @@ void netvsc_device_remove(struct hv_device *device)
netdev_dbg(ndev, "net device safe to remove\n");
 
/* older versions require that buffer be revoked before close */
-   if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_4)
+   if (vmbus_proto_version < VERSION_WIN10)
netvsc_teardown_gpadl(device, net_device);
 
/* Now, we can close the channel safely */
vmbus_close(device->channel);
 
-   if (net_device->nvsp_version >= NVSP_PROTOCOL_VERSION_4)
+   if (vmbus_proto_version >= VERSION_WIN10)
netvsc_teardown_gpadl(device, net_device);
 
/* Release all resources */
-- 
1.8.3.1

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


[PATCH net-next] hv_netvsc: Add NetVSP v6 into version negotiation

2018-04-05 Thread Haiyang Zhang
From: Haiyang Zhang 

This patch adds the NetVSP v6 message structures, and includes this
version into NetVSC/NetVSP version negotiation process.

Signed-off-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h | 33 +
 drivers/net/hyperv/netvsc.c |  3 ++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 960f06141472..036cd55c66fe 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -237,6 +237,7 @@ void netvsc_switch_datapath(struct net_device *nv_dev, bool 
vf);
 #define NVSP_PROTOCOL_VERSION_20x30002
 #define NVSP_PROTOCOL_VERSION_40x4
 #define NVSP_PROTOCOL_VERSION_50x5
+#define NVSP_PROTOCOL_VERSION_60x6
 
 enum {
NVSP_MSG_TYPE_NONE = 0,
@@ -308,6 +309,11 @@ enum {
NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
 
NVSP_MSG5_MAX = NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
+
+   /* Version 6 messages */
+   NVSP_MSG6_TYPE_PD_API,
+
+   NVSP_MSG6_MAX = NVSP_MSG6_TYPE_PD_API
 };
 
 enum {
@@ -619,12 +625,39 @@ union nvsp_5_message_uber {
struct nvsp_5_send_indirect_table send_table;
 } __packed;
 
+enum nvsp6_pd_api_op {
+   PD_API_OP_NOTIFY_VSP = 0,
+   PD_API_OP_CONFIG,
+   PD_API_OP_MAX
+};
+
+struct nvsp_6_pd_api_req {
+   u32 op;
+   u64 mmio_pa; /* MMIO Physical Address */
+   u32 mmio_len;
+   u32 num_subchn; /* Number of PD subchannels */
+} __packed;
+
+struct nvsp_6_pd_api_comp {
+   u32 op;
+   u32 status;
+   u32 num_subchn; /* Number of PD subchannels */
+   u8 is_supported; /* Is supported by VSP */
+   u8 is_enabled; /* Is enabled by VSP */
+} __packed;
+
+union nvsp_6_message_uber {
+   struct nvsp_6_pd_api_req pd_req;
+   struct nvsp_6_pd_api_comp pd_comp;
+} __packed;
+
 union nvsp_all_messages {
union nvsp_message_init_uber init_msg;
union nvsp_1_message_uber v1_msg;
union nvsp_2_message_uber v2_msg;
union nvsp_4_message_uber v4_msg;
union nvsp_5_message_uber v5_msg;
+   union nvsp_6_message_uber v6_msg;
 } __packed;
 
 /* ALL Messages */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index c9910c33e671..3abe57bd85bb 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -509,7 +509,8 @@ static int netvsc_connect_vsp(struct hv_device *device,
struct net_device *ndev = hv_get_drvdata(device);
static const u32 ver_list[] = {
NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
-   NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5
+   NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5,
+   NVSP_PROTOCOL_VERSION_6
};
struct nvsp_message *init_packet;
int ndis_version, i, ret;
-- 
2.15.1

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


Re: [bug report] staging: mt7621-mmc: MIPS: ralink: add sdhci for mt7620a SoC

2018-04-05 Thread Christian Lütke-Stetzkamp
On Thu, Apr 05, 2018 at 02:56:54PM +0300, Dan Carpenter wrote:
> Hello John Crispin,
> 
> The patch 8b634a9c7620: "staging: mt7621-mmc: MIPS: ralink: add sdhci
> for mt7620a SoC" from Mar 15, 2018, leads to the following static
> checker warning:
> 
>   drivers/staging/mt7621-mmc/sd.c:2790 msdc_drv_probe()
>   warn: curly braces intended?

Hi Dan,

in my understanding of the code around that place, these lines are
only indented by accident. The card detect low/high selection and the
activation of software poll should happen even when the SDIO(_EXT)
interrupt is not enabled, because they are not related.

The indentation will be fixed, once the patch series I sent yesterday
in version 2 gets merged.

Hopefully this answer is helpful,
Christian
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [bug report] staging: mt7621-mmc: MIPS: ralink: add sdhci for mt7620a SoC

2018-04-05 Thread Christian Lütke-Stetzkamp
On Thu, Apr 05, 2018 at 03:13:10PM +0300, Dan Carpenter wrote:
> [ I just decided to forward you guys all the Smatch warnings.  -dan ]
> 
> Hello John Crispin,
> 
> The patch 8b634a9c7620: "staging: mt7621-mmc: MIPS: ralink: add sdhci
> for mt7620a SoC" from Mar 15, 2018, leads to the following static
> checker warning:
>
>   drivers/staging/mt7621-mmc/sd.c:951 msdc_command_start()
>   warn: we tested 'opcode == 3' before and it was 'false'
>
> drivers/staging/mt7621-mmc/sd.c:2961 msdc_drv_suspend()
> warn: variable dereferenced before check 'mmc' (see line 2959)
>
> drivers/staging/mt7621-mmc/sd.c:2976 msdc_drv_resume()
> warn: variable dereferenced before check 'mmc' (see line 2972)
>
> drivers/staging/mt7621-mmc/dbg.c:270 msdc_debug_proc_write()
> warn: copy_to/from_user() returns a positive value
>
> drivers/staging/mt7621-mmc/dbg.c:339 msdc_debug_proc_init()
> warn: proc file '"msdc_debug"' is world writable
>
>   drivers/staging/mt7621-mmc/dbg.c:341 msdc_debug_proc_init()
>   warn: 'de' isn't an ERR_PTR

Hi Dan,

thanks for the report, I have created patches for all of these and
will send them, once my previous series got merged, because I based
them on that status.

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


Re: [GIT PULL] Staging/IIO driver changes for 4.17-rc1

2018-04-05 Thread Greg KH
On Wed, Apr 04, 2018 at 07:00:14PM -0700, Linus Torvalds wrote:
> On Wed, Apr 4, 2018 at 3:32 AM, Greg KH  wrote:
> >
> > It is a lot, over 500 changes, but not huge by previous kernel release
> > standards.  We deleted more lines than we added again (27k added vs. 91k
> > remvoed), thanks to finally being able to delete the IRDA drivers and
> > networking code.
> 
> Hmm. The irda sysctl tables are still there in the kernel. Overlooked?

Ah, I missed those, sorry about that.  I'll include the removal of those
bits and a few other documentation removals I just found, in a follow-up
pull request this -rc series.

thanks,

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


Re: [bug report] staging: mt7621-mmc: MIPS: ralink: add sdhci for mt7620a SoC

2018-04-05 Thread John Crispin

Hi Dan,

I explained why I think this should not be merged, i do not plan to fix 
any issues, please send all maintenance requests towards NeilBrown.


And .. it was merged it with an out dated defunct mail addr of mine.

    John


On 05/04/18 14:13, Dan Carpenter wrote:

[ I just decided to forward you guys all the Smatch warnings.  -dan ]

Hello John Crispin,

The patch 8b634a9c7620: "staging: mt7621-mmc: MIPS: ralink: add sdhci
for mt7620a SoC" from Mar 15, 2018, leads to the following static
checker warning:

drivers/staging/mt7621-mmc/sd.c:951 msdc_command_start()
warn: we tested 'opcode == 3' before and it was 'false'

drivers/staging/mt7621-mmc/sd.c
931  static unsigned int msdc_command_start(struct msdc_host   *host,
932struct mmc_command *cmd,
933int tune,   /* 
not used */
934unsigned long   timeout)
935  {
936  u32 base = host->base;
937  u32 opcode = cmd->opcode;
938  u32 rawcmd;
939  u32 wints = MSDC_INT_CMDRDY  | MSDC_INT_RSPCRCERR  | 
MSDC_INT_CMDTMO  |
940  MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | 
MSDC_INT_ACMDTMO |
941  MSDC_INT_ACMD19_DONE;
942
943  u32 resp;
944  unsigned long tmo;
945
946  /* Protocol layer does not provide response type, but our hardware 
needs
947   * to know exact type, not just size!
948   */
949  if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND)
950  resp = RESP_R3;
951  else if (opcode == MMC_SET_RELATIVE_ADDR || opcode == 
SD_SEND_RELATIVE_ADDR)
  
^^
MMC_SET_RELATIVE_ADDR and SD_SEND_RELATIVE_ADDR are both 3 so this
is redundant.

952  resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1;
953  else if (opcode == MMC_FAST_IO)
954  resp = RESP_R4;
955  else if (opcode == MMC_GO_IRQ_STATE)
956  resp = RESP_R5;
957  else if (opcode == MMC_SELECT_CARD)
958  resp = (cmd->arg != 0) ? RESP_R1B : RESP_NONE;
959  else if (opcode == SD_IO_RW_DIRECT || opcode == SD_IO_RW_EXTENDED)
960  resp = RESP_R1; /* SDIO workaround. */
961  else if (opcode == SD_SEND_IF_COND && (mmc_cmd_type(cmd) == 
MMC_CMD_BCR))
962  resp = RESP_R1;
963  else {
964  switch (mmc_resp_type(cmd)) {

 drivers/staging/mt7621-mmc/sd.c:2961 msdc_drv_suspend()
 warn: variable dereferenced before check 'mmc' (see line 2959)

 drivers/staging/mt7621-mmc/sd.c:2976 msdc_drv_resume()
 warn: variable dereferenced before check 'mmc' (see line 2972)

drivers/staging/mt7621-mmc/sd.c
   2953  /* Fix me: Power Flow */
   2954  #ifdef CONFIG_PM
   2955  static int msdc_drv_suspend(struct platform_device *pdev, pm_message_t 
state)
   2956  {
   2957  int ret = 0;
   2958  struct mmc_host *mmc = platform_get_drvdata(pdev);
   2959  struct msdc_host *host = mmc_priv(mmc);
  ^
Dereference

   2960
   2961  if (mmc && state.event == PM_EVENT_SUSPEND && (host->hw->flags & 
MSDC_SYS_SUSPEND)) { /* will set for card */
 ^^^
Check

   2962  msdc_pm(state, (void*)host);
   2963  }
   2964
   2965  return ret;
   2966  }
   2967
   2968  static int msdc_drv_resume(struct platform_device *pdev)
   2969  {
   2970  int ret = 0;
   2971  struct mmc_host *mmc = platform_get_drvdata(pdev);
   2972  struct msdc_host *host = mmc_priv(mmc);
  
Dereference

   2973  struct pm_message state;
   2974
   2975  state.event = PM_EVENT_RESUME;
   2976  if (mmc && (host->hw->flags & MSDC_SYS_SUSPEND)) {/* will set for 
card */
 ^^^
Check

   2977  msdc_pm(state, (void*)host);
   2978  }
   2979
   2980  /* This mean WIFI not controller by PM */
   2981
   2982  return ret;
   2983  }

 drivers/staging/mt7621-mmc/dbg.c:270 msdc_debug_proc_write()
 warn: copy_to/from_user() returns a positive value

drivers/staging/mt7621-mmc/dbg.c
257  static ssize_t msdc_debug_proc_write(struct file *file,
258  const char __user *buf, size_t count, loff_t 
*data)
259  {
260  int ret;
261
262  int cmd, p1, p2;
263  int id, zone;
264  int mode, size;
265
266  if (count == 0)return -1;
267  if(count > 255)count = 255;
268
269  ret = copy_from_user(cmd_buf, buf, count);
270  if (ret < 0)return -1;

This should be:

if (copy_from_user(cmd_buf, buf, count))
return -EFAULT;

271
272

Re: [bug report] staging: mt7621-mmc: MIPS: ralink: add sdhci for mt7620a SoC

2018-04-05 Thread John Crispin

Hi Dan,

I explained why I think this should not be merged, i do not plan to fix 
any issues, please send all maintenance requests towards NeilBrown.


And .. it was merged it with an out dated defunct mail addr of mine.

    John



On 05/04/18 13:56, Dan Carpenter wrote:

Hello John Crispin,

The patch 8b634a9c7620: "staging: mt7621-mmc: MIPS: ralink: add sdhci
for mt7620a SoC" from Mar 15, 2018, leads to the following static
checker warning:

drivers/staging/mt7621-mmc/sd.c:2790 msdc_drv_probe()
warn: curly braces intended?

drivers/staging/mt7621-mmc/sd.c
   2777  /* For sd card: MSDC_SYS_SUSPEND | MSDC_WP_PIN_EN | MSDC_CD_PIN_EN 
| MSDC_REMOVABLE | MSDC_HIGHSPEED,
   2778 For sdio   : MSDC_EXT_SDIO_IRQ | MSDC_HIGHSPEED */
   2779  if (hw->flags & MSDC_HIGHSPEED) {
   2780  mmc->caps   = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
   2781  }
   2782  if (hw->data_pins == 4) { /* current data_pins are all 4*/
   2783  mmc->caps  |= MMC_CAP_4_BIT_DATA;
   2784  } else if (hw->data_pins == 8) {
   2785  mmc->caps  |= MMC_CAP_8_BIT_DATA;
   2786  }
   2787  if ((hw->flags & MSDC_SDIO_IRQ) || (hw->flags & MSDC_EXT_SDIO_IRQ))

Are curly braces intended for this if statement?

   2788  mmc->caps |= MMC_CAP_SDIO_IRQ;  /* yes for sdio */
   2789
   2790  cd_active_low = !of_property_read_bool(pdev->dev.of_node, 
"mediatek,cd-high");
   2791  mtk_sw_poll = of_property_read_bool(pdev->dev.of_node, 
"mediatek,cd-poll");
   2792
   2793  if (mtk_sw_poll)
   2794  mmc->caps |= MMC_CAP_NEEDS_POLL;

because the indenting seems to say that the braces should reach up to
here.

   2795
   2796  /* MMC core transfer sizes tunable parameters */
   2797  #if LINUX_VERSION_CODE > KERNEL_VERSION(3,10,0)
   2798  mmc->max_segs  = MAX_HW_SGMTS;
   2799  #else
   2800  mmc->max_hw_segs   = MAX_HW_SGMTS;
   2801  mmc->max_phys_segs = MAX_PHY_SGMTS;
   2802  #endif


regards,
dan carpenter

___
Linux-mediatek mailing list
linux-media...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek


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


[bug report] staging: mt7621-mmc: MIPS: ralink: add sdhci for mt7620a SoC

2018-04-05 Thread Dan Carpenter
[ I just decided to forward you guys all the Smatch warnings.  -dan ]

Hello John Crispin,

The patch 8b634a9c7620: "staging: mt7621-mmc: MIPS: ralink: add sdhci
for mt7620a SoC" from Mar 15, 2018, leads to the following static
checker warning:

drivers/staging/mt7621-mmc/sd.c:951 msdc_command_start()
warn: we tested 'opcode == 3' before and it was 'false'

drivers/staging/mt7621-mmc/sd.c
   931  static unsigned int msdc_command_start(struct msdc_host   *host, 
   932struct mmc_command *cmd,
   933int tune,   /* 
not used */
   934unsigned long   timeout)
   935  {
   936  u32 base = host->base;
   937  u32 opcode = cmd->opcode;
   938  u32 rawcmd;
   939  u32 wints = MSDC_INT_CMDRDY  | MSDC_INT_RSPCRCERR  | 
MSDC_INT_CMDTMO  |  
   940  MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | 
MSDC_INT_ACMDTMO | 
   941  MSDC_INT_ACMD19_DONE;  
   942 
   943  u32 resp;  
   944  unsigned long tmo;
   945  
   946  /* Protocol layer does not provide response type, but our hardware 
needs 
   947   * to know exact type, not just size!
   948   */
   949  if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND)
   950  resp = RESP_R3;
   951  else if (opcode == MMC_SET_RELATIVE_ADDR || opcode == 
SD_SEND_RELATIVE_ADDR)
 
^^
MMC_SET_RELATIVE_ADDR and SD_SEND_RELATIVE_ADDR are both 3 so this
is redundant.

   952  resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1;
   953  else if (opcode == MMC_FAST_IO)
   954  resp = RESP_R4;
   955  else if (opcode == MMC_GO_IRQ_STATE)
   956  resp = RESP_R5;
   957  else if (opcode == MMC_SELECT_CARD)
   958  resp = (cmd->arg != 0) ? RESP_R1B : RESP_NONE;
   959  else if (opcode == SD_IO_RW_DIRECT || opcode == SD_IO_RW_EXTENDED)
   960  resp = RESP_R1; /* SDIO workaround. */
   961  else if (opcode == SD_SEND_IF_COND && (mmc_cmd_type(cmd) == 
MMC_CMD_BCR))
   962  resp = RESP_R1;
   963  else {
   964  switch (mmc_resp_type(cmd)) {

drivers/staging/mt7621-mmc/sd.c:2961 msdc_drv_suspend()
warn: variable dereferenced before check 'mmc' (see line 2959)

drivers/staging/mt7621-mmc/sd.c:2976 msdc_drv_resume()
warn: variable dereferenced before check 'mmc' (see line 2972)

drivers/staging/mt7621-mmc/sd.c
  2953  /* Fix me: Power Flow */
  2954  #ifdef CONFIG_PM
  2955  static int msdc_drv_suspend(struct platform_device *pdev, pm_message_t 
state)
  2956  {
  2957  int ret = 0;
  2958  struct mmc_host *mmc = platform_get_drvdata(pdev);
  2959  struct msdc_host *host = mmc_priv(mmc);
 ^
Dereference

  2960  
  2961  if (mmc && state.event == PM_EVENT_SUSPEND && (host->hw->flags & 
MSDC_SYS_SUSPEND)) { /* will set for card */
^^^
Check

  2962  msdc_pm(state, (void*)host);
  2963  }
  2964  
  2965  return ret;
  2966  }
  2967
  2968  static int msdc_drv_resume(struct platform_device *pdev)
  2969  {
  2970  int ret = 0;
  2971  struct mmc_host *mmc = platform_get_drvdata(pdev);
  2972  struct msdc_host *host = mmc_priv(mmc);
 
Dereference

  2973  struct pm_message state;
  2974  
  2975  state.event = PM_EVENT_RESUME;
  2976  if (mmc && (host->hw->flags & MSDC_SYS_SUSPEND)) {/* will set for 
card */
^^^
Check

  2977  msdc_pm(state, (void*)host);
  2978  }
  2979  
  2980  /* This mean WIFI not controller by PM */
  2981  
  2982  return ret;
  2983  }

drivers/staging/mt7621-mmc/dbg.c:270 msdc_debug_proc_write()
warn: copy_to/from_user() returns a positive value

drivers/staging/mt7621-mmc/dbg.c
   257  static ssize_t msdc_debug_proc_write(struct file *file, 
   258  const char __user *buf, size_t count, loff_t 
*data)
   259  {
   260  int ret;
   261  
   262  int cmd, p1, p2;   
   263  int id, zone;
   264  int mode, size;  
   265
   266  if (count == 0)return -1;
   267  if(count > 255)count = 255;
   268  
   269  ret = copy_from_user(cmd_buf, buf, count);
   270  if (ret < 0)return -1;

This should be:

if (copy_from_user(cmd_buf, buf, count))
return -EFAULT;

   271  
   272  cmd_buf[count] = '\0';
   273  printk("msdc Write %s\n", cmd_buf);
   274  

drivers/staging/mt7621-mmc/dbg.c:339 msdc_debug_proc_init()
warn: proc file '"msdc_debug"' is world writable

drivers/staging/mt7621-mmc/dbg.c:341 msdc_debug_proc_ini

[bug report] staging: mt7621-mmc: MIPS: ralink: add sdhci for mt7620a SoC

2018-04-05 Thread Dan Carpenter
Hello John Crispin,

The patch 8b634a9c7620: "staging: mt7621-mmc: MIPS: ralink: add sdhci
for mt7620a SoC" from Mar 15, 2018, leads to the following static
checker warning:

drivers/staging/mt7621-mmc/sd.c:2790 msdc_drv_probe()
warn: curly braces intended?

drivers/staging/mt7621-mmc/sd.c
  2777  /* For sd card: MSDC_SYS_SUSPEND | MSDC_WP_PIN_EN | MSDC_CD_PIN_EN 
| MSDC_REMOVABLE | MSDC_HIGHSPEED, 
  2778 For sdio   : MSDC_EXT_SDIO_IRQ | MSDC_HIGHSPEED */
  2779  if (hw->flags & MSDC_HIGHSPEED) {
  2780  mmc->caps   = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
  2781  }
  2782  if (hw->data_pins == 4) { /* current data_pins are all 4*/
  2783  mmc->caps  |= MMC_CAP_4_BIT_DATA;
  2784  } else if (hw->data_pins == 8) {
  2785  mmc->caps  |= MMC_CAP_8_BIT_DATA;
  2786  }
  2787  if ((hw->flags & MSDC_SDIO_IRQ) || (hw->flags & MSDC_EXT_SDIO_IRQ))

Are curly braces intended for this if statement?

  2788  mmc->caps |= MMC_CAP_SDIO_IRQ;  /* yes for sdio */
  2789  
  2790  cd_active_low = !of_property_read_bool(pdev->dev.of_node, 
"mediatek,cd-high");
  2791  mtk_sw_poll = of_property_read_bool(pdev->dev.of_node, 
"mediatek,cd-poll");
  2792  
  2793  if (mtk_sw_poll)
  2794  mmc->caps |= MMC_CAP_NEEDS_POLL;

because the indenting seems to say that the braces should reach up to
here.

  2795  
  2796  /* MMC core transfer sizes tunable parameters */
  2797  #if LINUX_VERSION_CODE > KERNEL_VERSION(3,10,0)
  2798  mmc->max_segs  = MAX_HW_SGMTS;
  2799  #else
  2800  mmc->max_hw_segs   = MAX_HW_SGMTS;
  2801  mmc->max_phys_segs = MAX_PHY_SGMTS;
  2802  #endif


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


Re: [PATCH v5 1/2] staging: vt6655: check for memory allocation failures

2018-04-05 Thread Dan Carpenter
Thanks.  These look good.  And to me, it's really easy to review now.

Reviewed-by: Dan Carpenter 

regards,
dan carpenter

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


[PATCH v5 2/2] staging: vt6655: add handling memory leak on vnt_start()

2018-04-05 Thread Ji-Hun Kim
There was no code for handling memory leaks of device_init_rings() and
request_irq(). It needs to free allocated memory in the device_init_rings()
, when request_irq() would be failed. Add freeing sequences of irq and
device init rings.

Signed-off-by: Ji-Hun Kim 
---
It's additional memory leak handling patch from the
[PATCH v5 1/2] staging: vt6655: check for memory allocation failures

Changes v2:
- Change label names following coding-style conventions.
- Remove uneccessary goto, just return error number like original code.

 drivers/staging/vt6655/device_main.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index 700c03c..1ab0e85 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1237,13 +1237,13 @@ static int vnt_start(struct ieee80211_hw *hw)
  IRQF_SHARED, "vt6655", priv);
if (ret) {
dev_dbg(&priv->pcid->dev, "failed to start irq\n");
-   return ret;
+   goto err_free_rings;
}
 
dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n");
ret = device_init_rd0_ring(priv);
if (ret)
-   return ret;
+   goto err_free_irq;
ret = device_init_rd1_ring(priv);
if (ret)
goto err_free_rd0_ring;
@@ -1269,6 +1269,10 @@ static int vnt_start(struct ieee80211_hw *hw)
device_free_rd1_ring(priv);
 err_free_rd0_ring:
device_free_rd0_ring(priv);
+err_free_irq:
+   free_irq(priv->pcid->irq, priv);
+err_free_rings:
+   device_free_rings(priv);
return ret;
 }
 
-- 
1.9.1

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


[PATCH v5 1/2] staging: vt6655: check for memory allocation failures

2018-04-05 Thread Ji-Hun Kim
There are no null pointer checking on rd_info and td_info values which
are allocated by kzalloc. It has potential null pointer dereferencing
issues. Implement error handling code on device_init_rd*, device_init_td*
and vnt_start for the allocation failures.

Signed-off-by: Ji-Hun Kim 
---
Changes v5:
- Add error handling case for device_alloc_rx_buf() failures.
- Add device_free_rx_buf() which is corresponding free function of
  device_allocated_rx_buf(). And change duplicated codes by this function.
- Modify error handling code about freeing allocated value in the loops to
  more proper ways.
- Change goto label names following coding-style conventions.

Changes v4:
- Fix potential memory leaks from error handling code from device init
  functions in vnt_start().

Changes v3:
- Modify return type of device_init_rd*, device_init_td*. Then add returns
  error code at those functions and vnt_start as well.

Changes v2:
- Delete WARN_ON which can makes crashes on some machines.
- Instead of return directly, goto freeing function for freeing previously
  allocated memory in the for loop after kzalloc() failed.
- In the freeing function, add if statement for freeing to only allocated
  values.

 drivers/staging/vt6655/device_main.c | 144 ---
 1 file changed, 118 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index fbc4bc6..700c03c 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -19,6 +19,7 @@
  *   device_print_info - print out resource
  *   device_rx_srv - rx service function
  *   device_alloc_rx_buf - rx buffer pre-allocated function
+ *   device_free_rx_buf - free rx buffer function
  *   device_free_tx_buf - free tx buffer function
  *   device_init_rd0_ring- initial rd dma0 ring
  *   device_init_rd1_ring- initial rd dma1 ring
@@ -124,14 +125,15 @@
 static void device_free_info(struct vnt_private *priv);
 static void device_print_info(struct vnt_private *priv);
 
-static void device_init_rd0_ring(struct vnt_private *priv);
-static void device_init_rd1_ring(struct vnt_private *priv);
-static void device_init_td0_ring(struct vnt_private *priv);
-static void device_init_td1_ring(struct vnt_private *priv);
+static int device_init_rd0_ring(struct vnt_private *priv);
+static int device_init_rd1_ring(struct vnt_private *priv);
+static int device_init_td0_ring(struct vnt_private *priv);
+static int device_init_td1_ring(struct vnt_private *priv);
 
 static int  device_rx_srv(struct vnt_private *priv, unsigned int idx);
 static int  device_tx_srv(struct vnt_private *priv, unsigned int idx);
 static bool device_alloc_rx_buf(struct vnt_private *, struct vnt_rx_desc *);
+static void device_free_rx_buf(struct vnt_private *priv, struct vnt_rx_desc 
*rd);
 static void device_init_registers(struct vnt_private *priv);
 static void device_free_tx_buf(struct vnt_private *, struct vnt_tx_desc *);
 static void device_free_td0_ring(struct vnt_private *priv);
@@ -528,20 +530,28 @@ static void device_free_rings(struct vnt_private *priv)
  priv->tx0_bufs, priv->tx_bufs_dma0);
 }
 
-static void device_init_rd0_ring(struct vnt_private *priv)
+static int device_init_rd0_ring(struct vnt_private *priv)
 {
int i;
dma_addr_t  curr = priv->rd0_pool_dma;
struct vnt_rx_desc *desc;
+   int ret;
 
/* Init the RD0 ring entries */
for (i = 0; i < priv->opts.rx_descs0;
 i ++, curr += sizeof(struct vnt_rx_desc)) {
desc = &priv->aRD0Ring[i];
desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_KERNEL);
+   if (!desc->rd_info) {
+   ret = -ENOMEM;
+   goto err_free_desc;
+   }
 
-   if (!device_alloc_rx_buf(priv, desc))
+   if (!device_alloc_rx_buf(priv, desc)) {
dev_err(&priv->pcid->dev, "can not alloc rx bufs\n");
+   ret = -ENOMEM;
+   goto err_free_rd;
+   }
 
desc->next = &priv->aRD0Ring[(i + 1) % priv->opts.rx_descs0];
desc->next_desc = cpu_to_le32(curr + sizeof(struct 
vnt_rx_desc));
@@ -550,22 +560,44 @@ static void device_init_rd0_ring(struct vnt_private *priv)
if (i > 0)
priv->aRD0Ring[i-1].next_desc = cpu_to_le32(priv->rd0_pool_dma);
priv->pCurrRD[0] = &priv->aRD0Ring[0];
+
+   return 0;
+
+err_free_rd:
+   kfree(desc->rd_info);
+
+err_free_desc:
+   while (--i) {
+   desc = &priv->aRD0Ring[i];
+   device_free_rx_buf(priv, desc);
+   kfree(desc->rd_info);
+   }
+
+   return ret;
 }
 
-static void device_init_rd1_ring(struct vnt_private *priv)
+static int device_init_rd1_ring(struct vnt_private *priv)
 {
int i;
dma_addr_t  curr = priv->rd1_pool_dma;
struct vn