From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: linux-rdma@vger.kernel.org
Subject: [PATCH rdma-next 07/10] RDMA/cm: Make find_remote_id() return a cm_id_private
Date: Wed, 6 May 2020 10:46:58 +0300 [thread overview]
Message-ID: <20200506074701.9775-8-leon@kernel.org> (raw)
In-Reply-To: <20200506074701.9775-1-leon@kernel.org>
From: Jason Gunthorpe <jgg@mellanox.com>
The only caller doesn't care about the timewait, so acquire and return the
cm_id_private from the function.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/core/cm.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index acb0c5c5c5cf..dfbad8b924b3 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -742,12 +742,14 @@ static struct cm_timewait_info * cm_insert_remote_id(struct cm_timewait_info
return NULL;
}
-static struct cm_timewait_info * cm_find_remote_id(__be64 remote_ca_guid,
- __be32 remote_id)
+static struct cm_id_private *cm_find_remote_id(__be64 remote_ca_guid,
+ __be32 remote_id)
{
struct rb_node *node = cm.remote_id_table.rb_node;
struct cm_timewait_info *timewait_info;
+ struct cm_id_private *res = NULL;
+ spin_lock_irq(&cm.lock);
while (node) {
timewait_info = rb_entry(node, struct cm_timewait_info,
remote_id_node);
@@ -759,10 +761,14 @@ static struct cm_timewait_info * cm_find_remote_id(__be64 remote_ca_guid,
node = node->rb_left;
else if (be64_gt(remote_ca_guid, timewait_info->remote_ca_guid))
node = node->rb_right;
- else
- return timewait_info;
+ else {
+ res = cm_acquire_id(timewait_info->work.local_id,
+ timewait_info->work.remote_id);
+ break;
+ }
}
- return NULL;
+ spin_unlock_irq(&cm.lock);
+ return res;
}
static struct cm_timewait_info * cm_insert_remote_qpn(struct cm_timewait_info
@@ -2993,24 +2999,15 @@ static void cm_format_rej_event(struct cm_work *work)
static struct cm_id_private * cm_acquire_rejected_id(struct cm_rej_msg *rej_msg)
{
- struct cm_timewait_info *timewait_info;
struct cm_id_private *cm_id_priv;
__be32 remote_id;
remote_id = cpu_to_be32(IBA_GET(CM_REJ_LOCAL_COMM_ID, rej_msg));
if (IBA_GET(CM_REJ_REASON, rej_msg) == IB_CM_REJ_TIMEOUT) {
- spin_lock_irq(&cm.lock);
- timewait_info = cm_find_remote_id(
+ cm_id_priv = cm_find_remote_id(
*((__be64 *)IBA_GET_MEM_PTR(CM_REJ_ARI, rej_msg)),
remote_id);
- if (!timewait_info) {
- spin_unlock_irq(&cm.lock);
- return NULL;
- }
- cm_id_priv =
- cm_acquire_id(timewait_info->work.local_id, remote_id);
- spin_unlock_irq(&cm.lock);
} else if (IBA_GET(CM_REJ_MESSAGE_REJECTED, rej_msg) ==
CM_MSG_RESPONSE_REQ)
cm_id_priv = cm_acquire_id(
--
2.26.2
next prev parent reply other threads:[~2020-05-06 7:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 7:46 [PATCH rdma-next 00/10] Various clean ups to ib_cm Leon Romanovsky
2020-05-06 7:46 ` [PATCH rdma-next 01/10] RDMA/addr: Mark addr_resolve as might_sleep() Leon Romanovsky
2020-05-06 7:46 ` [PATCH rdma-next 02/10] RDMA/cm: Remove return code from add_cm_id_to_port_list Leon Romanovsky
2020-05-06 7:46 ` [PATCH rdma-next 03/10] RDMA/cm: Remove unused store to ret in cm_rej_handler Leon Romanovsky
2020-05-06 7:46 ` [PATCH rdma-next 04/10] RDMA/cm: Pull duplicated code into cm_queue_work_unlock() Leon Romanovsky
2020-05-06 7:46 ` [PATCH rdma-next 05/10] RDMA/cm: Pass the cm_id_private into cm_cleanup_timewait Leon Romanovsky
2020-05-06 7:46 ` [PATCH rdma-next 06/10] RDMA/cm: Add a note explaining how the timewait is eventually freed Leon Romanovsky
2020-05-06 7:46 ` Leon Romanovsky [this message]
2020-05-06 7:46 ` [PATCH rdma-next 08/10] RDMA/cm: Remove the cm_free_id() wrapper function Leon Romanovsky
2020-05-06 7:47 ` [PATCH rdma-next 09/10] RDMA/cm: Remove needless cm_id variable Leon Romanovsky
2020-05-06 7:47 ` [PATCH rdma-next 10/10] RDMA/cm: Increment the refcount inside cm_find_listen() Leon Romanovsky
2020-05-13 0:35 ` [PATCH rdma-next 00/10] Various clean ups to ib_cm Jason Gunthorpe
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=20200506074701.9775-8-leon@kernel.org \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
/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).