ibmvnic: Fix passive VNIC server login process

In some cases, if there is no VNIC server available during the driver
probe, the driver should wait until it receives an initialization
request from the VNIC Server to start the login process. Recent testing
has show that this is incorrectly handled in the current driver.

The proposed solution handles this initialization request by scheduling
a task in the shared workqueue that completes the login process and
registers the net device.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Thomas Falcon 2016-07-06 15:35:18 -05:00 committed by David S. Miller
parent ea22d51a78
commit 65dc689182
2 changed files with 61 additions and 2 deletions

View File

@ -75,6 +75,7 @@
#include <linux/uaccess.h>
#include <asm/firmware.h>
#include <linux/seq_file.h>
#include <linux/workqueue.h>
#include "ibmvnic.h"
@ -3253,8 +3254,8 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
dev_info(dev, "Partner initialized\n");
/* Send back a response */
rc = ibmvnic_send_crq_init_complete(adapter);
if (rc == 0)
send_version_xchg(adapter);
if (!rc)
schedule_work(&adapter->vnic_crq_init);
else
dev_err(dev, "Can't send initrsp rc=%ld\n", rc);
break;
@ -3606,6 +3607,60 @@ static const struct file_operations ibmvnic_dump_ops = {
.release = single_release,
};
static void handle_crq_init_rsp(struct work_struct *work)
{
struct ibmvnic_adapter *adapter = container_of(work,
struct ibmvnic_adapter,
vnic_crq_init);
struct device *dev = &adapter->vdev->dev;
struct net_device *netdev = adapter->netdev;
unsigned long timeout = msecs_to_jiffies(30000);
int rc;
send_version_xchg(adapter);
reinit_completion(&adapter->init_done);
if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
dev_err(dev, "Passive init timeout\n");
goto task_failed;
}
do {
if (adapter->renegotiate) {
adapter->renegotiate = false;
release_sub_crqs_no_irqs(adapter);
send_cap_queries(adapter);
reinit_completion(&adapter->init_done);
if (!wait_for_completion_timeout(&adapter->init_done,
timeout)) {
dev_err(dev, "Passive init timeout\n");
goto task_failed;
}
}
} while (adapter->renegotiate);
rc = init_sub_crq_irqs(adapter);
if (rc)
goto task_failed;
netdev->real_num_tx_queues = adapter->req_tx_queues;
rc = register_netdev(netdev);
if (rc) {
dev_err(dev,
"failed to register netdev rc=%d\n", rc);
goto register_failed;
}
dev_info(dev, "ibmvnic registered\n");
return;
register_failed:
release_sub_crqs(adapter);
task_failed:
dev_err(dev, "Passive initialization was not successful\n");
}
static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
{
unsigned long timeout = msecs_to_jiffies(30000);
@ -3645,6 +3700,8 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
netdev->ethtool_ops = &ibmvnic_ethtool_ops;
SET_NETDEV_DEV(netdev, &dev->dev);
INIT_WORK(&adapter->vnic_crq_init, handle_crq_init_rsp);
spin_lock_init(&adapter->stats_lock);
rc = ibmvnic_init_crq_queue(adapter);

View File

@ -1045,4 +1045,6 @@ struct ibmvnic_adapter {
u64 opt_rxba_entries_per_subcrq;
__be64 tx_rx_desc_req;
u8 map_id;
struct work_struct vnic_crq_init;
};