stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/19] IB/hfi1,rdmavt,core: Patches for-next
@ 2017-04-28 17:38 Dennis Dalessandro
  2017-04-28 17:38 ` [PATCH v2 01/19] IB/core: If the MGID/MLID pair is not on the list return an error Dennis Dalessandro
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dennis Dalessandro @ 2017-04-28 17:38 UTC (permalink / raw)
  To: dledford
  Cc: Mike Marciniszyn, Stuart Summers, linux-rdma, Ira Weiny,
	Mitko Haralanov, Tadeusz Struk, stable, Michael J. Ruhl,
	Easwar Hariharan, Don Hiatt, Neel Desai, Leon Romanovsky,
	Sebastian Sanchez, Dasaratharaman Chandramouli

Doug,

Here are some patches for the next release. It includes the core fix that did
not apply from my last series. Other than that this is the usual bug fixes
and some minor clean ups.

Patches apply on top of your for-4.12 branch and can also be found in my
GitHub repo at: https://github.com/ddalessa/kernel/tree/for-4.12

---

Changes since V1:
* Dropped: [02/20] IB/hfi1: Remove hyper-thread siblings by walking CPU mask
* Fixed a scheduling while atomic bug in update_synth_timer

---

Dasaratharaman Chandramouli (1):
      IB/hfi1: Rename hdr2sc to hfi1_9B_get_sc5

Dennis Dalessandro (4):
      IB/hfi1: Fix misspelling in comment
      IB/hfi1: Convert %Lx to %llx
      IB/hfi1: Fix unbalanced braces around else
      IB/hfi1: Use bool in process_ecn

Don Hiatt (2):
      IB/hfi1: Add functions to parse 9B headers
      IB/hfi1: Use defines from common headers

Ira Weiny (1):
      IB/hfi: Protect against writable mmap

Michael J. Ruhl (5):
      IB/core: If the MGID/MLID pair is not on the list return an error
      IB/hfi1: Correct MulticastMask/CollectiveMask info to SMA output
      IB/core: For multicast functions, verify that LIDs are multicast LIDs
      IB/rdmavt/hfi1/qib: Use the MGID and MLID for multicast addressing
      IB/hfi1: Validate the TID count before using it

Mike Marciniszyn (1):
      IB/hfi1: Prevent kernel QP post send hard lockups

Neel Desai (2):
      IB/hfi1: Adjust high temperature warning for QSFP cable
      IB/hfi1: Permanently enable P_Key checking in HFI

Sebastian Sanchez (1):
      IB/hfi1: Return SC2VL mappings to FM with VL15 instead of ILLEGAL_VL

Stuart Summers (1):
      IB/hfi1: Cache neighbor secure data after link up

Tadeusz Struk (1):
      IB/hfi1: Fix softlockup issue


 drivers/infiniband/core/uverbs_cmd.c      |   13 ++-
 drivers/infiniband/core/verbs.c           |    8 +-
 drivers/infiniband/hw/hfi1/chip.c         |  121 ++++++++++++++---------------
 drivers/infiniband/hw/hfi1/common.h       |   15 ++--
 drivers/infiniband/hw/hfi1/driver.c       |   28 +++----
 drivers/infiniband/hw/hfi1/file_ops.c     |    4 +
 drivers/infiniband/hw/hfi1/hfi.h          |   27 ++++--
 drivers/infiniband/hw/hfi1/init.c         |   11 ++-
 drivers/infiniband/hw/hfi1/intr.c         |   27 ++++--
 drivers/infiniband/hw/hfi1/mad.c          |   56 +++++++------
 drivers/infiniband/hw/hfi1/pcie.c         |    2 
 drivers/infiniband/hw/hfi1/rc.c           |   19 ++---
 drivers/infiniband/hw/hfi1/ruc.c          |   52 +++++++-----
 drivers/infiniband/hw/hfi1/trace.c        |    5 -
 drivers/infiniband/hw/hfi1/trace_ibhdrs.h |    8 +-
 drivers/infiniband/hw/hfi1/uc.c           |    8 +-
 drivers/infiniband/hw/hfi1/ud.c           |   18 ++--
 drivers/infiniband/hw/hfi1/user_exp_rcv.c |    3 +
 drivers/infiniband/hw/hfi1/verbs.c        |   16 ++--
 drivers/infiniband/hw/hfi1/verbs.h        |    6 +
 drivers/infiniband/hw/qib/qib_verbs.c     |    2 
 drivers/infiniband/sw/rdmavt/mcast.c      |   61 +++++++++++----
 include/rdma/ib_hdrs.h                    |   66 ++++++++++++++++
 include/rdma/rdma_vt.h                    |    3 -
 include/rdma/rdmavt_qp.h                  |    7 +-
 25 files changed, 363 insertions(+), 223 deletions(-)

--
Signature

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 01/19] IB/core: If the MGID/MLID pair is not on the list return an error
  2017-04-28 17:38 [PATCH v2 00/19] IB/hfi1,rdmavt,core: Patches for-next Dennis Dalessandro
@ 2017-04-28 17:38 ` Dennis Dalessandro
  2017-04-28 17:39 ` [PATCH v2 03/19] IB/core: For multicast functions, verify that LIDs are multicast LIDs Dennis Dalessandro
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dennis Dalessandro @ 2017-04-28 17:38 UTC (permalink / raw)
  To: dledford; +Cc: linux-rdma, Leon Romanovsky, Ira Weiny, stable, Michael J. Ruhl

From: Michael J. Ruhl <michael.j.ruhl@intel.com>

A list of MGID/MLID pairs is built when doing a multicast attach.  When
the multicast detach is called, the list is searched, and regardless of
the search outcome, the driver detach is called.

If an MGID/MLID pair is not on the list, driver detach should not be
called, and an error should be returned.  Calling the driver without
removing an MGID/MLID pair from the list can leave the core and driver
out of sync.

Fixes: f4e401562c11 ("IB/uverbs: track multicast group membership for userspace QPs")
Cc: stable@vger.kernel.org
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
---
 drivers/infiniband/core/uverbs_cmd.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index b9024fa..27fcbeb 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2647,6 +2647,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
 	struct ib_qp                 *qp;
 	struct ib_uverbs_mcast_entry *mcast;
 	int                           ret = -EINVAL;
+	bool                          found = false;
 
 	if (copy_from_user(&cmd, buf, sizeof cmd))
 		return -EFAULT;
@@ -2658,18 +2659,22 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
 	obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
 	mutex_lock(&obj->mcast_lock);
 
-	ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
-	if (ret)
-		goto out_put;
-
 	list_for_each_entry(mcast, &obj->mcast_list, list)
 		if (cmd.mlid == mcast->lid &&
 		    !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
 			list_del(&mcast->list);
 			kfree(mcast);
+			found = true;
 			break;
 		}
 
+	if (!found) {
+		ret = -EINVAL;
+		goto out_put;
+	}
+
+	ret = ib_detach_mcast(qp, (union ib_gid *)cmd.gid, cmd.mlid);
+
 out_put:
 	mutex_unlock(&obj->mcast_lock);
 	uobj_put_obj_read(qp);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 03/19] IB/core: For multicast functions, verify that LIDs are multicast LIDs
  2017-04-28 17:38 [PATCH v2 00/19] IB/hfi1,rdmavt,core: Patches for-next Dennis Dalessandro
  2017-04-28 17:38 ` [PATCH v2 01/19] IB/core: If the MGID/MLID pair is not on the list return an error Dennis Dalessandro
