From: John Crispin <blogic@openwrt.org>
To: "David S. Miller" <davem@davemloft.net>
Cc: "Felix Fietkau" <nbd@openwrt.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Sean Wang (王志亘)" <sean.wang@mediatek.com>,
netdev@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-kernel@vger.kernel.org, "John Crispin" <blogic@openwrt.org>
Subject: [PATCH 6/9] net: mediatek: fix mtk_pending_work
Date: Thu, 7 Apr 2016 19:57:53 +0200 [thread overview]
Message-ID: <1460051876-53135-6-git-send-email-blogic@openwrt.org> (raw)
In-Reply-To: <1460051876-53135-1-git-send-email-blogic@openwrt.org>
The driver supports 2 MACs. Both run on the same DMA ring. If we hit a TX
timeout we need to stop both netdevs before restarting them again. If we
don't do this, mtk_stop() wont shutdown DMA and the consecutive call to
mtk_open() wont restart DMA and enable IRQs.
Signed-off-by: John Crispin <blogic@openwrt.org>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 31 ++++++++++++++++++---------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 4ebc42e..60b66ab 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1430,19 +1430,30 @@ static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static void mtk_pending_work(struct work_struct *work)
{
- struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
- struct mtk_eth *eth = mac->hw;
- struct net_device *dev = eth->netdev[mac->id];
- int err;
+ struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
+ int err, i;
+ unsigned long restart = 0;
rtnl_lock();
- mtk_stop(dev);
- err = mtk_open(dev);
- if (err) {
- netif_alert(eth, ifup, dev,
- "Driver up/down cycle failed, closing device.\n");
- dev_close(dev);
+ /* stop all devices to make sure that dma is properly shut down */
+ for (i = 0; i < MTK_MAC_COUNT; i++) {
+ if (!netif_oper_up(eth->netdev[i]))
+ continue;
+ mtk_stop(eth->netdev[i]);
+ __set_bit(i, &restart);
+ }
+
+ /* restart DMA and enable IRQs */
+ for (i = 0; i < MTK_MAC_COUNT; i++) {
+ if (!test_bit(i, &restart))
+ continue;
+ err = mtk_open(eth->netdev[i]);
+ if (err) {
+ netif_alert(eth, ifup, eth->netdev[i],
+ "Driver up/down cycle failed, closing device.\n");
+ dev_close(eth->netdev[i]);
+ }
}
rtnl_unlock();
}
--
1.7.10.4
next prev parent reply other threads:[~2016-04-07 17:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 17:57 [PATCH 1/9] net: mediatek: update the IRQ part of the binding document John Crispin
2016-04-07 17:57 ` John Crispin [this message]
2016-04-07 17:57 ` [PATCH 7/9] net: mediatek: fix TX locking John Crispin
[not found] ` <1460051876-53135-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2016-04-07 17:57 ` [PATCH 2/9] net: mediatek: watchdog_timeo was not set John Crispin
2016-04-07 17:57 ` [PATCH 3/9] net: mediatek: mtk_cal_txd_req() returns bad value John Crispin
2016-04-07 17:57 ` [PATCH 4/9] net: mediatek: remove superfluous reset call John Crispin
2016-04-07 17:57 ` [PATCH 5/9] net: mediatek: fix stop and wakeup of queue John Crispin
2016-04-07 17:57 ` [PATCH 8/9] net: mediatek: move the pending_work struct to the device generic struct John Crispin
2016-04-07 17:57 ` [PATCH 9/9] net: mediatek: do not set the QID field in the TX DMA descriptors John Crispin
2016-04-07 18:50 ` [PATCH 1/9] net: mediatek: update the IRQ part of the binding document David Miller
2016-04-11 15:24 ` Rob Herring
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=1460051876-53135-6-git-send-email-blogic@openwrt.org \
--to=blogic@openwrt.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@openwrt.org \
--cc=netdev@vger.kernel.org \
--cc=sean.wang@mediatek.com \
/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).