Re: [PATCH v3 1/2] drm: Add library for shmem backed GEM objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---


...

+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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux