* [PATCH v2] idpf: disable PCIe PTM on probe failure and removal
@ 2026-07-15 7:43 Myeonghun Pak
2026-07-15 9:38 ` [Intel-wired-lan] " Loktionov, Aleksandr
0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-07-15 7:43 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, intel-wired-lan
Cc: Milena Olech, Emil Tantilov, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
Myeonghun Pak, Ijae Kim
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.
If a later probe step fails, the error path releases the allocated
workqueues and adapter memory without disabling PTM. The remove path has
the same imbalance when a successfully probed device is detached. In
both cases, the PCI core's software PTM state and the device's PTM control
bits remain set with no bound driver.
Add pci_disable_ptm() to the common probe unwind after the PTM enable and
to idpf_remove(). pci_disable_ptm() is a no-op when PTM was not enabled,
so the non-fatal pci_enable_ptm() failure remains safe.
pcim_enable_device() only arranges for pci_disable_device() and does not
undo the PTM enable.
Fixes: 8d5e12c5921c ("idpf: add initial PTP support")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
Changes in v2:
- Disable PTM in the probe error path, as requested by Emil Tantilov.
drivers/net/ethernet/intel/idpf/idpf_main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
index 0dd741dcfc..f08ce13c20 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_main.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
@@ -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);
}
@@ -266,7 +267,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (err) {
pci_err(pdev, "DMA configuration failed: %pe\n", ERR_PTR(err));
- goto err_free;
+ goto err_disable_ptm;
}
pci_set_master(pdev);
@@ -279,7 +280,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!adapter->init_wq) {
dev_err(dev, "Failed to allocate init workqueue\n");
err = -ENOMEM;
- goto err_free;
+ goto err_disable_ptm;
}
adapter->serv_wq = alloc_workqueue("%s-%s-service",
@@ -366,6 +367,8 @@ err_mbx_wq_alloc:
destroy_workqueue(adapter->serv_wq);
err_serv_wq_alloc:
destroy_workqueue(adapter->init_wq);
+err_disable_ptm:
+ pci_disable_ptm(pdev);
err_free:
kfree(adapter);
return err;
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [Intel-wired-lan] [PATCH v2] idpf: disable PCIe PTM on probe failure and removal
2026-07-15 7:43 [PATCH v2] idpf: disable PCIe PTM on probe failure and removal Myeonghun Pak
@ 2026-07-15 9:38 ` Loktionov, Aleksandr
0 siblings, 0 replies; 2+ messages in thread
From: Loktionov, Aleksandr @ 2026-07-15 9:38 UTC (permalink / raw)
To: Myeonghun Pak, Nguyen, Anthony L, Kitszel, Przemyslaw,
intel-wired-lan@lists.osuosl.org
Cc: Olech, Milena, Tantilov, Emil S, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Ijae Kim
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Myeonghun Pak
> Sent: Wednesday, July 15, 2026 9:44 AM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel.com>; intel-wired-
> lan@lists.osuosl.org
> Cc: Olech, Milena <milena.olech@intel.com>; Tantilov, Emil S
> <emil.s.tantilov@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>;
> David S . Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; Myeonghun Pak <mhun512@gmail.com>; Ijae Kim
> <ae878000@gmail.com>
> Subject: [Intel-wired-lan] [PATCH v2] idpf: disable PCIe PTM on probe
> failure and 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.
>
> If a later probe step fails, the error path releases the allocated
> workqueues and adapter memory without disabling PTM. The remove path
> has the same imbalance when a successfully probed device is detached.
> In both cases, the PCI core's software PTM state and the device's PTM
> control bits remain set with no bound driver.
>
> Add pci_disable_ptm() to the common probe unwind after the PTM enable
> and to idpf_remove(). pci_disable_ptm() is a no-op when PTM was not
> enabled, so the non-fatal pci_enable_ptm() failure remains safe.
> pcim_enable_device() only arranges for pci_disable_device() and does
> not undo the PTM enable.
>
> Fixes: 8d5e12c5921c ("idpf: add initial PTP support")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
> Changes in v2:
> - Disable PTM in the probe error path, as requested by Emil Tantilov.
>
> drivers/net/ethernet/intel/idpf/idpf_main.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c
> b/drivers/net/ethernet/intel/idpf/idpf_main.c
> index 0dd741dcfc..f08ce13c20 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_main.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
> @@ -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);
> }
> @@ -266,7 +267,7 @@ static int idpf_probe(struct pci_dev *pdev, const
> struct pci_device_id *ent)
> if (err) {
> pci_err(pdev, "DMA configuration failed: %pe\n",
> ERR_PTR(err));
>
> - goto err_free;
> + goto err_disable_ptm;
> }
>
> pci_set_master(pdev);
> @@ -279,7 +280,7 @@ static int idpf_probe(struct pci_dev *pdev, const
> struct pci_device_id *ent)
> if (!adapter->init_wq) {
> dev_err(dev, "Failed to allocate init workqueue\n");
> err = -ENOMEM;
> - goto err_free;
> + goto err_disable_ptm;
> }
>
> adapter->serv_wq = alloc_workqueue("%s-%s-service", @@ -366,6
> +367,8 @@ err_mbx_wq_alloc:
> destroy_workqueue(adapter->serv_wq);
> err_serv_wq_alloc:
> destroy_workqueue(adapter->init_wq);
> +err_disable_ptm:
> + pci_disable_ptm(pdev);
> err_free:
> kfree(adapter);
> return err;
> --
> 2.47.1
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-15 9:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 7:43 [PATCH v2] idpf: disable PCIe PTM on probe failure and removal Myeonghun Pak
2026-07-15 9:38 ` [Intel-wired-lan] " Loktionov, Aleksandr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox