Skip to content

Commit 605728e

Browse files
Artemy-Mellanoxjgunthorpe
authored andcommitted
IB/umem: Set correct address to the invalidation function
The invalidate range was using PAGE_SIZE instead of the computed 'end', and had the wrong transformation of page_index due the weird construction. This can trigger during error unwind and would cause malfunction. Inline the code and correct the math. Fixes: 403cd12 ("IB/umem: Add contiguous ODP support") Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com> Signed-off-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 4d5422a commit 605728e

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/infiniband/core/umem_odp.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,6 @@ static void ib_umem_notifier_release(struct mmu_notifier *mn,
137137
up_read(&per_mm->umem_rwsem);
138138
}
139139

140-
static int invalidate_page_trampoline(struct ib_umem_odp *item, u64 start,
141-
u64 end, void *cookie)
142-
{
143-
ib_umem_notifier_start_account(item);
144-
item->umem.context->invalidate_range(item, start, start + PAGE_SIZE);
145-
ib_umem_notifier_end_account(item);
146-
return 0;
147-
}
148-
149140
static int invalidate_range_start_trampoline(struct ib_umem_odp *item,
150141
u64 start, u64 end, void *cookie)
151142
{
@@ -553,12 +544,13 @@ static int ib_umem_odp_map_dma_single_page(
553544
put_page(page);
554545

555546
if (remove_existing_mapping && umem->context->invalidate_range) {
556-
invalidate_page_trampoline(
547+
ib_umem_notifier_start_account(umem_odp);
548+
umem->context->invalidate_range(
557549
umem_odp,
558-
ib_umem_start(umem) + (page_index >> umem->page_shift),
559-
ib_umem_start(umem) + ((page_index + 1) >>
560-
umem->page_shift),
561-
NULL);
550+
ib_umem_start(umem) + (page_index << umem->page_shift),
551+
ib_umem_start(umem) +
552+
((page_index + 1) << umem->page_shift));
553+
ib_umem_notifier_end_account(umem_odp);
562554
ret = -EAGAIN;
563555
}
564556

0 commit comments

Comments
 (0)