mbox series

[v4,00/10] drm/msm: Userspace allocated GPU addresses

Message ID 20220411215849.297838-1-robdclark@gmail.com
Headers show
Series drm/msm: Userspace allocated GPU addresses | expand

Message

Rob Clark April 11, 2022, 9:58 p.m. UTC
From: Rob Clark <robdclark@chromium.org>

The first six paches are various cleanups and simplifications.  The
next two get rid of redundant vma lookups in the submit and retire
paths.  Following that, fenced vma lets us indicate a fence value
following which the vma is no longer used, which is needed because
otherwise userspace could observe the signaled fence prior to
retire_submits() finishing.  (With userspace allocated GPU addresses
userspace is tracking when a buffer is no longer used and it's vma can
be deleted.)  And finally the last patch adds the new uabi for user-
space allocated iova.

v2: Fix inuse check in last patch, split GEM_WARN_ON() conversion to
    separate patch, and nits
v3: Fix nested fb prepares in 06/10, return -EBUSY if trying to set
    iova on buffer that already has one in 10/10
v4: Fix race condition in 09/10

Rob Clark (10):
  drm/msm/gem: Move prototypes
  drm/msm/gpu: Drop duplicate fence counter
  drm/msm/gem: Convert some missed GEM_WARN_ON()s
  drm/msm/gem: Split out inuse helper
  drm/msm/gem: Drop PAGE_SHIFT for address space mm
  drm/msm: Drop msm_gem_iova()
  drm/msm/gem: Rework vma lookup and pin
  drm/msm/gem: Split vma lookup and pin
  drm/msm/gem: Add fenced vma unpin
  drm/msm: Add a way for userspace to allocate GPU iova

 drivers/gpu/drm/msm/adreno/a5xx_gpu.c   |   2 +-
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c   |   2 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c   |   2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c |  14 ++-
 drivers/gpu/drm/msm/msm_drv.c           |  21 ++++
 drivers/gpu/drm/msm/msm_drv.h           |  23 ----
 drivers/gpu/drm/msm/msm_fb.c            |  20 +++-
 drivers/gpu/drm/msm/msm_fence.c         |   6 +-
 drivers/gpu/drm/msm/msm_fence.h         |   3 +
 drivers/gpu/drm/msm/msm_gem.c           | 151 ++++++++++++++----------
 drivers/gpu/drm/msm/msm_gem.h           |  52 +++++++-
 drivers/gpu/drm/msm/msm_gem_submit.c    |  32 ++---
 drivers/gpu/drm/msm/msm_gem_vma.c       |  61 +++++++---
 drivers/gpu/drm/msm/msm_gpu.c           |   8 +-
 drivers/gpu/drm/msm/msm_gpu.h           |   2 +-
 drivers/gpu/drm/msm/msm_ringbuffer.c    |  13 +-
 drivers/gpu/drm/msm/msm_ringbuffer.h    |   1 -
 include/uapi/drm/msm_drm.h              |   3 +
 18 files changed, 277 insertions(+), 139 deletions(-)

Comments

Dmitry Baryshkov April 14, 2022, 9:22 p.m. UTC | #1
On 12/04/2022 00:58, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
> 
> Signed-off-by: Rob Clark <robdclark@chromium.org>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---
>   drivers/gpu/drm/msm/msm_gem_vma.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c
> index f914ddbaea89..64906594fc65 100644
> --- a/drivers/gpu/drm/msm/msm_gem_vma.c
> +++ b/drivers/gpu/drm/msm/msm_gem_vma.c
> @@ -44,7 +44,7 @@ void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
>   	unsigned size = vma->node.size << PAGE_SHIFT;
>   
>   	/* Print a message if we try to purge a vma in use */
> -	if (WARN_ON(vma->inuse > 0))
> +	if (GEM_WARN_ON(vma->inuse > 0))
>   		return;
>   
>   	/* Don't do anything if the memory isn't mapped */
> @@ -61,7 +61,7 @@ void msm_gem_purge_vma(struct msm_gem_address_space *aspace,
>   void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
>   		struct msm_gem_vma *vma)
>   {
> -	if (!WARN_ON(!vma->iova))
> +	if (!GEM_WARN_ON(!vma->iova))
>   		vma->inuse--;
>   }
>   
> @@ -73,7 +73,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace,
>   	unsigned size = npages << PAGE_SHIFT;
>   	int ret = 0;
>   
> -	if (WARN_ON(!vma->iova))
> +	if (GEM_WARN_ON(!vma->iova))
>   		return -EINVAL;
>   
>   	/* Increase the usage counter */
> @@ -100,7 +100,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace,
>   void msm_gem_close_vma(struct msm_gem_address_space *aspace,
>   		struct msm_gem_vma *vma)
>   {
> -	if (WARN_ON(vma->inuse > 0 || vma->mapped))
> +	if (GEM_WARN_ON(vma->inuse > 0 || vma->mapped))
>   		return;
>   
>   	spin_lock(&aspace->lock);
> @@ -120,7 +120,7 @@ int msm_gem_init_vma(struct msm_gem_address_space *aspace,
>   {
>   	int ret;
>   
> -	if (WARN_ON(vma->iova))
> +	if (GEM_WARN_ON(vma->iova))
>   		return -EBUSY;
>   
>   	spin_lock(&aspace->lock);