@ 2017-04-28 17:39 ` Dennis Dalessandro
  2017-04-28 17:39 ` [PATCH v2 10/19] IB/hfi1: Prevent kernel QP post send hard lockups Dennis Dalessandro
  2017-04-28 17:40 ` [PATCH v2 19/19] IB/hfi1: Use bool in process_ecn Dennis Dalessandro
  3 siblings, 0 replies; 5+ messages in thread
From: Dennis Dalessandro @ 2017-04-28 17:39 UTC (permalink / raw)
  To: dledford
  Cc: linux-rdma, Michael J. Ruhl, Ira Weiny, stable,
	Dasaratharaman Chandramouli

From: Michael J. Ruhl <michael.j.ruhl@intel.com>

The Infiniband spec defines "A multicast address is defined by a
MGID and a MLID" (section 10.5).  Currently the MLID value is not
validated.

Add check to verify that the MLID value is in the correct address
range.

Fixes: 0c33aeedb2cf ("[IB] Add checks to multicast attach and detach")
Cc: stable@vger.kernel.org
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
---
 drivers/infiniband/core/verbs.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 85ed505..207e5c2 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1519,7 +1519,9 @@ int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 
 	if (!qp->device->attach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
+	    lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
+	    lid == be16_to_cpu(IB_LID_PERMISSIVE))
 		return -EINVAL;
 
 	ret = qp->device->attach_mcast(qp, gid, lid);
@@ -1535,7 +1537,9 @@ int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 
 	if (!qp->device->detach_mcast)
 		return -ENOSYS;
-	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+	if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD ||
+	    lid < be16_to_cpu(IB_MULTICAST_LID_BASE) ||
+	    lid == be16_to_cpu(IB_LID_PERMISSIVE))
 		return -EINVAL;
 
 	ret = qp->device->detach_mcast(qp, gid, lid);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 10/19] IB/hfi1: Prevent kernel QP post send hard lockups
  2017-04-28 17:38 [PATCH v2 00/19] IB/hfi1,rdmavt,core: Patches for-next Dennis Dalessandro
  2017-04-28 17:38 ` [PATCH v2 01/19] IB/core: If the MGID/MLID pair is not on the list return an error Dennis Dalessandro
  2017-04-28 17:39 ` [PATCH v2 03/19] IB/core: For multicast functions, verify that LIDs are multicast LIDs Dennis Dalessandro
@ 2017-04-28 17:39 ` Dennis Dalessandro
  2017-04-28 17:40 ` [PATCH v2 19/19] IB/hfi1: Use bool in process_ecn Dennis Dalessandro
  3 siblings, 0 replies; 5+ messages in thread
From: Dennis Dalessandro @ 2017-04-28 17:39 UTC (permalink / raw)
  To: dledford; +Cc: linux-rdma, Mike Marciniszyn, stable

From: Mike Marciniszyn <mike.marciniszyn@intel.com>

The driver progress routines can call cond_resched() when
a timeslice is exhausted and irqs are enabled.

If the ULP had been holding a spin lock without disabling irqs and
the post send directly called the progress routine, the cond_resched()
could yield allowing another thread from the same ULP to deadlock
on that same lock.

Correct by replacing the current hfi1_do_send() calldown with a unique
one for post send and adding an argument to hfi1_do_send() to indicate
that the send engine is running in a thread.   If the routine is not
running in a thread, avoid calling cond_resched().

CC: <stable@vger.kernel.org> # 4.7.x-
Fixes: Commit 831464ce4b74 ("IB/hfi1: Don't call cond_resched in atomic mode when sending packets")
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
---
 drivers/infiniband/hw/hfi1/ruc.c   |   26 ++++++++++++++++----------
 drivers/infiniband/hw/hfi1/verbs.c |    4 ++--
 drivers/infiniband/hw/hfi1/verbs.h |    6 ++++--
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/ruc.c b/drivers/infiniband/hw/hfi1/ruc.c
index 879eb9b..ccf8d80 100644
--- a/drivers/infiniband/hw/hfi1/ruc.c
+++ b/drivers/infiniband/hw/hfi1/ruc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2015, 2016 Intel Corporation.
+ * Copyright(c) 2015 - 2017 Intel Corporation.
  *
  * This file is provided under a dual BSD/GPLv2 license.  When using or
  * redistributing this file, you may do so under either license.
@@ -784,23 +784,29 @@ void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
 /* when sending, force a reschedule every one of these periods */
 #define SEND_RESCHED_TIMEOUT (5 * HZ)  /* 5s in jiffies */
 
+void hfi1_do_send_from_rvt(struct rvt_qp *qp)
+{
+	hfi1_do_send(qp, false);
+}
+
 void _hfi1_do_send(struct work_struct *work)
 {
 	struct iowait *wait = container_of(work, struct iowait, iowork);
 	struct rvt_qp *qp = iowait_to_qp(wait);
 
-	hfi1_do_send(qp);
+	hfi1_do_send(qp, true);
 }
 
 /**
  * hfi1_do_send - perform a send on a QP
  * @work: contains a pointer to the QP
+ * @in_thread: true if in a workqueue thread
  *
  * Process entries in the send work queue until credit or queue is
  * exhausted.  Only allow one CPU to send a packet per QP.
  * Otherwise, two threads could send packets out of order.
  */
-void hfi1_do_send(struct rvt_qp *qp)
+void hfi1_do_send(struct rvt_qp *qp, bool in_thread)
 {
 	struct hfi1_pkt_state ps;
 	struct hfi1_qp_priv *priv = qp->priv;
@@ -868,8 +874,10 @@ void hfi1_do_send(struct rvt_qp *qp)
 			qp->s_hdrwords = 0;
 			/* allow other tasks to run */
 			if (unlikely(time_after(jiffies, timeout))) {
-				if (workqueue_congested(cpu,
-							ps.ppd->hfi1_wq)) {
+				if (!in_thread ||
+				    workqueue_congested(
+						cpu,
+						ps.ppd->hfi1_wq)) {
 					spin_lock_irqsave(
 						&qp->s_lock,
 						ps.flags);
@@ -882,11 +890,9 @@ void hfi1_do_send(struct rvt_qp *qp)
 						*ps.ppd->dd->send_schedule);
 					return;
 				}
-				if (!irqs_disabled()) {
-					cond_resched();
-					this_cpu_inc(
-					   *ps.ppd->dd->send_schedule);
-				}
+				cond_resched();
+				this_cpu_inc(
+					*ps.ppd->dd->send_schedule);
 				timeout = jiffies + (timeout_int) / 8;
 			}
 			spin_lock_irqsave(&qp->s_lock, ps.flags);
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 7f49719..e112762 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2015, 2016 Intel Corporation.
+ * Copyright(c) 2015 - 2017 Intel Corporation.
  *
  * This file is provided under a dual BSD/GPLv2 license.  When using or
  * redistributing this file, you may do so under either license.
@@ -1816,7 +1816,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 	dd->verbs_dev.rdi.driver_f.qp_priv_free = qp_priv_free;
 	dd->verbs_dev.rdi.driver_f.free_all_qps = free_all_qps;
 	dd->verbs_dev.rdi.driver_f.notify_qp_reset = notify_qp_reset;
-	dd->verbs_dev.rdi.driver_f.do_send = hfi1_do_send;
+	dd->verbs_dev.rdi.driver_f.do_send = hfi1_do_send_from_rvt;
 	dd->verbs_dev.rdi.driver_f.schedule_send = hfi1_schedule_send;
 	dd->verbs_dev.rdi.driver_f.schedule_send_no_lock = _hfi1_schedule_send;
 	dd->verbs_dev.rdi.driver_f.get_pmtu_from_attr = get_pmtu_from_attr;
diff --git a/drivers/infiniband/hw/hfi1/verbs.h b/drivers/infiniband/hw/hfi1/verbs.h
index 6c549e7..46b00ed 100644
--- a/drivers/infiniband/hw/hfi1/verbs.h
+++ b/drivers/infiniband/hw/hfi1/verbs.h
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2015, 2016 Intel Corporation.
+ * Copyright(c) 2015 - 2017 Intel Corporation.
  *
  * This file is provided under a dual BSD/GPLv2 license.  When using or
  * redistributing this file, you may do so under either license.
@@ -355,7 +355,9 @@ void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
 
 void _hfi1_do_send(struct work_struct *work);
 
-void hfi1_do_send(struct rvt_qp *qp);
+void hfi1_do_send_from_rvt(struct rvt_qp *qp);
+
+void hfi1_do_send(struct rvt_qp *qp, bool in_thread);
 
 void hfi1_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe,
 			enum ib_wc_status status);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 19/19] IB/hfi1: Use bool in process_ecn
  2017-04-28 17:38 [PATCH v2 00/19] IB/hfi1,rdmavt,core: Patches for-next Dennis Dalessandro
                   ` (2 preceding siblings ...)
  2017-04-28 17:39 ` [PATCH v2 10/19] IB/hfi1: Prevent kernel QP post send hard lockups Dennis Dalessandro
@ 2017-04-28 17:40 ` Dennis Dalessandro
  3 siblings, 0 replies; 5+ messages in thread
