Subject: Re: [PATCH net-2.6] tg3: Fix phylib locking strategy

From: "Matt Carlson" <[email-masked]>
Date: Mon, 5 Oct 2009 17:03:39 -0700

On Mon, Oct 05, 2009 at 02:29:57PM -0700, Michael Chan wrote:
> 
> On Mon, 2009-10-05 at 14:09 -0700, Matt Carlson wrote:
> > Felix, can you verify this solves your problem?
> > 
> > ---
> > 
> > Felix Radensky noted that chip resets were generating stack trace dumps.
> > This is because the driver is attempting to acquire the mdio bus mutex
> > while holding the tp->lock spinlock.  The fix is to change the code such
> > that every phy access takes the tp->lock spinlock instead.
> > 
> > Signed-off-by: Matt Carlson <[email-masked]>
> > ---
> >  drivers/net/tg3.c |   37 ++++++++++++-------------------------
> >  drivers/net/tg3.h |    1 -
> >  2 files changed, 12 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
> > index f09bc5d..8afc60e 100644
> > --- a/drivers/net/tg3.c
> > +++ b/drivers/net/tg3.c
> > @@ -902,11 +902,12 @@ static int tg3_mdio_read(struct mii_bus *bp, int mii_id, int reg)
> >  	struct tg3 *tp = bp->priv;
> >  	u32 val;
> >  
> > -	if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_PAUSED)
> > -		return -EAGAIN;
> > +	spin_lock(&tp->lock);
> >  
> 
> Matt, do we need spin_lock_bh() here?  The tp->lock can be taken in NAPI
> poll BH context.

Yes.  You are right.  And the same change needs to be made in
tg3_adjust_link().  V2 of the patch, coming up.