[PATCH 2/3] drm/panfrost: Don't try to map pages that are already mapped

Steven Price steven.price at arm.com
Mon Feb 1 12:13:42 UTC 2021


On 01/02/2021 08:21, Boris Brezillon wrote:
> We allocate 2MB chunks at a time, so it might appear that a page fault
> has already been handled by a previous page fault when we reach
> panfrost_mmu_map_fault_addr(). Bail out in that case to avoid mapping the
> same area twice.
> 
> Cc: <stable at vger.kernel.org>
> Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations")
> Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>

Reviewed-by: Steven Price <steven.price at arm.com>

> ---
>   drivers/gpu/drm/panfrost/panfrost_mmu.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> index 904d63450862..21e552d1ac71 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> @@ -488,8 +488,14 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
>   		}
>   		bo->base.pages = pages;
>   		bo->base.pages_use_count = 1;
> -	} else
> +	} else {
>   		pages = bo->base.pages;
> +		if (pages[page_offset]) {
> +			/* Pages are already mapped, bail out. */
> +			mutex_unlock(&bo->base.pages_lock);
> +			goto out;
> +		}
> +	}
>   
>   	mapping = bo->base.base.filp->f_mapping;
>   	mapping_set_unevictable(mapping);
> @@ -522,6 +528,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
>   
>   	dev_dbg(pfdev->dev, "mapped page fault @ AS%d %llx", as, addr);
>   
> +out:
>   	panfrost_gem_mapping_put(bomapping);
>   
>   	return 0;
> 



More information about the dri-devel mailing list