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

Change-Id: I90d98ef0f44b25a79ed3dcf9998c4e52ae4d7541
---
 drivers/infiniband/hw/mlx5/doorbell.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

--- a/drivers/infiniband/hw/mlx5/doorbell.c
+++ b/drivers/infiniband/hw/mlx5/doorbell.c
@@ -45,7 +45,11 @@ struct mlx5_ib_user_db_page {
 	struct mm_struct	*mm;
 };
 
-int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt,
+int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context,
+#ifdef HAVE_BASECODE_EXTRAS
+			struct ib_udata *udata,
+#endif
+			unsigned long virt,
 			struct mlx5_db *db)
 {
 	struct mlx5_ib_user_db_page *page;
@@ -67,8 +71,13 @@ int mlx5_ib_db_map_user(struct mlx5_ib_u
 	page->user_virt = (virt & PAGE_MASK);
 	page->refcnt    = 0;
 	page->umem =
+#ifdef HAVE_MMU_INTERVAL_NOTIFIER
 		ib_umem_get_peer(context->ibucontext.device, virt & PAGE_MASK,
 				 PAGE_SIZE, 0, 0);
+#else
+		ib_umem_get_peer(udata, virt & PAGE_MASK,
+				      PAGE_SIZE, 0, 0);
+#endif
 	if (IS_ERR(page->umem)) {
 		err = PTR_ERR(page->umem);
 		kfree(page);
@@ -80,8 +89,12 @@ int mlx5_ib_db_map_user(struct mlx5_ib_u
 	list_add(&page->list, &context->db_page_list);
 
 found:
+#ifdef HAVE_SG_APPEND_TABLE
 	db->dma = sg_dma_address(page->umem->sgt_append.sgt.sgl) +
 		  (virt & ~PAGE_MASK);
+#else
+	db->dma = sg_dma_address(page->umem->sg_head.sgl) + (virt & ~PAGE_MASK);
+#endif
 	db->u.user_page = page;
 	++page->refcnt;
 
