Commit 354d9c95 authored by Dean Luick's avatar Dean Luick Committed by Doug Ledford

staging/rdma/hfi1: Disclose more information when i2c fails

Improve logging messages when there are i2c failures.
Clean i2c read error handling.
Reviewed-by: default avatarEaswar Hariharan <easwar.hariharan@intel.com>
Signed-off-by: default avatarDean Luick <dean.luick@intel.com>
Signed-off-by: default avatarJubin John <jubin.john@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent ed6f653f
...@@ -102,7 +102,8 @@ int i2c_write(struct hfi1_pportdata *ppd, u32 target, int i2c_addr, int offset, ...@@ -102,7 +102,8 @@ int i2c_write(struct hfi1_pportdata *ppd, u32 target, int i2c_addr, int offset,
ret = hfi1_twsi_reset(ppd->dd, target); ret = hfi1_twsi_reset(ppd->dd, target);
if (ret) { if (ret) {
hfi1_dev_porterr(ppd->dd, ppd->port, hfi1_dev_porterr(ppd->dd, ppd->port,
"I2C write interface reset failed\n"); "I2C chain %d write interface reset failed\n",
target);
goto done; goto done;
} }
...@@ -121,15 +122,14 @@ static int __i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr, ...@@ -121,15 +122,14 @@ static int __i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr,
{ {
struct hfi1_devdata *dd = ppd->dd; struct hfi1_devdata *dd = ppd->dd;
int ret, cnt, pass = 0; int ret, cnt, pass = 0;
int stuck = 0; int orig_offset = offset;
u8 *buff = bp;
cnt = 0; cnt = 0;
while (cnt < len) { while (cnt < len) {
int rlen = len - cnt; int rlen = len - cnt;
ret = hfi1_twsi_blk_rd(dd, target, i2c_addr, offset, ret = hfi1_twsi_blk_rd(dd, target, i2c_addr, offset,
buff + cnt, rlen); bp + cnt, rlen);
/* Some QSFP's fail first try. Retry as experiment */ /* Some QSFP's fail first try. Retry as experiment */
if (ret && cnt == 0 && ++pass < I2C_MAX_RETRY) if (ret && cnt == 0 && ++pass < I2C_MAX_RETRY)
continue; continue;
...@@ -145,14 +145,11 @@ static int __i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr, ...@@ -145,14 +145,11 @@ static int __i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr,
ret = cnt; ret = cnt;
exit: exit:
if (stuck) if (ret < 0) {
dd_dev_err(dd, "I2C interface bus stuck non-idle\n");
if (pass >= I2C_MAX_RETRY && ret)
hfi1_dev_porterr(dd, ppd->port, hfi1_dev_porterr(dd, ppd->port,
"I2C failed even retrying\n"); "I2C chain %d read failed, addr 0x%x, offset 0x%x, len %d\n",
else if (pass) target, i2c_addr, orig_offset, len);
hfi1_dev_porterr(dd, ppd->port, "I2C retries: %d\n", pass); }
/* Must wait min 20us between qsfp i2c transactions */ /* Must wait min 20us between qsfp i2c transactions */
udelay(20); udelay(20);
...@@ -174,7 +171,8 @@ int i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr, int offset, ...@@ -174,7 +171,8 @@ int i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr, int offset,
ret = hfi1_twsi_reset(ppd->dd, target); ret = hfi1_twsi_reset(ppd->dd, target);
if (ret) { if (ret) {
hfi1_dev_porterr(ppd->dd, ppd->port, hfi1_dev_porterr(ppd->dd, ppd->port,
"I2C read interface reset failed\n"); "I2C chain %d read interface reset failed\n",
target);
goto done; goto done;
} }
...@@ -206,7 +204,8 @@ int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp, ...@@ -206,7 +204,8 @@ int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
ret = hfi1_twsi_reset(ppd->dd, target); ret = hfi1_twsi_reset(ppd->dd, target);
if (ret) { if (ret) {
hfi1_dev_porterr(ppd->dd, ppd->port, hfi1_dev_porterr(ppd->dd, ppd->port,
"QSFP write interface reset failed\n"); "QSFP chain %d write interface reset failed\n",
target);
mutex_unlock(&ppd->dd->qsfp_i2c_mutex); mutex_unlock(&ppd->dd->qsfp_i2c_mutex);
return ret; return ret;
} }
...@@ -221,10 +220,9 @@ int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp, ...@@ -221,10 +220,9 @@ int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
ret = __i2c_write(ppd, target, QSFP_DEV | QSFP_OFFSET_SIZE, ret = __i2c_write(ppd, target, QSFP_DEV | QSFP_OFFSET_SIZE,
QSFP_PAGE_SELECT_BYTE_OFFS, &page, 1); QSFP_PAGE_SELECT_BYTE_OFFS, &page, 1);
if (ret != 1) { if (ret != 1) {
hfi1_dev_porterr( hfi1_dev_porterr(ppd->dd, ppd->port,
ppd->dd, "QSFP chain %d can't write QSFP_PAGE_SELECT_BYTE: %d\n",
ppd->port, target, ret);
"can't write QSFP_PAGE_SELECT_BYTE: %d\n", ret);
ret = -EIO; ret = -EIO;
break; break;
} }
...@@ -272,7 +270,8 @@ int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp, ...@@ -272,7 +270,8 @@ int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
ret = hfi1_twsi_reset(ppd->dd, target); ret = hfi1_twsi_reset(ppd->dd, target);
if (ret) { if (ret) {
hfi1_dev_porterr(ppd->dd, ppd->port, hfi1_dev_porterr(ppd->dd, ppd->port,
"QSFP read interface reset failed\n"); "QSFP chain %d read interface reset failed\n",
target);
mutex_unlock(&ppd->dd->qsfp_i2c_mutex); mutex_unlock(&ppd->dd->qsfp_i2c_mutex);
return ret; return ret;
} }
...@@ -286,10 +285,9 @@ int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp, ...@@ -286,10 +285,9 @@ int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
ret = __i2c_write(ppd, target, QSFP_DEV | QSFP_OFFSET_SIZE, ret = __i2c_write(ppd, target, QSFP_DEV | QSFP_OFFSET_SIZE,
QSFP_PAGE_SELECT_BYTE_OFFS, &page, 1); QSFP_PAGE_SELECT_BYTE_OFFS, &page, 1);
if (ret != 1) { if (ret != 1) {
hfi1_dev_porterr( hfi1_dev_porterr(ppd->dd, ppd->port,
ppd->dd, "QSFP chain %d can't write QSFP_PAGE_SELECT_BYTE: %d\n",
ppd->port, target, ret);
"can't write QSFP_PAGE_SELECT_BYTE: %d\n", ret);
ret = -EIO; ret = -EIO;
break; break;
} }
......
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