netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: netdev@vger.kernel.org
Subject: Re: Proper suspend/resume flow
Date: Sat, 29 Mar 2014 20:19:39 +0000	[thread overview]
Message-ID: <20140329201939.GX7528@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1396123694.2898.93.camel@deadeye.wl.decadent.org.uk>

On Sat, Mar 29, 2014 at 08:08:14PM +0000, Ben Hutchings wrote:
> On Sat, 2014-03-29 at 18:03 +0000, Russell King - ARM Linux wrote:
> [...]
> > That said, for the case where a network driver does all it's packet
> > processing in the NAPI poll function, I think calling napi_disable()
> > is a good way to ensure that the poll function is not running, and
> > therefore there are can be no netif_wake_queue() calls - or anything
> > other than the ndo_start_xmit touching the rings or the device.  This
> > is needed anyway to stop receive packet processing looking at its
> > ring.
> > 
> > So, I've now come to this sequence:
> > 
> > suspend()
> > {
> > 	if (netif_running()) {
> > 		napi_disable();
> > 		netif_tx_lock();
> > 		netif_device_detach();
> > 		netif_tx_unlock();
> > 	}
> > 	... suspend device ...
> > }
> [...]
> 
> This is missing netif_stop_queue(), but I assume you do that somewhere
> after netif_device_detach().  I think this should work.

Ah, that's covered by netif_device_detach():

        if (test_and_clear_bit(__LINK_STATE_PRESENT, &dev->state) &&
            netif_running(dev)) {
                netif_tx_stop_all_queues(dev);
        }

provided __LINK_STATE_PRESENT was previously set, and the interface
was running.

netif_tx_stop_all_queues() is:

        for (i = 0; i < dev->num_tx_queues; i++) {
                struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
                netif_tx_stop_queue(txq);
        }

so with the above sequence, we end up stopping all queues under the
xmit lock.

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.

      reply	other threads:[~2014-03-29 20:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-26 11:58 Proper suspend/resume flow Russell King - ARM Linux
2014-03-27 10:10 ` Claudiu Manoil
2014-03-27 10:57   ` Russell King - ARM Linux
2014-03-29 16:37 ` Ben Hutchings
2014-03-29 18:03   ` Russell King - ARM Linux
2014-03-29 20:08     ` Ben Hutchings
2014-03-29 20:19       ` Russell King - ARM Linux [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=20140329201939.GX7528@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=ben@decadent.org.uk \
    --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;
as well as URLs for NNTP newsgroup(s).