Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iw_cxgb4: cq/qp mask depends on bar2 pages in a host page

Adjust the cq/qp mask based on the number of bar2 pages in a host page.

For user-mode rdma, the granularity of the BAR2 memory mapped to a user
rdma process during queue allocation must be based on the host page
size. The lld attributes udb_density and ucq_density are used to figure
out how many sge contexts are in a bar2 page. So the rdev->qpmask and
rdev->cqmask in iw_cxgb4 need to now be adjusted based on how many sge
bar2 pages are in a host page.

Otherwise the device fails to work on non 4k page size systems.

Fixes: 2391b0030e24 ("cxgb4: Remove SGE_HOST_PAGE_SIZE dependency on page size")
Signed-off-by: Raju Rangoju <rajur@chelsio.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Raju Rangoju and committed by
Jason Gunthorpe
f09ef134 fc4144e7

+13 -2
+13 -2
drivers/infiniband/hw/cxgb4/device.c
··· 783 783 static int c4iw_rdev_open(struct c4iw_rdev *rdev) 784 784 { 785 785 int err; 786 + unsigned int factor; 786 787 787 788 c4iw_init_dev_ucontext(rdev, &rdev->uctx); 788 789 ··· 807 806 return -EINVAL; 808 807 } 809 808 810 - rdev->qpmask = rdev->lldi.udb_density - 1; 811 - rdev->cqmask = rdev->lldi.ucq_density - 1; 809 + /* This implementation requires a sge_host_page_size <= PAGE_SIZE. */ 810 + if (rdev->lldi.sge_host_page_size > PAGE_SIZE) { 811 + pr_err("%s: unsupported sge host page size %u\n", 812 + pci_name(rdev->lldi.pdev), 813 + rdev->lldi.sge_host_page_size); 814 + return -EINVAL; 815 + } 816 + 817 + factor = PAGE_SIZE / rdev->lldi.sge_host_page_size; 818 + rdev->qpmask = (rdev->lldi.udb_density * factor) - 1; 819 + rdev->cqmask = (rdev->lldi.ucq_density * factor) - 1; 820 + 812 821 pr_debug("dev %s stag start 0x%0x size 0x%0x num stags %d pbl start 0x%0x size 0x%0x rq start 0x%0x size 0x%0x qp qid start %u size %u cq qid start %u size %u srq size %u\n", 813 822 pci_name(rdev->lldi.pdev), rdev->lldi.vr->stag.start, 814 823 rdev->lldi.vr->stag.size, c4iw_num_stags(rdev),