mm/hmm: make hmm_range_fault return 0 or -1
authorJason Gunthorpe <jgg@mellanox.com>
Fri, 1 May 2020 18:20:45 +0000 (15:20 -0300)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 11 May 2020 13:47:29 +0000 (10:47 -0300)
commitbe957c886d92aa9caf0f63aee2c77d1497217d93
tree945037adedcbcdbf4f3f6e309334d1c0eb583e3f
parent0e698dfa282211e414076f9dc7e83c1c288314fd
mm/hmm: make hmm_range_fault return 0 or -1

hmm_vma_walk->last is supposed to be updated after every write to the
pfns, so that it can be returned by hmm_range_fault(). However, this is
not done consistently. Fortunately nothing checks the return code of
hmm_range_fault() for anything other than error.

More importantly last must be set before returning -EBUSY as it is used to
prevent reading an output pfn as an input flags when the loop restarts.

For clarity and simplicity make hmm_range_fault() return 0 or -ERRNO. Only
set last when returning -EBUSY.

Link: https://lore.kernel.org/r/2-v2-b4e84f444c7d+24f57-hmm_no_flags_jgg@mellanox.com
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Tested-by: Ralph Campbell <rcampbell@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Documentation/vm/hmm.rst
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/nouveau/nouveau_svm.c
include/linux/hmm.h
mm/hmm.c