* [RFT] sky2: receive hang check
@ 2007-09-12 14:19 Stephen Hemminger
2007-09-17 10:08 ` Martin Josefsson
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2007-09-12 14:19 UTC (permalink / raw)
To: netdev
Would some of the users of 2.6.23-rc5 or later who still experience
hangs please test this.
IT IS EXPERIMENTAL AND NOT TESTED YET.
I am sending it out to see if it detects anything.
--- a/drivers/net/sky2.c 2007-09-12 14:52:18.000000000 +0200
+++ b/drivers/net/sky2.c 2007-09-12 15:53:16.000000000 +0200
@@ -1304,6 +1304,7 @@ static int sky2_up(struct net_device *de
/* Register is number of 4K blocks on internal RAM buffer. */
ramsize = sky2_read8(hw, B2_E_0) * 4;
printk(KERN_INFO PFX "%s: ram buffer %dK\n", dev->name, ramsize);
+ memset(&sky2->check, 0, sizeof(sky2->check));
if (ramsize > 0) {
u32 rxspace;
@@ -2446,11 +2447,42 @@ static void sky2_le_error(struct sky2_hw
sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_IRQ_CHK);
}
-/* Check for lost IRQ once a second */
+static void sky2_rx_check(struct net_device *dev)
+{
+ struct sky2_port *sky2 = netdev_priv(dev);
+ struct sky2_hw *hw = sky2->hw;
+ unsigned port = sky2->port;
+ unsigned rxq = rxqaddr[port];
+ u32 mac_rp = sky2_read32(hw, SK_REG(port, RX_GMF_RP));
+ u8 mac_lev = sky2_read8(hw, SK_REG(port, RX_GMF_RLEV));
+ u8 fifo_rp = sky2_read8(hw, Q_ADDR(rxq, Q_RP));
+ u8 fifo_lev = sky2_read8(hw, Q_ADDR(rxq, Q_RL));
+
+ /* If not idle and MAC or PCI is stuck */
+ if (sky2->check.last != dev->last_rx &&
+ ((mac_rp == sky2->check.mac_rp &&
+ mac_lev != 0 && mac_lev >= sky2->check.mac_lev) ||
+ /* Check if the PCI RX hang */
+ (fifo_rp == sky2->check.fifo_rp &&
+ fifo_lev != 0 && fifo_lev >= sky2->check.fifo_lev))) {
+
+ pr_info(PFX "%s: receiver hang detected\n", dev->name);
+ schedule_work(&hw->restart_work);
+ }
+
+ sky2->check.last = dev->last_rx;
+ sky2->check.mac_rp = mac_rp;
+ sky2->check.mac_lev = mac_lev;
+ sky2->check.fifo_rp = fifo_rp;
+ sky2->check.fifo_lev = fifo_lev;
+}
+
static void sky2_watchdog(unsigned long arg)
{
struct sky2_hw *hw = (struct sky2_hw *) arg;
+ int i;
+ /* Check for lost IRQ */
if (sky2_read32(hw, B0_ISRC)) {
struct net_device *dev = hw->dev[0];
@@ -2458,6 +2490,13 @@ static void sky2_watchdog(unsigned long
__netif_rx_schedule(dev);
}
+ /* Check for stuck receiver */
+ if (sky2_read8(hw, B2_E_0) != 0)
+ for (i = 0; i < hw->ports; i++)
+ if (netif_running(hw->dev[i]))
+ sky2_rx_check(hw->dev[i]);
+
+
if (hw->active > 0)
mod_timer(&hw->watchdog_timer, round_jiffies(jiffies + HZ));
}
--- a/drivers/net/sky2.h 2007-09-05 14:21:59.000000000 +0200
+++ b/drivers/net/sky2.h 2007-09-12 15:36:59.000000000 +0200
@@ -2017,6 +2017,14 @@ struct sky2_port {
u16 rx_tag;
struct vlan_group *vlgrp;
#endif
+ struct {
+ unsigned long last;
+ u32 mac_rp;
+ u8 mac_lev;
+ u8 fifo_rp;
+ u8 fifo_lev;
+ } check;
+
dma_addr_t rx_le_map;
dma_addr_t tx_le_map;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFT] sky2: receive hang check
2007-09-12 14:19 [RFT] sky2: receive hang check Stephen Hemminger
@ 2007-09-17 10:08 ` Martin Josefsson
0 siblings, 0 replies; 2+ messages in thread
From: Martin Josefsson @ 2007-09-17 10:08 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
On Wed, 12 Sep 2007, Stephen Hemminger wrote:
> -/* Check for lost IRQ once a second */
> +static void sky2_rx_check(struct net_device *dev)
> +{
> + struct sky2_port *sky2 = netdev_priv(dev);
> + struct sky2_hw *hw = sky2->hw;
> + unsigned port = sky2->port;
> + unsigned rxq = rxqaddr[port];
> + u32 mac_rp = sky2_read32(hw, SK_REG(port, RX_GMF_RP));
> + u8 mac_lev = sky2_read8(hw, SK_REG(port, RX_GMF_RLEV));
> + u8 fifo_rp = sky2_read8(hw, Q_ADDR(rxq, Q_RP));
> + u8 fifo_lev = sky2_read8(hw, Q_ADDR(rxq, Q_RL));
> +
> + /* If not idle and MAC or PCI is stuck */
> + if (sky2->check.last != dev->last_rx &&
Don't you want == here? You want to run the rest of this test when no
packets has been received for a while.
> + ((mac_rp == sky2->check.mac_rp &&
> + mac_lev != 0 && mac_lev >= sky2->check.mac_lev) ||
> + /* Check if the PCI RX hang */
> + (fifo_rp == sky2->check.fifo_rp &&
> + fifo_lev != 0 && fifo_lev >= sky2->check.fifo_lev))) {
> +
> + pr_info(PFX "%s: receiver hang detected\n", dev->name);
> + schedule_work(&hw->restart_work);
> + }
> +
> + sky2->check.last = dev->last_rx;
> + sky2->check.mac_rp = mac_rp;
> + sky2->check.mac_lev = mac_lev;
> + sky2->check.fifo_rp = fifo_rp;
> + sky2->check.fifo_lev = fifo_lev;
> +}
/Martin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-09-17 10:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-12 14:19 [RFT] sky2: receive hang check Stephen Hemminger
2007-09-17 10:08 ` Martin Josefsson
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).