Netdev List
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@freescale.com>
To: Andy Fleming <afleming@freescale.com>
Cc: netdev@vger.kernel.org
Subject: Re: phylib interrupt question
Date: Fri, 20 Jun 2008 13:34:46 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0806201319250.7584@t2.domain.actdsltmp> (raw)
In-Reply-To: <4B4372CF-7AE3-40B2-980D-4D65637E7382@freescale.com>

On Fri, 6 Jun 2008, Andy Fleming wrote:
> The Phylib supports *three* methods of link state detection:
>
> 1) The Phylib handles the irq.  To get this functionality, you set 
> phydev->irq to the irq number.  Obviously, this doesn't work if your PHY is 
> sending interrupts through your MAC's interrupt.  You don't want your MAC's 
> interrupts disabled while the PHY is being managed!

In my quest to decrease boot times, I've found something that seems odd about
the way phylib handles the phy IRQ.

phylib has a work queue, state_queue, that runs one per second
(PHY_STATE_TIME), in interrupt mode and polling mode.  In polling mode it
checks the phy status every other time it runs.  In interrupt mode only when
it's told.  Which makes me wonder if it really needs to always run once per
second in interrupt mode, but that's a different issue.

When a phy interrupt occurs, a different work queue, phy_queue which runs the
function phy_change(), is run.  It disables the irq, sets the phy state
machine to "changed", and re-enables the irq.  It's not clear to me why
interrupts need to be disabled, but that's not my point either.

My issue is that the code triggered by the irq never schedules the state_queue
work queue.  It sets the phy's state to changed, but doesn't actually _do_
anything.  The MAC, net layer, userspace, etc.  don't find out the link went
up or down until state_queue's timer runs the queue one second layer.

If you increase PHY_STATE_TIME to 10 seconds and un-plug/re-plug the cable,
you can see that it takes some time before the kernel responds to the link
change.  If you need to run DHCP to get your device online, then this waiting
time gets added to your boot time.

It seems like this simple patch is all that's needed to fix it:
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -728,6 +728,7 @@ static void phy_change(struct work_struct *work)
  	if (err)
 		goto irq_enable_err;

+	schedule_work(&phydev->state_queue);
  	return;

  irq_enable_err:


So is there any reason not to do this?

      parent reply	other threads:[~2008-06-20 20:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06 16:07 phylib interrupt question Steve.Glendinning
2008-06-06 17:11 ` Andy Fleming
2008-06-06 17:19   ` Andy Fleming
2008-06-20 20:34   ` Trent Piepho [this message]

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=Pine.LNX.4.64.0806201319250.7584@t2.domain.actdsltmp \
    --to=tpiepho@freescale.com \
    --cc=afleming@freescale.com \
    --cc=netdev@vger.kernel.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