From: Richard Cochran <richardcochran@gmail.com>
To: Fugang Duan <b38611@freescale.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, shawn.guo@linaro.org
Subject: Re: [PATCH v3 1/1] net: fec: ptp: avoid register access when ipg clock is disabled
Date: Fri, 15 Aug 2014 20:08:54 +0200 [thread overview]
Message-ID: <20140815180854.GA6897@localhost.localdomain> (raw)
In-Reply-To: <1408081975-15087-2-git-send-email-b38611@freescale.com>
Looks better, but ...
On Fri, Aug 15, 2014 at 01:52:55PM +0800, Fugang Duan wrote:
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 66fe1f6..ba35994 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1613,14 +1613,18 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
> ret = clk_prepare_enable(fep->clk_ptp);
> if (ret)
> goto failed_clk_ptp;
> + else
> + fep->ptp_clk_on = true;
> }
> } else {
> clk_disable_unprepare(fep->clk_ahb);
> clk_disable_unprepare(fep->clk_ipg);
> if (fep->clk_enet_out)
> clk_disable_unprepare(fep->clk_enet_out);
> - if (fep->clk_ptp)
> + if (fep->clk_ptp) {
> clk_disable_unprepare(fep->clk_ptp);
> + fep->ptp_clk_on = false;
Set the flag to false first, because this races ...
> diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
> index 82386b2..8084aaf 100644
> --- a/drivers/net/ethernet/freescale/fec_ptp.c
> +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> @@ -245,6 +245,10 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,
> u64 ns;
> unsigned long flags;
>
> + /* Check the ptp clock */
> + if (!fep->ptp_clk_on)
> + return -EINVAL;
with this and ...
> +
> ns = ts->tv_sec * 1000000000ULL;
> ns += ts->tv_nsec;
>
> @@ -338,17 +342,20 @@ int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr)
> * fec_time_keep - call timecounter_read every second to avoid timer overrun
> * because ENET just support 32bit counter, will timeout in 4s
> */
> -static void fec_time_keep(unsigned long _data)
> +static void fec_time_keep(struct work_struct *work)
> {
> - struct fec_enet_private *fep = (struct fec_enet_private *)_data;
> + struct delayed_work *dwork = to_delayed_work(work);
> + struct fec_enet_private *fep = container_of(dwork, struct fec_enet_private, time_keep);
> u64 ns;
> unsigned long flags;
>
> - spin_lock_irqsave(&fep->tmreg_lock, flags);
> - ns = timecounter_read(&fep->tc);
> - spin_unlock_irqrestore(&fep->tmreg_lock, flags);
> + if (fep->ptp_clk_on) {
with this.
> + spin_lock_irqsave(&fep->tmreg_lock, flags);
> + ns = timecounter_read(&fep->tc);
> + spin_unlock_irqrestore(&fep->tmreg_lock, flags);
> + }
Thanks,
Richard
next prev parent reply other threads:[~2014-08-15 18:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-15 5:52 [PATCH v3 0/1] net: fec: ptp: avoid register access when ipg clock is disabled Fugang Duan
2014-08-15 5:52 ` [PATCH v3 1/1] " Fugang Duan
2014-08-15 18:08 ` Richard Cochran [this message]
2014-08-18 5:26 ` fugang.duan
2014-08-18 6:07 ` fugang.duan
2014-08-18 19:42 ` Richard Cochran
2014-08-19 1:50 ` fugang.duan
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=20140815180854.GA6897@localhost.localdomain \
--to=richardcochran@gmail.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 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.