Skip to contentSkip to conversation

IB/hfi1,rdmavt,core: Patches for-next

PATCH Superseded Dennis Dalessandro 8 participants 34 messages Apr 9, 2017 – May 29, 2017 11 messages not in the archive

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover IB/hfi1,rdmavt,core: Patches for-next

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

---

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 (2):
IB/hfi1: Remove hyper-thread siblings by walking CPU mask 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/affinity.c     |   52 +++++++--------
 drivers/infiniband/hw/hfi1/affinity.h     |    4 -
 drivers/infiniband/hw/hfi1/chip.c         |   98 +++++++++++------------------
 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          |   23 ++++---
 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 ++
 27 files changed, 365 insertions(+), 250 deletions(-)

--
-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170409171329.10579.92775.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org

#2 lore raw

PATCH 1/20 IB/core: If the MGID/MLID pair is not on the list return an error

From: Michael J. Ruhl <[email protected]>

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")
---
 drivers/infiniband/core/uverbs_cmd.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +9 -4
index b9024fa..27fcbeb 100644
@@ -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);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 2/20 IB/hfi1: Remove hyper-thread siblings by walking CPU mask

In reply to a message not in the archive

From: Sebastian Sanchez <[email protected]>

The driver expects that hyper-thread siblings are allocated in blocks. This might not be a safe assumption. Walk through the "real_cpu_mask" picking up CPUs and removing its siblings instead of relying on the sibling CPUs being contiguous in the CPU mask.

---
 drivers/infiniband/hw/hfi1/affinity.c |   52 +++++++++++++++------------------
 drivers/infiniband/hw/hfi1/affinity.h |    4 +--
 2 files changed, 25 insertions(+), 31 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +24 -28
index e2cd2cd..3679959 100644
@@ -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.
@@ -78,37 +78,32 @@ static inline void init_cpu_mask_set(struct cpu_mask_set *set)
 }
 
 /* Initialize non-HT cpu cores mask */
-void init_real_cpu_mask(void)
+static int init_real_cpu_mask(void)
 {
-	int possible, curr_cpu, i, ht;
+	int curr_cpu, ret;
+	cpumask_var_t sibling_mask;
+	struct cpumask *real_cpu_mask = &node_affinity.real_cpu_mask;
 
-	cpumask_clear(&node_affinity.real_cpu_mask);
+	ret = zalloc_cpumask_var(&sibling_mask, GFP_KERNEL);
+	if (!ret)
+		return -ENOMEM;
 
-	/* Start with cpu online mask as the real cpu mask */
-	cpumask_copy(&node_affinity.real_cpu_mask, cpu_online_mask);
+	cpumask_clear(real_cpu_mask);
 
-	/*
-	 * Remove HT cores from the real cpu mask.  Do this in two steps below.
-	 */
-	possible = cpumask_weight(&node_affinity.real_cpu_mask);
-	ht = cpumask_weight(topology_sibling_cpumask(
-				cpumask_first(&node_affinity.real_cpu_mask)));
-	/*
-	 * Step 1.  Skip over the first N HT siblings and use them as the
-	 * "real" cores.  Assumes that HT cores are not enumerated in
-	 * succession (except in the single core case).
-	 */
-	curr_cpu = cpumask_first(&node_affinity.real_cpu_mask);
-	for (i = 0; i < possible / ht; i++)
-		curr_cpu = cpumask_next(curr_cpu, &node_affinity.real_cpu_mask);
-	/*
-	 * Step 2.  Remove the remaining HT siblings.  Use cpumask_next() to
-	 * skip any gaps.
-	 */
-	for (; i < possible; i++) {
-		cpumask_clear_cpu(curr_cpu, &node_affinity.real_cpu_mask);
-		curr_cpu = cpumask_next(curr_cpu, &node_affinity.real_cpu_mask);
+	/* Start with cpu online mask as the real cpu mask */
+	cpumask_copy(real_cpu_mask, cpu_online_mask);
+
+	/* Remove HT cores from the real cpu mask */
+	curr_cpu = cpumask_first(real_cpu_mask);
+	while (curr_cpu < nr_cpu_ids) {
+		cpumask_copy(sibling_mask, topology_sibling_cpumask(curr_cpu));
+		cpumask_clear_cpu(curr_cpu, sibling_mask);
+		cpumask_andnot(real_cpu_mask, real_cpu_mask, sibling_mask);
+		curr_cpu = cpumask_next(curr_cpu, real_cpu_mask);
 	}
+
+	free_cpumask_var(sibling_mask);
+	return 0;
 }
 
 int node_affinity_init(void)
@@ -134,7 +129,8 @@ int node_affinity_init(void)
 	 * initialized early. It is needed to calculate the number of user
 	 * contexts in set_up_context_variables().
 	 */
-	init_real_cpu_mask();
+	if (init_real_cpu_mask())
+		return -ENOMEM;
 
 	hfi1_per_node_cntr = kcalloc(node_affinity.num_possible_nodes,
 				     sizeof(*hfi1_per_node_cntr), GFP_KERNEL);
drivers/infiniband/hw/hfi1/affinity.h +1 -3
index e78c7aa..096866e 100644
@@ -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.
@@ -72,8 +72,6 @@ struct cpu_mask_set {
 
 struct hfi1_msix_entry;
 
-/* Initialize non-HT cpu cores mask */
-void init_real_cpu_mask(void);
 /* Initialize driver affinity data */
 int hfi1_dev_affinity_init(struct hfi1_devdata *);
 /*

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170409171537.10579.68545.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org

#5 lore raw

Re: [PATCH 02/20] IB/hfi1: Remove hyper-thread siblings by walking CPU mask

Please kill all thus code and use the PI/irq layer PCI_IRQ_AFFINITY flag. Same for the old qib driver. As an upside this will also let you into the automatic block queue assignment work that ٰSagi posted last week.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

RE: [PATCH 02/20] IB/hfi1: Remove hyper-thread siblings by walking CPU mask

VGhlIGlycSBsYXllciBQQ0lfSVJRX0FGRklOSVRZIGZsYWcgbWFrZXMgcGNpX2FsbG9jX2lycV92 ZWN0b3JzKCkgc3ByZWFkIGFsbCB0aGUgaW50ZXJydXB0cyBhcm91bmQgdGhlIGF2YWlsYWJsZSBD UFVzLCBob3dldmVyLCB0aGUgQVBJIGRvZXNuJ3QgYWxsb3cgdG8gZXhjbHVkZSB0aGUgaHlwZXIg dGhyZWFkaW5nIENQVSBjb3JlcyBvciBsaW1pdCB0aGUgQ1BVcyB0byB1c2UgZm9yIHRoZSBhZmZp bml0eSBtYXNrLiBJZiB0aGUgQVBJIGhhZCBhIHdheSB0byBwcm92aWRlIGFuIGFmZmluaXR5IGhp bnQgaW50byB0aGlzIGZ1bmN0aW9uIGluc3RlYWQgb2YgaGF2aW5nIHRoZW0gYXV0b21hdGljYWxs eSBnZW5lcmF0ZWQgaXQgcHJvdmlkZSBtb3JlIGZsZXhpYmlsaXR5IHRvIHRoZSBoZmkxIGRyaXZl ci4NCg0KU2ViYXN0aWFuDQo=
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 5CDA63463B33C94CA80846587415F07704076B86-8oqHQFITsIGkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org

#9 lore raw

Re: [PATCH 02/20] IB/hfi1: Remove hyper-thread siblings by walking CPU mask

Quoted 1 line · Sebastian

The irq layer PCI_IRQ_AFFINITY flag makes pci_alloc_irq_vectors() spread all the interrupts around the available CPUs, however, the API doesn't allow to exclude the hyper threading CPU cores or limit the CPUs to use for the affinity mask. If the API had a way to provide an affinity hint into this function instead of having them automatically generated it provide more flexibility to the hfi1 driver.

It is open source, add it if you need it.

Thanks

Quoted 2 lines

Sebastian

A message that is not in the archive (sent off-list or not yet received): 20170420173420.GR14088-U/[email protected]

#11 lore raw

Re: [PATCH 02/20] IB/hfi1: Remove hyper-thread siblings by walking CPU mask

Quoted 4 lines · Leon Romanovsky
Quoted 1 line · Sebastian

The irq layer PCI_IRQ_AFFINITY flag makes pci_alloc_irq_vectors() spread all the interrupts around the available CPUs, however, the API doesn't allow to exclude the hyper threading CPU cores or limit the CPUs to use for the affinity mask. If the API had a way to provide an affinity hint into this function instead of having them automatically generated it provide more flexibility to the hfi1 driver.

It is open source, add it if you need it.

Exactly. And it's not like hfi1 is a super special beast. IFF the hyperthread magic makes sense it will be useful for other device aswell.

So I'd like to repeat my NAK for "improving" any irq affinity magic in drivers. Move to the common code and improve it as needed instead of making the mess worse.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

PATCH 3/20 IB/hfi1: Correct MulticastMask/CollectiveMask info to SMA output

In reply to a message not in the archive

From: Michael J. Ruhl <[email protected]>

The FM uses the values of MulticastMask and CollectiveMask to determine the number of bits for net masks. The current values of 0 and 0 are incorrect. The values should be 4 and 1. Updated the necessary code to reflect the specified values.

---
 drivers/infiniband/hw/hfi1/common.h |    9 +++++++++
 drivers/infiniband/hw/hfi1/mad.c    |    5 +++++
 2 files changed, 14 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/common.h +9 -0
index 1b783bb..804150f 100644
@@ -338,6 +338,15 @@ struct diag_pkt {
 #define HFI1_BECN_MASK 1
 #define HFI1_BECN_SMASK BIT(HFI1_BECN_SHIFT)
 
+/**
+ * 0xF8 - 4 bits of multicast range and 1 bit for collective range
+ * Example: For 24 bit LID space,
+ * Multicast range: 0xF00000 to 0xF7FFFF
+ * Collective range: 0xF80000 to 0xFFFFFE
+ */
+#define HFI1_MCAST_NR 0x4 /* Number of top bits set */
+#define HFI1_COLLECTIVE_NR 0x1 /* Number of bits after MCAST_NR */
+
 #define HFI1_PSM_IOC_BASE_SEQ 0x0
 
 static inline __u64 rhf_to_cpu(const __le32 *rbuf)
drivers/infiniband/hw/hfi1/mad.c +5 -0
index 09cda3c..de34131 100644
@@ -702,6 +702,11 @@ static int __subn_get_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data,
 	pi->buffer_units = cpu_to_be32(buffer_units);
 
 	pi->opa_cap_mask = cpu_to_be16(OPA_CAP_MASK3_IsSharedSpaceSupported);
+	/* Driver does not support mcast/collective configuration */
+	pi->opa_cap_mask &=
+		cpu_to_be16(~OPA_CAP_MASK3_IsAddrRangeConfigSupported);
+	pi->collectivemask_multicastmask = ((HFI1_COLLECTIVE_NR & 0x7)
+					    << 3 | (HFI1_MCAST_NR & 0x7));
 
 	/* HFI supports a replay buffer 128 LTPs in size */
 	pi->replay_depth.buffer = 0x80;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw

PATCH 4/20 IB/core: For multicast functions, verify that LIDs are multicast LIDs

In reply to a message not in the archive

From: Michael J. Ruhl <[email protected]>

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.

---
 drivers/infiniband/core/verbs.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/infiniband/core/verbs.c +6 -2
index 85ed505..207e5c2 100644
@@ -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);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v1 4/20
#14 lore raw

Re: [PATCH 04/20] IB/core: For multicast functions, verify that LIDs are multicast LIDs

Quoted 15 lines · Dennis Dalessandro

From: Michael J. Ruhl <[email protected]>

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")
Quoted 4 lines
---
 drivers/infiniband/core/verbs.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Thanks,

#15 lore raw

PATCH 5/20 IB/rdmavt/hfi1/qib: Use the MGID and MLID for multicast addressing

In reply to a message not in the archive

From: Michael J. Ruhl <[email protected]>

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

The current code only uses the MGID for identifying multicast groups. Update the driver to be compliant with this definition.

---
 drivers/infiniband/hw/hfi1/verbs.c    |    2 +
 drivers/infiniband/hw/qib/qib_verbs.c |    2 +
 drivers/infiniband/sw/rdmavt/mcast.c  |   61 ++++++++++++++++++++++++---------
 include/rdma/rdma_vt.h                |    3 +-
 include/rdma/rdmavt_qp.h              |    7 +++-
 5 files changed, 54 insertions(+), 21 deletions(-)
drivers/infiniband/hw/hfi1/verbs.c +1 -1
index 070a349..f74abb1 100644
@@ -603,7 +603,7 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)
 
 		if (lnh != HFI1_LRH_GRH)
 			goto drop;
