Skip to content

Commit

Permalink
RH7: netvsc: get rid of completion timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nickme committed Aug 31, 2016
1 parent 17ff83e commit df897f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 101 deletions.
14 changes: 3 additions & 11 deletions hv-rhel7.x/hv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ static int netvsc_destroy_buf(struct hv_device *device)
static int netvsc_init_buf(struct hv_device *device)
{
int ret = 0;
unsigned long t;
struct netvsc_device *net_device;
struct nvsp_message *init_packet;
struct net_device *ndev;
Expand Down Expand Up @@ -303,9 +302,7 @@ static int netvsc_init_buf(struct hv_device *device)
goto cleanup;
}

t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ);
BUG_ON(t == 0);

wait_for_completion(&net_device->channel_init_wait);

/* Check the response */
if (init_packet->msg.v1_msg.
Expand Down Expand Up @@ -389,8 +386,7 @@ static int netvsc_init_buf(struct hv_device *device)
goto cleanup;
}

t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ);
BUG_ON(t == 0);
wait_for_completion(&net_device->channel_init_wait);

/* Check the response */
if (init_packet->msg.v1_msg.
Expand Down Expand Up @@ -444,7 +440,6 @@ static int negotiate_nvsp_ver(struct hv_device *device,
{
struct net_device *ndev = hv_get_drvdata(device);
int ret;
unsigned long t;

memset(init_packet, 0, sizeof(struct nvsp_message));
init_packet->hdr.msg_type = NVSP_MSG_TYPE_INIT;
Expand All @@ -461,10 +456,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
if (ret != 0)
return ret;

t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ);

if (t == 0)
return -ETIMEDOUT;
wait_for_completion(&net_device->channel_init_wait);

if (init_packet->msg.init_msg.init_complete.status !=
NVSP_STAT_SUCCESS)
Expand Down
118 changes: 28 additions & 90 deletions hv-rhel7.x/hv/rndis_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
struct rndis_query_request *query;
struct rndis_query_complete *query_complete;
int ret = 0;
unsigned long t;

if (!result)
return -EINVAL;
Expand Down Expand Up @@ -503,11 +502,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
if (ret != 0)
goto cleanup;

t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
if (t == 0) {
ret = -ETIMEDOUT;
goto cleanup;
}
wait_for_completion(&request->wait_event);

/* Copy the response back */
query_complete = &request->response_msg.msg.query_complete;
Expand Down Expand Up @@ -556,7 +551,6 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac)
u32 extlen = sizeof(struct rndis_config_parameter_info) +
2*NWADR_STRLEN + 4*ETH_ALEN;
int ret;
unsigned long t;

request = get_rndis_request(rdev, RNDIS_MSG_SET,
RNDIS_MESSAGE_SIZE(struct rndis_set_request) + extlen);
Expand Down Expand Up @@ -597,21 +591,13 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac)
if (ret != 0)
goto cleanup;

t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
if (t == 0) {
netdev_err(ndev, "timeout before we got a set response...\n");
/*
* can't put_rndis_request, since we may still receive a
* send-completion.
*/
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;
}
wait_for_completion(&request->wait_event);

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:
Expand All @@ -631,7 +617,6 @@ rndis_filter_set_offload_params(struct net_device *ndev,
struct rndis_set_complete *set_complete;
u32 extlen = sizeof(struct ndis_offload_params);
int ret;
unsigned long t;
u32 vsp_version = nvdev->nvsp_version;

if (vsp_version <= NVSP_PROTOCOL_VERSION_4) {
Expand Down Expand Up @@ -665,20 +650,12 @@ rndis_filter_set_offload_params(struct net_device *ndev,
if (ret != 0)
goto cleanup;

t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
if (t == 0) {
netdev_err(ndev, "timeout before we got aOFFLOAD set response...\n");
/* can't put_rndis_request, since we may still receive a
* send-completion.
*/
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;
}
wait_for_completion(&request->wait_event);
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:
Expand Down Expand Up @@ -706,7 +683,6 @@ static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue)
u32 *itab;
u8 *keyp;
int i, ret;
unsigned long t;

request = get_rndis_request(
rdev, RNDIS_MSG_SET,
Expand Down Expand Up @@ -749,20 +725,12 @@ static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue)
if (ret != 0)
goto cleanup;

t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
if (t == 0) {
netdev_err(ndev, "timeout before we got a set response...\n");
/* can't put_rndis_request, since we may still receive a
* send-completion.
*/
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;
}
wait_for_completion(&request->wait_event);
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:
Expand Down Expand Up @@ -791,8 +759,6 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
struct rndis_set_complete *set_complete;
u32 status;
int ret;
unsigned long t;
struct net_device *ndev = dev->ndev;

request = get_rndis_request(dev, RNDIS_MSG_SET,
RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
Expand All @@ -815,26 +781,13 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
if (ret != 0)
goto cleanup;

t = wait_for_completion_timeout(&request->wait_event, 5*HZ);

if (t == 0) {
netdev_err(ndev,
"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;
}
wait_for_completion(&request->wait_event);

set_complete = &request->response_msg.msg.set_complete;
status = set_complete->status;
cleanup:
if (request)
put_rndis_request(dev, request);
exit:
return ret;
}

Expand All @@ -846,7 +799,6 @@ static int rndis_filter_init_device(struct rndis_device *dev)
struct rndis_initialize_complete *init_complete;
u32 status;
int ret;
unsigned long t;
struct netvsc_device *nvdev = net_device_to_netvsc_device(dev->ndev);

request = get_rndis_request(dev, RNDIS_MSG_INIT,
Expand All @@ -870,12 +822,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
goto cleanup;
}

t = wait_for_completion_timeout(&request->wait_event, 5*HZ);

if (t == 0) {
ret = -ETIMEDOUT;
goto cleanup;
}
wait_for_completion(&request->wait_event);

init_complete = &request->response_msg.msg.init_complete;
status = init_complete->status;
Expand Down Expand Up @@ -1010,7 +957,6 @@ int rndis_filter_device_add(struct hv_device *dev,
struct netvsc_device_info *device_info = additional_info;
struct ndis_offload_params offloads;
struct nvsp_message *init_packet;
unsigned long t;
struct ndis_recv_scale_cap rsscap;
u32 rsscap_size = sizeof(struct ndis_recv_scale_cap);
u32 mtu, size;
Expand Down Expand Up @@ -1153,11 +1099,8 @@ int rndis_filter_device_add(struct hv_device *dev,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret)
goto out;
t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ);
if (t == 0) {
ret = -ETIMEDOUT;
goto out;
}
wait_for_completion(&net_device->channel_init_wait);

if (init_packet->msg.v5_msg.subchn_comp.status !=
NVSP_STAT_SUCCESS) {
ret = -ENODEV;
Expand Down Expand Up @@ -1194,17 +1137,12 @@ void rndis_filter_device_remove(struct hv_device *dev)
{
struct netvsc_device *net_dev = hv_device_to_netvsc_device(dev);
struct rndis_device *rndis_dev = net_dev->extension;
unsigned long t;

/* If not all subchannel offers are complete, wait for them until
* completion to avoid race.
*/
while (net_dev->num_sc_offered > 0) {
t = wait_for_completion_timeout(&net_dev->channel_init_wait,
10*HZ);
if (t == 0)
WARN(1, "Netvsc: Waiting for sub-channel processing");
}
if (net_dev->num_sc_offered > 0)
wait_for_completion(&net_dev->channel_init_wait);

/* Halt and release the rndis device */
rndis_filter_halt_device(rndis_dev);
Expand Down

0 comments on commit df897f6

Please sign in to comment.