summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2019-01-28 20:22:57 +0100
committerMarge Bot <eric+marge@anholt.net>2021-03-11 14:41:48 +0000
commit187218395d7c9e8257ac17c7cbf1cc7add5c9363 (patch)
tree6c43146300a304baf783672432899b7890883b29 /src/gallium/winsys
parent5487847d8c75b40ef53d881c9abe0afcca378e26 (diff)
renderonly: remove layering violations
The renderonly object is something the winsys creates, so the pipe driver has no business in memcpying or freeing it. Move those bits to the winsys. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Guido G√ľnther <agx@sigxcpu.org> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6983>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c27
-rw-r--r--src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c85
2 files changed, 72 insertions, 40 deletions
diff --git a/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c b/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
index 6c40453f3c9..d5670af8686 100644
--- a/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
+++ b/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
@@ -185,14 +185,29 @@ unlock:
return pscreen;
}
+static void etnaviv_ro_destroy(struct renderonly *ro)
+{
+ FREE(ro);
+}
+
struct pipe_screen *
etna_drm_screen_create(int fd)
{
- struct renderonly ro = {
- .create_for_resource = renderonly_create_gpu_import_for_resource,
- .kms_fd = -1,
- .gpu_fd = fd
- };
- return etna_drm_screen_create_renderonly(&ro);
+ struct renderonly *ro = CALLOC_STRUCT(renderonly);
+ struct pipe_screen *screen;
+
+ if (!ro)
+ return NULL;
+
+ ro->create_for_resource = renderonly_create_gpu_import_for_resource;
+ ro->destroy = etnaviv_ro_destroy;
+ ro->kms_fd = -1;
+ ro->gpu_fd = fd;
+
+ screen = etna_drm_screen_create_renderonly(ro);
+ if (!screen)
+ FREE(ro);
+
+ return screen;
}
diff --git a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
index bf599a1497c..9000a6ac3ed 100644
--- a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
+++ b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
@@ -36,92 +36,109 @@
#include "pipe/p_screen.h"
#include "renderonly/renderonly.h"
+#include "util/u_memory.h"
+
+static void kmsro_ro_destroy(struct renderonly *ro)
+{
+ FREE(ro);
+}
struct pipe_screen *kmsro_drm_screen_create(int fd,
const struct pipe_screen_config *config)
{
struct pipe_screen *screen = NULL;
- struct renderonly ro = {
- .kms_fd = fd,
- .gpu_fd = -1,
- };
+ struct renderonly *ro = CALLOC_STRUCT(renderonly);
+
+ if (!ro)
+ return NULL;
+
+ ro->kms_fd = fd;
+ ro->gpu_fd = -1;
+ ro->destroy = kmsro_ro_destroy;
#if defined(GALLIUM_VC4)
- ro.gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER);
- if (ro.gpu_fd >= 0) {
+ ro->gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER);
+ if (ro->gpu_fd >= 0) {
/* Passes the vc4-allocated BO through to the KMS-only DRM device using
* PRIME buffer sharing. The VC4 BO must be linear, which the SCANOUT
* flag on allocation will have ensured.
*/
- ro.create_for_resource = renderonly_create_gpu_import_for_resource,
- screen = vc4_drm_screen_create_renderonly(&ro, config);
+ ro->create_for_resource = renderonly_create_gpu_import_for_resource;
+ screen = vc4_drm_screen_create_renderonly(ro, config);
if (!screen)
- close(ro.gpu_fd);
+ goto out_free;
return screen;
}
#endif
#if defined(GALLIUM_ETNAVIV)
- ro.gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER);
- if (ro.gpu_fd >= 0) {
- ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
- screen = etna_drm_screen_create_renderonly(&ro);
+ ro->gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER);
+ if (ro->gpu_fd >= 0) {
+ ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource;
+ screen = etna_drm_screen_create_renderonly(ro);
if (!screen)
- close(ro.gpu_fd);
+ goto out_free;
return screen;
}
#endif
#if defined(GALLIUM_FREEDRENO)
- ro.gpu_fd = drmOpenWithType("msm", NULL, DRM_NODE_RENDER);
- if (ro.gpu_fd >= 0) {
- ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
- screen = fd_drm_screen_create(ro.gpu_fd, &ro);
+ ro->gpu_fd = drmOpenWithType("msm", NULL, DRM_NODE_RENDER);
+ if (ro->gpu_fd >= 0) {
+ ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource;
+ screen = fd_drm_screen_create(ro->gpu_fd, ro);
if (!screen)
- close(ro.gpu_fd);
+ goto out_free;
return screen;
}
#endif
#if defined(GALLIUM_PANFROST)
- ro.gpu_fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER);
+ ro->gpu_fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER);
- if (ro.gpu_fd >= 0) {
- ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
- screen = panfrost_drm_screen_create_renderonly(&ro);
+ if (ro->gpu_fd >= 0) {
+ ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
+ screen = panfrost_drm_screen_create_renderonly(ro);
if (!screen)
- close(ro.gpu_fd);
+ goto out_free;
return screen;
}
#endif
#if defined(GALLIUM_LIMA)
- ro.gpu_fd = drmOpenWithType("lima", NULL, DRM_NODE_RENDER);
- if (ro.gpu_fd >= 0) {
- ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
- screen = lima_drm_screen_create_renderonly(&ro);
+ ro->gpu_fd = drmOpenWithType("lima", NULL, DRM_NODE_RENDER);
+ if (ro->gpu_fd >= 0) {
+ ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
+ screen = lima_drm_screen_create_renderonly(ro);
if (!screen)
- close(ro.gpu_fd);
+ goto out_free;
return screen;
}
#endif
#if defined(GALLIUM_V3D)
- ro.gpu_fd = drmOpenWithType("v3d", NULL, DRM_NODE_RENDER);
- if (ro.gpu_fd >= 0) {
- ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
- screen = v3d_drm_screen_create_renderonly(&ro, config);
+ ro->gpu_fd = drmOpenWithType("v3d", NULL, DRM_NODE_RENDER);
+ if (ro->gpu_fd >= 0) {
+ ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
+ screen = v3d_drm_screen_create_renderonly(ro, config);
if (!screen)
- close(ro.gpu_fd);
+ goto out_free;
return screen;
}
#endif
return screen;
+
+out_free:
+ if (ro->gpu_fd >= 0)
+ close(ro->gpu_fd);
+ FREE(ro);
+
+ return NULL;
}