-		mcast = rvt_mcast_find(&ibp->rvp, &hdr->u.l.grh.dgid);
+		mcast = rvt_mcast_find(&ibp->rvp, &hdr->u.l.grh.dgid, lid);
 		if (!mcast)
 			goto drop;
 		list_for_each_entry_rcu(p, &mcast->qp_list, list) {
drivers/infiniband/hw/qib/qib_verbs.c +1 -1
index e120efe..68d449c 100644
@@ -356,7 +356,7 @@ void qib_ib_rcv(struct qib_ctxtdata *rcd, void *rhdr, void *data, u32 tlen)
 
 		if (lnh != QIB_LRH_GRH)
 			goto drop;
-		mcast = rvt_mcast_find(&ibp->rvp, &hdr->u.l.grh.dgid);
+		mcast = rvt_mcast_find(&ibp->rvp, &hdr->u.l.grh.dgid, lid);
 		if (mcast == NULL)
 			goto drop;
 		this_cpu_inc(ibp->pmastats->n_multicast_rcv);
drivers/infiniband/sw/rdmavt/mcast.c +44 -17

139 lines not on this page · raw message

include/rdma/rdma_vt.h +2 -1
index 8fc1ca7..7f89568 100644
@@ -516,6 +516,7 @@ int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,
 		u32 len, u64 vaddr, u32 rkey, int acc);
 int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,
 		struct rvt_sge *isge, struct ib_sge *sge, int acc);
-struct rvt_mcast *rvt_mcast_find(struct rvt_ibport *ibp, union ib_gid *mgid);
+struct rvt_mcast *rvt_mcast_find(struct rvt_ibport *ibp, union ib_gid *mgid,
+				 u16 lid);
 
 #endif          /* DEF_RDMA_VT_H */
include/rdma/rdmavt_qp.h +6 -1
index e3bb312..75a077c 100644
@@ -435,9 +435,14 @@ struct rvt_mcast_qp {
 	struct rvt_qp *qp;
 };
 
+struct rvt_mcast_addr {
+	union ib_gid mgid;
+	u16 lid;
+};
+
 struct rvt_mcast {
 	struct rb_node rb_node;
-	union ib_gid mgid;
+	struct rvt_mcast_addr mcast_addr;
 	struct list_head qp_list;
 	wait_queue_head_t wait;
 	atomic_t refcount;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw

PATCH 6/20 IB/hfi1: Validate the TID count before using it

In reply to a message not in the archive

From: Michael J. Ruhl <[email protected]>

Improve the safety of the code by validating the user supplied tidcnt before use.

---
 drivers/infiniband/hw/hfi1/user_exp_rcv.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/user_exp_rcv.c +3 -0
index 4a82953..9b8bdf7 100644
@@ -578,6 +578,9 @@ int hfi1_user_exp_rcv_clear(struct file *fp, struct hfi1_tid_info *tinfo)
 	u32 *tidinfo;
 	unsigned tididx;
 
+	if (unlikely(tinfo->tidcnt > fd->tid_used))
+		return -EINVAL;
+
 	tidinfo = memdup_user((void __user *)(unsigned long)tinfo->tidlist,
 			      sizeof(tidinfo[0]) * tinfo->tidcnt);
 	if (IS_ERR(tidinfo))

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#17 lore raw

PATCH 7/20 IB/hfi1: Return SC2VL mappings to FM with VL15 instead of ILLEGAL_VL

In reply to a message not in the archive

From: Sebastian Sanchez <[email protected]>

VL15 in the SC2VL table is used to indicate an invalid SC for the FM, however, internally the driver remaps SCs from VL15 to ILLEGAL_VL to prevent error counts. This mapping confuses the FM when performing a sweep, making it return a table mismatch error. Have SMA convert ILLEGAL_VL to VL15 entries for the SC2VL table queries.

---
 drivers/infiniband/hw/hfi1/mad.c |   41 +++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 16 deletions(-)
drivers/infiniband/hw/hfi1/mad.c +25 -16
index de34131..db5494d 100644
@@ -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.
@@ -1470,25 +1470,15 @@ static int __subn_set_opa_pkeytable(struct opa_smp *smp, u32 am, u8 *data,
 	return __subn_get_opa_pkeytable(smp, am, data, ibdev, port, resp_len);
 }
 
-static int get_sc2vlt_tables(struct hfi1_devdata *dd, void *data)
-{
-	u64 *val = data;
-
-	*val++ = read_csr(dd, SEND_SC2VLT0);
-	*val++ = read_csr(dd, SEND_SC2VLT1);
-	*val++ = read_csr(dd, SEND_SC2VLT2);
-	*val++ = read_csr(dd, SEND_SC2VLT3);
-	return 0;
-}
-
 #define ILLEGAL_VL 12
 /*
  * filter_sc2vlt changes mappings to VL15 to ILLEGAL_VL (except
  * for SC15, which must map to VL15). If we don't remap things this
  * way it is possible for VL15 counters to increment when we try to
  * send on a SC which is mapped to an invalid VL.
+ * When getting the table convert ILLEGAL_VL back to VL15.
  */
-static void filter_sc2vlt(void *data)
+static void filter_sc2vlt(void *data, bool set)
 {
 	int i;
 	u8 *pd = data;
@@ -1496,8 +1486,14 @@ static void filter_sc2vlt(void *data)
 	for (i = 0; i < OPA_MAX_SCS; i++) {
 		if (i == 15)
 			continue;
-		if ((pd[i] & 0x1f) == 0xf)
-			pd[i] = ILLEGAL_VL;
+
+		if (set) {
+			if ((pd[i] & 0x1f) == 0xf)
+				pd[i] = ILLEGAL_VL;
+		} else {
+			if ((pd[i] & 0x1f) == ILLEGAL_VL)
+				pd[i] = 0xf;
+		}
 	}
 }
 
@@ -1505,7 +1501,7 @@ static int set_sc2vlt_tables(struct hfi1_devdata *dd, void *data)
 {
 	u64 *val = data;
 
-	filter_sc2vlt(data);
+	filter_sc2vlt(data, true);
 
 	write_csr(dd, SEND_SC2VLT0, *val++);
 	write_csr(dd, SEND_SC2VLT1, *val++);
@@ -1517,6 +1513,19 @@ static int set_sc2vlt_tables(struct hfi1_devdata *dd, void *data)
 	return 0;
 }
 
+static int get_sc2vlt_tables(struct hfi1_devdata *dd, void *data)
+{
+	u64 *val = (u64 *)data;
+
+	*val++ = read_csr(dd, SEND_SC2VLT0);
+	*val++ = read_csr(dd, SEND_SC2VLT1);
+	*val++ = read_csr(dd, SEND_SC2VLT2);
+	*val++ = read_csr(dd, SEND_SC2VLT3);
+
+	filter_sc2vlt((u64 *)data, false);
+	return 0;
+}
+
 static int __subn_get_opa_sl_to_sc(struct opa_smp *smp, u32 am, u8 *data,
 				   struct ib_device *ibdev, u8 port,
 				   u32 *resp_len)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#18 lore raw

PATCH 8/20 IB/hfi1: Rename hdr2sc to hfi1_9B_get_sc5

In reply to a message not in the archive

From: Dasaratharaman Chandramouli <dasaratharaman.chandramouli-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

The function really returned the 5-bit sc value from the header and rhf. hdr2sc didn't quite describe what it did.

---
 drivers/infiniband/hw/hfi1/driver.c |    7 ++++---
 drivers/infiniband/hw/hfi1/hfi.h    |    2 +-
 drivers/infiniband/hw/hfi1/ud.c     |    2 +-
 drivers/infiniband/hw/hfi1/verbs.c  |    2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/infiniband/hw/hfi1/driver.c +4 -3
index 64bdbce..d731b5e 100644
@@ -397,7 +397,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
 			u16 rlid;
 			u8 svc_type, sl, sc5;
 
-			sc5 = hdr2sc(rhdr, packet->rhf);
+			sc5 = hfi1_9B_get_sc5(rhdr, packet->rhf);
 			sl = ibp->sc_to_sl[sc5];
 
 			lqpn = be32_to_cpu(bth[1]) & RVT_QPN_MASK;
@@ -492,7 +492,7 @@ void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
 		return;
 	}
 
