All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kwapulinski, Piotr <piotr.kwapulinski@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v8] i40e: add support for PTP external synchronization clock
Date: Thu, 7 Jan 2021 11:35:07 +0000	[thread overview]
Message-ID: <MN2PR11MB4616EBBFA9D3C2A98BB6FACAF3AF0@MN2PR11MB4616.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201208123523.GA17489@hoboy.vegasvil.org>

>> @@ -145,14 +398,35 @@ static int i40e_ptp_adjfreq(struct 
>> ptp_clock_info *ptp, s32 ppb)  static int i40e_ptp_adjtime(struct 
>> ptp_clock_info *ptp, s64 delta)  {
>>  	struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
>> -	struct timespec64 now, then;
>> +	struct i40e_hw *hw = &pf->hw;
>>  
>> -	then = ns_to_timespec64(delta);
>>  	mutex_lock(&pf->tmreg_lock);
>>  
>> -	i40e_ptp_read(pf, &now, NULL);
>> -	now = timespec64_add(now, then);
>> -	i40e_ptp_write(pf, (const struct timespec64 *)&now);
>> +	if (delta > -999999900LL && delta < 999999900LL) {
>> +		int neg_adj = 0;
>> +		u32 timadj;
>> +		u64 tohw;
>> +
>> +		if (delta < 0) {
>> +			neg_adj = 1;
>> +			tohw = -delta;
>> +		} else {
>> +			tohw = delta;
>> +		}
>> +
>> +		timadj = tohw & 0x3FFFFFFF;
>> +		if (neg_adj)
>> +			timadj |= I40E_ISGN;
>> +		wr32(hw, I40E_PRTTSYN_ADJ, timadj);
>> +	} else {
>> +		struct timespec64 then, now;
>> +
>> +		then = ns_to_timespec64(delta);
>> +		i40e_ptp_read(pf, &now, NULL);
>> +		now = timespec64_add(now, then);
>> +		i40e_ptp_write(pf, (const struct timespec64 *)&now);
>> +		i40e_ptp_set_1pps_signal_hw(pf);
>
>This enables a 1-PPS hardware output unconditionally?
>
>> +	}
>>  
>>  	mutex_unlock(&pf->tmreg_lock);
>>  
>
>> @@ -839,6 +1492,8 @@ void i40e_ptp_init(struct i40e_pf *pf)
>>  		/* Restore the clock time based on last known value */
>>  		i40e_ptp_restore_hw_time(pf);
>>  	}
>> +
>> +	i40e_ptp_set_1pps_signal_hw(pf);
>>  }
>
>Here again the 1-PPS is enabled unconditionally.
>
>Instead, why not allow the user to enable/disable this?
>
>There is a new ioctl variant designed for periodic outputs like a PPS.
>
>Bits of the ptp_perout_request.flags field can contain:
>
> PTP_PEROUT_DUTY_CYCLE
> PTP_PEROUT_PHASE
>
>You can enable the PPS when they are present in the request.

Thank you for review Richard.
I've uploaded the version 9 of the patch that also includes support for all possible HW PIN configurations.
I plan to implement your suggestions.
Do you think that for now your suggestions prevent this patch to be merged.
I understand that they are more functional suggestions rather than bugs.

Best Regards
Piotr

  reply	other threads:[~2021-01-07 11:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 21:47 [Intel-wired-lan] [PATCH v7] i40e: add support for PTP external synchronization clock Piotr Kwapulinski
2020-12-07 21:10 ` Paul Menzel
2020-12-08  9:57   ` Kwapulinski, Piotr
2020-12-08 15:41   ` [Intel-wired-lan] [PATCH v8] " Piotr Kwapulinski
2020-12-08 10:51     ` Paul Menzel
2020-12-08 11:13       ` Kwapulinski, Piotr
2020-12-08 12:35     ` Richard Cochran
2021-01-07 11:35       ` Kwapulinski, Piotr [this message]
2020-12-08 11:01 ` [Intel-wired-lan] [PATCH v7] " Maciej Fijalkowski

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=MN2PR11MB4616EBBFA9D3C2A98BB6FACAF3AF0@MN2PR11MB4616.namprd11.prod.outlook.com \
    --to=piotr.kwapulinski@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.