public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Mugunthan V N <mugunthanvnm@ti.com>,
	Sekhar Nori <nsekhar@ti.com>,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	devicetree@vger.kernel.org,
	Murali Karicheri <m-karicheri2@ti.com>,
	Wingman Kwok <w-kwok2@ti.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v4 09/13] net: ethernet: ti: cpts: rework initialization/deinitialization
Date: Tue, 6 Dec 2016 14:40:37 +0100	[thread overview]
Message-ID: <20161206134037.GA15946@localhost.localdomain> (raw)
In-Reply-To: <20161205200525.16664-10-grygorii.strashko@ti.com>

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

  reply	other threads:[~2016-12-06 13:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05 20:05 [PATCH v4 00/13] net: ethernet: ti: cpts: update and fixes Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 01/13] net: ethernet: ti: cpts: switch to readl/writel_relaxed() Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 02/13] net: ethernet: ti: allow cpts to be built separately Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 03/13] net: ethernet: ti: cpsw: minimize direct access to struct cpts Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 04/13] net: ethernet: ti: cpts: fix unbalanced clk api usage in cpts_register/unregister Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 05/13] net: ethernet: ti: cpts: fix registration order Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 06/13] net: ethernet: ti: cpts: disable cpts when unregistered Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 07/13] net: ethernet: ti: cpts: clean up event list if event pool is empty Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 08/13] net: ethernet: ti: cpts: drop excessive writes to CTRL and INT_EN regs Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 09/13] net: ethernet: ti: cpts: rework initialization/deinitialization Grygorii Strashko
2016-12-06 13:40   ` Richard Cochran [this message]
2016-12-06 16:45     ` Grygorii Strashko
2016-12-06 17:18       ` Richard Cochran
2016-12-06 17:49         ` Grygorii Strashko
2016-12-06 18:04           ` Richard Cochran
2016-12-05 20:05 ` [PATCH v4 10/13] net: ethernet: ti: cpts: move dt props parsing to cpts driver Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 11/13] clocksource: export the clocks_calc_mult_shift to use by timestamp code Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 12/13] net: ethernet: ti: cpts: calc mult and shift from refclk freq Grygorii Strashko
2016-12-05 20:05 ` [PATCH v4 13/13] net: ethernet: ti: cpts: fix overflow check period Grygorii Strashko

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=20161206134037.GA15946@localhost.localdomain \
    --to=richardcochran@gmail.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=grygorii.strashko@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=tglx@linutronix.de \
    --cc=w-kwok2@ti.com \
    /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