Historically we ignored pgoff, as it was a "fake" offset that simply served to map back to the gem handle. Mmaping a partial obj was dis- allowed.
But we can instead just subtract off the fake offset. drm_gem_mmap() still expects an exact match on pgoff, so unless we use our own path for that, like some other drivers, we don't fully support partial mmap. But this at least makes things more robust if userspace does funny things like partal unmap. Signed-off-by: Rob Clark <[email protected]> --- drivers/gpu/drm/msm/msm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 000dfcec7809..5826fd69abe4 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -374,8 +374,8 @@ static vm_fault_t msm_gem_fault(struct vm_fault *vmf) return vmf_error(PTR_ERR(pages)); } - /* We don't use vmf->pgoff since that has the fake offset: */ - pgoff = linear_page_delta(vma, vmf->address); + pgoff = linear_page_index(vma, vmf->address) - + drm_vma_node_start(&obj->vma_node); pfn = page_to_pfn(pages[pgoff]); -- 2.56.0
