On Wed, Oct 09, 2019 at 01:09:21PM -0300, Jason Gunthorpe wrote: > -static void mlx5_ib_prefetch_mr_work(struct work_struct *work) > +static int mlx5_ib_prefetch_sg_list(struct ib_pd *pd, > + enum ib_uverbs_advise_mr_advice advice, > + u32 pf_flags, struct ib_sge *sg_list, > + u32 num_sge) > { > - struct prefetch_mr_work *w = > - container_of(work, struct prefetch_mr_work, work); > + struct mlx5_ib_dev *dev = to_mdev(pd->device); > + u32 bytes_mapped = 0; > + int srcu_key; > + int ret = 0; > + u32 i; > > - if (ib_device_try_get(w->pd->device)) { > - mlx5_ib_prefetch_sg_list(w->pd, w->pf_flags, w->sg_list, > - w->num_sge); > - ib_device_put(w->pd->device); > + srcu_key = srcu_read_lock(&dev->mr_srcu); > + for (i = 0; i < num_sge; ++i) { > + struct mlx5_ib_mr *mr; > + > + mr = get_prefetchable_mr(pd, advice, sg_list[i].lkey); > + if (!mr) { > + ret = -ENOENT; > + goto out; > + } > + ret = pagefault_mr(mr, sg_list[i].addr, sg_list[i].length, > + &bytes_mapped, pf_flags); > + if (ret < 0) > + goto out; > } There is a mistake here, 'ret' has to be 0 when this function succeeds but pagefault_mr returns >0 on success. Needs a 'ret = 0' at this point Jason