forked from Minki/linux
drm/gem: Share code between drm_gem_fb_{begin,end}_cpu_access()
The error-recovery code in drm_gem_fb_begin() is of the same pattern as drm_gem_fb_end(). Implement both of them using an internal helper. No functional changes. v2: * print additional information in error message (Javier) * fix commit description (Javier) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Tested-by: Noralf Trønnes <noralf@tronnes.org> Acked-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220517113327.26919-2-tzimmermann@suse.de
This commit is contained in:
parent
c193a003dc
commit
f159b1b22c
@ -403,6 +403,28 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_gem_fb_vunmap);
|
EXPORT_SYMBOL(drm_gem_fb_vunmap);
|
||||||
|
|
||||||
|
static void __drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir,
|
||||||
|
unsigned int num_planes)
|
||||||
|
{
|
||||||
|
struct dma_buf_attachment *import_attach;
|
||||||
|
struct drm_gem_object *obj;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
while (num_planes) {
|
||||||
|
--num_planes;
|
||||||
|
obj = drm_gem_fb_get_obj(fb, num_planes);
|
||||||
|
if (!obj)
|
||||||
|
continue;
|
||||||
|
import_attach = obj->import_attach;
|
||||||
|
if (!import_attach)
|
||||||
|
continue;
|
||||||
|
ret = dma_buf_end_cpu_access(import_attach->dmabuf, dir);
|
||||||
|
if (ret)
|
||||||
|
drm_err(fb->dev, "dma_buf_end_cpu_access(%u, %d) failed: %d\n",
|
||||||
|
ret, num_planes, dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* drm_gem_fb_begin_cpu_access - prepares GEM buffer objects for CPU access
|
* drm_gem_fb_begin_cpu_access - prepares GEM buffer objects for CPU access
|
||||||
* @fb: the framebuffer
|
* @fb: the framebuffer
|
||||||
@ -422,7 +444,7 @@ int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direct
|
|||||||
struct dma_buf_attachment *import_attach;
|
struct dma_buf_attachment *import_attach;
|
||||||
struct drm_gem_object *obj;
|
struct drm_gem_object *obj;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret, ret2;
|
int ret;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(fb->obj); ++i) {
|
for (i = 0; i < ARRAY_SIZE(fb->obj); ++i) {
|
||||||
obj = drm_gem_fb_get_obj(fb, i);
|
obj = drm_gem_fb_get_obj(fb, i);
|
||||||
@ -433,28 +455,13 @@ int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direct
|
|||||||
continue;
|
continue;
|
||||||
ret = dma_buf_begin_cpu_access(import_attach->dmabuf, dir);
|
ret = dma_buf_begin_cpu_access(import_attach->dmabuf, dir);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_dma_buf_end_cpu_access;
|
goto err___drm_gem_fb_end_cpu_access;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_dma_buf_end_cpu_access:
|
err___drm_gem_fb_end_cpu_access:
|
||||||
while (i) {
|
__drm_gem_fb_end_cpu_access(fb, dir, i);
|
||||||
--i;
|
|
||||||
obj = drm_gem_fb_get_obj(fb, i);
|
|
||||||
if (!obj)
|
|
||||||
continue;
|
|
||||||
import_attach = obj->import_attach;
|
|
||||||
if (!import_attach)
|
|
||||||
continue;
|
|
||||||
ret2 = dma_buf_end_cpu_access(import_attach->dmabuf, dir);
|
|
||||||
if (ret2) {
|
|
||||||
drm_err(fb->dev,
|
|
||||||
"dma_buf_end_cpu_access() failed during error handling: %d\n",
|
|
||||||
ret2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_gem_fb_begin_cpu_access);
|
EXPORT_SYMBOL(drm_gem_fb_begin_cpu_access);
|
||||||
@ -472,23 +479,7 @@ EXPORT_SYMBOL(drm_gem_fb_begin_cpu_access);
|
|||||||
*/
|
*/
|
||||||
void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir)
|
void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir)
|
||||||
{
|
{
|
||||||
size_t i = ARRAY_SIZE(fb->obj);
|
__drm_gem_fb_end_cpu_access(fb, dir, ARRAY_SIZE(fb->obj));
|
||||||
struct dma_buf_attachment *import_attach;
|
|
||||||
struct drm_gem_object *obj;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
while (i) {
|
|
||||||
--i;
|
|
||||||
obj = drm_gem_fb_get_obj(fb, i);
|
|
||||||
if (!obj)
|
|
||||||
continue;
|
|
||||||
import_attach = obj->import_attach;
|
|
||||||
if (!import_attach)
|
|
||||||
continue;
|
|
||||||
ret = dma_buf_end_cpu_access(import_attach->dmabuf, dir);
|
|
||||||
if (ret)
|
|
||||||
drm_err(fb->dev, "dma_buf_end_cpu_access() failed: %d\n", ret);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_gem_fb_end_cpu_access);
|
EXPORT_SYMBOL(drm_gem_fb_end_cpu_access);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user