Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1536982

Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework initialization/deinitialization

From Richard Cochran <richardcochran@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework initialization/deinitialization
Date 2016-12-06 14:50 +0100
Message-ID <sLoi5-2FF-1@gated-at.bofh.it> (permalink)
References <sL7Ki-Dr-11@gated-at.bofh.it> <sL7Ki-Dr-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Dec 05, 2016 at 02:05:21PM -0600, Grygorii Strashko wrote:
> @@ -372,34 +354,27 @@ void cpts_tx_timestamp(struct cpts *cpts, struct sk_buff *skb)
>  }
>  EXPORT_SYMBOL_GPL(cpts_tx_timestamp);
>  
> -int cpts_register(struct device *dev, struct cpts *cpts,
> -		  u32 mult, u32 shift)
> +int cpts_register(struct cpts *cpts)
>  {
>  	int err, i;
>  
> -	cpts->info = cpts_info;
> -	spin_lock_init(&cpts->lock);
> -
> -	cpts->cc.read = cpts_systim_read;
> -	cpts->cc.mask = CLOCKSOURCE_MASK(32);
> -	cpts->cc_mult = mult;
> -	cpts->cc.mult = mult;
> -	cpts->cc.shift = shift;
> -
>  	INIT_LIST_HEAD(&cpts->events);
>  	INIT_LIST_HEAD(&cpts->pool);
>  	for (i = 0; i < CPTS_MAX_EVENTS; i++)
>  		list_add(&cpts->pool_data[i].list, &cpts->pool);
>  
> -	cpts_clk_init(dev, cpts);
> +	clk_enable(cpts->refclk);
> +
>  	cpts_write32(cpts, CPTS_EN, control);
>  	cpts_write32(cpts, TS_PEND_EN, int_enable);
>  
> +	/* reinitialize cc.mult to original value as it can be modified
> +	 * by cpts_ptp_adjfreq().
> +	 */
> +	cpts->cc.mult = cpts->cc_mult;

This still isn't quite right.  First of all, you shouldn't clobber the
learned cc.mult value in cpts_register().  Presumably, if PTP had been
run on this port before, then the learned frequency is approximately
correct, and it should be left alone.

[ BTW, resetting the timecounter here makes no sense either.  Why
  reset the clock just because the interface goes down?  ]

Secondly, you have made the initialization order of these fields hard
to follow.  With the whole series applied:

probe()
	cpts_create()
		cpts_of_parse()
		{
			/* Set cc_mult but not cc.mult! */
			set cc_mult
			set cc.shift
		}
		cpts_calc_mult_shift()
		{
			/* Set them both. */
			cpts->cc_mult = mult;
			cpts->cc.mult = mult;
			cpts->cc.shift = shift;
		}
/* later on */
cpts_register()
	cpts->cc.mult = cpts->cc_mult;

There is no need for such complexity.  Simply set cc.mult in
cpts_create() _once_, immediately after the call to
cpts_calc_mult_shift().

You can remove the assignment from cpts_calc_mult_shift() and
cpts_register().

Thanks,
Richard

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 09/13] net: ethernet: ti: cpts: rework initialization/deinitialization Grygorii Strashko <grygorii.strashko@ti.com> - 2016-12-05 21:10 +0100
  Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework  initialization/deinitialization Richard Cochran <richardcochran@gmail.com> - 2016-12-06 14:50 +0100
    Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework  initialization/deinitialization Grygorii Strashko <grygorii.strashko@ti.com> - 2016-12-06 17:50 +0100
      Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework  initialization/deinitialization Richard Cochran <richardcochran@gmail.com> - 2016-12-06 18:20 +0100
        Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework  initialization/deinitialization Grygorii Strashko <grygorii.strashko@ti.com> - 2016-12-06 18:50 +0100
          Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework  initialization/deinitialization Richard Cochran <richardcochran@gmail.com> - 2016-12-06 19:10 +0100

csiph-web