Netdev List
 help / color / mirror / Atom feed
From: luoxuanqiang <xuanqiang.luo@linux.dev>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	intel-wired-lan@lists.osuosl.org
Cc: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
	richardcochran@gmail.com, piotr.kwapulinski@intel.com,
	arkadiusz.kubalewski@intel.com, aleksandr.loktionov@intel.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Subject: Re: [PATCH iwl-net v1] i40e: fix races in PTP external timestamp work handling
Date: Wed, 5 Aug 2026 15:13:21 +0800	[thread overview]
Message-ID: <ea295e13-6a35-4ce5-b289-f9f37b67dcf8@linux.dev> (raw)
In-Reply-To: <dce23bb6-138b-4a53-9447-26e81c86c292@linux.dev>


在 2026/8/5 05:33, Vadim Fedorenko 写道:
> On 24/07/2026 10:34, xuanqiang.luo@linux.dev wrote:
>>
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c 
>> b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
>> index ff62b5f2c8150..fd51ab8c10c20 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
>> +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
>> @@ -169,6 +169,17 @@ static void i40e_ptp_extts0_work(struct 
>> work_struct *work)
>>       ptp_clock_event(pf->ptp_clock, &event);
>>   }
>>   +/**
>> + * i40e_ptp_init_work - Initialize PTP work for a PF
>> + * @pf: Board private structure
>> + *
>> + * Initialize work which must remain valid for the lifetime of the PF.
>> + */
>> +void i40e_ptp_init_work(struct i40e_pf *pf)
>> +{
>> +    INIT_WORK(&pf->ptp_extts0_work, i40e_ptp_extts0_work);
>> +}
>> +
>
> why do you need extra function for a single line of code? why cannot 
> you put it into i40e_ptp_init?
>
>
Thanks for pointing this out.

i40e_ptp_init() is also called from the reset/rebuild path:

   i40e_service_task()
     -> i40e_reset_subtask()
       -> i40e_reset_and_rebuild()
         -> i40e_rebuild()
           -> i40e_setup_pf_switch()
             -> i40e_ptp_init()

Putting INIT_WORK() there would reinitialize the work item during reset or
recovery. If the work is pending or running, this races with the workqueue,
resets its bookkeeping, and breaks the workqueue's non-reentrance
guarantee.

The work item is therefore initialized once per PF from i40e_sw_init().
The helper also keeps the work callback private to i40e_ptp.c.


  reply	other threads:[~2026-08-05  7:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  9:34 [PATCH iwl-net v1] i40e: fix races in PTP external timestamp work handling xuanqiang.luo
2026-07-30 12:25 ` Simon Horman
2026-08-05  6:55   ` luoxuanqiang
2026-08-04 21:33 ` Vadim Fedorenko
2026-08-05  7:13   ` luoxuanqiang [this message]
2026-08-05  9:49     ` Vadim Fedorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea295e13-6a35-4ce5-b289-f9f37b67dcf8@linux.dev \
    --to=xuanqiang.luo@linux.dev \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kuba@kernel.org \
    --cc=luoxuanqiang@kylinos.cn \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=piotr.kwapulinski@intel.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=richardcochran@gmail.com \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox