* [Intel-wired-lan] [PATCH net v1 0/2] Fix close path on shutdown and remove in iavf driver.
@ 2022-07-06 13:54 Mateusz Palczewski
2022-07-06 13:54 ` [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one Mateusz Palczewski
2022-07-06 13:54 ` [Intel-wired-lan] [PATCH net v1 2/2] iavf: Fix race condition between iavf_shutdown and iavf_remove Mateusz Palczewski
0 siblings, 2 replies; 5+ messages in thread
From: Mateusz Palczewski @ 2022-07-06 13:54 UTC (permalink / raw)
To: intel-wired-lan
iavf_shutdown was implementing an incomplete version
of iavf_remove. It misses several calls to the kernel like
iavf_free_misc_irq, iavf_reset_interrupt_capability, iounmap
that might break the system on reboot or hibernation.
Fix a deadlock introduced by commit
974578017fc1f ("iavf: Add waiting so the port is initialized in remove")
due to race condition between iavf_shutdown and iavf_remove, where
iavf_remove stucks forever in while loop since iavf_shutdown already
set __IAVF_REMOVE adapter state.
SlawomirX Laba (2):
iavf: Fix shutdown pci callback to match the remove one
iavf: Fix race condition between iavf_shutdown and iavf_remove
drivers/net/ethernet/intel/iavf/iavf_main.c | 59 ++++++++-------------
1 file changed, 22 insertions(+), 37 deletions(-)
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 5+ messages in thread* [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one
2022-07-06 13:54 [Intel-wired-lan] [PATCH net v1 0/2] Fix close path on shutdown and remove in iavf driver Mateusz Palczewski
@ 2022-07-06 13:54 ` Mateusz Palczewski
2022-07-12 22:01 ` Tony Nguyen
2022-07-06 13:54 ` [Intel-wired-lan] [PATCH net v1 2/2] iavf: Fix race condition between iavf_shutdown and iavf_remove Mateusz Palczewski
1 sibling, 1 reply; 5+ messages in thread
From: Mateusz Palczewski @ 2022-07-06 13:54 UTC (permalink / raw)
To: intel-wired-lan; +Cc: SlawomirX Laba
From: SlawomirX Laba <slawomirx.laba@intel.com>
Make the flow for pci shutdown be the same to the pci remove.
iavf_shutdown was implementing an incomplete version
of iavf_remove. It misses several calls to the kernel like
iavf_free_misc_irq, iavf_reset_interrupt_capability, iounmap
that might break the system on reboot or hibernation.
Implement the call of iavf_remove directly in iavf_shutdown to
close this gap.
Fixes: 5eae00c57f5e ("i40evf: main driver core")
Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 40 +++++++--------------
1 file changed, 12 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index f3ecb3bca33d..74be5e3a09df 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -4545,34 +4545,6 @@ int iavf_process_config(struct iavf_adapter *adapter)
return 0;
}
-/**
- * iavf_shutdown - Shutdown the device in preparation for a reboot
- * @pdev: pci device structure
- **/
-static void iavf_shutdown(struct pci_dev *pdev)
-{
- struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
- struct net_device *netdev = adapter->netdev;
-
- netif_device_detach(netdev);
-
- if (netif_running(netdev))
- iavf_close(netdev);
-
- if (iavf_lock_timeout(&adapter->crit_lock, 5000))
- dev_warn(&adapter->pdev->dev, "failed to acquire crit_lock in %s\n", __FUNCTION__);
- /* Prevent the watchdog from running. */
- iavf_change_state(adapter, __IAVF_REMOVE);
- adapter->aq_required = 0;
- mutex_unlock(&adapter->crit_lock);
-
-#ifdef CONFIG_PM
- pci_save_state(pdev);
-
-#endif
- pci_disable_device(pdev);
-}
-
/**
* iavf_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -4909,6 +4881,18 @@ static void iavf_remove(struct pci_dev *pdev)
pci_disable_device(pdev);
}
+/**
+ * iavf_shutdown - Shutdown the device in preparation for a reboot
+ * @pdev: pci device structure
+ **/
+static void iavf_shutdown(struct pci_dev *pdev)
+{
+ iavf_remove(pdev);
+
+ if (system_state == SYSTEM_POWER_OFF)
+ pci_set_power_state(pdev, PCI_D3hot);
+}
+
static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume);
static struct pci_driver iavf_driver = {
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one
2022-07-06 13:54 ` [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one Mateusz Palczewski
@ 2022-07-12 22:01 ` Tony Nguyen
0 siblings, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2022-07-12 22:01 UTC (permalink / raw)
To: Mateusz Palczewski, intel-wired-lan; +Cc: SlawomirX Laba
On 7/6/2022 6:54 AM, Mateusz Palczewski wrote:
> From: SlawomirX Laba <slawomirx.laba@intel.com>
From:/Signed-off-by: email name mismatch: 'From: SlawomirX Laba
<slawomirx.laba@intel.com>' != 'Signed-off-by: Slawomir Laba
<slawomirx.laba@intel.com>'
> Make the flow for pci shutdown be the same to the pci remove.
>
> iavf_shutdown was implementing an incomplete version
> of iavf_remove. It misses several calls to the kernel like
> iavf_free_misc_irq, iavf_reset_interrupt_capability, iounmap
> that might break the system on reboot or hibernation.
>
> Implement the call of iavf_remove directly in iavf_shutdown to
> close this gap.
>
> Fixes: 5eae00c57f5e ("i40evf: main driver core")
> Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
> Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
Same issue for patch 2.
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Intel-wired-lan] [PATCH net v1 2/2] iavf: Fix race condition between iavf_shutdown and iavf_remove
2022-07-06 13:54 [Intel-wired-lan] [PATCH net v1 0/2] Fix close path on shutdown and remove in iavf driver Mateusz Palczewski
2022-07-06 13:54 ` [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one Mateusz Palczewski
@ 2022-07-06 13:54 ` Mateusz Palczewski
1 sibling, 0 replies; 5+ messages in thread
From: Mateusz Palczewski @ 2022-07-06 13:54 UTC (permalink / raw)
To: intel-wired-lan; +Cc: SlawomirX Laba
From: SlawomirX Laba <slawomirx.laba@intel.com>
Fix a deadlock introduced by commit
974578017fc1 ("iavf: Add waiting so the port is initialized in remove")
due to race condition between iavf_shutdown and iavf_remove, where
iavf_remove stucks forever in while loop since iavf_shutdown already
set __IAVF_REMOVE adapter state.
Fix this by checking if the __IAVF_IN_REMOVE_TASK has already been
set and return if so.
Fixes: 974578017fc1 ("iavf: Add waiting so the port is initialized in remove")
Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 74be5e3a09df..d0889fe24b9e 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -4744,23 +4744,24 @@ static int __maybe_unused iavf_resume(struct device *dev_d)
static void iavf_remove(struct pci_dev *pdev)
{
struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
- struct net_device *netdev = adapter->netdev;
struct iavf_fdir_fltr *fdir, *fdirtmp;
struct iavf_vlan_filter *vlf, *vlftmp;
+ struct iavf_cloud_filter *cf, *cftmp;
struct iavf_adv_rss *rss, *rsstmp;
struct iavf_mac_filter *f, *ftmp;
- struct iavf_cloud_filter *cf, *cftmp;
- struct iavf_hw *hw = &adapter->hw;
+ struct net_device *netdev;
+ struct iavf_hw *hw;
int err;
- /* When reboot/shutdown is in progress no need to do anything
- * as the adapter is already REMOVE state that was set during
- * iavf_shutdown() callback.
- */
- if (adapter->state == __IAVF_REMOVE)
+ if (!adapter)
+ return;
+
+ netdev = adapter->netdev;
+ hw = &adapter->hw;
+
+ if (test_and_set_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section))
return;
- set_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section);
/* Wait until port initialization is complete.
* There are flows where register/unregister netdev may race.
*/
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one
@ 2022-07-04 12:41 Mateusz Palczewski
0 siblings, 0 replies; 5+ messages in thread
From: Mateusz Palczewski @ 2022-07-04 12:41 UTC (permalink / raw)
To: intel-wired-lan; +Cc: SlawomirX Laba
From: SlawomirX Laba <slawomirx.laba@intel.com>
Make the flow for pci shutdown be the same to the pci remove.
iavf_shutdown was implementing an incomplete version
of iavf_remove. It misses several calls to the kernel like
iavf_free_misc_irq, iavf_reset_interrupt_capability, iounmap
that might break the system on reboot or hibernation.
Implement the call of iavf_remove directly in iavf_shutdown to
close this gap.
Fixes: 5eae00c57f5e ("i40evf: main driver core")
Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 40 +++++++--------------
1 file changed, 12 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index f3ecb3bca33d..74be5e3a09df 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -4545,34 +4545,6 @@ int iavf_process_config(struct iavf_adapter *adapter)
return 0;
}
-/**
- * iavf_shutdown - Shutdown the device in preparation for a reboot
- * @pdev: pci device structure
- **/
-static void iavf_shutdown(struct pci_dev *pdev)
-{
- struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
- struct net_device *netdev = adapter->netdev;
-
- netif_device_detach(netdev);
-
- if (netif_running(netdev))
- iavf_close(netdev);
-
- if (iavf_lock_timeout(&adapter->crit_lock, 5000))
- dev_warn(&adapter->pdev->dev, "failed to acquire crit_lock in %s\n", __FUNCTION__);
- /* Prevent the watchdog from running. */
- iavf_change_state(adapter, __IAVF_REMOVE);
- adapter->aq_required = 0;
- mutex_unlock(&adapter->crit_lock);
-
-#ifdef CONFIG_PM
- pci_save_state(pdev);
-
-#endif
- pci_disable_device(pdev);
-}
-
/**
* iavf_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -4909,6 +4881,18 @@ static void iavf_remove(struct pci_dev *pdev)
pci_disable_device(pdev);
}
+/**
+ * iavf_shutdown - Shutdown the device in preparation for a reboot
+ * @pdev: pci device structure
+ **/
+static void iavf_shutdown(struct pci_dev *pdev)
+{
+ iavf_remove(pdev);
+
+ if (system_state == SYSTEM_POWER_OFF)
+ pci_set_power_state(pdev, PCI_D3hot);
+}
+
static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume);
static struct pci_driver iavf_driver = {
--
2.27.0
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-12 22:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-06 13:54 [Intel-wired-lan] [PATCH net v1 0/2] Fix close path on shutdown and remove in iavf driver Mateusz Palczewski
2022-07-06 13:54 ` [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one Mateusz Palczewski
2022-07-12 22:01 ` Tony Nguyen
2022-07-06 13:54 ` [Intel-wired-lan] [PATCH net v1 2/2] iavf: Fix race condition between iavf_shutdown and iavf_remove Mateusz Palczewski
-- strict thread matches above, loose matches on Subject: below --
2022-07-04 12:41 [Intel-wired-lan] [PATCH net v1 1/2] iavf: Fix shutdown pci callback to match the remove one Mateusz Palczewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox