[Intel-gfx] [PATCH 6/9] drm/shmem-helpers: Don't call get/put_pages on imported dma-buf in vmap
Thomas Zimmermann
tzimmermann at suse.de
Thu May 14 07:16:54 UTC 2020
Hi
Am 11.05.20 um 11:35 schrieb Daniel Vetter:
> There's no direct harm, because for the shmem helpers these are noops
> on imported buffers. The trouble is in the locks these take - I want
> to change dma_buf_vmap locking, and so need to make sure that we only
> ever take certain locks on one side of the dma-buf interface: Either
> for exporters, or for importers.
>
> Cc: Gerd Hoffmann <kraxel at redhat.com>
> Cc: Rob Herring <robh at kernel.org>
> Cc: Noralf Trønnes <noralf at tronnes.org>
> Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> ---
> drivers/gpu/drm/drm_gem_shmem_helper.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 2a70159d50ef..b9cba5cc61c3 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -252,32 +252,33 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem)
> if (shmem->vmap_use_count++ > 0)
> return shmem->vaddr;
>
> - ret = drm_gem_shmem_get_pages(shmem);
> - if (ret)
> - goto err_zero_use;
> -
> if (obj->import_attach) {
> shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
> } else {
> pgprot_t prot = PAGE_KERNEL;
>
> + ret = drm_gem_shmem_get_pages(shmem);
> + if (ret)
> + goto err;
> +
> if (!shmem->map_cached)
> prot = pgprot_writecombine(prot);
> shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
> VM_MAP, prot);
> +
> + if (!shmem->vaddr)
> + drm_gem_shmem_put_pages(shmem);
> }
>
> if (!shmem->vaddr) {
> DRM_DEBUG_KMS("Failed to vmap pages\n");
> ret = -ENOMEM;
> - goto err_put_pages;
> + goto err;
> }
>
> return shmem->vaddr;
>
> -err_put_pages:
> - drm_gem_shmem_put_pages(shmem);
I found the new code to be less readable. Maybe keep the error rollback
as-is and protect _put_pages() with if (!import_attach).
In any case
Acked-by: Thomas Zimmermann <tzimmermann at suse.de>
> -err_zero_use:
> +err:
> shmem->vmap_use_count = 0;
>
> return ERR_PTR(ret);
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/intel-gfx/attachments/20200514/16abcb0a/attachment.sig>
More information about the Intel-gfx
mailing list