Mesa (master): panfrost: Include glue for out-of-tree legacy code

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 7 01:59:31 UTC 2019


Module: Mesa
Branch: master
Commit: d43ec104b7487d3a8930c0d1cd2a2732967f6275
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d43ec104b7487d3a8930c0d1cd2a2732967f6275

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Tue Feb  5 05:13:50 2019 +0000

panfrost: Include glue for out-of-tree legacy code

In addition to the DRM interface in active development, for legacy
kernels Panfrost has a small, optional, out-of-tree glue repository. For
various reasons, this legacy code should not be included in Mesa proper,
but this commit allows it to coexist peacefully with upstream Panfrost.
If the nondrm repo is cloned/symlinked to the directory
`src/gallium/drivers/panfrost/nondrm`, legacy functionality will be
built. Otherwise, the driver will build normally, though a runtime error
message will be printed if a legacy kernel is detected.

This workaround is icky, but it allows a nearly-upstream Panfrost to
work on real hardware, today. Ideally, this patch will be reverted when
the Panfrost kernel module is mature and we drop legacy support.

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>

---

 src/gallium/drivers/panfrost/.gitignore    |  1 +
 src/gallium/drivers/panfrost/meson.build   | 21 ++++++++++++++++++---
 src/gallium/drivers/panfrost/pan_context.c |  3 ++-
 src/gallium/drivers/panfrost/pan_screen.c  |  9 +++++++--
 src/gallium/drivers/panfrost/pan_screen.h  |  2 +-
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/panfrost/.gitignore b/src/gallium/drivers/panfrost/.gitignore
new file mode 100644
index 0000000000..9d2c2c18be
--- /dev/null
+++ b/src/gallium/drivers/panfrost/.gitignore
@@ -0,0 +1 @@
+nondrm
diff --git a/src/gallium/drivers/panfrost/meson.build b/src/gallium/drivers/panfrost/meson.build
index 9b90035d69..5e799eae11 100644
--- a/src/gallium/drivers/panfrost/meson.build
+++ b/src/gallium/drivers/panfrost/meson.build
@@ -39,7 +39,7 @@ files_panfrost = files(
   'pan_blending.c',
   'pan_blend_shaders.c',
   'pan_wallpaper.c',
-  'pan_pretty_print.c'
+  'pan_pretty_print.c',
 )
 
 inc_panfrost = [
@@ -53,6 +53,21 @@ inc_panfrost = [
   include_directories('midgard'),
 ]
 
+compile_args_panfrost = [
+  '-DGALLIUM_PANFROST',
+  '-Wno-pointer-arith'
+]
+
+overlay = join_paths(meson.source_root(), meson.current_source_dir(), 'nondrm/pan_nondrm.c')
+nondrm_overlay_check = run_command('ls', overlay)
+has_nondrm_overlay = nondrm_overlay_check.returncode() == 0
+
+if has_nondrm_overlay
+  files_panfrost += files('nondrm/pan_nondrm.c')
+  inc_panfrost += include_directories('nondrm/include')
+  compile_args_panfrost += '-DPAN_NONDRM_OVERLAY'
+endif
+
 midgard_nir_algebraic_c = custom_target(
   'midgard_nir_algebraic.c',
   input : 'midgard/midgard_nir_algebraic.py',
@@ -73,11 +88,11 @@ libpanfrost = static_library(
     idep_nir
   ],
   include_directories : inc_panfrost,
-  c_args : [c_vis_args, c_msvc_compat_args],
+  c_args : [c_vis_args, c_msvc_compat_args, compile_args_panfrost],
 )
 
 driver_panfrost = declare_dependency(
-  compile_args : ['-DGALLIUM_PANFROST', '-Wno-pointer-arith'],
+  compile_args : compile_args_panfrost,
   link_with : [libpanfrost, libpanfrostwinsys],
 )
 
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 0551d55318..fb4130362e 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1431,7 +1431,8 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate)
 
 #ifndef DRY_RUN
         
-	int fragment_id = screen->driver->submit_vs_fs_job(ctx, has_draws);
+        bool is_scanout = panfrost_is_scanout(ctx);
+        int fragment_id = screen->driver->submit_vs_fs_job(ctx, has_draws, is_scanout);
 
         /* If visual, we can stall a frame */
 
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index d2ea5a692f..5ee3b4c600 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -50,7 +50,8 @@
 #include "pan_context.h"
 #include "midgard/midgard_compile.h"
 
-#include "pan_drm.h"
+struct panfrost_driver *panfrost_create_drm_driver(int fd);
+struct panfrost_driver *panfrost_create_nondrm_driver(int fd);
 
 static const char *
 panfrost_get_name(struct pipe_screen *screen)
@@ -539,8 +540,12 @@ panfrost_create_screen(int fd, struct renderonly *ro, bool is_drm)
         if (is_drm) {
                 screen->driver = panfrost_create_drm_driver(fd);
         } else {
-                fprintf(stderr, "Legacy (non-DRM) drivers are not supported in upstream Mesa\n");
+#ifdef PAN_NONDRM_OVERLAY
+                screen->driver = panfrost_create_nondrm_driver(fd);
+#else
+                fprintf(stderr, "Legacy (non-DRM) operation requires out-of-tree overlay\n");
                 return NULL;
+#endif
         }
 
 #ifdef DUMP_PERFORMANCE_COUNTERS
diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
index 4c8fe8dd72..59787c8017 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -53,7 +53,7 @@ struct panfrost_driver {
 	void (*unmap_bo) (struct panfrost_context *ctx, struct pipe_transfer *transfer);
 	void (*destroy_bo) (struct panfrost_screen *screen, struct panfrost_bo *bo);
 
-	int (*submit_vs_fs_job) (struct panfrost_context *ctx, bool has_draws);
+	int (*submit_vs_fs_job) (struct panfrost_context *ctx, bool has_draws, bool is_scanout);
 	void (*force_flush_fragment) (struct panfrost_context *ctx);
 	void (*allocate_slab) (struct panfrost_screen *screen,
 		               struct panfrost_memory *mem,




More information about the mesa-commit mailing list