Commit 65dc6891 authored by Thomas Falcon's avatar Thomas Falcon Committed by David S. Miller

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: default avatarThomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ea22d51a
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/workqueue.h>
#include "ibmvnic.h" #include "ibmvnic.h"
...@@ -3253,8 +3254,8 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq, ...@@ -3253,8 +3254,8 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
dev_info(dev, "Partner initialized\n"); dev_info(dev, "Partner initialized\n");
/* Send back a response */ /* Send back a response */
rc = ibmvnic_send_crq_init_complete(adapter); rc = ibmvnic_send_crq_init_complete(adapter);
if (rc == 0) if (!rc)
send_version_xchg(adapter); schedule_work(&adapter->vnic_crq_init);
else else
dev_err(dev, "Can't send initrsp rc=%ld\n", rc); dev_err(dev, "Can't send initrsp rc=%ld\n", rc);
break; break;
...@@ -3606,6 +3607,60 @@ static const struct file_operations ibmvnic_dump_ops = { ...@@ -3606,6 +3607,60 @@ static const struct file_operations ibmvnic_dump_ops = {
.release = single_release, .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) static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
{ {
unsigned long timeout = msecs_to_jiffies(30000); 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) ...@@ -3645,6 +3700,8 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
netdev->ethtool_ops = &ibmvnic_ethtool_ops; netdev->ethtool_ops = &ibmvnic_ethtool_ops;
SET_NETDEV_DEV(netdev, &dev->dev); SET_NETDEV_DEV(netdev, &dev->dev);
INIT_WORK(&adapter->vnic_crq_init, handle_crq_init_rsp);
spin_lock_init(&adapter->stats_lock); spin_lock_init(&adapter->stats_lock);
rc = ibmvnic_init_crq_queue(adapter); rc = ibmvnic_init_crq_queue(adapter);
......
...@@ -1045,4 +1045,6 @@ struct ibmvnic_adapter { ...@@ -1045,4 +1045,6 @@ struct ibmvnic_adapter {
u64 opt_rxba_entries_per_subcrq; u64 opt_rxba_entries_per_subcrq;
__be64 tx_rx_desc_req; __be64 tx_rx_desc_req;
u8 map_id; u8 map_id;
struct work_struct vnic_crq_init;
}; };
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