drm-shim: Let the driver choose to overwrite the first render node.
authorEric Anholt <eric@anholt.net>
Tue, 21 Apr 2020 16:21:52 +0000 (09:21 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Apr 2020 17:54:54 +0000 (17:54 +0000)
When I was writing drm-shim, I was focused on the v3d kmsro case -- use my
intel device as the kmsro display device and add on a simulator-based v3d
device that we could render with.  But for the noop backends we use for
shader-db, it's a lot more useful to just overwrite the first render node
in the system so that you don't have to pass a -d <how many render nodes I
already have in my system> argument.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4664>

src/broadcom/drm-shim/v3d.c
src/broadcom/drm-shim/v3d_noop.c
src/drm-shim/drm_shim.c
src/drm-shim/drm_shim.h
src/etnaviv/drm-shim/etnaviv_noop.c
src/freedreno/drm-shim/freedreno_noop.c

index 81e34c128e20b235fbd1ff8a8bc2861f226da1c0..f4d5bd31323390fba62d07a3d85cfe4bc11dd0cc 100644 (file)
@@ -28,6 +28,8 @@
 #include "v3d.h"
 #include "v3d_simulator_wrapper.h"
 
+bool drm_shim_driver_prefers_first_render_node = false;
+
 static struct v3d_device_info devinfo;
 struct v3d_shim_device v3d = {
         .devinfo = &devinfo
index 3caa757bb3ed1b25f85511445b8b183b8e41c2ca..fd92e8859c5a14f78dd4bb80395c1745261375ba 100644 (file)
@@ -28,6 +28,8 @@
 #include "drm-uapi/v3d_drm.h"
 #include "drm-shim/drm_shim.h"
 
+bool drm_shim_driver_prefers_first_render_node = true;
+
 struct v3d_bo {
         struct shim_bo base;
         uint32_t offset;
index 325a8a142e52756cb3335e12c1c65c7df999105a..61a1cb2ae50224cfeecb13542efb439ad9070529 100644 (file)
@@ -97,9 +97,11 @@ struct file_override {
 };
 static struct file_override file_overrides[10];
 static int file_overrides_count;
+extern bool drm_shim_driver_prefers_first_render_node;
 
-/* Come up with a filename for a render node that doesn't actually exist on
- * the system.
+/* Pick the minor and filename for our shimmed render node.  This can be
+ * either a new one that didn't exist on the system, or if the driver wants,
+ * it can replace the first render node.
  */
 static void
 get_dri_render_node_minor(void)
@@ -110,7 +112,8 @@ get_dri_render_node_minor(void)
       asprintf(&render_node_path, "/dev/dri/%s",
                render_node_dirent_name);
       struct stat st;
-      if (stat(render_node_path, &st) == -1) {
+      if (drm_shim_driver_prefers_first_render_node ||
+          stat(render_node_path, &st) == -1) {
 
          render_node_minor = minor;
          return;
index 2d262fa35d49344eed7a8baddb9f2016682e51c1..4a151d49bbc7c3ec23e5830d39eaf784721fa178 100644 (file)
@@ -85,3 +85,4 @@ uint64_t drm_shim_bo_get_mmap_offset(struct shim_fd *shim_fd,
 
 /* driver-specific hooks. */
 void drm_shim_driver_init(void);
+extern bool drm_shim_driver_prefers_new_render_node;
index f583e299a54540c3759de1d322ac0153848a01d7..77bb8d0d0dcdef0f5c4eddb287817259c5f3790f 100644 (file)
@@ -31,6 +31,8 @@
 #include "drm-shim/drm_shim.h"
 #include "util/u_debug.h"
 
+bool drm_shim_driver_prefers_first_render_node = true;
+
 struct etna_shim_gpu
 {
    const char *name;
index 48f1c8953f94dd45f7b120eee4b970c1f5698b01..b282ab6347f5fc3da302646234bedce8eb4a4e77 100644 (file)
@@ -28,6 +28,8 @@
 #include "drm-uapi/msm_drm.h"
 #include "drm-shim/drm_shim.h"
 
+bool drm_shim_driver_prefers_first_render_node = true;
+
 struct msm_bo {
        struct shim_bo base;
        uint32_t offset;