Skip to contentSkip to conversation

DRM-SHMEM fixes

PATCH Applied Dmitry Osipenko 2 participants 5 messages Jun 30, 2022 – Aug 9, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v7 cover DRM-SHMEM fixes

This series fixes two minor problems in the DRM-SHMEM helper.

Changelog:

v7: - Factored out DRM-SHMEM fixes from [1] since I'll be working on
the dma-buf locking in a separate patchset now.

[1] https://lore.kernel.org/all/[email protected]/

Dmitry Osipenko (2):
drm/shmem-helper: Add missing vunmap on error drm/shmem-helper: Correct doc-comment of drm_gem_shmem_get_sg_table()

 drivers/gpu/drm/drm_gem_shmem_helper.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH v7 1/2 drm/shmem-helper: Add missing vunmap on error

The vmapping of dma-buf may succeed, but DRM SHMEM rejects the IOMEM mapping, and thus, drm_gem_shmem_vmap_locked() should unvmap the IOMEM before erroring out.

Fixes 49a3f51dfeee ("drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends")
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_gem_shmem_helper.c +1 -0
index 8ad0e02991ca..904fc893c905 100644
@@ -302,6 +302,7 @@ static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
 		ret = dma_buf_vmap(obj->import_attach->dmabuf, map);
 		if (!ret) {
 			if (WARN_ON(map->is_iomem)) {
+				dma_buf_vunmap(obj->import_attach->dmabuf, map);
 				ret = -EIO;
 				goto err_put_pages;
 			}
Signature · 1 line
2.36.1
#2 lore raw

Re: [PATCH v7 1/2] drm/shmem-helper: Add missing vunmap on error

Quoted 7 lines · Dmitry Osipenko

The vmapping of dma-buf may succeed, but DRM SHMEM rejects the IOMEM mapping, and thus, drm_gem_shmem_vmap_locked() should unvmap the IOMEM before erroring out.

Fixes 49a3f51dfeee ("drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends")

Pushed to drm-misc-next-fixes, thanks for your patch. -Daniel

Quoted 19 lines
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_gem_shmem_helper.c +1 -0
index 8ad0e02991ca..904fc893c905 100644
@@ -302,6 +302,7 @@ static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
 		ret = dma_buf_vmap(obj->import_attach->dmabuf, map);
 		if (!ret) {
 			if (WARN_ON(map->is_iomem)) {
+				dma_buf_vunmap(obj->import_attach->dmabuf, map);
 				ret = -EIO;
 				goto err_put_pages;
 			}
Signature · 1 line
2.36.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#3 lore raw

PATCH v7 2/2 drm/shmem-helper: Correct doc-comment of drm_gem_shmem_get_sg_table()

In reply to Dmitry Osipenko

drm_gem_shmem_get_sg_table() never returns NULL on error, but a ERR_PTR. Correct the doc comment which says that it returns NULL on error.

---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +4 -2
index 904fc893c905..0b526657fbea 100644
@@ -663,7 +663,8 @@ EXPORT_SYMBOL(drm_gem_shmem_print_info);
  * drm_gem_shmem_get_pages_sgt() instead.
  *
  * Returns:
- * A pointer to the scatter/gather table of pinned pages or NULL on failure.
+ * A pointer to the scatter/gather table of pinned pages or an ERR_PTR()-encoded
+ * error code on failure.
  */
 struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem)
 {
@@ -689,7 +690,8 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table);
  * drm_gem_shmem_get_sg_table() should not be directly called by drivers.
  *
  * Returns:
- * A pointer to the scatter/gather table of pinned pages or errno on failure.
+ * A pointer to the scatter/gather table of pinned pages or an ERR_PTR()-encoded
+ * error code on failure.
  */
 struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
 {
Signature · 1 line
2.36.1
#4 lore raw

Re: [PATCH v7 2/2] drm/shmem-helper: Correct doc-comment of drm_gem_shmem_get_sg_table()

Quoted 14 lines · Dmitry Osipenko

drm_gem_shmem_get_sg_table() never returns NULL on error, but a ERR_PTR. Correct the doc comment which says that it returns NULL on error.

---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +0 -0
index 904fc893c905..0b526657fbea 100644

drivers/gpu/drm/drm_gem_shmem_helper.c EXPORT_SYMBOL(drm_gem_shmem_print_info); · line 667

Quoted 6 lines
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -1
@@ -663,7 +663,8 @@ EXPORT_SYMBOL(drm_gem_shmem_print_info);
  * drm_gem_shmem_get_pages_sgt() instead.
  *
  * Returns:
- * A pointer to the scatter/gather table of pinned pages or NULL on failure.
+ * A pointer to the scatter/gather table of pinned pages or an ERR_PTR()-encoded
+ * error code on failure.

There was a conflict here because another patch adjusted this already, but I fixed it up and merged this to drm-misc-next.

Thanks, Daniel

Quoted 16 lines
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -1
  */
 struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem)
 {
@@ -689,7 +690,8 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table);
  * drm_gem_shmem_get_sg_table() should not be directly called by drivers.
  *
  * Returns:
- * A pointer to the scatter/gather table of pinned pages or errno on failure.
+ * A pointer to the scatter/gather table of pinned pages or an ERR_PTR()-encoded
+ * error code on failure.
  */
 struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
 {
Signature · 1 line
2.36.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch