diff mbox series

[for-next,v2,5/7] RDMA/bnxt_re: Update alloc_page uapi for pacing

Message ID 1689573194-27687-6-git-send-email-selvin.xavier@broadcom.com (mailing list archive)
State Superseded
Headers show
Series RDMA/bnxt_re: Doorbell Drop Prevention | expand

Commit Message

Selvin Xavier July 17, 2023, 5:53 a.m. UTC
From: Chandramohan Akula <chandramohan.akula@broadcom.com>

Update the alloc_page uapi functionality for handling the
mapping of doorbell pacing shared page and bar address.

Signed-off-by: Chandramohan Akula <chandramohan.akula@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 34 +++++++++++++++++++++++++++++---
 drivers/infiniband/hw/bnxt_re/ib_verbs.h |  2 ++
 include/uapi/rdma/bnxt_re-abi.h          |  2 ++
 3 files changed, 35 insertions(+), 3 deletions(-)

Comments

kernel test robot July 18, 2023, 11:16 p.m. UTC | #1
Hi Selvin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.5-rc2 next-20230718]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Selvin-Xavier/bnxt_en-Share-the-bar0-address-with-the-RoCE-driver/20230718-174723
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/1689573194-27687-6-git-send-email-selvin.xavier%40broadcom.com
patch subject: [PATCH for-next v2 5/7] RDMA/bnxt_re: Update alloc_page uapi for pacing
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230719/202307190721.q4H3DjZs-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230719/202307190721.q4H3DjZs-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307190721.q4H3DjZs-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/arm64/include/asm/memory.h:337,
                    from arch/arm64/include/asm/thread_info.h:17,
                    from include/linux/thread_info.h:60,
                    from arch/arm64/include/asm/preempt.h:6,
                    from include/linux/preempt.h:79,
                    from include/linux/percpu.h:6,
                    from include/linux/context_tracking_state.h:5,
                    from include/linux/hardirq.h:5,
                    from include/linux/interrupt.h:11,
                    from drivers/infiniband/hw/bnxt_re/ib_verbs.c:39:
   drivers/infiniband/hw/bnxt_re/ib_verbs.c: In function 'bnxt_re_mmap':
>> drivers/infiniband/hw/bnxt_re/ib_verbs.c:4164:81: warning: passing argument 1 of 'virt_to_pfn' makes pointer from integer without a cast [-Wint-conversion]
    4164 |                 ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));
         |                                                                       ~~~~~~~~~~^~~~~~~~~~~~
         |                                                                                 |
         |                                                                                 u64 {aka long long unsigned int}
   include/asm-generic/memory_model.h:37:45: note: in definition of macro '__pfn_to_page'
      37 | #define __pfn_to_page(pfn)      (vmemmap + (pfn))
         |                                             ^~~
   drivers/infiniband/hw/bnxt_re/ib_verbs.c:4164:58: note: in expansion of macro 'virt_to_page'
    4164 |                 ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));
         |                                                          ^~~~~~~~~~~~
   arch/arm64/include/asm/memory.h:339:53: note: expected 'const void *' but argument is of type 'u64' {aka 'long long unsigned int'}
     339 | static inline unsigned long virt_to_pfn(const void *kaddr)
         |                                         ~~~~~~~~~~~~^~~~~


vim +/virt_to_pfn +4164 drivers/infiniband/hw/bnxt_re/ib_verbs.c

  4119	
  4120	/* Helper function to mmap the virtual memory from user app */
  4121	int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
  4122	{
  4123		struct bnxt_re_ucontext *uctx = container_of(ib_uctx,
  4124							   struct bnxt_re_ucontext,
  4125							   ib_uctx);
  4126		struct bnxt_re_user_mmap_entry *bnxt_entry;
  4127		struct rdma_user_mmap_entry *rdma_entry;
  4128		int ret = 0;
  4129		u64 pfn;
  4130	
  4131		rdma_entry = rdma_user_mmap_entry_get(&uctx->ib_uctx, vma);
  4132		if (!rdma_entry)
  4133			return -EINVAL;
  4134	
  4135		bnxt_entry = container_of(rdma_entry, struct bnxt_re_user_mmap_entry,
  4136					  rdma_entry);
  4137	
  4138		switch (bnxt_entry->mmap_flag) {
  4139		case BNXT_RE_MMAP_WC_DB:
  4140			pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
  4141			ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
  4142						pgprot_writecombine(vma->vm_page_prot),
  4143						rdma_entry);
  4144			break;
  4145		case BNXT_RE_MMAP_UC_DB:
  4146			pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
  4147			ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
  4148						pgprot_noncached(vma->vm_page_prot),
  4149					rdma_entry);
  4150			break;
  4151		case BNXT_RE_MMAP_SH_PAGE:
  4152			ret = vm_insert_page(vma, vma->vm_start, virt_to_page(uctx->shpg));
  4153			break;
  4154		case BNXT_RE_MMAP_DBR_BAR:
  4155			pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
  4156			ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
  4157						pgprot_noncached(vma->vm_page_prot),
  4158						rdma_entry);
  4159			break;
  4160		case BNXT_RE_MMAP_DBR_PAGE:
  4161			/* Driver doesn't expect write access for user space */
  4162			if (vma->vm_flags & VM_WRITE)
  4163				return -EFAULT;
