--- /dev/null
+From 852f6927594d0d3e8632c889b2ab38cbc46476ad Mon Sep 17 00:00:00 2001
+From: Jack Morgenstein <jackm@dev.mellanox.co.il>
+Date: Fri, 12 Jan 2018 07:58:40 +0200
+Subject: IB/mlx4: Fix incorrectly releasing steerable UD QPs when have only ETH ports
+
+From: Jack Morgenstein <jackm@dev.mellanox.co.il>
+
+commit 852f6927594d0d3e8632c889b2ab38cbc46476ad upstream.
+
+Allocating steerable UD QPs depends on having at least one IB port,
+while releasing those QPs does not.
+
+As a result, when there are only ETH ports, the IB (RoCE) driver
+requests releasing a qp range whose base qp is zero, with
+qp count zero.
+
+When SR-IOV is enabled, and the VF driver is running on a VM over
+a hypervisor which treats such qp release calls as errors
+(rather than NOPs), we see lines in the VM message log like:
+
+ mlx4_core 0002:00:02.0: Failed to release qp range base:0 cnt:0
+
+Fix this by adding a check for a zero count in mlx4_release_qp_range()
+(which thus treats releasing 0 qps as a nop), and eliminating the
+check for device managed flow steering when releasing steerable UD QPs.
+(Freeing ib_uc_qpns_bitmap unconditionally is also OK, since it
+remains NULL when steerable UD QPs are not allocated).
+
+Fixes: 4196670be786 ("IB/mlx4: Don't allocate range of steerable UD QPs for Ethernet-only device")
+Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
+Signed-off-by: Leon Romanovsky <leon@kernel.org>
+Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/hw/mlx4/main.c | 13 +++++--------
+ drivers/net/ethernet/mellanox/mlx4/qp.c | 3 +++
+ 2 files changed, 8 insertions(+), 8 deletions(-)
+
+--- a/drivers/infiniband/hw/mlx4/main.c
++++ b/drivers/infiniband/hw/mlx4/main.c
+@@ -2928,9 +2928,8 @@ err_steer_free_bitmap:
+ kfree(ibdev->ib_uc_qpns_bitmap);
+
+ err_steer_qp_release:
+- if (ibdev->steering_support == MLX4_STEERING_MODE_DEVICE_MANAGED)
+- mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
+- ibdev->steer_qpn_count);
++ mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
++ ibdev->steer_qpn_count);
+ err_counter:
+ for (i = 0; i < ibdev->num_ports; ++i)
+ mlx4_ib_delete_counters_table(ibdev, &ibdev->counters_table[i]);
+@@ -3035,11 +3034,9 @@ static void mlx4_ib_remove(struct mlx4_d
+ ibdev->iboe.nb.notifier_call = NULL;
+ }
+
+- if (ibdev->steering_support == MLX4_STEERING_MODE_DEVICE_MANAGED) {
+- mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
+- ibdev->steer_qpn_count);
+- kfree(ibdev->ib_uc_qpns_bitmap);
+- }
++ mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
++ ibdev->steer_qpn_count);
++ kfree(ibdev->ib_uc_qpns_bitmap);
+
+ iounmap(ibdev->uar_map);
+ for (p = 0; p < ibdev->num_ports; ++p)
+--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
++++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
+@@ -286,6 +286,9 @@ void mlx4_qp_release_range(struct mlx4_d
+ u64 in_param = 0;
+ int err;
+
++ if (!cnt)
++ return;
++
+ if (mlx4_is_mfunc(dev)) {
+ set_param_l(&in_param, base_qpn);
+ set_param_h(&in_param, cnt);
--- /dev/null
+From 87b3524cb5058fdc7c2afdb92bdb2e079661ddc4 Mon Sep 17 00:00:00 2001
+From: Mike Marciniszyn <mike.marciniszyn@intel.com>
+Date: Tue, 14 Nov 2017 04:34:52 -0800
+Subject: IB/qib: Fix comparison error with qperf compare/swap test
+
+From: Mike Marciniszyn <mike.marciniszyn@intel.com>
+
+commit 87b3524cb5058fdc7c2afdb92bdb2e079661ddc4 upstream.
+
+This failure exists with qib:
+
+ver_rc_compare_swap:
+mismatch, sequence 2, expected 123456789abcdef, got 0
+
+The request builder was using the incorrect inlines to
+build the request header resulting in incorrect data
+in the atomic header.
+
+Fix by using the appropriate inlines to create the request.
+
+Fixes: 261a4351844b ("IB/qib,IB/hfi: Use core common header file")
+Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
+Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
+Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
+Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/hw/qib/qib_rc.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/infiniband/hw/qib/qib_rc.c
++++ b/drivers/infiniband/hw/qib/qib_rc.c
+@@ -443,13 +443,13 @@ no_flow_control:
+ qp->s_state = OP(COMPARE_SWAP);
+ put_ib_ateth_swap(wqe->atomic_wr.swap,
+ &ohdr->u.atomic_eth);
+- put_ib_ateth_swap(wqe->atomic_wr.compare_add,
+- &ohdr->u.atomic_eth);
++ put_ib_ateth_compare(wqe->atomic_wr.compare_add,
++ &ohdr->u.atomic_eth);
+ } else {
+ qp->s_state = OP(FETCH_ADD);
+ put_ib_ateth_swap(wqe->atomic_wr.compare_add,
+ &ohdr->u.atomic_eth);
+- put_ib_ateth_swap(0, &ohdr->u.atomic_eth);
++ put_ib_ateth_compare(0, &ohdr->u.atomic_eth);
+ }
+ put_ib_ateth_vaddr(wqe->atomic_wr.remote_addr,
+ &ohdr->u.atomic_eth);
--- /dev/null
+From 4c1baad223906943b595a887305f2e8124821dad Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Tue, 9 Jan 2018 17:26:24 +0100
+Subject: kselftest: fix OOM in memory compaction test
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit 4c1baad223906943b595a887305f2e8124821dad upstream.
+
+Running the compaction_test sometimes results in out-of-memory
+failures. When I debugged this, it turned out that the code to
+reset the number of hugepages to the initial value is simply
+broken since we write into an open sysctl file descriptor
+multiple times without seeking back to the start.
+
+Adding the lseek here fixes the problem.
+
+Cc: stable@vger.kernel.org
+Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
+Link: https://bugs.linaro.org/show_bug.cgi?id=3145
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/testing/selftests/vm/compaction_test.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/tools/testing/selftests/vm/compaction_test.c
++++ b/tools/testing/selftests/vm/compaction_test.c
+@@ -136,6 +136,8 @@ int check_compaction(unsigned long mem_f
+ printf("No of huge pages allocated = %d\n",
+ (atoi(nr_hugepages)));
+
++ lseek(fd, 0, SEEK_SET);
++
+ if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
+ != strlen(initial_nr_hugepages)) {
+ perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");
--- /dev/null
+From 6f301e06de4cf9ab7303f5acd43e64fcd4aa04be Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bart.vanassche@wdc.com>
+Date: Tue, 9 Jan 2018 11:23:40 -0800
+Subject: RDMA/rxe: Fix a race condition related to the QP error state
+
+From: Bart Van Assche <bart.vanassche@wdc.com>
+
+commit 6f301e06de4cf9ab7303f5acd43e64fcd4aa04be upstream.
+
+The following sequence:
+* Change queue pair state into IB_QPS_ERR.
+* Post a work request on the queue pair.
+
+Triggers the following race condition in the rdma_rxe driver:
+* rxe_qp_error() triggers an asynchronous call of rxe_completer(), the function
+ that examines the QP send queue.
+* rxe_post_send() posts a work request on the QP send queue.
+
+If rxe_completer() runs prior to rxe_post_send(), it will drain the send
+queue and the driver will assume no further action is necessary.
+However, once we post the send to the send queue, because the queue is
+in error, no send completion will ever happen and the send will get
+stuck. In order to process the send, we need to make sure that
+rxe_completer() gets run after a send is posted to a queue pair in an
+error state. This patch ensures that happens.
+
+Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
+Cc: Moni Shoua <monis@mellanox.com>
+Cc: <stable@vger.kernel.org> # v4.8
+Signed-off-by: Doug Ledford <dledford@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/sw/rxe/rxe_verbs.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
++++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
+@@ -848,6 +848,8 @@ static int rxe_post_send_kernel(struct r
+ (queue_count(qp->sq.queue) > 1);
+
+ rxe_run_task(&qp->req.task, must_sched);
++ if (unlikely(qp->req.state == QP_STATE_ERROR))
++ rxe_run_task(&qp->comp.task, 1);
+
+ return err;
+ }
scsi-smartpqi-allow-static-build-built-in.patch
powerpc-64s-simple-rfi-macro-conversions.patch
+ib-qib-fix-comparison-error-with-qperf-compare-swap-test.patch
+ib-mlx4-fix-incorrectly-releasing-steerable-ud-qps-when-have-only-eth-ports.patch
+kselftest-fix-oom-in-memory-compaction-test.patch
+rdma-rxe-fix-a-race-condition-related-to-the-qp-error-state.patch