Commit 10a7bfef authored by Raghavendra Koushik's avatar Raghavendra Koushik Committed by Jeff Garzik

[PATCH] S2io: sw bug fixes

1. In free_rx_buffers clearing out RxDs not owned by Xena.

2. In alarm_intr_handler, when a serr error occurs, schedule a task
to reset the card rather than stopping Tx queue.

3. In s2io_close freeing IRQ before calling s2io_reset also added a
new call to flush queued tasks. This is not done if the s2io_close
itself is called from a queued task like s2io_restart_nic.

4. read_eeprom function has been changed such that data to be returned
is sent as an input argument and the return value represents a
pass/fail. The previous implementation as Randy had pointed out was
error prone as on failure it returned -1 which can be interpreted
as all ff's, so any data area which contained ff's in the eeprom was
likely to be treated as an error.

5. Added a flag "task_flag" to track if the call to s2io_close is
coming from the s2io_restart_nic function or from the ifconfig <I/F>
down called by user.

6. Moved register_netdev call from just after setting entry points
to the end of the s2io_init_nic function.

7. In s2io.h field added a new member into the s2io_nic structure
called "task_flag".
Signed-off-by: default avatarRaghavendra Koushik <raghavendra.koushik@s2io.com>
Signed-off-by: default avatarRavinandan Arakali <ravinandan.arakali@s2io.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 1dbd0fcf
......@@ -1525,6 +1525,11 @@ static void free_rx_buffers(struct s2io_nic *sp)
blk++;
}
if (!(rxdp->Control_1 & RXD_OWN_XENA)) {
memset(rxdp, 0, sizeof(RxD_t));
continue;
}
skb =
(struct sk_buff *) ((unsigned long) rxdp->
Host_Control);
......@@ -1887,7 +1892,7 @@ static void alarm_intr_handler(struct s2io_nic *nic)
if (val64 & SERR_SOURCE_ANY) {
DBG_PRINT(ERR_DBG, "%s: Device indicates ", dev->name);
DBG_PRINT(ERR_DBG, "serious error!!\n");
netif_stop_queue(dev);
schedule_work(&nic->rst_timer_task);
}
/* Other type of interrupts are not being handled now, TODO */
......@@ -2205,6 +2210,17 @@ int s2io_close(struct net_device *dev)
}
tasklet_kill(&sp->task);
/* Free the Registered IRQ */
free_irq(dev->irq, dev);
/* Flush all scheduled tasks */
if (sp->task_flag == 1) {
DBG_PRINT(INFO_DBG, "%s: Calling close from a task\n",
dev->name);
} else {
flush_scheduled_work();
}
/* Check if the device is Quiescent and then Reset the NIC */
do {
val64 = readq(&bar0->adapter_status);
......@@ -2225,9 +2241,6 @@ int s2io_close(struct net_device *dev)
} while (1);
s2io_reset(sp);
/* Free the Registered IRQ */
free_irq(dev->irq, dev);
/* Free all Tx Buffers waiting for transmission */
free_tx_buffers(sp);
......@@ -2982,9 +2995,10 @@ int s2io_ethtool_setpause_data(struct net_device *dev,
*/
#define S2IO_DEV_ID 5
static u32 read_eeprom(nic_t * sp, int off)
static int read_eeprom(nic_t * sp, int off, u32 * data)
{
u32 data = -1, exit_cnt = 0;
int ret = -1;
u32 exit_cnt = 0;
u64 val64;
XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
......@@ -2996,7 +3010,8 @@ static u32 read_eeprom(nic_t * sp, int off)
while (exit_cnt < 5) {
val64 = readq(&bar0->i2c_control);
if (I2C_CONTROL_CNTL_END(val64)) {
data = I2C_CONTROL_GET_DATA(val64);
*data = I2C_CONTROL_GET_DATA(val64);
ret = 0;
break;
}
set_current_state(TASK_UNINTERRUPTIBLE);
......@@ -3004,7 +3019,7 @@ static u32 read_eeprom(nic_t * sp, int off)
exit_cnt++;
}
return data;
return ret;
}
/**
......@@ -3073,8 +3088,7 @@ int s2io_ethtool_geeprom(struct net_device *dev,
eeprom->len = XENA_EEPROM_SPACE - eeprom->offset;
for (i = 0; i < eeprom->len; i += 4) {
data = read_eeprom(sp, eeprom->offset + i);
if (data < 0) {
if (read_eeprom(sp, (eeprom->offset + i), &data)) {
DBG_PRINT(ERR_DBG, "Read of EEPROM failed\n");
return -EFAULT;
}
......@@ -3213,7 +3227,8 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
{
int fail = 0, ret_data;
int fail = 0;
u32 ret_data;
/* Test Write Error at offset 0 */
if (!write_eeprom(sp, 0, 0, 3))
......@@ -3222,7 +3237,7 @@ static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
/* Test Write at offset 4f0 */
if (write_eeprom(sp, 0x4F0, 0x01234567, 3))
fail = 1;
if ((ret_data = read_eeprom(sp, 0x4F0)) < 0)
if (read_eeprom(sp, 0x4F0, &ret_data))
fail = 1;
if (ret_data != 0x01234567)
......@@ -3238,7 +3253,7 @@ static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
/* Test Write Request at offset 0x7fc */
if (write_eeprom(sp, 0x7FC, 0x01234567, 3))
fail = 1;
if ((ret_data = read_eeprom(sp, 0x7FC)) < 0)
if (read_eeprom(sp, 0x7FC, &ret_data))
fail = 1;
if (ret_data != 0x01234567)
......@@ -3811,7 +3826,9 @@ static void s2io_restart_nic(unsigned long data)
struct net_device *dev = (struct net_device *) data;
nic_t *sp = dev->priv;
sp->task_flag = 1;
s2io_close(dev);
sp->task_flag = 0;
sp->device_close_flag = TRUE;
s2io_open(dev);
DBG_PRINT(ERR_DBG,
......@@ -4275,18 +4292,13 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
INIT_WORK(&sp->set_link_task,
(void (*)(void *)) s2io_set_link, sp);
if (register_netdev(dev)) {
DBG_PRINT(ERR_DBG, "Device registration failed\n");
goto register_failed;
}
pci_save_state(sp->pdev, sp->config_space);
/* Setting swapper control on the NIC, for proper reset operation */
if (s2io_set_swapper(sp)) {
DBG_PRINT(ERR_DBG, "%s:swapper settings are wrong\n",
dev->name);
goto register_failed;
goto set_swap_failed;
}
/* Fix for all "FFs" MAC address problems observed on Alpha platforms */
......@@ -4363,6 +4375,11 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
sp->rx_csum = 1; /* Rx chksum verify enabled by default */
if (register_netdev(dev)) {
DBG_PRINT(ERR_DBG, "Device registration failed\n");
goto register_failed;
}
/*
* Make Link state as off at this point, when the Link change
* interrupt comes the state will be automatically changed to
......@@ -4373,9 +4390,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
return 0;
set_swap_failed:
unregister_netdev(dev);
register_failed:
set_swap_failed:
iounmap(sp->bar1);
bar1_remap_failed:
iounmap(sp->bar0);
......
......@@ -668,6 +668,8 @@ typedef struct s2io_nic {
u16 last_link_state;
#define LINK_DOWN 1
#define LINK_UP 2
int task_flag;
} nic_t;
#define RESET_ERROR 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment