netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: Fugang Duan <b38611@freescale.com>
Cc: shawn.guo@linaro.org, b20596@freescale.com, davem@davemloft.net,
	netdev@vger.kernel.org
Subject: Re: [PATCH] net: fec: ptp: avoid register access when ipg clock is disabled
Date: Mon, 21 Jul 2014 06:03:01 +0200	[thread overview]
Message-ID: <20140721040301.GA4035@localhost.localdomain> (raw)
In-Reply-To: <1405910155-29760-1-git-send-email-b38611@freescale.com>

On Mon, Jul 21, 2014 at 10:35:55AM +0800, Fugang Duan wrote:

> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index e0efb21..c4944e1 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -997,7 +997,7 @@ fec_restart(struct net_device *ndev)
>  	writel(ecntl, fep->hwp + FEC_ECNTRL);
>  	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
>  
> -	if (fep->bufdesc_ex)
> +	if (fep->bufdesc_ex && (fep->hwts_tx_en || fep->hwts_rx_en))
>  		fec_ptp_start_cyclecounter(ndev);
>  
>  	/* Enable interrupts we wish to service */
> @@ -1026,6 +1026,9 @@ fec_stop(struct net_device *ndev)
>  	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
>  	writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
>  
> +	if (fep->bufdesc_ex && (fep->hwts_tx_en || fep->hwts_rx_en))
> +		fec_ptp_stop(ndev);

So if user space turns time stamping off, then you keep running the
timer. That is wrong, isn't it?

>  	/* We have to keep ENET enabled to have MII interrupt stay working */
>  	if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {
>  		writel(2, fep->hwp + FEC_ECNTRL);
> diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
> index 82386b2..b2e9eb4 100644
> --- a/drivers/net/ethernet/freescale/fec_ptp.c
> +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> @@ -128,6 +128,9 @@ void fec_ptp_start_cyclecounter(struct net_device *ndev)
>  	timecounter_init(&fep->tc, &fep->cc, ktime_to_ns(ktime_get_real()));
>  
>  	spin_unlock_irqrestore(&fep->tmreg_lock, flags);
> +
> +	if (!timer_pending(&fep->time_keep))
> +		add_timer(&fep->time_keep);

Why not use a work queue for this?

Thanks,
Richard

>  }
>  
>  /**
> @@ -390,7 +393,6 @@ void fec_ptp_init(struct platform_device *pdev)
>  	fep->time_keep.data = (unsigned long)fep;
>  	fep->time_keep.function = fec_time_keep;
>  	fep->time_keep.expires = jiffies + HZ;
> -	add_timer(&fep->time_keep);
>  
>  	fep->ptp_clock = ptp_clock_register(&fep->ptp_caps, &pdev->dev);
>  	if (IS_ERR(fep->ptp_clock)) {
> @@ -398,3 +400,20 @@ void fec_ptp_init(struct platform_device *pdev)
>  		pr_err("ptp_clock_register failed\n");
>  	}
>  }
> +
> +/*
> + * Cleanup routine for 1588 module.
> + * When FEC is stopped this routing is called
> + */
> +void fec_ptp_stop(struct net_device *ndev)
> +{
> +	struct fec_enet_private *priv = netdev_priv(ndev);
> +
> +	writel(0, priv->hwp + FEC_ATIME_CTRL);
> +	writel(FEC_T_CTRL_RESTART, priv->hwp + FEC_ATIME_CTRL);
> +
> +	priv->hwts_tx_en = 0;
> +	priv->hwts_rx_en = 0;
> +
> +	del_timer_sync(&priv->time_keep);
> +}
> -- 
> 1.7.8
> 

  parent reply	other threads:[~2014-07-21  4:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21  2:35 [PATCH] net: fec: ptp: avoid register access when ipg clock is disabled Fugang Duan
2014-07-21  4:02 ` Shawn Guo
2014-07-21  4:03 ` Richard Cochran [this message]
2014-07-21 10:46   ` fugang.duan
2014-07-21 16:40     ` Richard Cochran

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=20140721040301.GA4035@localhost.localdomain \
    --to=richardcochran@gmail.com \
    --cc=b20596@freescale.com \
    --cc=b38611@freescale.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shawn.guo@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).