Merge branch 'svn-trunk'

This commit is contained in:
Bart Van Assche
2016-10-25 19:07:31 -07:00
7 changed files with 55 additions and 7 deletions

View File

@@ -233,7 +233,10 @@ struct isert_connection {
struct isert_device {
struct ib_device *ib_dev;
struct ib_pd *pd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
struct ib_mr *mr;
#endif
u32 lkey;
struct list_head devs_node;
/* conn_list and refcnt protected by dev_list_mutex */

View File

@@ -201,7 +201,7 @@ static int isert_alloc_for_rdma(struct isert_cmnd *pdu, int sge_cnt,
isert_wr_set_fields(&pdu->wr[i], isert_conn, pdu);
for (i = 0; i < sge_cnt; ++i)
pdu->sg_pool[i].lkey = isert_conn->isert_dev->mr->lkey;
pdu->sg_pool[i].lkey = isert_conn->isert_dev->lkey;
goto out;

View File

@@ -951,7 +951,9 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
struct isert_device *isert_dev;
int cqe_num, err;
struct ib_pd *pd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
struct ib_mr *mr;
#endif
struct ib_cq *cq;
char wq_name[64];
int i, j;
@@ -996,19 +998,21 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
goto fail_alloc_cq_desc;
}
pd = ib_alloc_pd(ib_dev);
pd = ib_alloc_pd(ib_dev, 0);
if (unlikely(IS_ERR(pd))) {
err = PTR_ERR(pd);
PRINT_ERROR("Failed to alloc iser dev pd, err:%d", err);
goto fail_pd;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE);
if (unlikely(IS_ERR(mr))) {
err = PTR_ERR(mr);
PRINT_ERROR("Failed to get dma mr, err: %d", err);
goto fail_mr;
}
#endif
cqe_num = min(isert_dev->device_attr.max_cqe, ISER_CQ_ENTRIES);
cqe_num = cqe_num / isert_dev->num_cqs;
@@ -1091,7 +1095,12 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
isert_dev->ib_dev = ib_dev;
isert_dev->pd = pd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
isert_dev->mr = mr;
isert_dev->lkey = mr->lkey;
#else
isert_dev->lkey = pd->local_dma_lkey;
#endif
INIT_LIST_HEAD(&isert_dev->conn_list);
@@ -1109,8 +1118,10 @@ fail_cq:
if (isert_dev->cq_desc[j].cq_workqueue)
destroy_workqueue(isert_dev->cq_desc[j].cq_workqueue);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
ib_dereg_mr(mr);
fail_mr:
#endif
ib_dealloc_pd(pd);
fail_pd:
vfree(isert_dev->cq_desc);
@@ -1153,9 +1164,11 @@ static void isert_device_release(struct isert_device *isert_dev)
destroy_workqueue(cq_desc->cq_workqueue);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
err = ib_dereg_mr(isert_dev->mr);
if (unlikely(err))
PRINT_ERROR("Failed to destroy mr, err:%d", err);
#endif
ib_dealloc_pd(isert_dev->pd);
vfree(isert_dev->cq_desc);

View File

@@ -25,6 +25,7 @@
#include <linux/slab.h> /* kmalloc() */
#include <linux/writeback.h> /* sync_page_range() */
#include <scsi/scsi_cmnd.h> /* struct scsi_cmnd */
#include <rdma/ib_verbs.h>
/* <asm-generic/barrier.h> */
@@ -512,6 +513,19 @@ typedef void (*rcu_callback_t)(struct rcu_head *);
__kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
#endif
/* <rdma/ib_verbs.h> */
/* commit ed082d36 */
#ifndef ib_alloc_pd
static inline struct ib_pd *ib_alloc_pd_backport(struct ib_device *device)
{
return ib_alloc_pd(device);
}
#define ib_alloc_pd(device, flags) \
({ \
(void)(flags), ib_alloc_pd_backport(device); \
})
#endif
/* <linux/sched.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && \

View File

@@ -1267,8 +1267,13 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff,
(ucmd->cmd != NULL) ? ucmd->cmd->bufflen : -1);
down_read(&tsk->mm->mmap_sem);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
rc = get_user_pages(ubuff, ucmd->num_data_pages, 1/*writable*/,
0/*don't force*/, ucmd->data_pages, NULL);
#else
rc = get_user_pages(ubuff, ucmd->num_data_pages, FOLL_WRITE,
ucmd->data_pages, NULL);
#endif
up_read(&tsk->mm->mmap_sem);
/* get_user_pages() flushes dcache */

View File

@@ -958,7 +958,7 @@ static int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch,
list.addr = ioctx->ioctx.dma + ioctx->ioctx.offset;
list.length = srp_max_req_size;
list.lkey = sdev->mr->lkey;
list.lkey = sdev->lkey;
wr.next = NULL;
wr.sg_list = &list;
@@ -1001,7 +1001,7 @@ static int srpt_post_send(struct srpt_rdma_ch *ch,
list.addr = ioctx->ioctx.dma;
list.length = len;
list.lkey = sdev->mr->lkey;
list.lkey = sdev->lkey;
wr.next = NULL;
wr.wr_id = encode_wr_id(SRPT_SEND, ioctx->ioctx.index);
@@ -3299,7 +3299,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
while (rsize > 0 && tsize > 0) {
sge->addr = dma_addr;
sge->lkey = ch->sport->sdev->mr->lkey;
sge->lkey = ch->sport->sdev->lkey;
if (rsize >= dma_len) {
sge->length =
@@ -4346,17 +4346,22 @@ static void srpt_add_one(struct ib_device *device)
sdev->dev_attr = device->attrs;
#endif
sdev->pd = ib_alloc_pd(device);
sdev->pd = ib_alloc_pd(device, 0);
if (IS_ERR(sdev->pd)) {
pr_err("ib_alloc_pd() failed: %ld\n", PTR_ERR(sdev->pd));
goto free_dev;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
sdev->mr = ib_get_dma_mr(sdev->pd, IB_ACCESS_LOCAL_WRITE);
if (IS_ERR(sdev->mr)) {
pr_err("ib_get_dma_mr() failed: %ld\n", PTR_ERR(sdev->mr));
goto err_pd;
}
sdev->lkey = sdev->mr->lkey;
#else
sdev->lkey = sdev->pd->local_dma_lkey;
#endif
sdev->srq_size = min(max(srpt_srq_size, MIN_SRPT_SRQ_SIZE),
sdev->dev_attr.max_srq_wr);
@@ -4480,8 +4485,10 @@ err_ring:
if (sdev->use_srq)
ib_destroy_srq(sdev->srq);
err_mr:
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
ib_dereg_mr(sdev->mr);
err_pd:
#endif
ib_dealloc_pd(sdev->pd);
free_dev:
kfree(sdev);
@@ -4553,7 +4560,9 @@ static void srpt_remove_one(struct ib_device *device, void *client_data)
if (sdev->use_srq)
ib_destroy_srq(sdev->srq);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
ib_dereg_mr(sdev->mr);
#endif
ib_dealloc_pd(sdev->pd);
kfree(sdev);

View File

@@ -442,7 +442,8 @@ struct srpt_port {
* struct srpt_device - Information associated by SRPT with a single HCA.
* @device: Backpointer to the struct ib_device managed by the IB core.
* @pd: IB protection domain.
* @mr: L_Key (local key) with write access to all local memory.
* @mr: MR with write access to all local memory.
* @lkey: L_Key (local key) with write access to all local memory.
* @srq: Per-HCA SRQ (shared receive queue).
* @cm_id: Connection identifier.
* @dev_attr: Attributes of the InfiniBand device as obtained during the
@@ -456,10 +457,13 @@ struct srpt_port {
struct srpt_device {
struct ib_device *device;
struct ib_pd *pd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
struct ib_mr *mr;
#endif
struct ib_srq *srq;
struct ib_cm_id *cm_id;
struct ib_device_attr dev_attr;
u32 lkey;
int srq_size;
bool use_srq;
struct srpt_recv_ioctx **ioctx_ring;