-	sc = hdr2sc(hdr, pkt->rhf);
+	sc = hfi1_9B_get_sc5(hdr, pkt->rhf);
 
 	bth1 = be32_to_cpu(ohdr->bth[1]);
 	if (do_cnp && (bth1 & HFI1_FECN_SMASK)) {
@@ -909,7 +909,8 @@ static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd,
 						   packet->rhf_addr);
 	u8 etype = rhf_rcv_type(packet->rhf);
 
-	if (etype == RHF_RCV_TYPE_IB && hdr2sc(hdr, packet->rhf) != 0xf) {
+	if (etype == RHF_RCV_TYPE_IB &&
+	    hfi1_9B_get_sc5(hdr, packet->rhf) != 0xf) {
 		int hwstate = read_logical_state(dd);
 
 		if (hwstate != LSTATE_ACTIVE) {
drivers/infiniband/hw/hfi1/hfi.h +1 -1
index a31638c..8509502 100644
@@ -1261,7 +1261,7 @@ static inline u32 driver_lstate(struct hfi1_pportdata *ppd)
 void receive_interrupt_work(struct work_struct *work);
 
 /* extract service channel from header and rhf */
-static inline int hdr2sc(struct ib_header *hdr, u64 rhf)
+static inline int hfi1_9B_get_sc5(struct ib_header *hdr, u64 rhf)
 {
 	return ((be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf) |
 	       ((!!(rhf_dc_info(rhf))) << 4);
drivers/infiniband/hw/hfi1/ud.c +1 -1
index 13ea4eb..fd105cf 100644
@@ -680,7 +680,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
 	u32 tlen = packet->tlen;
 	struct rvt_qp *qp = packet->qp;
 	bool has_grh = rcv_flags & HFI1_HAS_GRH;
-	u8 sc5 = hdr2sc(hdr, packet->rhf);
+	u8 sc5 = hfi1_9B_get_sc5(hdr, packet->rhf);
 	u32 bth1;
 	u8 sl_from_sc, sl;
 	u16 slid;
drivers/infiniband/hw/hfi1/verbs.c +1 -1
index f74abb1..66a2378 100644
@@ -1928,7 +1928,7 @@ void hfi1_cnp_rcv(struct hfi1_packet *packet)
 		return;
 	}
 
-	sc5 = hdr2sc(hdr, packet->rhf);
+	sc5 = hfi1_9B_get_sc5(hdr, packet->rhf);
 	sl = ibp->sc_to_sl[sc5];
 	lqpn = qp->ibqp.qp_num;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#19 lore raw

PATCH 9/20 IB/hfi1: Add functions to parse 9B headers

In reply to a message not in the archive

From: Don Hiatt <[email protected]>

These inline functions improve code readability by enabling callers to read specific fields from the header without knowledge of byte offsets.

---
 drivers/infiniband/hw/hfi1/driver.c |   13 ++++----
 drivers/infiniband/hw/hfi1/hfi.h    |    3 +-
 drivers/infiniband/hw/hfi1/rc.c     |   14 ++++----
 drivers/infiniband/hw/hfi1/ruc.c    |   24 +++++++-------
 drivers/infiniband/hw/hfi1/trace.c  |    5 +--
 drivers/infiniband/hw/hfi1/uc.c     |    8 ++---
 drivers/infiniband/hw/hfi1/ud.c     |   14 ++++----
 drivers/infiniband/hw/hfi1/verbs.c  |    8 ++---
 include/rdma/ib_hdrs.h              |   60 +++++++++++++++++++++++++++++++++++
 9 files changed, 102 insertions(+), 47 deletions(-)
drivers/infiniband/hw/hfi1/driver.c +6 -7
index d731b5e..7e6d86b 100644
@@ -284,7 +284,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
 {
 	struct ib_header *rhdr = packet->hdr;
 	u32 rte = rhf_rcv_type_err(packet->rhf);
-	int lnh = be16_to_cpu(rhdr->lrh[0]) & 3;
+	int lnh = ib_get_lnh(rhdr);
 	struct hfi1_ibport *ibp = rcd_to_iport(rcd);
 	struct hfi1_devdata *dd = ppd->dd;
 	struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
@@ -296,7 +296,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
 		/* For TIDERR and RC QPs preemptively schedule a NAK */
 		struct ib_other_headers *ohdr = NULL;
 		u32 tlen = rhf_pkt_len(packet->rhf); /* in bytes */
-		u16 lid  = be16_to_cpu(rhdr->lrh[1]);
+		u16 lid  = ib_get_dlid(rhdr);
 		u32 qp_num;
 		u32 rcv_flags = 0;
 
@@ -415,7 +415,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
 				svc_type = IB_CC_SVCTYPE_UD;
 				break;
 			case IB_QPT_UC:
-				rlid = be16_to_cpu(rhdr->lrh[3]);
+				rlid = ib_get_slid(rhdr);
 				rqpn = qp->remote_qpn;
 				svc_type = IB_CC_SVCTYPE_UC;
 				break;
@@ -461,7 +461,7 @@ void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
 	struct ib_other_headers *ohdr = pkt->ohdr;
 	struct ib_grh *grh = NULL;
 	u32 rqpn = 0, bth1;
-	u16 rlid, dlid = be16_to_cpu(hdr->lrh[1]);
+	u16 rlid, dlid = ib_get_dlid(hdr);
 	u8 sc, svc_type;
 	bool is_mcast = false;
 
@@ -472,7 +472,7 @@ void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
 	case IB_QPT_SMI:
 	case IB_QPT_GSI:
 	case IB_QPT_UD:
-		rlid = be16_to_cpu(hdr->lrh[3]);
+		rlid = ib_get_slid(hdr);
 		rqpn = be32_to_cpu(ohdr->u.ud.deth[1]) & RVT_QPN_MASK;
 		svc_type = IB_CC_SVCTYPE_UD;
 		is_mcast = (dlid > be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
@@ -622,8 +622,7 @@ static void __prescan_rxq(struct hfi1_packet *packet)
 
 		packet->hdr = hfi1_get_msgheader(dd, rhf_addr);
 		hdr = packet->hdr;
-
-		lnh = be16_to_cpu(hdr->lrh[0]) & 3;
+		lnh = ib_get_lnh(hdr);
 
 		if (lnh == HFI1_LRH_BTH) {
 			packet->ohdr = &hdr->u.oth;
drivers/infiniband/hw/hfi1/hfi.h +1 -2
index 8509502..1d9436c 100644
@@ -1263,8 +1263,7 @@ static inline u32 driver_lstate(struct hfi1_pportdata *ppd)
 /* extract service channel from header and rhf */
 static inline int hfi1_9B_get_sc5(struct ib_header *hdr, u64 rhf)
 {
-	return ((be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf) |
-	       ((!!(rhf_dc_info(rhf))) << 4);
+	return ib_get_sc(hdr) | ((!!(rhf_dc_info(rhf))) << 4);
 }
 
 #define HFI1_JKEY_WIDTH       16
drivers/infiniband/hw/hfi1/rc.c +7 -7
index 0e56578..623209a 100644
@@ -994,12 +994,12 @@ void hfi1_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr)
 		return;
 
 	/* Find out where the BTH is */
-	if ((be16_to_cpu(hdr->lrh[0]) & 3) == HFI1_LRH_BTH)
+	if (ib_get_lnh(hdr) == HFI1_LRH_BTH)
 		ohdr = &hdr->u.oth;
 	else
 		ohdr = &hdr->u.l.oth;
 
-	opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
+	opcode = ib_bth_get_opcode(ohdr);
 	if (opcode >= OP(RDMA_READ_RESPONSE_FIRST) &&
 	    opcode <= OP(ATOMIC_ACKNOWLEDGE)) {
 		WARN_ON(!qp->s_rdma_ack_cnt);
@@ -1524,7 +1524,7 @@ static void rc_rcv_resp(struct hfi1_ibport *ibp,
 		if (!do_rc_ack(qp, aeth, psn, opcode, 0, rcd))
 			goto ack_done;
 		/* Get the number of bytes the message was padded by. */
-		pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
+		pad = ib_bth_get_pad(ohdr);
 		/*
 		 * Check that the data size is >= 0 && <= pmtu.
 		 * Remember to account for ICRC (4).
@@ -1548,7 +1548,7 @@ static void rc_rcv_resp(struct hfi1_ibport *ibp,
 		if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ))
 			goto ack_op_err;
 		/* Get the number of bytes the message was padded by. */
-		pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
+		pad = ib_bth_get_pad(ohdr);
 		/*
 		 * Check that the data size is >= 1 && <= pmtu.
 		 * Remember to account for ICRC (4).
@@ -1942,7 +1942,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
 	is_fecn = process_ecn(qp, packet, false);
 
 	psn = be32_to_cpu(ohdr->bth[2]);
-	opcode = (bth0 >> 24) & 0xff;
+	opcode = ib_bth_get_opcode(ohdr);
 
 	/*
 	 * Process responses (ACKs) before anything else.  Note that the
@@ -2073,7 +2073,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
 		wc.ex.imm_data = 0;
 send_last:
 		/* Get the number of bytes the message was padded by. */
-		pad = (bth0 >> 20) & 3;
+		pad = ib_bth_get_pad(ohdr);
 		/* Check for invalid length. */
 		/* LAST len should be >= 1 */
 		if (unlikely(tlen < (hdrsize + pad + 4)))
@@ -2386,7 +2386,7 @@ void hfi1_rc_hdrerr(
 		return;
 
 	psn = be32_to_cpu(ohdr->bth[2]);
-	opcode = (bth0 >> 24) & 0xff;
+	opcode = ib_bth_get_opcode(ohdr);
 
 	/* Only deal with RDMA Writes for now */
 	if (opcode < IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST) {
drivers/infiniband/hw/hfi1/ruc.c +12 -12
index eeb650d..2730915 100644
@@ -238,18 +238,18 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct ib_header *hdr,
 				qp->alt_ah_attr.grh.dgid.global.interface_id))
 				goto err;
 		}
-		if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0,
-					    sc5, be16_to_cpu(hdr->lrh[3])))) {
+		if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0, sc5,
+					    ib_get_slid(hdr)))) {
 			hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_P_KEY,
 				       (u16)bth0,
-				       (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF,
+				       ib_get_sl(hdr),
 				       0, qp->ibqp.qp_num,
-				       be16_to_cpu(hdr->lrh[3]),
-				       be16_to_cpu(hdr->lrh[1]));
+				       ib_get_slid(hdr),
+				       ib_get_dlid(hdr));
 			goto err;
 		}
 		/* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */
-		if (be16_to_cpu(hdr->lrh[3]) != qp->alt_ah_attr.dlid ||
+		if (ib_get_slid(hdr) != qp->alt_ah_attr.dlid ||
 		    ppd_from_ibp(ibp)->port != qp->alt_ah_attr.port_num)
 			goto err;
 		spin_lock_irqsave(&qp->s_lock, flags);
@@ -273,18 +273,18 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct ib_header *hdr,
 			     qp->remote_ah_attr.grh.dgid.global.interface_id))
 				goto err;
 		}
