idpf: disable PCIe PTM on device removal
Subsystems (3)
PATCH 1/1 idpf: disable PCIe PTM on device removal
idpf_probe() enables PCIe Precision Time Measurement with pci_enable_ptm(pdev, NULL), which programs the PTM control bits and sets pdev->ptm_enabled when the bus/controller supports it. The teardown path in idpf_remove() releases the workqueues, vports, mutexes and the adapter memory but never calls pci_disable_ptm(), so PTM is left enabled on the device after the driver detaches.
This leaves the PCI core's software PTM state and the device's PTM control bits set with no bound driver. pcim_enable_device() only arranges for pci_disable_device() on teardown and does not undo the PTM enable, so it is not a substitute here.
Pair the enable with pci_disable_ptm(pdev) in idpf_remove(), matching the igc and mlx5 drivers which already disable PTM on their remove paths.
--- drivers/net/ethernet/intel/idpf/idpf_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_main.c +1 -0
@@ -159,6 +159,7 @@ static void idpf_remove(struct pci_dev *pdev)mutex_destroy (&adapter->queue_lock);mutex_destroy (&adapter->vc_buf_lock); +pci_disable_ptm (pdev);pci_set_drvdata (pdev,NULL );kfree (adapter); }
Signature · 1 line
2.47.1
Quoted 28 lines · Myeonghun Pak
idpf_probe()enables PCIe Precision Time Measurement withpci_enable_ptm(pdev, NULL), which programs the PTM control bits and setspdev->ptm_enabledwhen the bus/controller supports it. The teardown path inidpf_remove()releases the workqueues, vports, mutexes and the adapter memory but never callspci_disable_ptm(), so PTM is left enabled on the device after the driver detaches.This leaves the PCI core's software PTM state and the device's PTM control bits set with no bound driver.
pcim_enable_device()only arranges forpci_disable_device()on teardown and does not undo the PTM enable, so it is not a substitute here.Pair the enable with
pci_disable_ptm(pdev)inidpf_remove(), matching the igc and mlx5 drivers which already disable PTM on their remove paths.Fixes 8d5e12c5921c ("idpf: add initial PTP support")Co-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>--- drivers/net/ethernet/intel/idpf/idpf_main.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/intel/idpf/idpf_main.c +0
-0
drivers/net/ethernet/intel/idpf/idpf_main.c static void idpf_remove(struct pci_dev *pdev) · line 165
Quoted 7 lines
drivers/net/ethernet/intel/idpf/idpf_main.c +1
-0@@ -159,6 +159,7 @@ static void idpf_remove(struct pci_dev *pdev)mutex_destroy (&adapter->queue_lock);mutex_destroy (&adapter->vc_buf_lock); +pci_disable_ptm (pdev);pci_set_drvdata (pdev,NULL );kfree (adapter); }
Quoted 28 lines · Myeonghun Pak
idpf_probe()enables PCIe Precision Time Measurement withpci_enable_ptm(pdev, NULL), which programs the PTM control bits and setspdev->ptm_enabledwhen the bus/controller supports it. The teardown path inidpf_remove()releases the workqueues, vports, mutexes and the adapter memory but never callspci_disable_ptm(), so PTM is left enabled on the device after the driver detaches.This leaves the PCI core's software PTM state and the device's PTM control bits set with no bound driver.
pcim_enable_device()only arranges forpci_disable_device()on teardown and does not undo the PTM enable, so it is not a substitute here.Pair the enable with
pci_disable_ptm(pdev)inidpf_remove(), matching the igc and mlx5 drivers which already disable PTM on their remove paths.Fixes 8d5e12c5921c ("idpf: add initial PTP support")Co-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>--- drivers/net/ethernet/intel/idpf/idpf_main.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/intel/idpf/idpf_main.c +0
-0
drivers/net/ethernet/intel/idpf/idpf_main.c static void idpf_remove(struct pci_dev *pdev) · line 165
Quoted 7 lines
drivers/net/ethernet/intel/idpf/idpf_main.c +1
-0@@ -159,6 +159,7 @@ static void idpf_remove(struct pci_dev *pdev)mutex_destroy (&adapter->queue_lock);mutex_destroy (&adapter->vc_buf_lock); +pci_disable_ptm (pdev);pci_set_drvdata (pdev,NULL );kfree (adapter); }
I think another call will also be needed in idpf_probe() in the error path, following pci_enable_ptm().
Thanks,
Emil
Thanks, you're right. A successful pci_enable_ptm() is followed by several operations that may fail, and those paths currently return without disabling PTM.
I'll add pci_disable_ptm() to the common probe error unwind path and send a v2.
Thanks,
Myeonghun
2026년 7월 15일 (수) 오전 1:37, Tantilov, Emil S <[email protected]>님이 작성:
Quoted 43 lines · Myeonghun Pak
Quoted 28 lines
idpf_probe()enables PCIe Precision Time Measurement withpci_enable_ptm(pdev, NULL), which programs the PTM control bits and setspdev->ptm_enabledwhen the bus/controller supports it. The teardown path inidpf_remove()releases the workqueues, vports, mutexes and the adapter memory but never callspci_disable_ptm(), so PTM is left enabled on the device after the driver detaches.This leaves the PCI core's software PTM state and the device's PTM control bits set with no bound driver.
pcim_enable_device()only arranges forpci_disable_device()on teardown and does not undo the PTM enable, so it is not a substitute here.Pair the enable with
pci_disable_ptm(pdev)inidpf_remove(), matching the igc and mlx5 drivers which already disable PTM on their remove paths.Fixes 8d5e12c5921c ("idpf: add initial PTP support")Co-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>--- drivers/net/ethernet/intel/idpf/idpf_main.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/intel/idpf/idpf_main.c +0
-0drivers/net/ethernet/intel/idpf/idpf_main.c static void idpf_remove(struct pci_dev *pdev) · line 165
Quoted 7 lines
drivers/net/ethernet/intel/idpf/idpf_main.c +1
-0@@ -159,6 +159,7 @@ static void idpf_remove(struct pci_dev *pdev)mutex_destroy (&adapter->queue_lock);mutex_destroy (&adapter->vc_buf_lock); +pci_disable_ptm (pdev);pci_set_drvdata (pdev,NULL );kfree (adapter); }I think another call will also be needed in
idpf_probe()in the error path, followingpci_enable_ptm().Thanks,
Emil