ena module for Driver Update Program
CentOS Sources
2019-01-09 fc384122a7a805dde4dbbf3c4c4ef94a5ca0f2fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Date: Tue, 30 Oct 2018 13:25:20 -0400
From: linville@redhat.com
To: rhkernel-list@redhat.com
Cc: Lin Liu <linl@redhat.com>
Subject: [RHEL7 05/28] net: ena: fix device destruction to gracefully free
 resources
 
From: "John W. Linville" <linville@redhat.com>
 
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1633418
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=18850510
 
When ena_destroy_device() is called from ena_suspend(), the device is
still reachable from the driver. Therefore, the driver can send a command
to the device to free all resources.
However, in all other cases of calling ena_destroy_device(), the device is
potentially in an error state and unreachable from the driver. In these
cases the driver must not send commands to the device.
 
The current implementation does not request resource freeing from the
device even when possible. We add the graceful parameter to
ena_destroy_device() to enable resource freeing when possible, and
use it in ena_suspend().
 
Signed-off-by: Netanel Belgazal <netanel@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit cfa324a514233b28a6934de619183eee941f02d7)
Signed-off-by: John W. Linville <linville@redhat.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
 
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 773834b87a8c..5b32fbc6ed5d 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -76,7 +76,7 @@ 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 void ena_destroy_device(struct ena_adapter *adapter, bool graceful);
 static int ena_restore_device(struct ena_adapter *adapter);
 
 static void ena_tx_timeout(struct net_device *dev)
@@ -1893,7 +1893,7 @@ static int ena_close(struct net_device *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_destroy_device(adapter, false);
         ena_restore_device(adapter);
     }
 
@@ -2543,7 +2543,7 @@ err_disable_msix:
     return rc;
 }
 
-static void ena_destroy_device(struct ena_adapter *adapter)
+static void ena_destroy_device(struct ena_adapter *adapter, bool graceful)
 {
     struct net_device *netdev = adapter->netdev;
     struct ena_com_dev *ena_dev = adapter->ena_dev;
@@ -2556,7 +2556,8 @@ static void ena_destroy_device(struct ena_adapter *adapter)
     dev_up = test_bit(ENA_FLAG_DEV_UP, &adapter->flags);
     adapter->dev_up_before_reset = dev_up;
 
-    ena_com_set_admin_running_state(ena_dev, false);
+    if (!graceful)
+        ena_com_set_admin_running_state(ena_dev, false);
 
     if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
         ena_down(adapter);
@@ -2658,7 +2659,7 @@ static void ena_fw_reset_device(struct work_struct *work)
         return;
     }
     rtnl_lock();
-    ena_destroy_device(adapter);
+    ena_destroy_device(adapter, false);
     ena_restore_device(adapter);
     rtnl_unlock();
 }
@@ -3487,7 +3488,7 @@ static int ena_suspend(struct pci_dev *pdev,  pm_message_t state)
             "ignoring device reset request as the device is being suspended\n");
         clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
     }
-    ena_destroy_device(adapter);
+    ena_destroy_device(adapter, true);
     rtnl_unlock();
     return 0;
 }
-- 
2.17.1