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 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08
Date: Wed, 21 Aug 2019 21:14:28 +0800 [thread overview]
Message-ID: <1566393276-42555-2-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1566393276-42555-1-git-send-email-oulijun@huawei.com>
From: Yixian Liu <liuyixian@huawei.com>
This patch refactor the initialization of cmd, and also for the cmd
mode selection on event and poll mode.
Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Lang Chen <chenglang@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_cmd.c | 14 ++++----------
drivers/infiniband/hw/hns/hns_roce_main.c | 18 ++++++++----------
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c
index ade26fa..547002f 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cmd.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c
@@ -251,23 +251,17 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev)
hr_cmd->token_mask = CMD_TOKEN_MASK;
hr_cmd->use_events = 1;
- down(&hr_cmd->poll_sem);
-
return 0;
}
void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev)
{
struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;
- int i;
-
- hr_cmd->use_events = 0;
- for (i = 0; i < hr_cmd->max_cmds; ++i)
- down(&hr_cmd->event_sem);
-
- kfree(hr_cmd->context);
- up(&hr_cmd->poll_sem);
+ if (hr_cmd->use_events) {
+ kfree(hr_cmd->context);
+ hr_cmd->use_events = 0;
+ }
}
struct hns_roce_cmd_mailbox
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
index 1b757cc..f3b2f67 100644
--- a/drivers/infiniband/hw/hns/hns_roce_main.c
+++ b/drivers/infiniband/hw/hns/hns_roce_main.c
@@ -902,6 +902,7 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
goto error_failed_cmd_init;
}
+ /* EQ depends on poll mode, event mode depends on EQ */
ret = hr_dev->hw->init_eq(hr_dev);
if (ret) {
dev_err(dev, "eq init failed!\n");
@@ -911,8 +912,9 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
if (hr_dev->cmd_mod) {
ret = hns_roce_cmd_use_events(hr_dev);
if (ret) {
- dev_err(dev, "Switch to event-driven cmd failed!\n");
- goto error_failed_use_event;
+ dev_warn(dev,
+ "Cmd event mode failed, set back to poll!\n");
+ hns_roce_cmd_use_polling(hr_dev);
}
}
@@ -928,12 +930,10 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
goto error_failed_setup_hca;
}
- if (hr_dev->hw->hw_init) {
- ret = hr_dev->hw->hw_init(hr_dev);
- if (ret) {
- dev_err(dev, "hw_init failed!\n");
- goto error_failed_engine_init;
- }
+ ret = hr_dev->hw->hw_init(hr_dev);
+ if (ret) {
+ dev_err(dev, "hw_init failed!\n");
+ goto error_failed_engine_init;
}
ret = hns_roce_register_device(hr_dev);
@@ -955,8 +955,6 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
error_failed_init_hem:
if (hr_dev->cmd_mod)
hns_roce_cmd_use_polling(hr_dev);
-
-error_failed_use_event:
hr_dev->hw->cleanup_eq(hr_dev);
error_failed_eq_table:
--
2.8.1
next prev 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 ` Lijun Ou [this message]
2019-08-21 17:19 ` [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08 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 ` [PATCH for-next 4/9] RDMA/hns: Remove the some magic number Lijun Ou
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-2-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).