linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lijun Ou <oulijun@huawei.com>
To: <dledford@redhat.com>, <jgg@ziepe.ca>
Cc: <linux-rdma@vger.kernel.org>, <linuxarm@huawei.com>
Subject: [PATCH for-next 4/9] RDMA/hns: Remove the some magic number
Date: Wed, 21 Aug 2019 21:14:31 +0800	[thread overview]
Message-ID: <1566393276-42555-5-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1566393276-42555-1-git-send-email-oulijun@huawei.com>

Here uses the meaningful macro instead of the magic number
for readability.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Lang Chen <chenglang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_device.h | 5 +++++
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  | 3 ++-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  | 4 ++--
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h  | 3 ++-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 011e038..5eb7134 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -127,6 +127,11 @@
 #define HNS_ROCE_IDX_QUE_ENTRY_SZ		4
 #define SRQ_DB_REG				0x230
 
+/* The chip implementation of the consumer index is calculated
+ * according to twice the actual EQ depth
+ */
+#define EQ_DEPTH_COEFF				2
+
 enum {
 	HNS_ROCE_SUPPORT_RQ_RECORD_DB = 1 << 0,
 	HNS_ROCE_SUPPORT_SQ_RECORD_DB = 1 << 1,
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index d5be11a..73d17a3 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -4016,7 +4016,8 @@ static int hns_roce_v1_ceq_int(struct hns_roce_dev *hr_dev,
 		++eq->cons_index;
 		ceqes_found = 1;
 
-		if (eq->cons_index > 2 * hr_dev->caps.ceqe_depth - 1) {
+		if (eq->cons_index >
+		    EQ_DEPTH_COEFF * hr_dev->caps.ceqe_depth - 1) {
 			dev_warn(&eq->hr_dev->pdev->dev,
 				"cons_index overflow, set back to 0.\n");
 			eq->cons_index = 0;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 67e56b8..d4c4c41 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -5084,7 +5084,7 @@ static int hns_roce_v2_ceq_int(struct hns_roce_dev *hr_dev,
 		++eq->cons_index;
 		ceqe_found = 1;
 
-		if (eq->cons_index > (2 * eq->entries - 1)) {
+		if (eq->cons_index > (EQ_DEPTH_COEFF * eq->entries - 1)) {
 			dev_warn(dev, "cons_index overflow, set back to 0.\n");
 			eq->cons_index = 0;
 		}
@@ -6501,7 +6501,7 @@ static int hns_roce_hw_v2_reset_notify_uninit(struct hnae3_handle *handle)
 
 	handle->rinfo.reset_state = HNS_ROCE_STATE_RST_UNINIT;
 	dev_info(&handle->pdev->dev, "In reset process RoCE client uninit.\n");
-	msleep(100);
+	msleep(HNS_ROCE_V2_HW_RST_UNINT_DELAY);
 	__hns_roce_hw_v2_uninit_instance(handle, false);
 
 	return 0;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index 58931b5..1301629 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -96,7 +96,8 @@
 #define HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE	2
 #define HNS_ROCE_V2_RSV_QPS			8
 
-#define HNS_ROCE_V2_HW_RST_TIMEOUT             1000
+#define HNS_ROCE_V2_HW_RST_TIMEOUT		1000
+#define HNS_ROCE_V2_HW_RST_UNINT_DELAY		100
 
 #define HNS_ROCE_CONTEXT_HOP_NUM		1
 #define HNS_ROCE_SCCC_HOP_NUM			1
-- 
2.8.1


  parent reply	other threads:[~2019-08-21 13:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08 Lijun Ou
2019-08-21 17:19   ` Leon Romanovsky
2019-08-26  8:43     ` liweihang
2019-08-21 13:14 ` [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp Lijun Ou
2019-08-28 15:19   ` Doug Ledford
2019-08-29  0:56     ` oulijun
2019-08-21 13:14 ` [PATCH for-next 3/9] RDMA/hns: Modify the data structure of hns_roce_av Lijun Ou
2019-08-21 13:14 ` Lijun Ou [this message]
2019-08-21 13:14 ` [PATCH for-next 5/9] RDMA/hns: Fix cast from or to restricted __le32 for driver Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 6/9] RDMA/hns: Add reset process for function-clear Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 7/9] RDMA/hns: Remove if-else judgment statements for creating srq Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 8/9] RDMA/hns: Delete the not-used lines Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 9/9] RDMA/hns: Fix wrong assignment of qp_access_flags Lijun Ou
2019-08-28 15:31 ` [PATCH for-next 0/9] Fixes for hip08 driver Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1566393276-42555-5-git-send-email-oulijun@huawei.com \
    --to=oulijun@huawei.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).