All of lore.kernel.org
 help / color / mirror / Atom feed
From: Domen Puncer <domen@coderock.org>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: netdev@vger.kernel.org, linuxppc-embedded@ozlabs.org
Subject: Re: [RFC PATCH v0.2] net driver: mpc52xx fec
Date: Tue, 2 Oct 2007 16:32:02 +0200	[thread overview]
Message-ID: <20071002143202.GQ32628@nd47.coderock.org> (raw)
In-Reply-To: <20071002124939.GC10481@pengutronix.de>

On 02/10/07 14:49 +0200, Sascha Hauer wrote:
> 
> Hi Domen,

Hi Sascha!


> 
> On Sun, Sep 02, 2007 at 09:41:43AM +0200, Domen Puncer wrote:
>  + */
> > +static void fec_start(struct net_device *dev)
> > +{
> > +	struct fec_priv *priv = netdev_priv(dev);
> > +	struct mpc52xx_fec __iomem *fec = priv->fec;
> > +	u32 rcntrl;
> > +	u32 tcntrl;
> > +	u32 tmp;
> > +
> > +	/* clear sticky error bits */
> > +	tmp = FEC_FIFO_STATUS_ERR | FEC_FIFO_STATUS_UF | FEC_FIFO_STATUS_OF;
> > +	out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status) & tmp);
> > +	out_be32(&fec->tfifo_status, in_be32(&fec->tfifo_status) & tmp);
> > +
> > +	/* FIFOs will reset on fec_enable */
> > +	out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_ENABLE_IS_RESET);
> > +
> > +	/* Set station address. */
> > +	fec_set_paddr(dev, dev->dev_addr);
> > +
> > +	fec_set_multicast_list(dev);
> > +
> > +	/* set max frame len, enable flow control, select mii mode */
> > +	rcntrl = FEC_RX_BUFFER_SIZE << 16;	/* max frame length */
> > +	rcntrl |= FEC_RCNTRL_FCE;
> > +	rcntrl |= MII_RCNTL_MODE;
> > +	if (priv->duplex == DUPLEX_FULL)
> > +		tcntrl = FEC_TCNTRL_FDEN;	/* FD enable */
> > +	else {
> > +		rcntrl |= FEC_RCNTRL_DRT;	/* disable Rx on Tx (HD) */
> > +		tcntrl = 0;
> > +	}
> > +	out_be32(&fec->r_cntrl, rcntrl);
> > +	out_be32(&fec->x_cntrl, tcntrl);
> > +
> > +	/* Clear any outstanding interrupt. */
> > +	out_be32(&fec->ievent, 0xffffffff);
> > +
> > +	/* Enable interrupts we wish to service. */
> > +	out_be32(&fec->imask, FEC_IMASK_ENABLE);
> 
> 
> This disables phy interrupts.

Right, oops.

> 
> 
> > +static int fec_mdio_read(struct mii_bus *bus, int phy_id, int reg)
> > +{
> > +	struct fec_mdio_priv *priv = bus->priv;
> > +	int tries = 100;
> > +
> > +	u32 request = FEC_MII_READ_FRAME;
> > +	request |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK;
> > +	request |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK;
> > +
> > +	out_be32(&priv->regs->mii_data, request);
> > +
> > +	/* wait for it to finish, this takes about 23 us on lite5200b */
> > +	while (priv->completed == 0 && tries--)
> > +		udelay(5);
> > +
> > +	priv->completed = 0;
> > +
> > +	if (tries == 0)
> > +		return -ETIMEDOUT;
> 
> This does not work as expected. When a timeout occurs tries is -1 not 0,
> so the test above will never trigger.
> Using --tries instead of tries-- reveals another bug. We get a timeout
> everytime now, because MII interrupts are accidently disabled in
> fec_start().

Oh, double bug made it work! ;-)


> 
> We cannot use a waitqueue or similar for waiting for the mii transfer
> because we are atomic here.
> A simple fix is provided below. It removes the need for the interrupt
> handler in the phy handling routines. Anyway, it might be better to fix
> the phy layer not to use atomic contexts, so this patch might not be the
> way to go.

Doh, looks like this was the problem with wq's, but I forgot to remove
them, when I "fixed" the code.

> 
> 
> Regards, 
>   Sascha
> 
>  +
> > +static int fec_mdio_probe(struct of_device *of, const struct of_device_id *match)
> > +{
> > +	struct device *dev = &of->dev;
> >
> >       [...]
> >
> > +	init_waitqueue_head(&priv->wq);
> 
> This waitqueue is never used. wake_up() is called in the interrupt
> handler, but noone ever sleeps on the queue.
> 
> 
> ---
>  drivers/net/fec_mpc52xx/fec.c     |    7 +---
>  drivers/net/fec_mpc52xx/fec_phy.c |   59 +++++++-------------------------------
>  2 files changed, 15 insertions(+), 51 deletions(-)

The patch looks ok to me.


	Domen

  reply	other threads:[~2007-10-02 14:32 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-10  9:51 [RFC PATCH v0.1] net driver: mpc52xx fec Domen Puncer
2007-08-10 13:02 ` Arnaldo Carvalho de Melo
2007-08-13  7:21   ` Domen Puncer
2007-08-18 10:06 ` Domen Puncer
2007-08-19 15:39   ` Matt Sealey
2007-08-20  8:31     ` Domen Puncer
2007-08-20 13:13       ` Domen Puncer
2007-08-20 19:02         ` Matt Sealey
2007-08-21  5:49           ` Domen Puncer
2007-09-02  7:41 ` [RFC PATCH v0.2] " Domen Puncer
2007-09-03 15:57   ` Grant Likely
2007-09-03 16:09     ` Jon Smirl
2007-09-03 16:41       ` Grant Likely
2007-09-15 12:14     ` Domen Puncer
2007-09-17  9:53       ` Sven Luther
2007-09-17 20:21         ` [PATCH] phy: export phy_mii_ioctl Domen Puncer
2007-09-17 22:08           ` Jon Smirl
2007-09-18 15:16             ` Domen Puncer
2007-09-18 19:17               ` Jon Smirl
2007-09-19 11:56                 ` Domen Puncer
2007-09-19 18:44                   ` Jon Smirl
2007-09-19 21:18                     ` Jon Smirl
2007-09-18 19:29               ` Jon Smirl
2007-09-19  8:54                 ` Pedro Luis D. L.
2007-09-19 10:37                   ` Juergen Beisert
2007-09-19 11:38                     ` Pedro Luis D. L.
2007-09-19 14:51                       ` Juergen Beisert
2007-09-19 15:11                         ` Pedro Luis D. L.
2007-09-19 13:56                   ` Jon Smirl
2007-09-19 14:31                     ` Pedro Luis D. L.
2007-09-19  8:54                 ` Pedro Luis D. L.
2007-09-20  6:36           ` Jeff Garzik
2007-10-02 12:49   ` [RFC PATCH v0.2] net driver: mpc52xx fec Sascha Hauer
2007-10-02 14:32     ` Domen Puncer [this message]
2007-10-02 15:46       ` Robert Schwebel
2007-09-27 17:07 ` [RFC PATCH v0.1] " Juergen Beisert
2007-09-27 18:12   ` Jon Smirl
2007-09-27 18:43     ` Scott Wood
2007-09-28  9:12       ` Juergen Beisert
2007-09-28 15:40         ` Scott Wood
2007-10-08  8:48         ` Sascha Hauer
2007-10-08  9:01         ` Sascha Hauer
2007-10-08 16:46           ` Jon Smirl
2007-09-28 15:07   ` Juergen Beisert
2007-09-28 15:38     ` Jon Smirl
2007-10-01  8:35       ` Juergen Beisert
2007-10-01 16:24         ` Juergen Beisert

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=20071002143202.GQ32628@nd47.coderock.org \
    --to=domen@coderock.org \
    --cc=linuxppc-embedded@ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    /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.