Skip to content

Commit

Permalink
RDMA/hns: Fix error with to_hr_hem_entries_count()
Browse files Browse the repository at this point in the history
For ilog2(x), if x is 0 and not a constant variable, it will return
-1. And there will be an error as below:

 hns3 0000:7d:00.0 hns_0: Local work queue 0x8 catast error, sub_event type is: 2

So modify to_hr_hem_entries_shift() to return 0 if conut is 0.

Fixes: 54d6638 ("RDMA/hns: Optimize WQE buffer size calculating process")
Link: https://lore.kernel.org/r/1588931159-56875-6-git-send-email-liweihang@huawei.com
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Weihang Li authored and Jason Gunthorpe committed May 19, 2020
1 parent 6968aeb commit d4d8138
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/infiniband/hw/hns/hns_roce_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,9 @@ static inline u32 to_hr_hem_entries_count(u32 count, u32 buf_shift)

static inline u32 to_hr_hem_entries_shift(u32 count, u32 buf_shift)
{
if (!count)
return 0;

return ilog2(to_hr_hem_entries_count(count, buf_shift));
}

Expand Down

0 comments on commit d4d8138

Please sign in to comment.