> 4164			ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));
  4165			break;
  4166		default:
  4167			ret = -EINVAL;
  4168			break;
  4169		}
  4170	
  4171		rdma_user_mmap_entry_put(rdma_entry);
  4172		return ret;
  4173	}
  4174
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 86b71c7..8238c4b 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -565,6 +565,8 @@  bnxt_re_mmap_entry_insert(struct bnxt_re_ucontext *uctx, u64 mem_offset,
 		break;
 	case BNXT_RE_MMAP_UC_DB:
 	case BNXT_RE_MMAP_WC_DB:
+	case BNXT_RE_MMAP_DBR_BAR:
+	case BNXT_RE_MMAP_DBR_PAGE:
 		ret = rdma_user_mmap_entry_insert(&uctx->ib_uctx,
 						  &entry->rdma_entry, PAGE_SIZE);
 		break;
@@ -4149,6 +4151,18 @@  int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
 	case BNXT_RE_MMAP_SH_PAGE:
 		ret = vm_insert_page(vma, vma->vm_start, virt_to_page(uctx->shpg));
 		break;
+	case BNXT_RE_MMAP_DBR_BAR:
+		pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
+		ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
+					pgprot_noncached(vma->vm_page_prot),
+					rdma_entry);
+		break;
+	case BNXT_RE_MMAP_DBR_PAGE:
+		/* Driver doesn't expect write access for user space */
+		if (vma->vm_flags & VM_WRITE)
+			return -EFAULT;
+		ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));
+		break;
 	default:
 		ret = -EINVAL;
 		break;
@@ -4180,7 +4194,7 @@  static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
 	u64 mmap_offset;
 	u32 length;
 	u32 dpi;
-	u64 dbr;
+	u64 addr;
 	int err;
 
 	uctx = container_of(ib_uverbs_get_ucontext(attrs), struct bnxt_re_ucontext, ib_uctx);
@@ -4202,19 +4216,30 @@  static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
 				return -ENOMEM;
 			length = PAGE_SIZE;
 			dpi = uctx->wcdpi.dpi;
-			dbr = (u64)uctx->wcdpi.umdbr;
+			addr = (u64)uctx->wcdpi.umdbr;
 			mmap_flag = BNXT_RE_MMAP_WC_DB;
 		} else {
 			return -EINVAL;
 		}
 
 		break;
+	case BNXT_RE_ALLOC_DBR_BAR_PAGE:
+		length = PAGE_SIZE;
+		addr = (u64)rdev->pacing.dbr_bar_addr;
+		mmap_flag = BNXT_RE_MMAP_DBR_BAR;
+		break;
+
+	case BNXT_RE_ALLOC_DBR_PAGE:
+		length = PAGE_SIZE;
+		addr = (u64)rdev->pacing.dbr_page;
+		mmap_flag = BNXT_RE_MMAP_DBR_PAGE;
+		break;
 
 	default:
 		return -EOPNOTSUPP;
 	}
 
-	entry = bnxt_re_mmap_entry_insert(uctx, dbr, mmap_flag, &mmap_offset);
+	entry = bnxt_re_mmap_entry_insert(uctx, addr, mmap_flag, &mmap_offset);
 	if (!entry)
 		return -ENOMEM;
 
@@ -4254,6 +4279,9 @@  static int alloc_page_obj_cleanup(struct ib_uobject *uobject,
 			uctx->wcdpi.dbr = NULL;
 		}
 		break;
+	case BNXT_RE_MMAP_DBR_BAR:
+	case BNXT_RE_MMAP_DBR_PAGE:
+		break;
 	default:
 		goto exit;
 	}
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.h b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
index 32d9e9d..f392a09 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.h
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
@@ -146,6 +146,8 @@  enum bnxt_re_mmap_flag {
 	BNXT_RE_MMAP_SH_PAGE,
 	BNXT_RE_MMAP_UC_DB,
 	BNXT_RE_MMAP_WC_DB,
+	BNXT_RE_MMAP_DBR_PAGE,
+	BNXT_RE_MMAP_DBR_BAR,
 };
 
 struct bnxt_re_user_mmap_entry {
diff --git a/include/uapi/rdma/bnxt_re-abi.h b/include/uapi/rdma/bnxt_re-abi.h
index 060bf1d..78a324f 100644
--- a/include/uapi/rdma/bnxt_re-abi.h
+++ b/include/uapi/rdma/bnxt_re-abi.h
@@ -136,6 +136,8 @@  enum bnxt_re_objects {
 
 enum bnxt_re_alloc_page_type {
 	BNXT_RE_ALLOC_WC_PAGE = 0,
+	BNXT_RE_ALLOC_DBR_BAR_PAGE,
+	BNXT_RE_ALLOC_DBR_PAGE,
 };
 
 enum bnxt_re_var_alloc_page_attrs {