Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
ibmvnic: Make CRQ interrupt tasklet wait for all capabilities crqs
Browse files Browse the repository at this point in the history
After sending device capability queries and requests to the vNIC Server,
an interrupt is triggered and the responses are written to the driver's
CRQ response buffer. Since the interrupt can be triggered before all
responses are written and visible to the partition, there is a danger
that the interrupt handler or tasklet can terminate before all responses
are read, resulting in a failure to initialize the device.

To avoid this scenario, when capability commands are sent, we set
a flag that will be checked in the following interrupt tasklet that
will handle the capability responses from the server. Once all
responses have been handled, the flag is disabled; and the tasklet
is allowed to terminate.

Signed-off-by: Thomas Falcon <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tlfalcon authored and davem330 committed Feb 19, 2017
1 parent 901e040 commit 249168a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions drivers/net/ethernet/ibm/ibmvnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,7 @@ static void handle_request_cap_rsp(union ibmvnic_crq *crq,
struct ibmvnic_query_ip_offload_buffer *ip_offload_buf =
&adapter->ip_offload_buf;

adapter->wait_capability = false;
adapter->ip_offload_tok = dma_map_single(dev, ip_offload_buf,
buf_sz,
DMA_FROM_DEVICE);
Expand Down Expand Up @@ -2713,9 +2714,11 @@ static void handle_query_cap_rsp(union ibmvnic_crq *crq,
}

out:
if (atomic_read(&adapter->running_cap_crqs) == 0)
if (atomic_read(&adapter->running_cap_crqs) == 0) {
adapter->wait_capability = false;
init_sub_crqs(adapter, 0);
/* We're done querying the capabilities, initialize sub-crqs */
}
}

static void handle_control_ras_rsp(union ibmvnic_crq *crq,
Expand Down Expand Up @@ -3458,9 +3461,18 @@ static void ibmvnic_tasklet(void *data)
ibmvnic_handle_crq(crq, adapter);
crq->generic.first = 0;
} else {
done = true;
/* remain in tasklet until all
* capabilities responses are received
*/
if (!adapter->wait_capability)
done = true;
}
}
/* if capabilities CRQ's were sent in this tasklet, the following
* tasklet must wait until all responses are received
*/
if (atomic_read(&adapter->running_cap_crqs) != 0)
adapter->wait_capability = true;
spin_unlock_irqrestore(&queue->lock, flags);
}

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/ibm/ibmvnic.h
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ struct ibmvnic_adapter {
int login_rsp_buf_sz;

atomic_t running_cap_crqs;
bool wait_capability;

struct ibmvnic_sub_crq_queue **tx_scrq;
struct ibmvnic_sub_crq_queue **rx_scrq;
Expand Down

0 comments on commit 249168a

Please sign in to comment.