LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
To: <dledford@redhat.com>, <jgg@ziepe.ca>
Cc: <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<xavier.huwei@tom.com>, <lijun_nudt@163.com>
Subject: [PATCH rdma-next 1/5] RDMA/hns: Implement the disassociate_ucontext API
Date: Thu, 17 May 2018 16:02:49 +0800 [thread overview]
Message-ID: <1526544173-106587-2-git-send-email-xavier.huwei@huawei.com> (raw)
In-Reply-To: <1526544173-106587-1-git-send-email-xavier.huwei@huawei.com>
This patch Implements the IB core disassociate_ucontext API.
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_main.c | 36 +++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
index 96fb6a9..7fafe9d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_main.c
+++ b/drivers/infiniband/hw/hns/hns_roce_main.c
@@ -33,6 +33,9 @@
#include <linux/acpi.h>
#include <linux/of_platform.h>
#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/sched/mm.h>
+#include <linux/sched/task.h>
#include <rdma/ib_addr.h>
#include <rdma/ib_smi.h>
#include <rdma/ib_user_verbs.h>
@@ -422,6 +425,38 @@ static int hns_roce_port_immutable(struct ib_device *ib_dev, u8 port_num,
return 0;
}
+static void hns_roce_disassociate_ucontext(struct ib_ucontext *ibcontext)
+{
+ struct task_struct *process;
+ struct mm_struct *mm;
+
+ process = get_pid_task(ibcontext->tgid, PIDTYPE_PID);
+ if (!process)
+ return;
+
+ mm = get_task_mm(process);
+ if (!mm) {
+ pr_info("no mm, disassociate ucontext is pending task termination\n");
+ while (1) {
+ put_task_struct(process);
+ usleep_range(1000, 2000);
+ process = get_pid_task(ibcontext->tgid, PIDTYPE_PID);
+ if (!process || process->state == TASK_DEAD) {
+ pr_info("disassociate ucontext done, task was terminated\n");
+ /* if task was dead, need to release the task
+ * struct.
+ */
+ if (process)
+ put_task_struct(process);
+ return;
+ }
+ }
+ }
+
+ mmput(mm);
+ put_task_struct(process);
+}
+
static void hns_roce_unregister_device(struct hns_roce_dev *hr_dev)
{
struct hns_roce_ib_iboe *iboe = &hr_dev->iboe;
@@ -516,6 +551,7 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
/* OTHERS */
ib_dev->get_port_immutable = hns_roce_port_immutable;
+ ib_dev->disassociate_ucontext = hns_roce_disassociate_ucontext;
ib_dev->driver_id = RDMA_DRIVER_HNS;
ret = ib_register_device(ib_dev, NULL);
--
1.9.1
next prev parent reply other threads:[~2018-05-17 7:30 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-17 8:02 [PATCH rdma-next 0/5] Misc update for hns driver Wei Hu (Xavier)
2018-05-17 8:02 ` Wei Hu (Xavier) [this message]
2018-05-17 15:00 ` [PATCH rdma-next 1/5] RDMA/hns: Implement the disassociate_ucontext API Jason Gunthorpe
2018-05-19 8:24 ` Wei Hu (Xavier)
2018-05-22 20:21 ` Jason Gunthorpe
2018-05-23 9:33 ` Wei Hu (Xavier)
2018-05-17 8:02 ` [PATCH rdma-next 2/5] RDMA/hns: Modify uar allocation algorithm to avoid bitmap exhaust Wei Hu (Xavier)
2018-05-23 6:05 ` Leon Romanovsky
2018-05-23 6:49 ` Wei Hu (Xavier)
2018-05-23 7:00 ` Leon Romanovsky
2018-05-23 7:12 ` Wei Hu (Xavier)
2018-05-23 7:22 ` Leon Romanovsky
2018-05-17 8:02 ` [PATCH rdma-next 3/5] RDMA/hns: Increase checking CMQ status timeout value Wei Hu (Xavier)
2018-05-23 5:49 ` Leon Romanovsky
2018-05-23 6:09 ` Wei Hu (Xavier)
2018-05-23 6:15 ` Wei Hu (Xavier)
2018-05-23 6:23 ` Leon Romanovsky
2018-05-17 8:02 ` [PATCH rdma-next 4/5] RDMA/hns: Add reset process for RoCE in hip08 Wei Hu (Xavier)
2018-05-17 15:14 ` Jason Gunthorpe
2018-05-18 3:28 ` Wei Hu (Xavier)
2018-05-18 4:15 ` Jason Gunthorpe
2018-05-18 7:23 ` Wei Hu (Xavier)
2018-05-22 20:26 ` Jason Gunthorpe
2018-05-23 2:54 ` Wei Hu (Xavier)
2018-05-23 3:47 ` Jason Gunthorpe
2018-05-23 9:35 ` Wei Hu (Xavier)
2018-05-23 3:49 ` Wei Hu (Xavier)
2018-05-17 8:02 ` [PATCH rdma-next 5/5] RDMA/hns: Fix the illegal memory operation when cross page Wei Hu (Xavier)
2018-05-23 6:17 ` Leon Romanovsky
2018-05-23 6:38 ` Wei Hu (Xavier)
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=1526544173-106587-2-git-send-email-xavier.huwei@huawei.com \
--to=xavier.huwei@huawei.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=lijun_nudt@163.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=xavier.huwei@tom.com \
--subject='Re: [PATCH rdma-next 1/5] RDMA/hns: Implement the disassociate_ucontext API' \
/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
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).