linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: jgg-uk2M96/98Pc@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: [PATCH v2 for-next] IB/SA: Check dlid before SA agent queries for ClassPortInfo
Date: Mon, 18 Dec 2017 19:26:58 -0800	[thread overview]
Message-ID: <20171219032656.13381.35960.stgit@scvm10.sc.intel.com> (raw)
In-Reply-To: <20171114123428.10579.94740.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>

From: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

SA queries SM for class port info when there is a LID_CHANGE event.

When a base lid is configured before fm is started ie when smlid is
not yet assigned, SA handles the LID_CHANGE event and tries query SM
with lid 0. This will cause an hang.

[ 1106.958820] INFO: task kworker/2:0:23 blocked for more than 120 seconds.
[ 1106.965082] Tainted: G O 4.12.0+ #1
[ 1106.969602] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables
 this message.
[ 1106.977227] kworker/2:0 D 0 23 2 0x00000000
[ 1106.977250] Workqueue: infiniband update_ib_cpi [ib_core]
[ 1106.977261] Call Trace:
[ 1106.977273] __schedule+0x28e/0x860
[ 1106.977285] schedule+0x36/0x80
[ 1106.977298] schedule_timeout+0x1a3/0x2e0
[ 1106.977310] ? radix_tree_iter_tag_clear+0x1b/0x20
[ 1106.977322] ? idr_alloc+0x64/0x90
[ 1106.977334] wait_for_completion+0xe3/0x140
[ 1106.977347] ? wake_up_q+0x80/0x80
[ 1106.977369] update_ib_cpi+0x163/0x210 [ib_core]
[ 1106.977381] process_one_work+0x147/0x370
[ 1106.977394] worker_thread+0x4a/0x390
[ 1106.977406] kthread+0x109/0x140
[ 1106.977418] ? process_one_work+0x370/0x370
[ 1106.977430] ? kthread_park+0x60/0x60
[ 1106.977443] ret_from_fork+0x22/0x30

Always ensure a proper smlid is assigned before querying SM for cpi.

Fixes: ee1c60b1bff ("IB/SA: Modify SA to implicitly cache Class Port info")
Reviewed-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

---
changes since v1:
	Add inline function to check for valid lid
