ib_srpt: Port to Linux kernel v4.9

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7018 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2016-10-25 20:50:34 +00:00
parent 120c66f924
commit 8c04ce53f4
3 changed files with 25 additions and 1 deletions
+14
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) && \
+9 -1
View File
@@ -4346,18 +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);
@@ -4481,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);
@@ -4554,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);
+2
View File
@@ -457,7 +457,9 @@ 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;