aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorSagi Grimberg <sagig@mellanox.com>2014-12-11 10:04:16 -0500
committerRoland Dreier <roland@purestorage.com>2014-12-15 21:13:35 -0500
commit860f10a799c83e38a69d5a69d80da5312a4c4106 (patch)
tree32bc827e3535988397e99b11f9db5c429c09511f /drivers/infiniband
parent5a77abf9a97a7ecc8fb0f6bf4ad411fb12b02f31 (diff)
IB/core: Add flags for on demand paging support
* Add a configuration option for enable on-demand paging support in the infiniband subsystem (CONFIG_INFINIBAND_ON_DEMAND_PAGING). In a later patch, this configuration option will select the MMU_NOTIFIER configuration option to enable mmu notifiers. * Add a flag for on demand paging (ODP) support in the IB device capabilities. * Add a flag to request ODP MR in the access flags to reg_mr. * Fail registrations done with the ODP flag when the low-level driver doesn't support this. * Change the conditions in which an MR will be writable to explicitly specify the access flags. This is to avoid making an MR writable just because it is an ODP MR. * Add a ODP capabilities to the extended query device verb. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Shachar Raindel <raindel@mellanox.com> Signed-off-by: Haggai Eran <haggaie@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/Kconfig10
-rw-r--r--drivers/infiniband/core/umem.c8
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c25
3 files changed, 40 insertions, 3 deletions
diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig
index 77089399359b..089a2c2af329 100644
--- a/drivers/infiniband/Kconfig
+++ b/drivers/infiniband/Kconfig
@@ -38,6 +38,16 @@ config INFINIBAND_USER_MEM
38 depends on INFINIBAND_USER_ACCESS != n 38 depends on INFINIBAND_USER_ACCESS != n
39 default y 39 default y
40 40
41config INFINIBAND_ON_DEMAND_PAGING
42 bool "InfiniBand on-demand paging support"
43 depends on INFINIBAND_USER_MEM
44 default y
45 ---help---
46 On demand paging support for the InfiniBand subsystem.
47 Together with driver support this allows registration of
48 memory regions without pinning their pages, fetching the
49 pages on demand instead.
50
41config INFINIBAND_ADDR_TRANS 51config INFINIBAND_ADDR_TRANS
42 bool 52 bool
43 depends on INFINIBAND 53 depends on INFINIBAND
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 6f152628e0d2..c328e4693d14 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -107,13 +107,15 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
107 umem->page_size = PAGE_SIZE; 107 umem->page_size = PAGE_SIZE;
108 umem->pid = get_task_pid(current, PIDTYPE_PID); 108 umem->pid = get_task_pid(current, PIDTYPE_PID);
109 /* 109 /*
110 * We ask for writable memory if any access flags other than 110 * We ask for writable memory if any of the following
111 * "remote read" are set. "Local write" and "remote write" 111 * access flags are set. "Local write" and "remote write"
112 * obviously require write access. "Remote atomic" can do 112 * obviously require write access. "Remote atomic" can do
113 * things like fetch and add, which will modify memory, and 113 * things like fetch and add, which will modify memory, and
114 * "MW bind" can change permissions by binding a window. 114 * "MW bind" can change permissions by binding a window.
115 */ 115 */
116 umem->writable = !!(access & ~IB_ACCESS_REMOTE_READ); 116 umem->writable = !!(access &
117 (IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
118 IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND));
117 119
118 /* We assume the memory is from hugetlb until proved otherwise */ 120 /* We assume the memory is from hugetlb until proved otherwise */
119 umem->hugetlb = 1; 121 umem->hugetlb = 1;
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index c7a43624c96b..f9326ccda4b5 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -953,6 +953,18 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
953 goto err_free; 953 goto err_free;
954 } 954 }
955 955
956 if (cmd.access_flags & IB_ACCESS_ON_DEMAND) {
957 struct ib_device_attr attr;
958
959 ret = ib_query_device(pd->device, &attr);
960 if (ret || !(attr.device_cap_flags &
961 IB_DEVICE_ON_DEMAND_PAGING)) {
962 pr_debug("ODP support not available\n");
963 ret = -EINVAL;
964 goto err_put;
965 }
966 }
967
956 mr = pd->device->reg_user_mr(pd, cmd.start, cmd.length, cmd.hca_va, 968 mr = pd->device->reg_user_mr(pd, cmd.start, cmd.length, cmd.hca_va,
957 cmd.access_flags, &udata); 969 cmd.access_flags, &udata);
958 if (IS_ERR(mr)) { 970 if (IS_ERR(mr)) {
@@ -3289,6 +3301,19 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
3289 copy_query_dev_fields(file, &resp.base, &attr); 3301 copy_query_dev_fields(file, &resp.base, &attr);
3290 resp.comp_mask = 0; 3302 resp.comp_mask = 0;
3291 3303
3304#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
3305 if (cmd.comp_mask & IB_USER_VERBS_EX_QUERY_DEVICE_ODP) {
3306 resp.odp_caps.general_caps = attr.odp_caps.general_caps;
3307 resp.odp_caps.per_transport_caps.rc_odp_caps =
3308 attr.odp_caps.per_transport_caps.rc_odp_caps;
3309 resp.odp_caps.per_transport_caps.uc_odp_caps =
3310 attr.odp_caps.per_transport_caps.uc_odp_caps;
3311 resp.odp_caps.per_transport_caps.ud_odp_caps =
3312 attr.odp_caps.per_transport_caps.ud_odp_caps;
3313 resp.comp_mask |= IB_USER_VERBS_EX_QUERY_DEVICE_ODP;
3314 }
3315#endif
3316
3292 err = ib_copy_to_udata(ucore, &resp, sizeof(resp)); 3317 err = ib_copy_to_udata(ucore, &resp, sizeof(resp));
3293 if (err) 3318 if (err)
3294 return err; 3319 return err;