Message ID | 20190616120558.12960-1-leon@kernel.org (mailing list archive) |
---|---|
State | Mainlined |
Commit | da3929218a4481fc12f9eaa30c9edb09aad5ff24 |
Headers | show |
Series | [rdma-next] RDMa/hns: Don't stuck in endless timeout loop | expand |
在 2019/6/16 20:05, Leon Romanovsky 写道: > From: Leon Romanovsky <leonro@mellanox.com> > > The "end" variable is declared as unsigned and can't be negative, it > leads to the situation where timeout limit is not honored, so let's > convert logic to ensure that loop is bounded. > > drivers/infiniband/hw/hns/hns_roce_hw_v1.c: In function _hns_roce_v1_clear_hem_: > drivers/infiniband/hw/hns/hns_roce_hw_v1.c:2471:12: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] > 2471 | if (end < 0) { > | ^ > > Fixes: 669cefb654cb ("RDMA/hns: Remove jiffies operation in disable interrupt context") > Signed-off-by: Leon Romanovsky <leonro@mellanox.com> > --- > drivers/infiniband/hw/hns/hns_roce_hem.h | 2 +- > drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.h b/drivers/infiniband/hw/hns/hns_roce_hem.h > index d9d668992e49..258682cbe532 100644 > --- a/drivers/infiniband/hw/hns/hns_roce_hem.h > +++ b/drivers/infiniband/hw/hns/hns_roce_hem.h > @@ -34,8 +34,8 @@ > #ifndef _HNS_ROCE_HEM_H > #define _HNS_ROCE_HEM_H > > -#define HW_SYNC_TIMEOUT_MSECS 500 > #define HW_SYNC_SLEEP_TIME_INTERVAL 20 > +#define HW_SYNC_TIMEOUT_MSECS (25 * HW_SYNC_SLEEP_TIME_INTERVAL) > #define BT_CMD_SYNC_SHIFT 31 > > enum { > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > index cc1ea69d0f29..056a6873df7a 100644 > --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c > @@ -2468,7 +2468,7 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev, > end = HW_SYNC_TIMEOUT_MSECS; > while (1) { > if (readl(bt_cmd) >> BT_CMD_SYNC_SHIFT) { > - if (end < 0) { > + if (!end) { > dev_err(dev, "Write bt_cmd err,hw_sync is not zero.\n"); > spin_unlock_irqrestore(&hr_dev->bt_cmd_lock, > flags); Yes, thanks.
On Sun, 2019-06-16 at 15:05 +0300, Leon Romanovsky wrote: > From: Leon Romanovsky <leonro@mellanox.com> > > The "end" variable is declared as unsigned and can't be negative, it > leads to the situation where timeout limit is not honored, so let's > convert logic to ensure that loop is bounded. > > drivers/infiniband/hw/hns/hns_roce_hw_v1.c: In function > _hns_roce_v1_clear_hem_: > drivers/infiniband/hw/hns/hns_roce_hw_v1.c:2471:12: warning: > comparison of unsigned expression < 0 is always false [-Wtype-limits] > 2471 | if (end < 0) { > | ^ > > Fixes: 669cefb654cb ("RDMA/hns: Remove jiffies operation in disable > interrupt context") > Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Thanks, applied to for-next.
diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.h b/drivers/infiniband/hw/hns/hns_roce_hem.h index d9d668992e49..258682cbe532 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hem.h +++ b/drivers/infiniband/hw/hns/hns_roce_hem.h @@ -34,8 +34,8 @@ #ifndef _HNS_ROCE_HEM_H #define _HNS_ROCE_HEM_H -#define HW_SYNC_TIMEOUT_MSECS 500 #define HW_SYNC_SLEEP_TIME_INTERVAL 20 +#define HW_SYNC_TIMEOUT_MSECS (25 * HW_SYNC_SLEEP_TIME_INTERVAL) #define BT_CMD_SYNC_SHIFT 31 enum { diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index cc1ea69d0f29..056a6873df7a 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c @@ -2468,7 +2468,7 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev, end = HW_SYNC_TIMEOUT_MSECS; while (1) { if (readl(bt_cmd) >> BT_CMD_SYNC_SHIFT) { - if (end < 0) { + if (!end) { dev_err(dev, "Write bt_cmd err,hw_sync is not zero.\n"); spin_unlock_irqrestore(&hr_dev->bt_cmd_lock, flags);