All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Lechner <david@lechnology.com>
To: "Noralf Trønnes" <noralf@tronnes.org>, dri-devel@lists.freedesktop.org
Cc: sam@ravnborg.org
Subject: Re: [PATCH v3 1/2] drm: Add library for shmem backed GEM objects
Date: Wed, 12 Sep 2018 20:33:32 -0500	[thread overview]
Message-ID: <f7bb2392-45bb-0aff-f440-a2521144adfe@lechnology.com> (raw)
In-Reply-To: <20180911124400.40588-2-noralf@tronnes.org>

On 09/11/2018 07:43 AM, Noralf Trønnes wrote:
> This adds a library for shmem backed GEM objects with the necessary
> drm_driver callbacks.
> 
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
> 

...

> +static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem)
> +{
> +	struct drm_gem_object *obj = &shmem->base;
> +	int ret;
> +
> +	if (shmem->vmap_use_count++ > 0)
> +		return 0;
> +
> +	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;
> +
> +		switch (shmem->cache_mode) {
> +		case DRM_GEM_SHMEM_BO_UNKNOWN:
> +			DRM_DEBUG_KMS("Can't vmap cache mode is unknown\n");
> +			ret = -EINVAL;
> +			goto err_put_pages;
> +
> +		case DRM_GEM_SHMEM_BO_WRITECOMBINED:
> +			prot = pgprot_writecombine(PAGE_KERNEL);
> +			break;
> +
> +		case DRM_GEM_SHMEM_BO_UNCACHED:
> +			prot = pgprot_noncached(PAGE_KERNEL);
> +			break;
> +
> +		case DRM_GEM_SHMEM_BO_CACHED:
> +			prot = PAGE_KERNEL;
> +			break;
> +		}
> +
> +		shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT, VM_MAP, prot);

I get a gcc warning here:

/home/david/work/ev3dev2/ev3dev-kernel/drivers/gpu/drm/drm_gem_shmem_helper.c:220:18: warning: ‘prot’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT, VM_MAP, prot);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/david/work/ev3dev2/ev3dev-kernel/drivers/gpu/drm/drm_gem_shmem_helper.c:199:12: note: ‘prot’ was declared here
    pgprot_t prot;
             ^~~~

---

And since I am making a comment anyway, it is not clear to me
what BO means in the enum names. I didn't see any hints in the
doc comments either.


> +	}
> +
> +	if (!shmem->vaddr) {
> +		DRM_DEBUG_KMS("Failed to vmap pages\n");
> +		ret = -ENOMEM;
> +		goto err_put_pages;
> +	}
> +
> +	return 0;
> +
> +err_put_pages:
> +	drm_gem_shmem_put_pages(shmem);
> +err_zero_use:
> +	shmem->vmap_use_count = 0;
> +
> +	return ret;
> +}
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-09-13  2:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11 12:43 [PATCH v3 0/2] drm: Add shmem GEM library Noralf Trønnes
2018-09-11 12:43 ` [PATCH v3 1/2] drm: Add library for shmem backed GEM objects Noralf Trønnes
2018-09-13  1:33   ` David Lechner [this message]
2018-09-14 10:10     ` Eric Engestrom
2018-09-14 16:37       ` Noralf Trønnes
2018-09-11 12:44 ` [PATCH v3 2/2] drm/tinydrm: Switch from CMA to shmem buffers Noralf Trønnes
2018-09-13  1:35   ` David Lechner
2018-09-14 15:48 ` [PATCH v3 0/2] drm: Add shmem GEM library Thomas Hellstrom
2018-09-14 16:13   ` Daniel Vetter
2018-09-14 16:51     ` Noralf Trønnes
2018-09-14 17:11       ` Thomas Hellstrom
2018-09-14 18:09         ` Noralf Trønnes
2018-09-14 20:13           ` Thomas Hellstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7bb2392-45bb-0aff-f440-a2521144adfe@lechnology.com \
    --to=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=noralf@tronnes.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.