From: Dennis Dalessandro @ 2017-04-28 17:40 UTC (permalink / raw)
  To: dledford; +Cc: linux-rdma, Mike Marciniszyn, stable

The process_ecn intends to return a bool value. However it is doing
so incorrectly by ANDing the fecn mask. The fecn bit is bit 31. Bool is
not a native data type and is up to the compiler to implement how it
sees fit. It is conceivable that this upper bit gets washed out.

Fix by converting to a bool properly.

Cc: stable@vger.kernel.org
Fixes: Commit fd2b562edca6 ("IB/hfi1: Pull FECN/BECN processing to a common place")
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
---
 drivers/infiniband/hw/hfi1/hfi.h |    2 +-
 drivers/infiniband/hw/hfi1/rc.c  |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
index fec6eb6..51fffdf 100644
--- a/drivers/infiniband/hw/hfi1/hfi.h
+++ b/drivers/infiniband/hw/hfi1/hfi.h
@@ -1609,7 +1609,7 @@ static inline bool process_ecn(struct rvt_qp *qp, struct hfi1_packet *pkt,
 	bth1 = be32_to_cpu(ohdr->bth[1]);
 	if (unlikely(bth1 & (IB_BECN_SMASK | IB_FECN_SMASK))) {
 		hfi1_process_ecn_slowpath(qp, pkt, do_cnp);
-		return bth1 & IB_FECN_SMASK;
+		return !!(bth1 & IB_FECN_SMASK);
 	}
 	return false;
 }
diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c
index da968b7..9b3333f 100644
--- a/drivers/infiniband/hw/hfi1/rc.c
+++ b/drivers/infiniband/hw/hfi1/rc.c
@@ -1930,7 +1930,8 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
 	int diff;
 	struct ib_reth *reth;
 	unsigned long flags;
-	int ret, is_fecn = 0;
+	int ret;
+	bool is_fecn = false;
 	bool copy_last = false;
 	u32 rkey;
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-28 17:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-28 17:38 [PATCH v2 00/19] IB/hfi1,rdmavt,core: Patches for-next Dennis Dalessandro
2017-04-28 17:38 ` [PATCH v2 01/19] IB/core: If the MGID/MLID pair is not on the list return an error Dennis Dalessandro
2017-04-28 17:39 ` [PATCH v2 03/19] IB/core: For multicast functions, verify that LIDs are multicast LIDs Dennis Dalessandro
2017-04-28 17:39 ` [PATCH v2 10/19] IB/hfi1: Prevent kernel QP post send hard lockups Dennis Dalessandro
2017-04-28 17:40 ` [PATCH v2 19/19] IB/hfi1: Use bool in process_ecn Dennis Dalessandro

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).