-		if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0,
-					    sc5, be16_to_cpu(hdr->lrh[3])))) {
+		if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0, sc5,
+					    ib_get_slid(hdr)))) {
 			hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_P_KEY,
 				       (u16)bth0,
-				       (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF,
+				       ib_get_sl(hdr),
 				       0, qp->ibqp.qp_num,
-				       be16_to_cpu(hdr->lrh[3]),
-				       be16_to_cpu(hdr->lrh[1]));
+				       ib_get_slid(hdr),
+				       ib_get_dlid(hdr));
 			goto err;
 		}
 		/* Validate the SLID. See Ch. 9.6.1.5 */
-		if (be16_to_cpu(hdr->lrh[3]) != qp->remote_ah_attr.dlid ||
+		if (ib_get_slid(hdr) != qp->remote_ah_attr.dlid ||
 		    ppd_from_ibp(ibp)->port != qp->port_num)
 			goto err;
 		if (qp->s_mig_state == IB_MIG_REARM &&
drivers/infiniband/hw/hfi1/trace.c +2 -3
index e86798a..eafae48 100644
@@ -51,13 +51,12 @@ u8 ibhdr_exhdr_len(struct ib_header *hdr)
 {
 	struct ib_other_headers *ohdr;
 	u8 opcode;
-	u8 lnh = (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
 
-	if (lnh == HFI1_LRH_BTH)
+	if (ib_get_lnh(hdr) == HFI1_LRH_BTH)
 		ohdr = &hdr->u.oth;
 	else
 		ohdr = &hdr->u.l.oth;
-	opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
+	opcode = ib_bth_get_opcode(ohdr);
 	return hdr_len_by_opcode[opcode] == 0 ?
 	       0 : hdr_len_by_opcode[opcode] - (12 + 8);
 }
drivers/infiniband/hw/hfi1/uc.c +4 -4
index 4b2a840..f0bdb10 100644
@@ -320,7 +320,7 @@ void hfi1_uc_rcv(struct hfi1_packet *packet)
 	process_ecn(qp, packet, true);
 
 	psn = be32_to_cpu(ohdr->bth[2]);
-	opcode = (bth0 >> 24) & 0xff;
+	opcode = ib_bth_get_opcode(ohdr);
 
 	/* Compare the PSN verses the expected PSN. */
 	if (unlikely(cmp_psn(psn, qp->r_psn) != 0)) {
@@ -433,7 +433,7 @@ void hfi1_uc_rcv(struct hfi1_packet *packet)
 		wc.wc_flags = 0;
 send_last:
 		/* Get the number of bytes the message was padded by. */
-		pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
+		pad = ib_bth_get_pad(ohdr);
 		/* Check for invalid length. */
 		/* LAST len should be >= 1 */
 		if (unlikely(tlen < (hdrsize + pad + 4)))
@@ -528,7 +528,7 @@ void hfi1_uc_rcv(struct hfi1_packet *packet)
 		wc.wc_flags = IB_WC_WITH_IMM;
 
 		/* Get the number of bytes the message was padded by. */
-		pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
+		pad = ib_bth_get_pad(ohdr);
 		/* Check for invalid length. */
 		/* LAST len should be >= 1 */
 		if (unlikely(tlen < (hdrsize + pad + 4)))
@@ -555,7 +555,7 @@ void hfi1_uc_rcv(struct hfi1_packet *packet)
 	case OP(RDMA_WRITE_LAST):
 rdma_last:
 		/* Get the number of bytes the message was padded by. */
-		pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
+		pad = ib_bth_get_pad(ohdr);
 		/* Check for invalid length. */
 		/* LAST len should be >= 1 */
 		if (unlikely(tlen < (hdrsize + pad + 4)))
drivers/infiniband/hw/hfi1/ud.c +6 -8
index fd105cf..8b3403a 100644
@@ -688,18 +688,16 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
 
 	qkey = be32_to_cpu(ohdr->u.ud.deth[0]);
 	src_qp = be32_to_cpu(ohdr->u.ud.deth[1]) & RVT_QPN_MASK;
-	dlid = be16_to_cpu(hdr->lrh[1]);
+	dlid = ib_get_dlid(hdr);
 	bth1 = be32_to_cpu(ohdr->bth[1]);
-	slid = be16_to_cpu(hdr->lrh[3]);
-	pkey = (u16)be32_to_cpu(ohdr->bth[0]);
-	sl = (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xf;
-	extra_bytes = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
+	slid = ib_get_slid(hdr);
+	pkey = ib_bth_get_pkey(ohdr);
+	opcode = ib_bth_get_opcode(ohdr);
+	sl = ib_get_sl(hdr);
+	extra_bytes = ib_bth_get_pad(ohdr);
 	extra_bytes += (SIZE_OF_CRC << 2);
 	sl_from_sc = ibp->sc_to_sl[sc5];
 
-	opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
-	opcode &= 0xff;
-
 	process_ecn(qp, packet, (opcode != IB_OPCODE_CNP));
 	/*
 	 * Get the number of bytes the message was padded by
drivers/infiniband/hw/hfi1/verbs.c +4 -4
index 66a2378..7f49719 100644
@@ -571,7 +571,7 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)
 	u16 lid;
 
 	/* Check for GRH */
-	lnh = be16_to_cpu(hdr->lrh[0]) & 3;
+	lnh = ib_get_lnh(hdr);
 	if (lnh == HFI1_LRH_BTH) {
 		packet->ohdr = &hdr->u.oth;
 	} else if (lnh == HFI1_LRH_GRH) {
@@ -590,12 +590,12 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)
 
 	trace_input_ibhdr(rcd->dd, hdr);
 
-	opcode = (be32_to_cpu(packet->ohdr->bth[0]) >> 24);
+	opcode = ib_bth_get_opcode(packet->ohdr);
 	inc_opstats(tlen, &rcd->opstats->stats[opcode]);
 
 	/* Get the destination QP number. */
 	qp_num = be32_to_cpu(packet->ohdr->bth[1]) & RVT_QPN_MASK;
-	lid = be16_to_cpu(hdr->lrh[1]);
+	lid = ib_get_dlid(hdr);
 	if (unlikely((lid >= be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
 		     (lid != be16_to_cpu(IB_LID_PERMISSIVE)))) {
 		struct rvt_mcast *mcast;
@@ -1230,7 +1230,7 @@ int hfi1_verbs_send(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
 
 	hdr = &ps->s_txreq->phdr.hdr;
 	/* locate the pkey within the headers */
-	lnh = be16_to_cpu(hdr->lrh[0]) & 3;
+	lnh = ib_get_lnh(hdr);
 	if (lnh == HFI1_LRH_GRH)
 		ohdr = &hdr->u.l.oth;
 	else
include/rdma/ib_hdrs.h +60 -0

64 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

PATCH 10/20 IB/hfi1: Use defines from common headers

In reply to a message not in the archive

From: Don Hiatt <[email protected]>

Move FECN and BECN related defines to common header files

---
 drivers/infiniband/hw/hfi1/common.h       |    6 ------
 drivers/infiniband/hw/hfi1/driver.c       |    8 ++++----
 drivers/infiniband/hw/hfi1/hfi.h          |    4 ++--
 drivers/infiniband/hw/hfi1/rc.c           |    2 +-
 drivers/infiniband/hw/hfi1/ruc.c          |    2 +-
 drivers/infiniband/hw/hfi1/trace_ibhdrs.h |    8 ++++----
 drivers/infiniband/hw/hfi1/ud.c           |    2 +-
 include/rdma/ib_hdrs.h                    |    6 ++++++
 8 files changed, 19 insertions(+), 19 deletions(-)
drivers/infiniband/hw/hfi1/common.h +0 -6
index 804150f..995d62c 100644
@@ -331,12 +331,6 @@ struct diag_pkt {
 #define FULL_MGMT_P_KEY      0xFFFF
 
 #define DEFAULT_P_KEY LIM_MGMT_P_KEY
-#define HFI1_FECN_SHIFT 31
-#define HFI1_FECN_MASK 1
-#define HFI1_FECN_SMASK BIT(HFI1_FECN_SHIFT)
-#define HFI1_BECN_SHIFT 30
-#define HFI1_BECN_MASK 1
-#define HFI1_BECN_SMASK BIT(HFI1_BECN_SHIFT)
 
 /**
  * 0xF8 - 4 bits of multicast range and 1 bit for collective range
drivers/infiniband/hw/hfi1/driver.c +4 -4
index 7e6d86b..fc5753c 100644
@@ -495,13 +495,13 @@ void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
 	sc = hfi1_9B_get_sc5(hdr, pkt->rhf);
 
 	bth1 = be32_to_cpu(ohdr->bth[1]);
-	if (do_cnp && (bth1 & HFI1_FECN_SMASK)) {
+	if (do_cnp && (bth1 & IB_FECN_SMASK)) {
 		u16 pkey = (u16)be32_to_cpu(ohdr->bth[0]);
 
 		return_cnp(ibp, qp, rqpn, pkey, dlid, rlid, sc, grh);
 	}
 
-	if (!is_mcast && (bth1 & HFI1_BECN_SMASK)) {
+	if (!is_mcast && (bth1 & IB_BECN_SMASK)) {
 		struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
 		u32 lqpn = bth1 & RVT_QPN_MASK;
 		u8 sl = ibp->sc_to_sl[sc];
@@ -634,7 +634,7 @@ static void __prescan_rxq(struct hfi1_packet *packet)
 		}
 
 		bth1 = be32_to_cpu(packet->ohdr->bth[1]);
-		is_ecn = !!(bth1 & (HFI1_FECN_SMASK | HFI1_BECN_SMASK));
+		is_ecn = !!(bth1 & (IB_FECN_SMASK | IB_BECN_SMASK));
 
 		if (!is_ecn)
 			goto next;
@@ -652,7 +652,7 @@ static void __prescan_rxq(struct hfi1_packet *packet)
 		rcu_read_unlock();
 
 		/* turn off BECN, FECN */
-		bth1 &= ~(HFI1_FECN_SMASK | HFI1_BECN_SMASK);
+		bth1 &= ~(IB_FECN_SMASK | IB_BECN_SMASK);
 		packet->ohdr->bth[1] = cpu_to_be32(bth1);
 next:
 		update_ps_mdata(&mdata, rcd);
drivers/infiniband/hw/hfi1/hfi.h +2 -2
index 1d9436c..79c4289 100644
@@ -1597,9 +1597,9 @@ static inline bool process_ecn(struct rvt_qp *qp, struct hfi1_packet *pkt,
 	u32 bth1;
 
 	bth1 = be32_to_cpu(ohdr->bth[1]);
-	if (unlikely(bth1 & (HFI1_BECN_SMASK | HFI1_FECN_SMASK))) {
+	if (unlikely(bth1 & (IB_BECN_SMASK | IB_FECN_SMASK))) {
 		hfi1_process_ecn_slowpath(qp, pkt, do_cnp);
-		return bth1 & HFI1_FECN_SMASK;
+		return bth1 & IB_FECN_SMASK;
 	}
 	return false;
 }
drivers/infiniband/hw/hfi1/rc.c +1 -1
index 623209a..da968b7 100644
@@ -773,7 +773,7 @@ void hfi1_send_rc_ack(struct hfi1_ctxtdata *rcd, struct rvt_qp *qp,
 	hdr.lrh[3] = cpu_to_be16(ppd->lid | qp->remote_ah_attr.src_path_bits);
 	ohdr->bth[0] = cpu_to_be32(bth0);
 	ohdr->bth[1] = cpu_to_be32(qp->remote_qpn);
-	ohdr->bth[1] |= cpu_to_be32((!!is_fecn) << HFI1_BECN_SHIFT);
+	ohdr->bth[1] |= cpu_to_be32((!!is_fecn) << IB_BECN_SHIFT);
 	ohdr->bth[2] = cpu_to_be32(mask_psn(qp->r_ack_psn));
 
 	/* Don't try to send ACKs if the link isn't ACTIVE */
drivers/infiniband/hw/hfi1/ruc.c +1 -1
index 2730915..879eb9b 100644
@@ -775,7 +775,7 @@ void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
 	if (qp->s_flags & RVT_S_ECN) {
 		qp->s_flags &= ~RVT_S_ECN;
 		/* we recently received a FECN, so return a BECN */
-		bth1 |= (HFI1_BECN_MASK << HFI1_BECN_SHIFT);
+		bth1 |= (IB_BECN_MASK << IB_BECN_SHIFT);
 	}
 	ohdr->bth[1] = cpu_to_be32(bth1);
 	ohdr->bth[2] = cpu_to_be32(bth2);
drivers/infiniband/hw/hfi1/trace_ibhdrs.h +4 -4
index 382fcda..090f6b5 100644
@@ -139,11 +139,11 @@
 			__entry->pkey =
 			be32_to_cpu(ohdr->bth[0]) & 0xffff;
 			__entry->f =
-			(be32_to_cpu(ohdr->bth[1]) >> HFI1_FECN_SHIFT) &
-			HFI1_FECN_MASK;
+			(be32_to_cpu(ohdr->bth[1]) >> IB_FECN_SHIFT) &
+			IB_FECN_MASK;
 			__entry->b =
-			(be32_to_cpu(ohdr->bth[1]) >> HFI1_BECN_SHIFT) &
-			HFI1_BECN_MASK;
+			(be32_to_cpu(ohdr->bth[1]) >> IB_BECN_SHIFT) &
+			IB_BECN_MASK;
 			__entry->qpn =
 			be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
 			__entry->a =
drivers/infiniband/hw/hfi1/ud.c +1 -1
index 8b3403a..45bc3f0 100644
@@ -537,7 +537,7 @@ void return_cnp(struct hfi1_ibport *ibp, struct rvt_qp *qp, u32 remote_qpn,
 	bth0 = pkey | (IB_OPCODE_CNP << 24);
 	ohdr->bth[0] = cpu_to_be32(bth0);
 
-	ohdr->bth[1] = cpu_to_be32(remote_qpn | (1 << HFI1_BECN_SHIFT));
+	ohdr->bth[1] = cpu_to_be32(remote_qpn | (1 << IB_BECN_SHIFT));
 	ohdr->bth[2] = 0; /* PSN 0 */
 
 	hdr.lrh[0] = cpu_to_be16(lrh0);
include/rdma/ib_hdrs.h +6 -0
index 9cf42bc..5519f31 100644
@@ -74,6 +74,12 @@
 #define IB_GRH_FLOW_MASK	0xFFFFF
 #define IB_GRH_FLOW_SHIFT	0
 #define IB_GRH_NEXT_HDR		0x1B
+#define IB_FECN_SHIFT 31
+#define IB_FECN_MASK 1
+#define IB_FECN_SMASK BIT(IB_FECN_SHIFT)
+#define IB_BECN_SHIFT 30
+#define IB_BECN_MASK 1
+#define IB_BECN_SMASK BIT(IB_BECN_SHIFT)
 
 #define IB_AETH_CREDIT_SHIFT	24
 #define IB_AETH_CREDIT_MASK	0x1F

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#21 lore raw

PATCH 11/20 IB/hfi1: Prevent kernel QP post send hard lockups

In reply to a message not in the archive

From: Mike Marciniszyn <[email protected]>

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 <[email protected]> # 4.7.x-
Fixes Commit 831464ce4b74 ("IB/hfi1: Don't call cond_resched in atomic mode when sending packets")
---
 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(-)
drivers/infiniband/hw/hfi1/ruc.c +16 -10
index 879eb9b..ccf8d80 100644
@@ -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);
drivers/infiniband/hw/hfi1/verbs.c +2 -2
index 7f49719..e112762 100644
@@ -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;
drivers/infiniband/hw/hfi1/verbs.h +4 -2
index 6c549e7..46b00ed 100644
@@ -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);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#22 lore raw

PATCH 12/20 IB/hfi1: Fix softlockup issue

In reply to a message not in the archive

From: Tadeusz Struk <[email protected]>

Soft lockups can occur because the mad processing on different CPUs acquire the spin lock dc8051_lock:

[534552.835870]  [<ffffffffa026f993>] ? read_dev_port_cntr.isra.37+0x23/0x160 [hfi1]
[534552.835880]  [<ffffffffa02775af>] read_dev_cntr+0x4f/0x60 [hfi1]
[534552.835893]  [<ffffffffa028d7cd>] pma_get_opa_portstatus+0x64d/0x8c0 [hfi1]
[534552.835904]  [<ffffffffa0290e7d>] hfi1_process_mad+0x48d/0x18c0 [hfi1]
[534552.835908]  [<ffffffff811dc1f1>] ? __slab_free+0x81/0x2f0
[534552.835936]  [<ffffffffa024c34e>] ? ib_mad_recv_done+0x21e/0xa30 [ib_core]
[534552.835939]  [<ffffffff811dd153>] ? __kmalloc+0x1f3/0x240
[534552.835947]  [<ffffffffa024c3fb>] ib_mad_recv_done+0x2cb/0xa30 [ib_core]
[534552.835955]  [<ffffffffa0237c85>] __ib_process_cq+0x55/0xd0 [ib_core]
[534552.835962]  [<ffffffffa0237d70>] ib_cq_poll_work+0x20/0x60 [ib_core]
[534552.835964]  [<ffffffff810a7f3b>] process_one_work+0x17b/0x470
[534552.835966]  [<ffffffff810a8d76>] worker_thread+0x126/0x410
[534552.835969]  [<ffffffff810a8c50>] ? rescuer_thread+0x460/0x460
[534552.835971]  [<ffffffff810b052f>] kthread+0xcf/0xe0
[534552.835974]  [<ffffffff810b0460>] ? kthread_create_on_node+0x140/0x140
[534552.835977]  [<ffffffff81696418>] ret_from_fork+0x58/0x90
[534552.835980]  [<ffffffff810b0460>] ? kthread_create_on_node+0x140/0x140

This issue is made worse when the 8051 is busy and the reads take longer. Fix by using a non-spinning lock procure.

---
 drivers/infiniband/hw/hfi1/chip.c |   63 +++++++++++++++++++------------------
 drivers/infiniband/hw/hfi1/hfi.h  |    3 +-
 drivers/infiniband/hw/hfi1/init.c |    2 +
 3 files changed, 34 insertions(+), 34 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +32 -31
index 79a316a..c904c29 100644
@@ -6381,18 +6381,17 @@ static void lcb_shutdown(struct hfi1_devdata *dd, int abort)
  *
  * The expectation is that the caller of this routine would have taken
  * care of properly transitioning the link into the correct state.
+ * NOTE: the caller needs to acquire the dd->dc8051_lock lock
+ *       before calling this function.
  */
-static void dc_shutdown(struct hfi1_devdata *dd)
+static void _dc_shutdown(struct hfi1_devdata *dd)
 {
-	unsigned long flags;
+	lockdep_assert_held(&dd->dc8051_lock);
 
-	spin_lock_irqsave(&dd->dc8051_lock, flags);
-	if (dd->dc_shutdown) {
-		spin_unlock_irqrestore(&dd->dc8051_lock, flags);
+	if (dd->dc_shutdown)
 		return;
-	}
+
 	dd->dc_shutdown = 1;
-	spin_unlock_irqrestore(&dd->dc8051_lock, flags);
 	/* Shutdown the LCB */
 	lcb_shutdown(dd, 1);
 	/*
@@ -6403,35 +6402,45 @@ static void dc_shutdown(struct hfi1_devdata *dd)
 	write_csr(dd, DC_DC8051_CFG_RST, 0x1);
 }
 
+static void dc_shutdown(struct hfi1_devdata *dd)
+{
+	mutex_lock(&dd->dc8051_lock);
+	_dc_shutdown(dd);
+	mutex_unlock(&dd->dc8051_lock);
+}
+
 /*
  * Calling this after the DC has been brought out of reset should not
  * do any damage.
+ * NOTE: the caller needs to acquire the dd->dc8051_lock lock
+ *       before calling this function.
  */
-static void dc_start(struct hfi1_devdata *dd)
+static void _dc_start(struct hfi1_devdata *dd)
 {
-	unsigned long flags;
-	int ret;
+	lockdep_assert_held(&dd->dc8051_lock);
 
-	spin_lock_irqsave(&dd->dc8051_lock, flags);
 	if (!dd->dc_shutdown)
-		goto done;
-	spin_unlock_irqrestore(&dd->dc8051_lock, flags);
+		return;
+
 	/* Take the 8051 out of reset */
 	write_csr(dd, DC_DC8051_CFG_RST, 0ull);
 	/* Wait until 8051 is ready */
-	ret = wait_fm_ready(dd, TIMEOUT_8051_START);
-	if (ret) {
+	if (wait_fm_ready(dd, TIMEOUT_8051_START))
 		dd_dev_err(dd, "%s: timeout starting 8051 firmware\n",
 			   __func__);
-	}
+
 	/* Take away reset for LCB and RX FPE (set in lcb_shutdown). */
 	write_csr(dd, DCC_CFG_RESET, 0x10);
 	/* lcb_shutdown() with abort=1 does not restore these */
 	write_csr(dd, DC_LCB_ERR_EN, dd->lcb_err_en);
-	spin_lock_irqsave(&dd->dc8051_lock, flags);
 	dd->dc_shutdown = 0;
-done:
-	spin_unlock_irqrestore(&dd->dc8051_lock, flags);
+}
+
+static void dc_start(struct hfi1_devdata *dd)
+{
+	mutex_lock(&dd->dc8051_lock);
+	_dc_start(dd);
+	mutex_unlock(&dd->dc8051_lock);
 }
 
 /*
@@ -8475,16 +8484,11 @@ static int do_8051_command(
 {
 	u64 reg, completed;
 	int return_code;
-	unsigned long flags;
 	unsigned long timeout;
 
 	hfi1_cdbg(DC8051, "type %d, data 0x%012llx", type, in_data);
 
-	/*
-	 * Alternative to holding the lock for a long time:
-	 * - keep busy wait - have other users bounce off
-	 */
-	spin_lock_irqsave(&dd->dc8051_lock, flags);
+	mutex_lock(&dd->dc8051_lock);
 
 	/* We can't send any commands to the 8051 if it's in reset */
 	if (dd->dc_shutdown) {
@@ -8510,10 +8514,8 @@ static int do_8051_command(
 			return_code = -ENXIO;
 			goto fail;
 		}
-		spin_unlock_irqrestore(&dd->dc8051_lock, flags);
-		dc_shutdown(dd);
-		dc_start(dd);
-		spin_lock_irqsave(&dd->dc8051_lock, flags);
+		_dc_shutdown(dd);
+		_dc_start(dd);
 	}
 
 	/*
@@ -8594,8 +8596,7 @@ static int do_8051_command(
 	write_csr(dd, DC_DC8051_CFG_HOST_CMD_0, 0);
 
 fail:
-	spin_unlock_irqrestore(&dd->dc8051_lock, flags);
-
+	mutex_unlock(&dd->dc8051_lock);
 	return return_code;
 }
 
drivers/infiniband/hw/hfi1/hfi.h +1 -2
index 79c4289..f44513c 100644
@@ -926,8 +926,7 @@ struct hfi1_devdata {
 	spinlock_t rcvctrl_lock; /* protect changes to RcvCtrl */
 	/* around rcd and (user ctxts) ctxt_cnt use (intr vs free) */
 	spinlock_t uctxt_lock; /* rcd and user context changes */
-	/* exclusive access to 8051 */
-	spinlock_t dc8051_lock;
+	struct mutex dc8051_lock; /* exclusive access to 8051 */
 	/* exclusive access to 8051 memory */
 	spinlock_t dc8051_memlock;
 	int dc8051_timed_out;	/* remember if the 8051 timed out */
drivers/infiniband/hw/hfi1/init.c +1 -1
index 9bfb8eb..55a11a6 100644
@@ -1078,11 +1078,11 @@ struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra)
 	spin_lock_init(&dd->uctxt_lock);
 	spin_lock_init(&dd->hfi1_diag_trans_lock);
 	spin_lock_init(&dd->sc_init_lock);
-	spin_lock_init(&dd->dc8051_lock);
 	spin_lock_init(&dd->dc8051_memlock);
 	seqlock_init(&dd->sc2vl_lock);
 	spin_lock_init(&dd->sde_map_lock);
 	spin_lock_init(&dd->pio_map_lock);
+	mutex_init(&dd->dc8051_lock);
 	init_waitqueue_head(&dd->event_queue);
 
 	dd->int_counter = alloc_percpu(u64);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#23 lore raw

PATCH 13/20 IB/hfi1: Adjust high temperature warning for QSFP cable

In reply to a message not in the archive

From: Neel Desai <[email protected]>

When we receive a QSFP_HIGH_TEMP_ALARM or QSFP_HIGH_TEMP_WARNING interrupt, print a "QSFP cable temperature too high" message.

---
 drivers/infiniband/hw/hfi1/chip.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +1 -1
index c904c29..b5cbffa 100644
@@ -9325,7 +9325,7 @@ static int handle_qsfp_error_conditions(struct hfi1_pportdata *ppd,
 
 	if ((qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_ALARM) ||
 	    (qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_WARNING))
-		dd_dev_info(dd, "%s: QSFP cable on fire\n",
+		dd_dev_info(dd, "%s: QSFP cable temperature too high\n",
 			    __func__);
 
 	if ((qsfp_interrupt_status[0] & QSFP_LOW_TEMP_ALARM) ||

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170409171646.10579.73509.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org

#25 lore raw

Re: [PATCH 13/20] IB/hfi1: Adjust high temperature warning for QSFP cable

Quoted 11 lines · Dennis Dalessandro
drivers/infiniband/hw/hfi1/chip.c +0 -0
@@ -9325,7 +9325,7 @@ static int handle_qsfp_error_conditions(struct
 hfi1_pportdata *ppd,


        if ((qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_ALARM) || (qsfp_interrupt_status[0] & QSFP_HIGH_TEMP_WARNING)) -               dd_dev_info(dd, "%s: QSFP cable on fire\n", +               dd_dev_info(dd, "%s: QSFP cable temperature too high\n",
                            __func__);

Aww, man, being professional takes the fun out of everything :-/

Signature · 9 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#26 lore raw

PATCH 14/20 IB/hfi1: Cache neighbor secure data after link up

In reply to a message not in the archive

From: Stuart Summers <[email protected]>

Secure data is transferred across the link during verify cap. This includes Neighbor Guid, Type, and Port Number. This transfer is not guaranteed to complete until the 8051 firmware has completed processing of the state_complete frame. Move the consumption of this data from verify cap handling to link up handling to ensure the data is finalized.

Additionally, do not notify the SM that the link is up until after this data is actually available.

---
 drivers/infiniband/hw/hfi1/chip.c |   27 +--------------------------
 drivers/infiniband/hw/hfi1/hfi.h  |   11 ++++++++++-
 drivers/infiniband/hw/hfi1/intr.c |   27 ++++++++++++++++-----------
 3 files changed, 27 insertions(+), 38 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +1 -26
index b5cbffa..b840656 100644
@@ -7288,15 +7288,6 @@ void handle_verify_cap(struct work_struct *work)
 	lcb_shutdown(dd, 0);
 	adjust_lcb_for_fpga_serdes(dd);
 
-	/*
-	 * These are now valid:
-	 *	remote VerifyCap fields in the general LNI config
-	 *	CSR DC8051_STS_REMOTE_GUID
-	 *	CSR DC8051_STS_REMOTE_NODE_TYPE
-	 *	CSR DC8051_STS_REMOTE_FM_SECURITY
-	 *	CSR DC8051_STS_REMOTE_PORT_NO
-	 */
-
 	read_vc_remote_phy(dd, &power_management, &continious);
 	read_vc_remote_fabric(dd, &vau, &z, &vcu, &vl15buf,
 			      &partner_supported_crc);
@@ -7427,20 +7418,6 @@ void handle_verify_cap(struct work_struct *work)
 	write_csr(dd, DC_LCB_ERR_EN, 0); /* mask LCB errors */
 	set_8051_lcb_access(dd);
 
-	ppd->neighbor_guid =
-		read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
-	ppd->neighbor_port_number = read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
-					DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
-	ppd->neighbor_type =
-		read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
-		DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
-	ppd->neighbor_fm_security =
-		read_csr(dd, DC_DC8051_STS_REMOTE_FM_SECURITY) &
-		DC_DC8051_STS_LOCAL_FM_SECURITY_DISABLED_MASK;
-	dd_dev_info(dd,
-		    "Neighbor Guid: %llx Neighbor type %d MgmtAllowed %d FM security bypass %d\n",
-		    ppd->neighbor_guid, ppd->neighbor_type,
-		    ppd->mgmt_allowed, ppd->neighbor_fm_security);
 	if (ppd->mgmt_allowed)
 		add_full_mgmt_pkey(ppd);
 
@@ -10497,11 +10474,8 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)
 			goto unexpected;
 		}
 
-		ppd->host_link_state = HLS_UP_INIT;
 		ret = wait_logical_linkstate(ppd, IB_PORT_INIT, 1000);
 		if (ret) {
-			/* logical state didn't change, stay at going_up */
-			ppd->host_link_state = HLS_GOING_UP;
 			dd_dev_err(dd,
 				   "%s: logical state did not change to INIT\n",
 				   __func__);
@@ -10515,6 +10489,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)
 			add_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
 
 			handle_linkup_change(dd, 1);
+			ppd->host_link_state = HLS_UP_INIT;
 		}
 		break;
 	case HLS_UP_ARMED:
drivers/infiniband/hw/hfi1/hfi.h +10 -1
index f44513c..9aec0a2 100644
@@ -1254,7 +1254,16 @@ void hfi1_init_pportdata(struct pci_dev *, struct hfi1_pportdata *,
 /* return the driver's idea of the logical OPA port state */
 static inline u32 driver_lstate(struct hfi1_pportdata *ppd)
 {
-	return ppd->lstate; /* use the cached value */
+	/*
+	 * The driver does some processing from the time the logical
+	 * link state is at INIT to the time the SM can be notified
+	 * as such. Return IB_PORT_DOWN until the software state
+	 * is ready.
+	 */
+	if (ppd->lstate == IB_PORT_INIT && !(ppd->host_link_state & HLS_UP))
+		return IB_PORT_DOWN;
+	else
+		return ppd->lstate;
 }
 
 void receive_interrupt_work(struct work_struct *work);
drivers/infiniband/hw/hfi1/intr.c +16 -11
index 65348d1..232014d 100644
@@ -131,19 +131,24 @@ void handle_linkup_change(struct hfi1_devdata *dd, u32 linkup)
 		if (quick_linkup || dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
 			set_up_vl15(dd, dd->vau, dd->vl15_init);
 			assign_remote_cm_au_table(dd, dd->vcu);
-			ppd->neighbor_guid =
-				read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
-			ppd->neighbor_type =
-				read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
-					DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
-			ppd->neighbor_port_number =
-				read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
-					 DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
-			dd_dev_info(dd, "Neighbor GUID: %llx Neighbor type %d\n",
-				    ppd->neighbor_guid,
-				    ppd->neighbor_type);
 		}
 
+		ppd->neighbor_guid =
+			read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
+		ppd->neighbor_type =
+			read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
+				 DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
+		ppd->neighbor_port_number =
+			read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
+				 DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
+		ppd->neighbor_fm_security =
+			read_csr(dd, DC_DC8051_STS_REMOTE_FM_SECURITY) &
+				 DC_DC8051_STS_LOCAL_FM_SECURITY_DISABLED_MASK;
+		dd_dev_info(dd,
+			    "Neighbor Guid %llx, Type %d, Port Num %d\n",
+			    ppd->neighbor_guid, ppd->neighbor_type,
+			    ppd->neighbor_port_number);
+
 		/* physical link went up */
 		ppd->linkup = 1;
 		ppd->offline_disabled_reason =

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#27 lore raw

PATCH 15/20 IB/hfi1: Permanently enable P_Key checking in HFI

In reply to a message not in the archive

From: Neel Desai <[email protected]>

Ingress and egress port P_Key checking should always be performed for HFIs. This patch will enable ingress and egress P_Key checking when the port is initialized and will ignore the P_Key information sent by the FM in the port info structure which is meant to be used only by the switch.

---
 drivers/infiniband/hw/hfi1/init.c |    3 +++
 drivers/infiniband/hw/hfi1/mad.c  |   10 ----------
 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/infiniband/hw/hfi1/init.c +3 -0
index 55a11a6..838d3a8 100644
@@ -482,6 +482,9 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
 	default_pkey_idx = 1;
 
 	ppd->pkeys[default_pkey_idx] = DEFAULT_P_KEY;
+	ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
+	ppd->part_enforce |= HFI1_PART_ENFORCE_OUT;
+
 	if (loopback) {
 		hfi1_early_err(&pdev->dev,
 			       "Faking data partition 0x8001 in idx %u\n",
drivers/infiniband/hw/hfi1/mad.c +0 -10
index db5494d..7059a0f 100644
@@ -1151,16 +1151,6 @@ static int __subn_set_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data,
 		ppd->linkinit_reason =
 			(pi->partenforce_filterraw &
 			 OPA_PI_MASK_LINKINIT_REASON);
-	/* enable/disable SW pkey checking as per FM control */
-	if (pi->partenforce_filterraw & OPA_PI_MASK_PARTITION_ENFORCE_IN)
-		ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
-	else
-		ppd->part_enforce &= ~HFI1_PART_ENFORCE_IN;
-
-	if (pi->partenforce_filterraw & OPA_PI_MASK_PARTITION_ENFORCE_OUT)
-		ppd->part_enforce |= HFI1_PART_ENFORCE_OUT;
-	else
-		ppd->part_enforce &= ~HFI1_PART_ENFORCE_OUT;
 
 	/* Must be a valid unicast LID address. */
 	if ((smlid == 0 && ls_old > IB_PORT_INIT) ||

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170409171658.10579.67996.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org

#29 lore raw

Re: [PATCH 15/20] IB/hfi1: Permanently enable P_Key checking in HFI

Quoted 22 lines · Dennis Dalessandro

From: Neel Desai <[email protected]>

Ingress and egress port P_Key checking should always be performed for HFIs. This patch will enable ingress and egress P_Key checking when the port is initialized and will ignore the P_Key information sent by the FM in the port info structure which is meant to be used only by the switch.

---
 drivers/infiniband/hw/hfi1/init.c |    3 +++
 drivers/infiniband/hw/hfi1/mad.c  |   10 ----------
 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/infiniband/hw/hfi1/init.c +0 -0
index 55a11a6..838d3a8 100644

drivers/infiniband/hw/hfi1/init.c void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd, · line 487

Quoted 6 lines
drivers/infiniband/hw/hfi1/init.c +3 -0
@@ -482,6 +482,9 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
 	default_pkey_idx = 1;
 
 	ppd->pkeys[default_pkey_idx] = DEFAULT_P_KEY;
+	ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
+	ppd->part_enforce |= HFI1_PART_ENFORCE_OUT;
+

Isn't better just remove these enforcement checks if it always should be performed?

➜ linux-rdma git:(rdma-next) git grep part_enforce drivers/infiniband/

drivers/infiniband/hw/hfi1/hfi.h:       u8 part_enforce; /* partition enforcement flags */
drivers/infiniband/hw/hfi1/hfi.h:       if (!(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
drivers/infiniband/hw/hfi1/hfi.h:       if (!(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
drivers/infiniband/hw/hfi1/mad.c:       if (ppd->part_enforce & HFI1_PART_ENFORCE_IN)
drivers/infiniband/hw/hfi1/mad.c:       if (ppd->part_enforce & HFI1_PART_ENFORCE_OUT)
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce &= ~HFI1_PART_ENFORCE_IN;
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce |= HFI1_PART_ENFORCE_OUT;
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce &= ~HFI1_PART_ENFORCE_OUT;

drivers/infiniband/hw/hfi1/verbs.c: if (!(ppd->part_enforce & HFI1_PART_ENFORCE_OUT))

Thanks

Quoted 29 lines
drivers/infiniband/hw/hfi1/init.c +0 -0
 	if (loopback) {
 		hfi1_early_err(&pdev->dev,
 			       "Faking data partition 0x8001 in idx %u\n",
drivers/infiniband/hw/hfi1/mad.c +0 -11
index db5494d..7059a0f 100644
@@ -1151,16 +1151,6 @@ static int __subn_set_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data,
 		ppd->linkinit_reason =
 			(pi->partenforce_filterraw &
 			 OPA_PI_MASK_LINKINIT_REASON);
-	/* enable/disable SW pkey checking as per FM control */
-	if (pi->partenforce_filterraw & OPA_PI_MASK_PARTITION_ENFORCE_IN)
-		ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
-	else
-		ppd->part_enforce &= ~HFI1_PART_ENFORCE_IN;
-
-	if (pi->partenforce_filterraw & OPA_PI_MASK_PARTITION_ENFORCE_OUT)
-		ppd->part_enforce |= HFI1_PART_ENFORCE_OUT;
-	else
-		ppd->part_enforce &= ~HFI1_PART_ENFORCE_OUT;
 
 	/* Must be a valid unicast LID address. */
 	if ((smlid == 0 && ls_old > IB_PORT_INIT) ||
 
--

To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170415145317.GM1343-U/[email protected]

#31 lore raw

Re: [PATCH 15/20] IB/hfi1: Permanently enable P_Key checking in HFI

Quoted 17 lines · Leon Romanovsky

drivers/infiniband/hw/hfi1/init.c void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd, · line 487

Quoted 4 lines
  	ppd->pkeys[default_pkey_idx] = DEFAULT_P_KEY;
drivers/infiniband/hw/hfi1/init.c +3 -0
+	ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
+	ppd->part_enforce |= HFI1_PART_ENFORCE_OUT;
+

Isn't better just remove these enforcement checks if it always should be performed?

➜ linux-rdma git:(rdma-next) git grep part_enforce drivers/infiniband/

drivers/infiniband/hw/hfi1/hfi.h:       u8 part_enforce; /* partition enforcement flags */
drivers/infiniband/hw/hfi1/hfi.h:       if (!(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
drivers/infiniband/hw/hfi1/hfi.h:       if (!(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
drivers/infiniband/hw/hfi1/mad.c:       if (ppd->part_enforce & HFI1_PART_ENFORCE_IN)
drivers/infiniband/hw/hfi1/mad.c:       if (ppd->part_enforce & HFI1_PART_ENFORCE_OUT)
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce |= HFI1_PART_ENFORCE_IN;
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce &= ~HFI1_PART_ENFORCE_IN;
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce |= HFI1_PART_ENFORCE_OUT;
drivers/infiniband/hw/hfi1/mad.c:               ppd->part_enforce &= ~HFI1_PART_ENFORCE_OUT;
Quoted 1 line

drivers/infiniband/hw/hfi1/verbs.c: if (!(ppd->part_enforce & HFI1_PART_ENFORCE_OUT))

I agree with you, but I have asked Neel to do a bit of due diligence and make sure this is indeed what we actually want to do. Thanks for pointing this out.

-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#32 lore raw

PATCH 16/20 IB/hfi1: Fix misspelling in comment

In reply to a message not in the archive

Checkpatch flagged a misspelled word. Fix it.

Fixes 8764522e5251 ("staging/rdma/hfi1: Unexpected link up pkey values are not an error")
---
 drivers/infiniband/hw/hfi1/chip.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +1 -1
index b840656..c0cfcd1 100644
@@ -7088,7 +7088,7 @@ static void add_full_mgmt_pkey(struct hfi1_pportdata *ppd)
 {
 	struct hfi1_devdata *dd = ppd->dd;
 
-	/* Sanity check - ppd->pkeys[2] should be 0, or already initalized */
+	/* Sanity check - ppd->pkeys[2] should be 0, or already initialized */
 	if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
 		dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it to 0x%x\n",
 			    __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#33 lore raw

PATCH 17/20 IB/hfi1: Convert %Lx to %llx

In reply to a message not in the archive

According to checkpatch %Lx is not standard C so remove it and use the suggested %llx.

Fixes 7724105686e7 ("IB/hfi1: add driver files")
---
 drivers/infiniband/hw/hfi1/pcie.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/hfi1/pcie.c +1 -1
index 0829fce..e39e01b 100644
@@ -583,7 +583,7 @@ static void tune_pcie_caps(struct hfi1_devdata *dd)
 		if (words == ~0ULL)
 			ret = PCI_ERS_RESULT_NEED_RESET;
 		dd_dev_info(dd,
-			    "HFI1 mmio_enabled function called, read wordscntr %Lx, returning %d\n",
+			    "HFI1 mmio_enabled function called, read wordscntr %llx, returning %d\n",
 			    words, ret);
 	}
 	return  ret;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#34 lore raw

PATCH 18/20 IB/hfi1: Fix unbalanced braces around else

In reply to a message not in the archive

Add missing braces around else blocks in a few places to make checkpatch happy.

Fixes 7724105686e7 ("IB/hfi1: add driver files")
---
 drivers/infiniband/hw/hfi1/chip.c |    4 ++--
 drivers/infiniband/hw/hfi1/init.c |    6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +2 -2
index c0cfcd1..19fab90 100644
@@ -8147,10 +8147,10 @@ static irqreturn_t sdma_interrupt(int irq, void *data)
 
 		/* handle the interrupt(s) */
 		sdma_engine_interrupt(sde, status);
-	} else
+	} else {
 		dd_dev_err(dd, "SDMA engine %u interrupt, but no status bits set\n",
 			   sde->this_idx);
-
+	}
 	return IRQ_HANDLED;
 }
 
drivers/infiniband/hw/hfi1/init.c +4 -2
index 838d3a8..e9b33c8 100644
@@ -245,9 +245,10 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt,
 			if (ctxt < kctxt_ngroups) {
 				base = ctxt * (dd->rcv_entries.ngroups + 1);
 				rcd->rcv_array_groups++;
-			} else
+			} else {
 				base = kctxt_ngroups +
 					(ctxt * dd->rcv_entries.ngroups);
+			}
 		} else {
 			u16 ct = ctxt - dd->first_user_ctxt;
 
@@ -256,9 +257,10 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt,
 			if (ct < dd->rcv_entries.nctxt_extra) {
 				base += ct * (dd->rcv_entries.ngroups + 1);
 				rcd->rcv_array_groups++;
-			} else
+			} else {
 				base += dd->rcv_entries.nctxt_extra +
 					(ct * dd->rcv_entries.ngroups);
+			}
 		}
 		rcd->eager_base = base * dd->rcv_entries.group_size;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170409171717.10579.36147.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org

#36 lore raw

Re: [PATCH 18/20] IB/hfi1: Fix unbalanced braces around else

Quoted 15 lines · Dennis Dalessandro

Add missing braces around else blocks in a few places to make checkpatch happy.

Fixes 7724105686e7 ("IB/hfi1: add driver files")
---
 drivers/infiniband/hw/hfi1/chip.c |    4 ++--
 drivers/infiniband/hw/hfi1/init.c |    6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +0 -0
index c0cfcd1..19fab90 100644

drivers/infiniband/hw/hfi1/chip.c static irqreturn_t sdma_interrupt(int irq, void *data) · line 8152

Quoted 7 lines
drivers/infiniband/hw/hfi1/chip.c +1 -1
@@ -8147,10 +8147,10 @@ static irqreturn_t sdma_interrupt(int irq, void *data)
 
 		/* handle the interrupt(s) */
 		sdma_engine_interrupt(sde, status);
-	} else
+	} else {
 		dd_dev_err(dd, "SDMA engine %u interrupt, but no status bits set\n",
 			   sde->this_idx);

Not relevant to this patch, but interesting to hear. Does such error print produce dmesg storm in case of error or this is one time failure?

Thanks

Quoted 38 lines
drivers/infiniband/hw/hfi1/chip.c +1 -1
-
+	}
 	return IRQ_HANDLED;
 }
 
drivers/infiniband/hw/hfi1/init.c +4 -3
index 838d3a8..e9b33c8 100644
@@ -245,9 +245,10 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt,
 			if (ctxt < kctxt_ngroups) {
 				base = ctxt * (dd->rcv_entries.ngroups + 1);
 				rcd->rcv_array_groups++;
-			} else
+			} else {
 				base = kctxt_ngroups +
 					(ctxt * dd->rcv_entries.ngroups);
+			}
 		} else {
 			u16 ct = ctxt - dd->first_user_ctxt;
 
@@ -256,9 +257,10 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt,
 			if (ct < dd->rcv_entries.nctxt_extra) {
 				base += ct * (dd->rcv_entries.ngroups + 1);
 				rcd->rcv_array_groups++;
-			} else
+			} else {
 				base += dd->rcv_entries.nctxt_extra +
 					(ct * dd->rcv_entries.ngroups);
+			}
 		}
 		rcd->eager_base = base * dd->rcv_entries.group_size;
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170413060343.GC1343-U/[email protected]

#38 lore raw

Re: [PATCH 18/20] IB/hfi1: Fix unbalanced braces around else

Quoted 6 lines · Leon Romanovsky
Quoted 6 lines
drivers/infiniband/hw/hfi1/chip.c +0 -0
index c0cfcd1..19fab90 100644
@@ -8147,10 +8147,10 @@ static irqreturn_t sdma_interrupt(int irq, void *data)
 
Quoted 9 lines

drivers/infiniband/hw/hfi1/chip.c static irqreturn_t sdma_interrupt(int irq, void *data) · line 8152

Quoted 6 lines
drivers/infiniband/hw/hfi1/chip.c +1 -1
 		/* handle the interrupt(s) */
 		sdma_engine_interrupt(sde, status);
-	} else
+	} else {
 		dd_dev_err(dd, "SDMA engine %u interrupt, but no status bits set\n",
 			   sde->this_idx);

Not relevant to this patch, but interesting to hear. Does such error print produce dmesg storm in case of error or this is one time failure?

I think it could possibly. We should probably look into making this rate limited. Thanks for noticing.

-Denny

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#39 lore raw

PATCH 19/20 IB/hfi: Protect against writable mmap

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

The device/port status is not intended to be changed from user space. Prevent a user from mapping them as write or execute.

---
 drivers/infiniband/hw/hfi1/file_ops.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/infiniband/hw/hfi1/file_ops.c +4 -0
index f78c739..d575499 100644
@@ -597,6 +597,10 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma)
 		vmf = 1;
 		break;
 	case STATUS:
+		if (flags & (unsigned long)(VM_WRITE | VM_EXEC)) {
+			ret = -EPERM;
+			goto done;
+		}
 		memaddr = kvirt_to_phys((void *)dd->status);
 		memlen = PAGE_SIZE;
 		flags |= VM_IO | VM_DONTEXPAND;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#40 lore raw

PATCH 20/20 IB/hfi1: Use bool in process_ecn

In reply to Dennis Dalessandro

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.

Fixes Commit fd2b562edca6 ("IB/hfi1: Pull FECN/BECN processing to a common place")
---
 drivers/infiniband/hw/hfi1/hfi.h |    2 +-
 drivers/infiniband/hw/hfi1/rc.c  |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/hfi.h +1 -1
index 9aec0a2..d83bdb4 100644
@@ -1607,7 +1607,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;
 }
drivers/infiniband/hw/hfi1/rc.c +2 -1
index da968b7..9b3333f 100644
@@ -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;
 
#41 lore raw
In reply to Dennis Dalessandro
Quoted 8 lines · Dennis Dalessandro

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.

Quoted 4 lines

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

Series, minus patch #2 because of community NAK, applied.

Signature · 4 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

A message that is not in the archive (sent off-list or not yet received): 1493401510.3041.164.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#43 lore raw
Quoted 9 lines · Doug Ledford
Quoted 8 lines · Dennis Dalessandro

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.

Quoted 7 lines
Quoted 4 lines

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

Series, minus patch #2 because of community NAK, applied.

Looks like we are working at the same time. A v2 was literally sent 5 minutes ago. The only changes were to drop that NAKed patch and fix up the soft-lockup patch so if you just want to grab:

https://patchwork.kernel.org/patch/9705175/

to replace the original:

https://patchwork.kernel.org/patch/9671675/

That would be good or I could send a separate patch with the fix-ups. Whichever is easiest.

-Denny

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#44 lore raw
Quoted 33 lines · Dennis Dalessandro
Quoted 13 lines · Doug Ledford
Quoted 11 lines · Dennis Dalessandro

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.

Quoted 8 lines
Quoted 5 lines

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

Series, minus patch #2 because of community NAK, applied.

Looks like we are working at the same time. A v2 was literally sent 5
minutes ago. The only changes were to drop that NAKed patch and fix up
the soft-lockup patch so if you just want to grab:

https://patchwork.kernel.org/patch/9705175/

to replace the original:

Quoted 7 lines

https://patchwork.kernel.org/patch/9671675/

That would be good or I could send a separate patch with the fix- ups.
Whichever is easiest.

-Denny

I grabbed the updated patch 11, it's all good.

Signature · 4 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD