Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
[Dell S5232F, Z9264F] Harden FPGA driver kernel module
Browse files Browse the repository at this point in the history
For Dell S5232F and Z9264F platforms, be more strict when checking state
in ISR of FPGA driver, to harden against spurious interrupts.

Signed-off-by: Howard Persh <Howard_Persh@dell.com>
  • Loading branch information
hpersh-dell committed Aug 16, 2019
1 parent 1e45d9f commit bdba462
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,15 +653,20 @@ static void fpgai2c_process(struct fpgalogic_i2c *i2c)
}
}

if (i2c->state == STATE_READ) {
switch (i2c->state) {
case STATE_READ:
PRINT("fpgai2c_poll STATE_READ i2c->pos=%d msg->len-1 = 0x%x set FPGAI2C_REG_CMD = 0x%x\n",i2c->pos, msg->len-1,
i2c->pos == (msg->len-1) ? FPGAI2C_REG_CMD_READ_NACK : FPGAI2C_REG_CMD_READ_ACK);
fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, i2c->pos == (msg->len-1) ?
FPGAI2C_REG_CMD_READ_NACK : FPGAI2C_REG_CMD_READ_ACK);
} else {
break;
case STATE_WRITE:
PRINT("fpgai2c_process set FPGAI2C_REG_DATA(0x%x)\n",FPGAI2C_REG_DATA);
fpgai2c_reg_set(i2c, FPGAI2C_REG_DATA, msg->buf[i2c->pos++]);
fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_WRITE);
break;
default:
printk("Unexpected state, %s:%u state=%d\n", __FILE__, __LINE__, i2c->state);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,15 +654,20 @@ static void fpgai2c_process(struct fpgalogic_i2c *i2c)
}
}

if (i2c->state == STATE_READ) {
switch (i2c->state) {
case STATE_READ:
PRINT("fpgai2c_poll STATE_READ i2c->pos=%d msg->len-1 = 0x%x set FPGAI2C_REG_CMD = 0x%x\n",i2c->pos, msg->len-1,
i2c->pos == (msg->len-1) ? FPGAI2C_REG_CMD_READ_NACK : FPGAI2C_REG_CMD_READ_ACK);
fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, i2c->pos == (msg->len-1) ?
FPGAI2C_REG_CMD_READ_NACK : FPGAI2C_REG_CMD_READ_ACK);
} else {
break;
case STATE_WRITE:
PRINT("fpgai2c_process set FPGAI2C_REG_DATA(0x%x)\n",FPGAI2C_REG_DATA);
fpgai2c_reg_set(i2c, FPGAI2C_REG_DATA, msg->buf[i2c->pos++]);
fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_WRITE);
break;
default:
printk("Unexpected state, %s:%u state=%d\n", __FILE__, __LINE__, i2c->state);
}
}

Expand Down

0 comments on commit bdba462

Please sign in to comment.