Commit 5362855a authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by David S. Miller

netvsc: get rid of completion timeouts

I'm hitting 5 second timeout in rndis_filter_set_rss_param() while setting
RSS parameters for the device. When this happens we end up returning
-ETIMEDOUT from the function and rndis_filter_device_add() falls back to
setting

        net_device->max_chn = 1;
        net_device->num_chn = 1;
        net_device->num_sc_offered = 0;

but after a moment the rndis request succeeds and subchannels start to
appear. netvsc_sc_open() does unconditional nvscdev->num_sc_offered-- and
it becomes U32_MAX-1. Consequent rndis_filter_device_remove() will hang
while waiting for all U32_MAX-1 subchannels to appear and this is not
going to happen.

The immediate issue could be solved by adding num_sc_offered > 0 check to
netvsc_sc_open() but we're getting out of sync with the host and it's not
easy to adjust things later, e.g. in this particular case we'll be creating
queues without a user request for it and races are expected. Same applies
to other parts of the driver which have the same completion timeout.

Following the trend in drivers/hv/* code I suggest we remove all these
timeouts completely. As a guest we can always trust the host we're running
on and if the host screws things up there is no easy way to recover anyway.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent adba931f
...@@ -244,7 +244,6 @@ static int netvsc_destroy_buf(struct hv_device *device) ...@@ -244,7 +244,6 @@ static int netvsc_destroy_buf(struct hv_device *device)
static int netvsc_init_buf(struct hv_device *device) static int netvsc_init_buf(struct hv_device *device)
{ {
int ret = 0; int ret = 0;
unsigned long t;
struct netvsc_device *net_device; struct netvsc_device *net_device;
struct nvsp_message *init_packet; struct nvsp_message *init_packet;
struct net_device *ndev; struct net_device *ndev;
...@@ -305,9 +304,7 @@ static int netvsc_init_buf(struct hv_device *device) ...@@ -305,9 +304,7 @@ static int netvsc_init_buf(struct hv_device *device)
goto cleanup; goto cleanup;
} }
t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ); wait_for_completion(&net_device->channel_init_wait);
BUG_ON(t == 0);
/* Check the response */ /* Check the response */
if (init_packet->msg.v1_msg. if (init_packet->msg.v1_msg.
...@@ -390,8 +387,7 @@ static int netvsc_init_buf(struct hv_device *device) ...@@ -390,8 +387,7 @@ static int netvsc_init_buf(struct hv_device *device)
goto cleanup; goto cleanup;
} }
t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ); wait_for_completion(&net_device->channel_init_wait);
BUG_ON(t == 0);
/* Check the response */ /* Check the response */
if (init_packet->msg.v1_msg. if (init_packet->msg.v1_msg.
...@@ -445,7 +441,6 @@ static int negotiate_nvsp_ver(struct hv_device *device, ...@@ -445,7 +441,6 @@ static int negotiate_nvsp_ver(struct hv_device *device,
{ {
struct net_device *ndev = hv_get_drvdata(device); struct net_device *ndev = hv_get_drvdata(device);
int ret; int ret;
unsigned long t;
memset(init_packet, 0, sizeof(struct nvsp_message)); memset(init_packet, 0, sizeof(struct nvsp_message));
init_packet->hdr.msg_type = NVSP_MSG_TYPE_INIT; init_packet->hdr.msg_type = NVSP_MSG_TYPE_INIT;
...@@ -462,10 +457,7 @@ static int negotiate_nvsp_ver(struct hv_device *device, ...@@ -462,10 +457,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
if (ret != 0) if (ret != 0)
return ret; return ret;
t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ); wait_for_completion(&net_device->channel_init_wait);
if (t == 0)
return -ETIMEDOUT;
if (init_packet->msg.init_msg.init_complete.status != if (init_packet->msg.init_msg.init_complete.status !=
NVSP_STAT_SUCCESS) NVSP_STAT_SUCCESS)
......
...@@ -466,7 +466,6 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, ...@@ -466,7 +466,6 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
struct rndis_query_request *query; struct rndis_query_request *query;
struct rndis_query_complete *query_complete; struct rndis_query_complete *query_complete;
int ret = 0; int ret = 0;
unsigned long t;
if (!result) if (!result)
return -EINVAL; return -EINVAL;
...@@ -503,11 +502,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, ...@@ -503,11 +502,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
if (ret != 0) if (ret != 0)
goto cleanup; goto cleanup;
t = wait_for_completion_timeout(&request->wait_event, 5*HZ); wait_for_completion(&request->wait_event);
if (t == 0) {
ret = -ETIMEDOUT;
goto cleanup;
}
/* Copy the response back */ /* Copy the response back */
query_complete = &request->response_msg.msg.query_complete; query_complete = &request->response_msg.msg.query_complete;
...@@ -556,7 +551,6 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac) ...@@ -556,7 +551,6 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac)
u32 extlen = sizeof(struct rndis_config_parameter_info) + u32 extlen = sizeof(struct rndis_config_parameter_info) +
2*NWADR_STRLEN + 4*ETH_ALEN; 2*NWADR_STRLEN + 4*ETH_ALEN;
int ret; int ret;
unsigned long t;
request = get_rndis_request(rdev, RNDIS_MSG_SET, request = get_rndis_request(rdev, RNDIS_MSG_SET,
RNDIS_MESSAGE_SIZE(struct rndis_set_request) + extlen); RNDIS_MESSAGE_SIZE(struct rndis_set_request) + extlen);
...@@ -597,21 +591,13 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac) ...@@ -597,21 +591,13 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac)
if (ret != 0) if (ret != 0)
goto cleanup; goto cleanup;
t = wait_for_completion_timeout(&request->wait_event, 5*HZ); wait_for_completion(&request->wait_event);
if (t == 0) {
netdev_err(ndev, "timeout before we got a set response...\n"); set_complete = &request->response_msg.msg.set_complete;
/* if (set_complete->status != RNDIS_STATUS_SUCCESS) {
* can't put_rndis_request, since we may still receive a netdev_err(ndev, "Fail to set MAC on host side:0x%x\n",
* send-completion. set_complete->status);
*/ ret = -EINVAL;
return -EBUSY;
} else {
set_complete = &request->response_msg.msg.set_complete;
if (set_complete->status != RNDIS_STATUS_SUCCESS) {
netdev_err(ndev, "Fail to set MAC on host side:0x%x\n",
set_complete->status);
ret = -EINVAL;
}
} }
cleanup: cleanup:
...@@ -631,7 +617,6 @@ rndis_filter_set_offload_params(struct net_device *ndev, ...@@ -631,7 +617,6 @@ rndis_filter_set_offload_params(struct net_device *ndev,
struct rndis_set_complete *set_complete; struct rndis_set_complete *set_complete;
u32 extlen = sizeof(struct ndis_offload_params); u32 extlen = sizeof(struct ndis_offload_params);
int ret; int ret;
unsigned long t;
u32 vsp_version = nvdev->nvsp_version; u32 vsp_version = nvdev->nvsp_version;
if (vsp_version <= NVSP_PROTOCOL_VERSION_4) { if (vsp_version <= NVSP_PROTOCOL_VERSION_4) {
...@@ -665,20 +650,12 @@ rndis_filter_set_offload_params(struct net_device *ndev, ...@@ -665,20 +650,12 @@ rndis_filter_set_offload_params(struct net_device *ndev,
if (ret != 0) if (ret != 0)
goto cleanup; goto cleanup;
t = wait_for_completion_timeout(&request->wait_event, 5*HZ); wait_for_completion(&request->wait_event);
if (t == 0) { set_complete = &request->response_msg.msg.set_complete;
netdev_err(ndev, "timeout before we got aOFFLOAD set response...\n"); if (set_complete->status != RNDIS_STATUS_SUCCESS) {
/* can't put_rndis_request, since we may still receive a netdev_err(ndev, "Fail to set offload on host side:0x%x\n",
* send-completion. set_complete->status);
*/ ret = -EINVAL;
return -EBUSY;
} else {
set_complete = &request->response_msg.msg.set_complete;
if (set_complete->status != RNDIS_STATUS_SUCCESS) {
netdev_err(ndev, "Fail to set offload on host side:0x%x\n",
set_complete->status);
ret = -EINVAL;
}
} }
cleanup: cleanup:
...@@ -706,7 +683,6 @@ static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue) ...@@ -706,7 +683,6 @@ static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue)
u32 *itab; u32 *itab;
u8 *keyp; u8 *keyp;
int i, ret; int i, ret;
unsigned long t;
request = get_rndis_request( request = get_rndis_request(
rdev, RNDIS_MSG_SET, rdev, RNDIS_MSG_SET,
...@@ -749,20 +725,12 @@ static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue) ...@@ -749,20 +725,12 @@ static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue)
if (ret != 0) if (ret != 0)
goto cleanup; goto cleanup;
t = wait_for_completion_timeout(&request->wait_event, 5*HZ); wait_for_completion(&request->wait_event);
if (t == 0) { set_complete = &request->response_msg.msg.set_complete;
netdev_err(ndev, "timeout before we got a set response...\n"); if (set_complete->status != RNDIS_STATUS_SUCCESS) {
/* can't put_rndis_request, since we may still receive a netdev_err(ndev, "Fail to set RSS parameters:0x%x\n",
* send-completion. set_complete->status);
*/ ret = -EINVAL;
return -ETIMEDOUT;
} else {
set_complete = &request->response_msg.msg.set_complete;
if (set_complete->status != RNDIS_STATUS_SUCCESS) {
netdev_err(ndev, "Fail to set RSS parameters:0x%x\n",
set_complete->status);
ret = -EINVAL;
}
} }
cleanup: cleanup:
...@@ -791,8 +759,6 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter) ...@@ -791,8 +759,6 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
struct rndis_set_complete *set_complete; struct rndis_set_complete *set_complete;
u32 status; u32 status;
int ret; int ret;
unsigned long t;
struct net_device *ndev = dev->ndev;
request = get_rndis_request(dev, RNDIS_MSG_SET, request = get_rndis_request(dev, RNDIS_MSG_SET,
RNDIS_MESSAGE_SIZE(struct rndis_set_request) + RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
...@@ -815,26 +781,14 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter) ...@@ -815,26 +781,14 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
if (ret != 0) if (ret != 0)
goto cleanup; goto cleanup;
t = wait_for_completion_timeout(&request->wait_event, 5*HZ); wait_for_completion(&request->wait_event);
if (t == 0) { set_complete = &request->response_msg.msg.set_complete;
netdev_err(ndev, status = set_complete->status;
"timeout before we got a set response...\n");
ret = -ETIMEDOUT;
/*
* We can't deallocate the request since we may still receive a
* send completion for it.
*/
goto exit;
} else {
set_complete = &request->response_msg.msg.set_complete;
status = set_complete->status;
}
cleanup: cleanup:
if (request) if (request)
put_rndis_request(dev, request); put_rndis_request(dev, request);
exit:
return ret; return ret;
} }
...@@ -846,7 +800,6 @@ static int rndis_filter_init_device(struct rndis_device *dev) ...@@ -846,7 +800,6 @@ static int rndis_filter_init_device(struct rndis_device *dev)
struct rndis_initialize_complete *init_complete; struct rndis_initialize_complete *init_complete;
u32 status; u32 status;
int ret; int ret;
unsigned long t;
struct netvsc_device *nvdev = net_device_to_netvsc_device(dev->ndev); struct netvsc_device *nvdev = net_device_to_netvsc_device(dev->ndev);
request = get_rndis_request(dev, RNDIS_MSG_INIT, request = get_rndis_request(dev, RNDIS_MSG_INIT,
...@@ -870,12 +823,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) ...@@ -870,12 +823,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
goto cleanup; goto cleanup;
} }
t = wait_for_completion_timeout(&request->wait_event, 5*HZ); wait_for_completion(&request->wait_event);
if (t == 0) {
ret = -ETIMEDOUT;
goto cleanup;
}
init_complete = &request->response_msg.msg.init_complete; init_complete = &request->response_msg.msg.init_complete;
status = init_complete->status; status = init_complete->status;
...@@ -1008,7 +956,6 @@ int rndis_filter_device_add(struct hv_device *dev, ...@@ -1008,7 +956,6 @@ int rndis_filter_device_add(struct hv_device *dev,
struct netvsc_device_info *device_info = additional_info; struct netvsc_device_info *device_info = additional_info;
struct ndis_offload_params offloads; struct ndis_offload_params offloads;
struct nvsp_message *init_packet; struct nvsp_message *init_packet;
unsigned long t;
struct ndis_recv_scale_cap rsscap; struct ndis_recv_scale_cap rsscap;
u32 rsscap_size = sizeof(struct ndis_recv_scale_cap); u32 rsscap_size = sizeof(struct ndis_recv_scale_cap);
u32 mtu, size; u32 mtu, size;
...@@ -1151,11 +1098,8 @@ int rndis_filter_device_add(struct hv_device *dev, ...@@ -1151,11 +1098,8 @@ int rndis_filter_device_add(struct hv_device *dev,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret) if (ret)
goto out; goto out;
t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ); wait_for_completion(&net_device->channel_init_wait);
if (t == 0) {
ret = -ETIMEDOUT;
goto out;
}
if (init_packet->msg.v5_msg.subchn_comp.status != if (init_packet->msg.v5_msg.subchn_comp.status !=
NVSP_STAT_SUCCESS) { NVSP_STAT_SUCCESS) {
ret = -ENODEV; ret = -ENODEV;
...@@ -1192,17 +1136,12 @@ void rndis_filter_device_remove(struct hv_device *dev) ...@@ -1192,17 +1136,12 @@ void rndis_filter_device_remove(struct hv_device *dev)
{ {
struct netvsc_device *net_dev = hv_device_to_netvsc_device(dev); struct netvsc_device *net_dev = hv_device_to_netvsc_device(dev);
struct rndis_device *rndis_dev = net_dev->extension; struct rndis_device *rndis_dev = net_dev->extension;
unsigned long t;
/* If not all subchannel offers are complete, wait for them until /* If not all subchannel offers are complete, wait for them until
* completion to avoid race. * completion to avoid race.
*/ */
while (net_dev->num_sc_offered > 0) { if (net_dev->num_sc_offered > 0)
t = wait_for_completion_timeout(&net_dev->channel_init_wait, wait_for_completion(&net_dev->channel_init_wait);
10 * HZ);
if (t == 0)
WARN(1, "Netvsc: Waiting for sub-channel processing");
}
/* Halt and release the rndis device */ /* Halt and release the rndis device */
rndis_filter_halt_device(rndis_dev); rndis_filter_halt_device(rndis_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment