From f873866a05cc4ca718e4f2fb6f2601a7869f3e12 Mon Sep 17 00:00:00 2001 From: Thomas Falcon Date: Wed, 7 Mar 2018 17:51:45 -0600 Subject: [PATCH 1/3] ibmvnic: Clean up device close Remove some dead code now that RX pools are being cleaned. This was included to wait until any pending RX queue interrupts are processed, but NAPI polling should be disabled by this point. Another minor change is to use the net device parameter for any print functions instead of accessing it from the adapter structure. Signed-off-by: Thomas Falcon Signed-off-by: David S. Miller --- drivers/net/ethernet/ibm/ibmvnic.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 765407179fdd..fca0533d517f 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -1162,7 +1162,7 @@ static int __ibmvnic_close(struct net_device *netdev) if (adapter->tx_scrq) { for (i = 0; i < adapter->req_tx_queues; i++) if (adapter->tx_scrq[i]->irq) { - netdev_dbg(adapter->netdev, + netdev_dbg(netdev, "Disabling tx_scrq[%d] irq\n", i); disable_irq(adapter->tx_scrq[i]->irq); } @@ -1174,18 +1174,8 @@ static int __ibmvnic_close(struct net_device *netdev) if (adapter->rx_scrq) { for (i = 0; i < adapter->req_rx_queues; i++) { - int retries = 10; - - while (pending_scrq(adapter, adapter->rx_scrq[i])) { - retries--; - mdelay(100); - - if (retries == 0) - break; - } - if (adapter->rx_scrq[i]->irq) { - netdev_dbg(adapter->netdev, + netdev_dbg(netdev, "Disabling rx_scrq[%d] irq\n", i); disable_irq(adapter->rx_scrq[i]->irq); } From 01d9bd792d1603761dcc2644ccf4cc35a4658ab6 Mon Sep 17 00:00:00 2001 From: Thomas Falcon Date: Wed, 7 Mar 2018 17:51:46 -0600 Subject: [PATCH 2/3] ibmvnic: Reorganize device close Introduce a function to halt network operations and clean up any unused or outstanding socket buffers. Then, during device close, disable backing adapter before halting all queues and performing cleanup. This ensures all backing device operations will be stopped before the driver cleans up shared resources. Signed-off-by: Thomas Falcon Signed-off-by: David S. Miller --- drivers/net/ethernet/ibm/ibmvnic.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index fca0533d517f..d93f28658a2c 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -1143,14 +1143,11 @@ static void clean_tx_pools(struct ibmvnic_adapter *adapter) } } -static int __ibmvnic_close(struct net_device *netdev) +static void ibmvnic_cleanup(struct net_device *netdev) { struct ibmvnic_adapter *adapter = netdev_priv(netdev); - int rc = 0; int i; - adapter->state = VNIC_CLOSING; - /* ensure that transmissions are stopped if called by do_reset */ if (adapter->resetting) netif_tx_disable(netdev); @@ -1168,10 +1165,6 @@ static int __ibmvnic_close(struct net_device *netdev) } } - rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN); - if (rc) - return rc; - if (adapter->rx_scrq) { for (i = 0; i < adapter->req_rx_queues; i++) { if (adapter->rx_scrq[i]->irq) { @@ -1183,8 +1176,20 @@ static int __ibmvnic_close(struct net_device *netdev) } clean_rx_pools(adapter); clean_tx_pools(adapter); +} + +static int __ibmvnic_close(struct net_device *netdev) +{ + struct ibmvnic_adapter *adapter = netdev_priv(netdev); + int rc = 0; + + adapter->state = VNIC_CLOSING; + rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN); + if (rc) + return rc; + ibmvnic_cleanup(netdev); adapter->state = VNIC_CLOSED; - return rc; + return 0; } static int ibmvnic_close(struct net_device *netdev) From 18b8d6bbad47efd9bd1595c57271fbacc5eb0d46 Mon Sep 17 00:00:00 2001 From: Thomas Falcon Date: Wed, 7 Mar 2018 17:51:47 -0600 Subject: [PATCH 3/3] ibmvnic: Do not disable device during failover or partition migration During a device failover or partition migration reset, it is not necessary to disable the backing adapter since it should not be running yet and its Command-Response Queue is closed. Sending device commands during this time could result in an error or timeout disrupting the reset process. In these cases, just halt transmissions, clean up resources, and continue with reset. Signed-off-by: Thomas Falcon Signed-off-by: David S. Miller --- drivers/net/ethernet/ibm/ibmvnic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index d93f28658a2c..7be4b06f69d2 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -1653,12 +1653,15 @@ static int do_reset(struct ibmvnic_adapter *adapter, rc = ibmvnic_reenable_crq_queue(adapter); if (rc) return 0; + ibmvnic_cleanup(netdev); + } else if (rwi->reset_reason == VNIC_RESET_FAILOVER) { + ibmvnic_cleanup(netdev); + } else { + rc = __ibmvnic_close(netdev); + if (rc) + return rc; } - rc = __ibmvnic_close(netdev); - if (rc) - return rc; - if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM || adapter->wait_for_reset) { release_resources(adapter);