[PATCH for-next 5/9] RDMA/hns: Fix error with to_hr_hem_entries_count()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: 54d6638765b0 ("RDMA/hns: Optimize WQE buffer size calculating process")
Signed-off-by: Weihang Li <liweihang@xxxxxxxxxx>
---
 drivers/infiniband/hw/hns/hns_roce_device.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 5cac14d..5564773 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -1111,6 +1111,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));
 }
 
-- 
2.8.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux