@@ -160,16 +160,11 @@ static void unpin_rcv_pages(struct hfi1_filedata *fd,
160
160
static int pin_rcv_pages (struct hfi1_filedata * fd , struct tid_user_buf * tidbuf )
161
161
{
162
162
int pinned ;
163
- unsigned int npages ;
163
+ unsigned int npages = tidbuf -> npages ;
164
164
unsigned long vaddr = tidbuf -> vaddr ;
165
165
struct page * * pages = NULL ;
166
166
struct hfi1_devdata * dd = fd -> uctxt -> dd ;
167
167
168
- /* Get the number of pages the user buffer spans */
169
- npages = num_user_pages (vaddr , tidbuf -> length );
170
- if (!npages )
171
- return - EINVAL ;
172
-
173
168
if (npages > fd -> uctxt -> expected_count ) {
174
169
dd_dev_err (dd , "Expected buffer too big\n" );
175
170
return - EINVAL ;
@@ -196,7 +191,6 @@ static int pin_rcv_pages(struct hfi1_filedata *fd, struct tid_user_buf *tidbuf)
196
191
return pinned ;
197
192
}
198
193
tidbuf -> pages = pages ;
199
- tidbuf -> npages = npages ;
200
194
fd -> tid_n_pinned += pinned ;
201
195
return pinned ;
202
196
}
@@ -274,6 +268,7 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
274
268
mutex_init (& tidbuf -> cover_mutex );
275
269
tidbuf -> vaddr = tinfo -> vaddr ;
276
270
tidbuf -> length = tinfo -> length ;
271
+ tidbuf -> npages = num_user_pages (tidbuf -> vaddr , tidbuf -> length );
277
272
tidbuf -> psets = kcalloc (uctxt -> expected_count , sizeof (* tidbuf -> psets ),
278
273
GFP_KERNEL );
279
274
if (!tidbuf -> psets ) {
0 commit comments