* [PATCH net V2 1/2] net: ena: unmask MSI-X only after device initialization is completed
2018-01-03 6:17 [PATCH net V2 0/2] bug fixes for ENA Ethernet driver netanel
@ 2018-01-03 6:17 ` netanel
2018-01-03 6:17 ` [PATCH net V2 2/2] net: ena: fix error handling in ena_down() sequence netanel
2018-01-03 17:21 ` [PATCH net V2 0/2] bug fixes for ENA Ethernet driver David Miller
2 siblings, 0 replies; 4+ messages in thread
From: netanel @ 2018-01-03 6:17 UTC (permalink / raw)
To: davem, netdev
Cc: Netanel Belgazal, dwmw, zorik, matua, saeedb, msw, aliguori,
nafea, evgenys, gtzalik
From: Netanel Belgazal <netanel@amazon.com>
Under certain conditions MSI-X interrupt might arrive right after it
was unmasked in ena_up(). There is a chance it would be processed by
the driver before device ENA_FLAG_DEV_UP flag is set. In such a case
the interrupt is ignored.
ENA device operates in auto-masked mode, therefore ignoring
interrupt leaves it masked for good.
Moving unmask of interrupt to be the last step in ena_up().
Signed-off-by: Netanel Belgazal <netanel@amazon.com>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 97c5a89a9cf7..6fb28fd43eb3 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -1565,7 +1565,7 @@ static int ena_rss_configure(struct ena_adapter *adapter)
static int ena_up_complete(struct ena_adapter *adapter)
{
- int rc, i;
+ int rc;
rc = ena_rss_configure(adapter);
if (rc)
@@ -1584,17 +1584,6 @@ static int ena_up_complete(struct ena_adapter *adapter)
ena_napi_enable_all(adapter);
- /* Enable completion queues interrupt */
- for (i = 0; i < adapter->num_queues; i++)
- ena_unmask_interrupt(&adapter->tx_ring[i],
- &adapter->rx_ring[i]);
-
- /* schedule napi in case we had pending packets
- * from the last time we disable napi
- */
- for (i = 0; i < adapter->num_queues; i++)
- napi_schedule(&adapter->ena_napi[i].napi);
-
return 0;
}
@@ -1731,7 +1720,7 @@ static int ena_create_all_io_rx_queues(struct ena_adapter *adapter)
static int ena_up(struct ena_adapter *adapter)
{
- int rc;
+ int rc, i;
netdev_dbg(adapter->netdev, "%s\n", __func__);
@@ -1774,6 +1763,17 @@ static int ena_up(struct ena_adapter *adapter)
set_bit(ENA_FLAG_DEV_UP, &adapter->flags);
+ /* Enable completion queues interrupt */
+ for (i = 0; i < adapter->num_queues; i++)
+ ena_unmask_interrupt(&adapter->tx_ring[i],
+ &adapter->rx_ring[i]);
+
+ /* schedule napi in case we had pending packets
+ * from the last time we disable napi
+ */
+ for (i = 0; i < adapter->num_queues; i++)
+ napi_schedule(&adapter->ena_napi[i].napi);
+
return rc;
err_up:
--
2.7.3.AMZN
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net V2 2/2] net: ena: fix error handling in ena_down() sequence
2018-01-03 6:17 [PATCH net V2 0/2] bug fixes for ENA Ethernet driver netanel
2018-01-03 6:17 ` [PATCH net V2 1/2] net: ena: unmask MSI-X only after device initialization is completed netanel
@ 2018-01-03 6:17 ` netanel
2018-01-03 17:21 ` [PATCH net V2 0/2] bug fixes for ENA Ethernet driver David Miller
2 siblings, 0 replies; 4+ messages in thread
From: netanel @ 2018-01-03 6:17 UTC (permalink / raw)
To: davem, netdev
Cc: Netanel Belgazal, dwmw, zorik, matua, saeedb, msw, aliguori,
nafea, evgenys, gtzalik
From: Netanel Belgazal <netanel@amazon.com>
ENA admin command queue errors are not handled as part of ena_down().
As a result, in case of error admin queue transitions to non-running
state and aborts all subsequent commands including those coming from
ena_up(). Reset scheduled by the driver from the timer service
context would not proceed due to sharing rtnl with ena_up()/ena_down()
Signed-off-by: Netanel Belgazal <netanel@amazon.com>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 6fb28fd43eb3..fbe21a817bd8 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -75,6 +75,9 @@ static struct workqueue_struct *ena_wq;
MODULE_DEVICE_TABLE(pci, ena_pci_tbl);
static int ena_rss_init_default(struct ena_adapter *adapter);
+static void check_for_admin_com_state(struct ena_adapter *adapter);
+static void ena_destroy_device(struct ena_adapter *adapter);
+static int ena_restore_device(struct ena_adapter *adapter);
static void ena_tx_timeout(struct net_device *dev)
{
@@ -1884,6 +1887,17 @@ static int ena_close(struct net_device *netdev)
if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
ena_down(adapter);
+ /* Check for device status and issue reset if needed*/
+ check_for_admin_com_state(adapter);
+ if (unlikely(test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))) {
+ netif_err(adapter, ifdown, adapter->netdev,
+ "Destroy failure, restarting device\n");
+ ena_dump_stats_to_dmesg(adapter);
+ /* rtnl lock already obtained in dev_ioctl() layer */
+ ena_destroy_device(adapter);
+ ena_restore_device(adapter);
+ }
+
return 0;
}
@@ -2544,11 +2558,12 @@ static void ena_destroy_device(struct ena_adapter *adapter)
ena_com_set_admin_running_state(ena_dev, false);
- ena_close(netdev);
+ if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
+ ena_down(adapter);
/* Before releasing the ENA resources, a device reset is required.
* (to prevent the device from accessing them).
- * In case the reset flag is set and the device is up, ena_close
+ * In case the reset flag is set and the device is up, ena_down()
* already perform the reset, so it can be skipped.
*/
if (!(test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags) && dev_up))
--
2.7.3.AMZN
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net V2 0/2] bug fixes for ENA Ethernet driver
2018-01-03 6:17 [PATCH net V2 0/2] bug fixes for ENA Ethernet driver netanel
2018-01-03 6:17 ` [PATCH net V2 1/2] net: ena: unmask MSI-X only after device initialization is completed netanel
2018-01-03 6:17 ` [PATCH net V2 2/2] net: ena: fix error handling in ena_down() sequence netanel
@ 2018-01-03 17:21 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-01-03 17:21 UTC (permalink / raw)
To: netanel
Cc: netdev, dwmw, zorik, matua, saeedb, msw, aliguori, nafea, evgenys,
gtzalik
From: <netanel@amazon.com>
Date: Wed, 3 Jan 2018 06:17:28 +0000
> From: Netanel Belgazal <netanel@amazon.com>
>
> Changes from V1:
> Revome incorrect "ena: invoke netif_carrier_off() only after netdev
> registered" patch
>
> This patchset contains 2 bug fixes:
> * handle rare race condition during MSI-X initialization
> * fix error processing in ena_down()
Series applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread