From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/infiniband/hw/mlx5/qp.c

Change-Id: Icf55b1bfe3288dfc193d7b3bad30176421031546
---
 drivers/infiniband/hw/mlx5/qp.c | 40 ++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 6 deletions(-)

--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1039,8 +1039,14 @@ static int create_user_rq(struct mlx5_ib
 	if (!ucmd->buf_addr)
 		return -EINVAL;
 
+#ifdef HAVE_MMU_INTERVAL_NOTIFIER
 	rwq->umem = ib_umem_get_peer(&dev->ib_dev, ucmd->buf_addr,
 				     rwq->buf_size, 0, 0);
+#else
+	rwq->umem = ib_umem_get_peer(udata, ucmd->buf_addr,
+   				     rwq->buf_size, 0, 0);
+#endif
+
 	if (IS_ERR(rwq->umem)) {
 		mlx5_ib_dbg(dev, "umem_get failed\n");
 		err = PTR_ERR(rwq->umem);
@@ -1068,7 +1074,11 @@ static int create_user_rq(struct mlx5_ib
 		ib_umem_num_pages(rwq->umem), page_size, rwq->rq_num_pas,
 		offset);
 
-	err = mlx5_ib_db_map_user(ucontext, ucmd->db_addr, &rwq->db);
+	err = mlx5_ib_db_map_user(ucontext,
+#ifdef HAVE_BASECODE_EXTRAS
+				  udata,
+#endif
+				  ucmd->db_addr, &rwq->db);
 	if (err) {
 		mlx5_ib_dbg(dev, "map failed\n");
 		goto err_umem;
@@ -1151,8 +1161,13 @@ static int _create_user_qp(struct mlx5_i
 	if (ucmd->buf_addr && ubuffer->buf_size) {
 		ubuffer->buf_addr = ucmd->buf_addr;
 		ubuffer->umem =
+#ifdef HAVE_MMU_INTERVAL_NOTIFIER
 			ib_umem_get_peer(&dev->ib_dev, ubuffer->buf_addr,
 					 ubuffer->buf_size, 0, 0);
+#else
+			ib_umem_get_peer(udata, ubuffer->buf_addr,
+					 ubuffer->buf_size, 0, 0);
+#endif
 		if (IS_ERR(ubuffer->umem)) {
 			err = PTR_ERR(ubuffer->umem);
 			goto err_bfreg;
@@ -1195,7 +1210,11 @@ static int _create_user_qp(struct mlx5_i
 		resp->bfreg_index = MLX5_IB_INVALID_BFREG;
 	qp->bfregn = bfregn;
 
-	err = mlx5_ib_db_map_user(context, ucmd->db_addr, &qp->db);
+	err = mlx5_ib_db_map_user(context,
+#ifdef HAVE_BASECODE_EXTRAS
+				  udata,
+#endif
+				  ucmd->db_addr, &qp->db);
 	if (err) {
 		mlx5_ib_dbg(dev, "map failed\n");
 		goto err_free;
@@ -1507,8 +1526,13 @@ static int create_raw_packet_qp_sq(struc
 	if (ts_format < 0)
 		return ts_format;
 
+#ifdef HAVE_MMU_INTERVAL_NOTIFIER
 	sq->ubuffer.umem = ib_umem_get_peer(&dev->ib_dev, ubuffer->buf_addr,
 				       ubuffer->buf_size, 0, 0);
+#else
+	sq->ubuffer.umem = ib_umem_get_peer(udata, ubuffer->buf_addr,
+				       	    ubuffer->buf_size, 0, 0);
+#endif
 	if (IS_ERR(sq->ubuffer.umem))
 		return PTR_ERR(sq->ubuffer.umem);
 	page_size = mlx5_umem_find_best_quantized_pgoff(
@@ -2237,10 +2261,10 @@ static int create_dci(struct mlx5_ib_dev
 	struct mlx5_ib_cq *recv_cq;
 	unsigned long flags;
 	struct mlx5_ib_qp_base *base;
-	int ts_format;
+	int ts_format = 0;
 	int mlx5_st;
 	void *qpc;
-	u32 *in;
+	u32 *in = NULL;
 	int err;
 
 	spin_lock_init(&qp->sq.lock);
@@ -2398,10 +2422,10 @@ static int create_user_qp(struct mlx5_ib
 	struct mlx5_ib_cq *recv_cq;
 	unsigned long flags;
 	struct mlx5_ib_qp_base *base;
-	int ts_format;
+	int ts_format = 0;
 	int mlx5_st;
 	void *qpc;
-	u32 *in;
+	u32 *in = NULL;
 	int err;
 
 	spin_lock_init(&qp->sq.lock);
@@ -6021,9 +6045,13 @@ static void handle_drain_completion(stru
 		if (triggered) {
 			/* Wait for any scheduled/running task to be ended */
 			switch (cq->poll_ctx) {
+#if IS_ENABLED(CONFIG_IRQ_POLL)
 			case IB_POLL_SOFTIRQ:
+#if IS_ENABLED(CONFIG_IRQ_POLL)
 				irq_poll_disable(&cq->iop);
 				irq_poll_enable(&cq->iop);
+#endif
+#endif
 				break;
 			case IB_POLL_WORKQUEUE:
 				cancel_work_sync(&cq->work);
