diff options
author | Shachar Raindel <raindel@mellanox.com> | 2014-12-11 10:04:17 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-12-15 21:13:36 -0500 |
commit | 8ada2c1c0c1d75a60723cd2ca7d49c594a146af6 (patch) | |
tree | a80d10bb8cf4888a7f6313698a40980de5724b51 /include/rdma | |
parent | 860f10a799c83e38a69d5a69d80da5312a4c4106 (diff) |
IB/core: Add support for on demand paging regions
* Extend the umem struct to keep the ODP related data.
* Allocate and initialize the ODP related information in the umem
(page_list, dma_list) and freeing as needed in the end of the run.
* Store a reference to the process PID struct in the ucontext. Used to
safely obtain the task_struct and the mm during fault handling,
without preventing the task destruction if needed.
* Add 2 helper functions: ib_umem_odp_map_dma_pages and
ib_umem_odp_unmap_dma_pages. These functions get the DMA addresses
of specific pages of the umem (and, currently, pin them).
* Support for page faults only - IB core will keep the reference on
the pages used and call put_page when freeing an ODP umem
area. Invalidations support will be added in a later patch.
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: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include/rdma')
-rw-r--r-- | include/rdma/ib_umem.h | 2 | ||||
-rw-r--r-- | include/rdma/ib_umem_odp.h | 97 | ||||
-rw-r--r-- | include/rdma/ib_verbs.h | 2 |
3 files changed, 101 insertions, 0 deletions
diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h index a51f4091489a..2d83cfd7e6ce 100644 --- a/include/rdma/ib_umem.h +++ b/include/rdma/ib_umem.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/workqueue.h> | 38 | #include <linux/workqueue.h> |
39 | 39 | ||
40 | struct ib_ucontext; | 40 | struct ib_ucontext; |
41 | struct ib_umem_odp; | ||
41 | 42 | ||
42 | struct ib_umem { | 43 | struct ib_umem { |
43 | struct ib_ucontext *context; | 44 | struct ib_ucontext *context; |
@@ -50,6 +51,7 @@ struct ib_umem { | |||
50 | struct pid *pid; | 51 | struct pid *pid; |
51 | struct mm_struct *mm; | 52 | struct mm_struct *mm; |
52 | unsigned long diff; | 53 | unsigned long diff; |
54 | struct ib_umem_odp *odp_data; | ||
53 | struct sg_table sg_head; | 55 | struct sg_table sg_head; |
54 | int nmap; | 56 | int nmap; |
55 | int npages; | 57 | int npages; |
diff --git a/include/rdma/ib_umem_odp.h b/include/rdma/ib_umem_odp.h new file mode 100644 index 000000000000..b5a2df1923b7 --- /dev/null +++ b/include/rdma/ib_umem_odp.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2014 Mellanox Technologies. All rights reserved. | ||
3 | * | ||
4 | * This software is available to you under a choice of one of two | ||
5 | * licenses. You may choose to be licensed under the terms of the GNU | ||
6 | * General Public License (GPL) Version 2, available from the file | ||
7 | * COPYING in the main directory of this source tree, or the | ||
8 | * OpenIB.org BSD license below: | ||
9 | * | ||
10 | * Redistribution and use in source and binary forms, with or | ||
11 | * without modification, are permitted provided that the following | ||
12 | * conditions are met: | ||
13 | * | ||
14 | * - Redistributions of source code must retain the above | ||
15 | * copyright notice, this list of conditions and the following | ||
16 | * disclaimer. | ||
17 | * | ||
18 | * - Redistributions in binary form must reproduce the above | ||
19 | * copyright notice, this list of conditions and the following | ||
20 | * disclaimer in the documentation and/or other materials | ||
21 | * provided with the distribution. | ||
22 | * | ||
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
30 | * SOFTWARE. | ||
31 | */ | ||
32 | |||
33 | #ifndef IB_UMEM_ODP_H | ||
34 | #define IB_UMEM_ODP_H | ||
35 | |||
36 | #include <rdma/ib_umem.h> | ||
37 | |||
38 | struct ib_umem_odp { | ||
39 | /* | ||
40 | * An array of the pages included in the on-demand paging umem. | ||
41 | * Indices of pages that are currently not mapped into the device will | ||
42 | * contain NULL. | ||
43 | */ | ||
44 | struct page **page_list; | ||
45 | /* | ||
46 | * An array of the same size as page_list, with DMA addresses mapped | ||
47 | * for pages the pages in page_list. The lower two bits designate | ||
48 | * access permissions. See ODP_READ_ALLOWED_BIT and | ||
49 | * ODP_WRITE_ALLOWED_BIT. | ||
50 | */ | ||
51 | dma_addr_t *dma_list; | ||
52 | /* | ||
53 | * The umem_mutex protects the page_list and dma_list fields of an ODP | ||
54 | * umem, allowing only a single thread to map/unmap pages. | ||
55 | */ | ||
56 | struct mutex umem_mutex; | ||
57 | void *private; /* for the HW driver to use. */ | ||
58 | }; | ||
59 | |||
60 | #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING | ||
61 | |||
62 | int ib_umem_odp_get(struct ib_ucontext *context, struct ib_umem *umem); | ||
63 | |||
64 | void ib_umem_odp_release(struct ib_umem *umem); | ||
65 | |||
66 | /* | ||
67 | * The lower 2 bits of the DMA address signal the R/W permissions for | ||
68 | * the entry. To upgrade the permissions, provide the appropriate | ||
69 | * bitmask to the map_dma_pages function. | ||
70 | * | ||
71 | * Be aware that upgrading a mapped address might result in change of | ||
72 | * the DMA address for the page. | ||
73 | */ | ||
74 | #define ODP_READ_ALLOWED_BIT (1<<0ULL) | ||
75 | #define ODP_WRITE_ALLOWED_BIT (1<<1ULL) | ||
76 | |||
77 | #define ODP_DMA_ADDR_MASK (~(ODP_READ_ALLOWED_BIT | ODP_WRITE_ALLOWED_BIT)) | ||
78 | |||
79 | int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 start_offset, u64 bcnt, | ||
80 | u64 access_mask, unsigned long current_seq); | ||
81 | |||
82 | void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 start_offset, | ||
83 | u64 bound); | ||
84 | |||
85 | #else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */ | ||
86 | |||
87 | static inline int ib_umem_odp_get(struct ib_ucontext *context, | ||
88 | struct ib_umem *umem) | ||
89 | { | ||
90 | return -EINVAL; | ||
91 | } | ||
92 | |||
93 | static inline void ib_umem_odp_release(struct ib_umem *umem) {} | ||
94 | |||
95 | #endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */ | ||
96 | |||
97 | #endif /* IB_UMEM_ODP_H */ | ||
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index a41bc5a39ebf..3af5dcad1b69 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -1151,6 +1151,8 @@ struct ib_ucontext { | |||
1151 | struct list_head xrcd_list; | 1151 | struct list_head xrcd_list; |
1152 | struct list_head rule_list; | 1152 | struct list_head rule_list; |
1153 | int closing; | 1153 | int closing; |
1154 | |||
1155 | struct pid *tgid; | ||
1154 | }; | 1156 | }; |
1155 | 1157 | ||
1156 | struct ib_uobject { | 1158 | struct ib_uobject { |