idpf: cleanup remaining SKBs in PTP flows
Subsystems (3)
PATCH 1/1 idpf: cleanup remaining SKBs in PTP flows
From: Milena Olech <[email protected]>
When the driver requests Tx timestamp value, one of the first steps is to clone SKB using skb_get. It increases the reference counter for that SKB to prevent unexpected freeing by another component. However, there may be a case where the index is requested, SKB is assigned and never consumed by PTP flows - for example due to reset during running PTP apps.
Add a check in release timestamping function to verify if the SKB assigned to Tx timestamp latch was freed, and release remaining SKBs.
--- drivers/net/ethernet/intel/idpf/idpf_ptp.c | 3 +++ drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c | 1 + 2 files changed, 4 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_ptp.c +3 -0
@@ -855,6 +855,9 @@ static void idpf_ptp_release_vport_tstamp(struct idpf_vport *vport) head = &vport->tx_tstamp_caps->latches_in_use;list_for_each_entry_safe (ptp_tx_tstamp, tmp, head, list_member) {list_del (&ptp_tx_tstamp->list_member); +if (ptp_tx_tstamp->skb) +consume_skb (ptp_tx_tstamp->skb); +kfree (ptp_tx_tstamp); }
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +1 -0
@@ -517,6 +517,7 @@ idpf_ptp_get_tstamp_value(struct idpf_vport *vport, shhwtstamps.hwtstamp =ns_to_ktime (tstamp);skb_tstamp_tx (ptp_tx_tstamp->skb, &shhwtstamps);consume_skb (ptp_tx_tstamp->skb); + ptp_tx_tstamp->skb =NULL ;list_add (&ptp_tx_tstamp->list_member, &tx_tstamp_caps->latches_free);
base-commit: 94f1d1440652b6145cbaa026f376ae4e7fb95843
Signature · 1 line
2.42.0
Dear Anton, dear Milena,
Thank you for the patch.
Am 13.08.25 um 19:33 schrieb Anton Nadezhdin:
Quoted 40 lines
From: Milena Olech <[email protected]>
When the driver requests Tx timestamp value, one of the first steps is to clone SKB using
skb_get. It increases the reference counter for that SKB to prevent unexpected freeing by another component. However, there may be a case where the index is requested, SKB is assigned and never consumed by PTP flows - for example due to reset during running PTP apps.Add a check in release timestamping function to verify if the SKB assigned to Tx timestamp latch was freed, and release remaining SKBs.
Fixes 4901e83a94ef ("idpf: add Tx timestamp capabilities negotiation")Signed-off-by Milena Olech <[email protected]>Signed-off-by Anton Nadezhdin <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>--- drivers/net/ethernet/intel/idpf/idpf_ptp.c | 3 +++ drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c | 1 + 2 files changed, 4 insertions(+)drivers/net/ethernet/intel/idpf/idpf_ptp.c +3
-0@@ -855,6 +855,9 @@ static void idpf_ptp_release_vport_tstamp(struct idpf_vport *vport) head = &vport->tx_tstamp_caps->latches_in_use;list_for_each_entry_safe (ptp_tx_tstamp, tmp, head, list_member) {list_del (&ptp_tx_tstamp->list_member); +if (ptp_tx_tstamp->skb) +consume_skb (ptp_tx_tstamp->skb); +kfree (ptp_tx_tstamp); }drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +0
-0
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c idpf_ptp_get_tstamp_value(struct idpf_vport *vport, · line 520
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +1
-0@@ -517,6 +517,7 @@ idpf_ptp_get_tstamp_value(struct idpf_vport *vport, shhwtstamps.hwtstamp =ns_to_ktime (tstamp);skb_tstamp_tx (ptp_tx_tstamp->skb, &shhwtstamps);consume_skb (ptp_tx_tstamp->skb); + ptp_tx_tstamp->skb =NULL ;
This hunk is not clear to me from the commit message, and the whole diff.
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c idpf_ptp_get_tstamp_value(struct idpf_vport *vport, · line 523
Quoted 3 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +0
-0list_add (&ptp_tx_tstamp->list_member, &tx_tstamp_caps->latches_free);
Kind regards,
Paul
Quoted 47 lines · Paul Menzel
Dear Anton, dear Milena,
Thank you for the patch.
Am 13.08.25 um 19:33 schrieb Anton Nadezhdin:
Quoted 41 lines
From: Milena Olech <[email protected]>
When the driver requests Tx timestamp value, one of the first steps is to clone SKB using
skb_get. It increases the reference counter for that SKB to prevent unexpected freeing by another component. However, there may be a case where the index is requested, SKB is assigned and never consumed by PTP flows - for example due to reset during
running PTP apps.Add a check in release timestamping function to verify if the SKB assigned to Tx timestamp latch was freed, and release remaining SKBs.
Fixes 4901e83a94ef ("idpf: add Tx timestamp capabilities negotiation")Signed-off-by Milena Olech <[email protected]>Signed-off-by Anton Nadezhdin <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>---
drivers/net/ethernet/intel/idpf/idpf_ptp.c | 3 +++drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c| 1 +2 files changed, 4 insertions(+)drivers/net/ renamed from drivers/net/ethernet/intel/idpf/idpf_ptp.c +0
-0
ethernet/intel/idpf/idpf_ptp.c
indexee21f2ff0cad..63a41e688733100644drivers/net/ethernet/intel/idpf/idpf_ptp.c +3
-0@@ -855,6 +855,9 @@ static void idpf_ptp_release_vport_tstamp(struct idpf_vport *vport) head = &vport->tx_tstamp_caps->latches_in_use; list_for_each_entry_safe(ptp_tx_tstamp, tmp, head, list_member) { list_del(&ptp_tx_tstamp->list_member); + if (ptp_tx_tstamp->skb) + consume_skb(ptp_tx_tstamp->skb); + kfree(ptp_tx_tstamp); }diff --git
a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.cb/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
index4f1fb0cefe51..688a6f4e0acc100644
---a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_ptp.c idpf_ptp_get_tstamp_value(struct idpf_vport *vport, · line 520
Quoted 6 lines
+++
b/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.cdrivers/net/ethernet/intel/idpf/idpf_ptp.c +1
-0@@ -517,6 +517,7 @@ idpf_ptp_get_tstamp_value(struct idpf_vport *vport, shhwtstamps.hwtstamp = ns_to_ktime(tstamp); skb_tstamp_tx(ptp_tx_tstamp->skb, &shhwtstamps); consume_skb(ptp_tx_tstamp->skb); + ptp_tx_tstamp->skb = NULL;This hunk is not clear to me from the commit message, and the whole diff.
So in idpf_ptp_request_ts the code is making copy of skb, normally when this copy is consumed in idpf_ptp_get_tstamp_value but in case of a reset the normal flow is interrupted and skb is still in hold. This patch release it during reset procedure.
Quoted 7 lines
drivers/net/ethernet/intel/idpf/idpf_ptp.c idpf_ptp_get_tstamp_value(struct idpf_vport *vport, · line 522
Quoted 3 lines
drivers/net/ethernet/intel/idpf/idpf_ptp.c +0
-0list_add(&ptp_tx_tstamp->list_member, &tx_tstamp_caps->latches_free);Kind regards,
Paul
Salin, Samuel
Tested-byQuoted 73 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nadezhdin, Anton
Sent: Thursday, August 14, 2025 1:17 AM
To: Paul Menzel <[email protected]>; Olech, Milena <[email protected]>
Cc: [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; Loktionov, Aleksandr <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-net] idpf: cleanup remaining SKBs in PTP flowsQuoted 49 lines · Paul Menzel
Dear Anton, dear Milena,
Thank you for the patch.
Am 13.08.25 um 19:33 schrieb Anton Nadezhdin:
Quoted 43 lines
From: Milena Olech <[email protected]>
When the driver requests Tx timestamp value, one of the first steps is to clone SKB using
skb_get. It increases the reference counter for that SKB to prevent unexpected freeing by another component. However, there may be a case where the index is requested, SKB is assigned and never consumed by PTP flows - for example due to reset during running PTP apps.Add a check in release timestamping function to verify if the SKB assigned to Tx timestamp latch was freed, and release remaining SKBs.
Fixes 4901e83a94ef ("idpf: add Tx timestamp capabilitiesnegotiation")
Signed-off-by Milena Olech <[email protected]>Signed-off-by Anton Nadezhdin <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>---
drivers/net/ethernet/intel/idpf/idpf_ptp.c | 3 +++drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c| 1 +2 files changed, 4 insertions(+)(quoted diff) +0
-0b/drivers/net/
ethernet/intel/idpf/idpf_ptp.cindexee21f2ff0cad..63a41e688733100644drivers/net/ethernet/intel/idpf/idpf_ptp.c +3
-0@@ -855,6 +855,9 @@ static void idpf_ptp_release_vport_tstamp(struct idpf_vport *vport) head = &vport->tx_tstamp_caps->latches_in_use; list_for_each_entry_safe(ptp_tx_tstamp, tmp, head, list_member) { list_del(&ptp_tx_tstamp->list_member); + if (ptp_tx_tstamp->skb) + consume_skb(ptp_tx_tstamp->skb); + kfree(ptp_tx_tstamp);}
diff --gita/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.cb/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
index4f1fb0cefe51..688a6f4e0acc100644drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +0
-0Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c idpf_ptp_get_tstamp_value(struct idpf_vport · line 521
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +1
-0@@ -517,6 +517,7 @@ idpf_ptp_get_tstamp_value(struct idpf_vport *vport, shhwtstamps.hwtstamp = ns_to_ktime(tstamp); skb_tstamp_tx(ptp_tx_tstamp->skb, &shhwtstamps); consume_skb(ptp_tx_tstamp->skb); + ptp_tx_tstamp->skb = NULL;This hunk is not clear to me from the commit message, and the whole diff.
Quoted 12 lines
So in
idpf_ptp_request_tsthe code is making copy of skb, normally when this copy is consumed inidpf_ptp_get_tstamp_valuebut in case of a reset the normal flow is interrupted and skb is still in hold.
This patch release it during reset procedure.Quoted 7 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c idpf_ptp_get_tstamp_value(struct idpf_vport *vport, · line 523
Quoted 3 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c +0
-0list_add(&ptp_tx_tstamp->list_member, &tx_tstamp_caps->latches_free);Kind regards,
Paul