Skip to content

Commit

Permalink
[devices]: Fixed Fpga crash on dell z9264 (#3672)
Browse files Browse the repository at this point in the history
Fixed the fpga crash issue which we see in 15-20 mins time frame after onie-install. Accessing stale i2c transfer message buffer causes this crash. Te message buffer becomes stale due to race between i2c transfer and fpga interrupt handler.

This new state STATE_STOP will not be exposed for the wake up call till all the ISR of previous transfer is completed successfully.
  • Loading branch information
rkdevi27 authored and lguohan committed Nov 5, 2019
1 parent d6f3fde commit ebcd2d5
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ enum {
STATE_START,
STATE_WRITE,
STATE_READ,
STATE_STOP,
STATE_ERROR,
};

Expand Down Expand Up @@ -591,10 +592,13 @@ static void fpgai2c_process(struct fpgalogic_i2c *i2c)

PRINT("fpgai2c_process in. status reg :0x%x\n", stat);

if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) {
if ((i2c->state == STATE_STOP) || (i2c->state == STATE_ERROR)) {
/* stop has been sent */
PRINT("fpgai2c_process FPGAI2C_REG_CMD_IACK stat = 0x%x Set FPGAI2C_REG_CMD(0%x) FPGAI2C_REG_CMD_IACK = 0x%x\n",stat, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_IACK);
fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_IACK);
if(i2c->state == STATE_STOP) {
i2c->state = STATE_DONE;
}
wake_up(&i2c->wait);
return;
}
Expand Down Expand Up @@ -648,7 +652,7 @@ static void fpgai2c_process(struct fpgalogic_i2c *i2c)
? STATE_READ : STATE_WRITE;
}
} else {
i2c->state = STATE_DONE;
i2c->state = STATE_STOP;
fpgai2c_stop(i2c);
return;
}
Expand Down Expand Up @@ -722,6 +726,7 @@ static int fpgai2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)


} else {
ret = -ETIMEDOUT;
PRINT("Set FPGAI2C_REG_DATA(0%x) val = 0x%x\n",FPGAI2C_REG_DATA,
(i2c->msg->addr << 1) | ((i2c->msg->flags & I2C_M_RD) ? 1:0));

Expand All @@ -733,9 +738,8 @@ static int fpgai2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
/* Interrupt mode */
if (wait_event_timeout(i2c->wait, (i2c->state == STATE_ERROR) ||
(i2c->state == STATE_DONE), HZ))
return (i2c->state == STATE_DONE) ? num : -EIO;
else
return -ETIMEDOUT;
ret = (i2c->state == STATE_DONE) ? num : -EIO;
return ret;
}
}

Expand Down

0 comments on commit ebcd2d5

Please sign in to comment.