From: Russell King <rmk+kernel@arm.linux.org.uk>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH B 04/10] net: fec: move calls to quiesce/resume packet processing out of fec_restart()
Date: Tue, 08 Jul 2014 12:40:12 +0100 [thread overview]
Message-ID: <E1X4Tkq-0005o2-Tc@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20140708113911.GH21766@n2100.arm.linux.org.uk>
Move the calls to quiesce and resume packet processing out of
fec_restart() to its call sites. This is the first step in a two stage
clean up of this code, where we just move the calls out of fec_restart()
without changing them. Not everywhere needs to issue these calls, and
not everywhere needs all of these calls to be issued.
Acked-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/net/ethernet/freescale/fec_main.c | 64 ++++++++++++++++++++++---------
1 file changed, 45 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index bfb2bb00c493..b71b7491f38f 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -818,9 +818,10 @@ static void fec_enet_bd_init(struct net_device *dev)
fep->dirty_tx = bdp;
}
-/* This function is called to start or restart the FEC during a link
- * change. This only happens when switching between half and full
- * duplex.
+/*
+ * This function is called to start or restart the FEC during a link
+ * change, transmit timeout, or to reconfigure the FEC. The network
+ * packet processing for this device must be stopped before this call.
*/
static void
fec_restart(struct net_device *ndev, int duplex)
@@ -834,13 +835,6 @@ fec_restart(struct net_device *ndev, int duplex)
u32 rcntl = OPT_FRAME_SIZE | 0x04;
u32 ecntl = 0x2; /* ETHEREN */
- if (netif_running(ndev)) {
- netif_device_detach(ndev);
- napi_disable(&fep->napi);
- netif_tx_disable(ndev);
- netif_tx_lock_bh(ndev);
- }
-
/* Whack a reset. We should wait for this. */
writel(1, fep->hwp + FEC_ECNTRL);
udelay(10);
@@ -1009,13 +1003,6 @@ fec_restart(struct net_device *ndev, int duplex)
/* Enable interrupts we wish to service */
writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
-
- if (netif_running(ndev)) {
- netif_tx_unlock_bh(ndev);
- netif_wake_queue(ndev);
- napi_enable(&fep->napi);
- netif_device_attach(ndev);
- }
}
static void
@@ -1071,8 +1058,15 @@ static void fec_enet_work(struct work_struct *work)
fep->delay_work.timeout = false;
rtnl_lock();
if (netif_device_present(ndev) || netif_running(ndev)) {
+ netif_device_detach(ndev);
+ napi_disable(&fep->napi);
+ netif_tx_disable(ndev);
+ netif_tx_lock_bh(ndev);
fec_restart(ndev, fep->full_duplex);
+ netif_tx_unlock_bh(ndev);
netif_wake_queue(ndev);
+ napi_enable(&fep->napi);
+ netif_device_attach(ndev);
}
rtnl_unlock();
}
@@ -1529,8 +1523,17 @@ static void fec_enet_adjust_link(struct net_device *ndev)
}
/* if any of the above changed restart the FEC */
- if (status_change)
+ if (status_change) {
+ netif_device_detach(ndev);
+ napi_disable(&fep->napi);
+ netif_tx_disable(ndev);
+ netif_tx_lock_bh(ndev);
fec_restart(ndev, phy_dev->duplex);
+ netif_tx_unlock_bh(ndev);
+ netif_wake_queue(ndev);
+ napi_enable(&fep->napi);
+ netif_device_attach(ndev);
+ }
} else {
if (fep->link) {
fec_stop(ndev);
@@ -1915,8 +1918,17 @@ static int fec_enet_set_pauseparam(struct net_device *ndev,
fec_stop(ndev);
phy_start_aneg(fep->phy_dev);
}
- if (netif_running(ndev))
+ if (netif_running(ndev)) {
+ netif_device_detach(ndev);
+ napi_disable(&fep->napi);
+ netif_tx_disable(ndev);
+ netif_tx_lock_bh(ndev);
fec_restart(ndev, fep->full_duplex);
+ netif_tx_unlock_bh(ndev);
+ netif_wake_queue(ndev);
+ napi_enable(&fep->napi);
+ netif_device_attach(ndev);
+ }
return 0;
}
@@ -2359,8 +2371,15 @@ static int fec_set_features(struct net_device *netdev,
if (netif_running(netdev)) {
fec_stop(netdev);
+ netif_device_detach(netdev);
+ napi_disable(&fep->napi);
+ netif_tx_disable(netdev);
+ netif_tx_lock_bh(netdev);
fec_restart(netdev, fep->phy_dev->duplex);
+ netif_tx_unlock_bh(netdev);
netif_wake_queue(netdev);
+ napi_enable(&fep->napi);
+ netif_device_attach(netdev);
}
}
@@ -2728,7 +2747,14 @@ fec_resume(struct device *dev)
rtnl_lock();
if (netif_running(ndev)) {
+ netif_device_detach(ndev);
+ napi_disable(&fep->napi);
+ netif_tx_disable(ndev);
+ netif_tx_lock_bh(ndev);
fec_restart(ndev, fep->full_duplex);
+ netif_tx_unlock_bh(ndev);
+ netif_wake_queue(ndev);
+ napi_enable(&fep->napi);
netif_device_attach(ndev);
phy_start(fep->phy_dev);
}
--
1.8.3.1
next prev parent reply other threads:[~2014-07-08 11:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-08 11:39 [PATCH B 00/10] Freescale ethernet driver updates (part 2) Russell King - ARM Linux
2014-07-08 11:39 ` [PATCH B 01/10] net: fec: improve safety of suspend/resume/transmit timeout paths Russell King
2014-07-08 11:40 ` [PATCH B 02/10] net: fec: ensure fec_enet_close() copes with resume failure Russell King
2014-07-08 11:40 ` [PATCH B 03/10] net: fec: only restart or stop the device if it is present and running Russell King
2014-07-08 11:40 ` Russell King [this message]
2014-07-08 11:40 ` [PATCH B 05/10] net: fec: remove inappropriate calls around fec_restart() Russell King
2014-07-08 11:40 ` [PATCH B 06/10] net: fec: quiesce packet processing before stopping device in fec_suspend() Russell King
2014-07-08 11:40 ` [PATCH B 07/10] net: fec: quiesce packet processing before stopping device in fec_set_features() Russell King
2014-07-08 11:40 ` [PATCH B 08/10] net: fec: quiesce packet processing before changing features Russell King
2014-07-08 11:40 ` [PATCH B 09/10] net: fec: quiesce packet processing when taking link down in fec_enet_adjust_link() Russell King
2014-07-08 11:40 ` [PATCH B 10/10] net: fec: clean up duplex mode handling Russell King
2014-07-09 3:03 ` [PATCH B 00/10] Freescale ethernet driver updates (part 2) David Miller
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=E1X4Tkq-0005o2-Tc@rmk-PC.arm.linux.org.uk \
--to=rmk+kernel@arm.linux.org.uk \
--cc=davem@davemloft.net \
--cc=linux-arm-kernel@lists.infradead.org \
--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).