From: Claudiu Manoil <claudiu.manoil@freescale.com>
To: <netdev@vger.kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Xiubo Li <Li.Xiubo@freescale.com>,
Shruti Kanetkar <Shruti@freescale.com>
Subject: [net 7/8] gianfar: Replace spin_event_timeout() with arch independent
Date: Fri, 3 Oct 2014 19:02:48 +0300 [thread overview]
Message-ID: <1412352169-14414-8-git-send-email-claudiu.manoil@freescale.com> (raw)
In-Reply-To: <1412352169-14414-1-git-send-email-claudiu.manoil@freescale.com>
Use arch independent code to replace the powerpc dependent
spin_event_timeout() from gfar_halt_nodisable().
Added GRS/GTS read accessors to clean-up the implementation
of gfar_halt_nodisable().
Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
drivers/net/ethernet/freescale/gianfar.c | 32 +++++++++++++++++++-------------
drivers/net/ethernet/freescale/gianfar.h | 15 +++++++++++++++
2 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 961198a..356a998 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1762,26 +1762,32 @@ static void gfar_halt_nodisable(struct gfar_private *priv)
{
struct gfar __iomem *regs = priv->gfargrp[0].regs;
u32 tempval;
+ unsigned int timeout;
+ int stopped;
gfar_ints_disable(priv);
+ if (gfar_is_dma_stopped(priv))
+ return;
+
/* Stop the DMA, and wait for it to stop */
tempval = gfar_read(®s->dmactrl);
- if ((tempval & (DMACTRL_GRS | DMACTRL_GTS)) !=
- (DMACTRL_GRS | DMACTRL_GTS)) {
- int ret;
-
- tempval |= (DMACTRL_GRS | DMACTRL_GTS);
- gfar_write(®s->dmactrl, tempval);
+ tempval |= (DMACTRL_GRS | DMACTRL_GTS);
+ gfar_write(®s->dmactrl, tempval);
- do {
- ret = spin_event_timeout(((gfar_read(®s->ievent) &
- (IEVENT_GRSC | IEVENT_GTSC)) ==
- (IEVENT_GRSC | IEVENT_GTSC)), 1000000, 0);
- if (!ret && !(gfar_read(®s->ievent) & IEVENT_GRSC))
- ret = __gfar_is_rx_idle(priv);
- } while (!ret);
+retry:
+ timeout = 1000;
+ while (!(stopped = gfar_is_dma_stopped(priv)) && timeout) {
+ cpu_relax();
+ timeout--;
}
+
+ if (!timeout)
+ stopped = gfar_is_dma_stopped(priv);
+
+ if (!stopped && !gfar_is_rx_dma_stopped(priv) &&
+ !__gfar_is_rx_idle(priv))
+ goto retry;
}
/* Halt the receive and transmit queues */
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 84632c5..0b37722 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -1226,6 +1226,21 @@ static inline void gfar_write_isrg(struct gfar_private *priv)
}
}
+static inline int gfar_is_dma_stopped(struct gfar_private *priv)
+{
+ struct gfar __iomem *regs = priv->gfargrp[0].regs;
+
+ return ((gfar_read(®s->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) ==
+ (IEVENT_GRSC | IEVENT_GTSC));
+}
+
+static inline int gfar_is_rx_dma_stopped(struct gfar_private *priv)
+{
+ struct gfar __iomem *regs = priv->gfargrp[0].regs;
+
+ return gfar_read(®s->ievent) & IEVENT_GRSC;
+}
+
irqreturn_t gfar_receive(int irq, void *dev_id);
int startup_gfar(struct net_device *dev);
void stop_gfar(struct net_device *dev);
--
1.7.11.7
next prev parent reply other threads:[~2014-10-03 16:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
2014-10-03 16:02 ` [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM Claudiu Manoil
2014-10-03 18:39 ` Sergei Shtylyov
2014-10-03 16:02 ` [net 2/8] net/fsl_pq_mdio: Use ioread/iowrite32be() portable accessors Claudiu Manoil
2014-10-03 16:02 ` [net 3/8] net/fsl_pq_mdio: Replace spin_event_timeout() with arch independent Claudiu Manoil
2014-10-03 16:02 ` [net 4/8] gianfar: Include missing headers for ARM builds Claudiu Manoil
2014-10-03 16:02 ` [net 5/8] gianfar: Exclude PPC specific errata handling from " Claudiu Manoil
2014-10-03 16:02 ` [net 6/8] gianfar: Make MAC addr setup endian safe, cleanup Claudiu Manoil
2014-10-03 16:02 ` Claudiu Manoil [this message]
2014-10-03 16:02 ` [net 8/8] gianfar: Replace eieio with wmb for non-PPC archs Claudiu Manoil
2014-10-03 21:20 ` [net 0/8] gianfar: ARM port driver updates (1/2) Kim Phillips
2014-10-06 1:27 ` David Miller
2014-10-06 7:55 ` Claudiu Manoil
2014-10-06 19:07 ` 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=1412352169-14414-8-git-send-email-claudiu.manoil@freescale.com \
--to=claudiu.manoil@freescale.com \
--cc=Li.Xiubo@freescale.com \
--cc=Shruti@freescale.com \
--cc=davem@davemloft.net \
--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).