---
 drivers/infiniband/core/sa_query.c |   10 ++++++++++
 include/rdma/opa_addr.h            |   16 ++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index ab5e102..62d7def 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -1345,6 +1345,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
 
 static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
 {
+	struct rdma_ah_attr ah_attr;
 	unsigned long flags;
 
 	spin_lock_irqsave(&query->port->ah_lock, flags);
@@ -1356,6 +1357,15 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
 	query->sm_ah = query->port->sm_ah;
 	spin_unlock_irqrestore(&query->port->ah_lock, flags);
 
+	/*
+	 * Always check if sm_ah has valid dlid assigned,
+	 * before querying for class port info
+	 */
+	if ((rdma_query_ah(query->sm_ah->ah, &ah_attr) < 0) ||
+	    !rdma_is_valid_unicast_lid(&ah_attr)) {
+		kref_put(&query->sm_ah->ref, free_sm_ah);
+		return -EAGAIN;
+	}
 	query->mad_buf = ib_create_send_mad(query->port->agent, 1,
 					    query->sm_ah->pkey_index,
 					    0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA,
diff --git a/include/rdma/opa_addr.h b/include/rdma/opa_addr.h
index f68fca2..2bbb7a6 100644
--- a/include/rdma/opa_addr.h
+++ b/include/rdma/opa_addr.h
@@ -114,4 +114,20 @@ static inline u32 opa_get_mcast_base(u32 nr_top_bits)
 	return (be32_to_cpu(OPA_LID_PERMISSIVE) << (32 - nr_top_bits));
 }
 
+/* Check for a valid unicast LID for non-SM traffic types */
+static inline bool rdma_is_valid_unicast_lid(struct rdma_ah_attr *attr)
+{
+	if (attr->type == RDMA_AH_ATTR_TYPE_IB) {
+		if (!rdma_ah_get_dlid(attr) ||
+		    rdma_ah_get_dlid(attr) >=
+		    be32_to_cpu(IB_MULTICAST_LID_BASE))
+			return false;
+	} else if (attr->type == RDMA_AH_ATTR_TYPE_OPA) {
+		if (!rdma_ah_get_dlid(attr) ||
+		    rdma_ah_get_dlid(attr) >=
+		    opa_get_mcast_base(OPA_MCAST_NR))
+			return false;
+	}
+	return true;
+}
 #endif /* OPA_ADDR_H */

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-12-19  3:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 12:34 [PATCH for-next 0/6] IB/hfi1, qib, cm, sa: Last set for 4.15 merge window Dennis Dalessandro
     [not found] ` <20171114122859.10579.79788.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-11-14 12:34   ` [PATCH for-next 1/6] IB/hfi1: Mask the path bits with the LMC for 16B RC Acks Dennis Dalessandro
     [not found]     ` <20171114123413.10579.33655.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-12-11 23:37       ` [for-next, " Jason Gunthorpe
2017-11-14 12:34   ` [PATCH for-next 2/6] IB/hfi1: Initialize bth1 in 16B rc ack builder Dennis Dalessandro
     [not found]     ` <20171114123421.10579.19151.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-12-02  0:01       ` [for-next,2/6] " Jason Gunthorpe
2017-11-14 12:34   ` [PATCH for-next 3/6] IB/SA: Check dlid before SA agent queries for ClassPortInfo Dennis Dalessandro
     [not found]     ` <20171114123428.10579.94740.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-11-14 13:11       ` Hal Rosenstock
     [not found]         ` <9f775a16-08b4-033b-7003-93a327bf68f8-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2017-11-20 19:11           ` Dhanalakota, Venkata S
     [not found]             ` <8C8FAED8CED26F4C8245E7FC6A20F9062BA45FA1-8oqHQFITsIGkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-11-20 19:16               ` Jason Gunthorpe
2017-12-19  3:26       ` Dennis Dalessandro [this message]
     [not found]         ` <20171219032656.13381.35960.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-12-19 20:50           ` [PATCH v2 for-next] " Jason Gunthorpe
2017-12-22 23:39           ` Jason Gunthorpe
     [not found]             ` <bbf566a9-0d8d-c6f8-da54-8244cebdfea8@intel.com>
     [not found]               ` <bbf566a9-0d8d-c6f8-da54-8244cebdfea8-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-01-10 20:04                 ` Dhanalakota, Venkata S
2017-11-14 12:34   ` [PATCH for-next 4/6] IB/CM: Change sgid to IB GID when handling CM request Dennis Dalessandro
     [not found]     ` <20171114123436.10579.95655.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-11-14 18:50       ` Parav Pandit
     [not found]         ` <VI1PR0502MB3008698B4478B2973FE1FA27D1280-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-30 23:39           ` Don Hiatt
     [not found]             ` <3d9177ff-b546-15aa-b237-e776e82dac1d-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-12-01  1:27               ` Parav Pandit
2017-11-14 12:34   ` [PATCH for-next 5/6] IB/hfi1: Use 4096 for default active MTU in query_qp Dennis Dalessandro
2017-11-29 18:43   ` [PATCH for-next 0/6] IB/hfi1, qib, cm, sa: Last set for 4.15 merge window Dennis Dalessandro
     [not found]     ` <0b5b45ef-9a05-7c89-7926-27d097bae68e-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-11-29 18:47       ` Parav Pandit
     [not found]         ` <VI1PR0502MB3008FD5232D8F5CECAD4BB9AD13B0-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-11-29 18:54           ` Don Hiatt
2017-11-29 19:08       ` Jason Gunthorpe
2017-11-14 12:34 ` [PATCH for-next 6/6] IB/qib: Fix comparison error with qperf compare/swap test Dennis Dalessandro

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=20171219032656.13381.35960.stgit@scvm10.sc.intel.com \
    --to=dennis.dalessandro-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jgg-uk2M96/98Pc@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).