Blame SOURCES/0004-ionic_protect_vf_calls_from_fw_reset.patch

1632d2
Date: Thu, 18 Jun 2020 19:42:40 -0400
1632d2
From: Jonathan Toppins <jtoppins@redhat.com>
1632d2
To: rhkernel-list@redhat.com
1632d2
Cc: darcari@redhat.com, nhorman@redhat.com, linville@redhat.com
1632d2
Subject: [PATCH RHEL-8.3 05/16] ionic: protect vf calls from fw reset
1632d2
1632d2
When going into a firmware upgrade cycle, we set the device as
1632d2
not present to keep some user commands from trying to change
1632d2
the driver while we're only half there.  Unfortunately, the
1632d2
ndo_vf_* calls don't check netif_device_present() so we need
1632d2
to add a check in the callbacks.
1632d2
1632d2
Signed-off-by: Shannon Nelson <snelson@pensando.io>
1632d2
Signed-off-by: David S. Miller <davem@davemloft.net>
1632d2
(cherry picked from commit a836c352291d4ad4031743a97a61f7916fe519b7)
1632d2
Bugzilla: 1848149
1632d2
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=29498383
1632d2
Tested: QE tested devel kernel as well as the partner
1632d2
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
1632d2
---
1632d2
 drivers/net/ethernet/pensando/ionic/ionic_lif.c | 26 ++++++++++++++++++++++++-
1632d2
 1 file changed, 25 insertions(+), 1 deletion(-)
1632d2
1632d2
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
1632d2
index d60ef816604a..423d2443d1c8 100644
1632d2
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
1632d2
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
1632d2
@@ -1707,7 +1707,7 @@ int ionic_stop(struct net_device *netdev)
1632d2
 {
1632d2
 	struct ionic_lif *lif = netdev_priv(netdev);
1632d2
 
1632d2
-	if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
1632d2
+	if (!netif_device_present(netdev))
1632d2
 		return 0;
1632d2
 
1632d2
 	ionic_stop_queues(lif);
1632d2
@@ -1724,6 +1724,9 @@ static int ionic_get_vf_config(struct net_device *netdev,
1632d2
 	struct ionic *ionic = lif->ionic;
1632d2
 	int ret = 0;
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_read(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
@@ -1751,6 +1754,9 @@ static int ionic_get_vf_stats(struct net_device *netdev, int vf,
1632d2
 	struct ionic_lif_stats *vs;
1632d2
 	int ret = 0;
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_read(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
@@ -1786,6 +1792,9 @@ static int ionic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
1632d2
 	if (!(is_zero_ether_addr(mac) || is_valid_ether_addr(mac)))
1632d2
 		return -EINVAL;
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_write(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
@@ -1817,6 +1826,9 @@ static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
1632d2
 	if (proto != htons(ETH_P_8021Q))
1632d2
 		return -EPROTONOSUPPORT;
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_write(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
@@ -1843,6 +1855,9 @@ static int ionic_set_vf_rate(struct net_device *netdev, int vf,
1632d2
 	if (tx_min)
1632d2
 		return -EINVAL;
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_write(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
@@ -1865,6 +1880,9 @@ static int ionic_set_vf_spoofchk(struct net_device *netdev, int vf, bool set)
1632d2
 	u8 data = set;  /* convert to u8 for config */
1632d2
 	int ret;
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_write(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
@@ -1887,6 +1905,9 @@ static int ionic_set_vf_trust(struct net_device *netdev, int vf, bool set)
1632d2
 	u8 data = set;  /* convert to u8 for config */
1632d2
 	int ret;
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_write(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
@@ -1923,6 +1944,9 @@ static int ionic_set_vf_link_state(struct net_device *netdev, int vf, int set)
1632d2
 		return -EINVAL;
1632d2
 	}
1632d2
 
1632d2
+	if (!netif_device_present(netdev))
1632d2
+		return -EBUSY;
1632d2
+
1632d2
 	down_write(&ionic->vf_op_lock);
1632d2
 
1632d2
 	if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
1632d2
-- 
1632d2
2.16.4
1632d2
1632d2