Skip to contentSkip to conversation

net: dec: tulip: de2104x: Add shutdown handler to stop NIC

PATCH Superseded Moritz Fischer 2 participants 4 messages Oct 23, 2020 – Oct 29, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net: dec: tulip: de2104x: Add shutdown handler to stop NIC

The driver does not implement a shutdown handler which leads to issues when using kexec in certain scenarios. The NIC keeps on fetching descriptors which gets flagged by the IOMMU with errors like this:

DMAR: DMAR:[DMA read] Request device [5e:00.0]fault addr fffff000
DMAR: DMAR:[DMA read] Request device [5e:00.0]fault addr fffff000
DMAR: DMAR:[DMA read] Request device [5e:00.0]fault addr fffff000
DMAR: DMAR:[DMA read] Request device [5e:00.0]fault addr fffff000
DMAR: DMAR:[DMA read] Request device [5e:00.0]fault addr fffff000

---

I'd consider it a bug-fix but Jakub said it's a feature, so net-next it is. I don't have a strong preference either way.

Changes from v2:
- Changed to net-next
- Removed extra whitespace

Changes from v1:
- Replace call to de_remove_one with de_shutdown() function as suggested by James.

---
 drivers/net/ethernet/dec/tulip/de2104x.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/dec/tulip/de2104x.c +8 -0
index d9f6c19940ef..ea7442cc8e75 100644
@@ -2175,11 +2175,19 @@ static int __maybe_unused de_resume(struct device *dev_d)
 
 static SIMPLE_DEV_PM_OPS(de_pm_ops, de_suspend, de_resume);
 
+static void de_shutdown(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+
+	de_close(dev);
+}
+
 static struct pci_driver de_driver = {
 	.name		= DRV_NAME,
 	.id_table	= de_pci_tbl,
 	.probe		= de_init_one,
 	.remove		= de_remove_one,
+	.shutdown	= de_shutdown,
 	.driver.pm	= &de_pm_ops,
 };
 
Signature · 1 line
2.28.0
maintainer
#1 lore raw

drivers/net/ethernet/dec/tulip/de2104x.c static int __maybe_unused de_resume(struct device *dev_d) · line 2182

Quoted 13 lines · On Fri, 23 Oct 2020 13:28:34 -0700 Moritz Fischer wrote:
drivers/net/ethernet/dec/tulip/de2104x.c +5 -0
index d9f6c19940ef..ea7442cc8e75 100644
@@ -2175,11 +2175,19 @@ static int __maybe_unused de_resume(struct device *dev_d)
 
 static SIMPLE_DEV_PM_OPS(de_pm_ops, de_suspend, de_resume);
 
+static void de_shutdown(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+
+	de_close(dev);

Apparently I get all the best ideas when I'm about to apply something..

I don't think you can just call de_close() like that, because
(a) it may expect rtnl_lock() to be held, and (b) it may not be open.

Perhaps call unregister_netdev(dev) - that'll close the device. Or rtnl_lock(); dev_close(dev); rtnl_unlock();

Quoted 11 lines
drivers/net/ethernet/dec/tulip/de2104x.c +3 -0
+}
+
 static struct pci_driver de_driver = {
 	.name		= DRV_NAME,
 	.id_table	= de_pci_tbl,
 	.probe		= de_init_one,
 	.remove		= de_remove_one,
+	.shutdown	= de_shutdown,
 	.driver.pm	= &de_pm_ops,
 };
 
#2 lore raw

Hi Jakub,

Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Fri, 23 Oct 2020 13:28:34 -0700 Moritz Fischer wrote:
drivers/net/ethernet/dec/tulip/de2104x.c +0 -0
index d9f6c19940ef..ea7442cc8e75 100644
@@ -2175,11 +2175,19 @@ static int __maybe_unused de_resume(struct device *dev_d)
 
 static SIMPLE_DEV_PM_OPS(de_pm_ops, de_suspend, de_resume);
 
Quoted 7 lines

drivers/net/ethernet/dec/tulip/de2104x.c static int __maybe_unused de_resume(struct device *dev_d) · line 2182

Quoted 5 lines
drivers/net/ethernet/dec/tulip/de2104x.c +5 -0
+static void de_shutdown(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+
+	de_close(dev);

Apparently I get all the best ideas when I'm about to apply something..

Better now than after =)

Quoted 2 lines

I don't think you can just call de_close() like that, because
(a) it may expect rtnl_lock() to be held, and (b) it may not be open.

how about:

rtnl_lock();
if (netif_running(dev))

	dev_close(dev);

rtnl_unlock();

Quoted 4 lines

Perhaps call unregister_netdev(dev) - that'll close the device. Or rtnl_lock(); dev_close(dev); rtnl_unlock();

Quoted 12 lines

drivers/net/ethernet/dec/tulip/de2104x.c static int __maybe_unused de_resume(struct device *dev_d) · line 2193

Quoted 11 lines
drivers/net/ethernet/dec/tulip/de2104x.c +3 -0
+}
+
 static struct pci_driver de_driver = {
 	.name		= DRV_NAME,
 	.id_table	= de_pci_tbl,
 	.probe		= de_init_one,
 	.remove		= de_remove_one,
+	.shutdown	= de_shutdown,
 	.driver.pm	= &de_pm_ops,
 };
 

Cheers,
Moritz

maintainer
#3 lore raw
Quoted 25 lines · On Tue, 27 Oct 2020 18:59:09 -0700 Moritz Fischer wrote:

Hi Jakub,

Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Fri, 23 Oct 2020 13:28:34 -0700 Moritz Fischer wrote:
drivers/net/ethernet/dec/tulip/de2104x.c +0 -0
index d9f6c19940ef..ea7442cc8e75 100644
@@ -2175,11 +2175,19 @@ static int __maybe_unused de_resume(struct device *dev_d)
 
 static SIMPLE_DEV_PM_OPS(de_pm_ops, de_suspend, de_resume);
 
Quoted 7 lines

drivers/net/ethernet/dec/tulip/de2104x.c static int __maybe_unused de_resume(struct device *dev_d) · line 2182

Quoted 5 lines
drivers/net/ethernet/dec/tulip/de2104x.c +5 -0
+static void de_shutdown(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+
+	de_close(dev);  

Apparently I get all the best ideas when I'm about to apply something..

Better now than after =)

Quoted 2 lines

I don't think you can just call de_close() like that, because
(a) it may expect rtnl_lock() to be held, and (b) it may not be open.

Quoted 6 lines

how about:

rtnl_lock();
if (netif_running(dev))

	dev_close(dev);

rtnl_unlock();

That's fine as well, although dev_close() checks if the device is UP AFAICT.