Skip to contentSkip to conversation

xf86drm: open correct render node on non-linux

PATCH In review Jonathan Gray 2 participants 3 messages May 12, 2019 – Jul 3, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xf86drm: open correct render node on non-linux

drm render nodes have the same major as drm primary devices but offset the minor by a base of 128.

I expected the name of the device to have numbering starting at 0 when these non-linux codepaths were added (before OpenBSD had render nodes).

---
 xf86drm.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)
xf86drm.c +6 -18
index 42022cac..0763fd26 100644
@@ -2931,7 +2931,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
     char buf[PATH_MAX + 1];
     const char *dev_name;
     unsigned int maj, min;
-    int n, base;
+    int n;
 
     if (fstat(fd, &sbuf))
         return NULL;
@@ -2956,11 +2956,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
         return NULL;
     };
 
-    base = drmGetMinorBase(type);
-    if (base < 0)
-        return NULL;
-
-    n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= sizeof(buf))
         return NULL;
 
@@ -3854,7 +3850,7 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
     char             node[PATH_MAX + 1];
     const char      *dev_name;
     int              node_type, subsystem_type;
-    int              maj, min, n, ret, base;
+    int              maj, min, n, ret;
 
     if (fd == -1 || device == NULL)
         return -EINVAL;
@@ -3886,11 +3882,7 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
         return -EINVAL;
     };
 
-    base = drmGetMinorBase(node_type);
-    if (base < 0)
-        return -EINVAL;
-
-    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= PATH_MAX)
       return -errno;
     if (stat(node, &sbuf))
@@ -4110,7 +4102,7 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
     char             node[PATH_MAX + 1];
     const char      *dev_name;
     int              node_type;
-    int              maj, min, n, base;
+    int              maj, min, n;
 
     if (fstat(fd, &sbuf))
         return NULL;
@@ -4139,11 +4131,7 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
         return NULL;
     };
 
-    base = drmGetMinorBase(node_type);
-    if (base < 0)
-        return NULL;
-
-    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= PATH_MAX)
       return NULL;
 
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jonathan Gray

drm render nodes have the same major as drm primary devices but offset the minor by a base of 128.

I expected the name of the device to have numbering starting at 0 when these non-linux codepaths were added (before OpenBSD had render nodes).

I didn't check that OpenBSD is the way you say, but the libdrm code here matches with that, so this patch is

and pushed :)

Quoted 81 lines
---
 xf86drm.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)
xf86drm.c +6 -18
index 42022cac..0763fd26 100644
@@ -2931,7 +2931,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
     char buf[PATH_MAX + 1];
     const char *dev_name;
     unsigned int maj, min;
-    int n, base;
+    int n;
 
     if (fstat(fd, &sbuf))
         return NULL;
@@ -2956,11 +2956,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
         return NULL;
     };
 
-    base = drmGetMinorBase(type);
-    if (base < 0)
-        return NULL;
-
-    n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= sizeof(buf))
         return NULL;
 
@@ -3854,7 +3850,7 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
     char             node[PATH_MAX + 1];
     const char      *dev_name;
     int              node_type, subsystem_type;
-    int              maj, min, n, ret, base;
+    int              maj, min, n, ret;
 
     if (fd == -1 || device == NULL)
         return -EINVAL;
@@ -3886,11 +3882,7 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
         return -EINVAL;
     };
 
-    base = drmGetMinorBase(node_type);
-    if (base < 0)
-        return -EINVAL;
-
-    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= PATH_MAX)
       return -errno;
     if (stat(node, &sbuf))
@@ -4110,7 +4102,7 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
     char             node[PATH_MAX + 1];
     const char      *dev_name;
     int              node_type;
-    int              maj, min, n, base;
+    int              maj, min, n;
 
     if (fstat(fd, &sbuf))
         return NULL;
@@ -4139,11 +4131,7 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
         return NULL;
     };
 
-    base = drmGetMinorBase(node_type);
-    if (base < 0)
-        return NULL;
-
-    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= PATH_MAX)
       return NULL;
 
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 7 lines · Eric Engestrom
Quoted 6 lines · Jonathan Gray

drm render nodes have the same major as drm primary devices but offset the minor by a base of 128.

I expected the name of the device to have numbering starting at 0 when these non-linux codepaths were added (before OpenBSD had render nodes).

Quoted 6 lines
Quoted 1 line

I didn't check that OpenBSD is the way you say, but the libdrm code here matches with that, so this patch is

and pushed :)

Thanks for looking over these and pushing. OpenBSD snapshots have contained these changes as local patches since I sent the mails out so not expecting any issues.

We are trying to keep the kernel side as close as possible to the original linux code.

Quoted 75 lines
Quoted 75 lines
---
 xf86drm.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)
xf86drm.c +6 -18
index 42022cac..0763fd26 100644
@@ -2931,7 +2931,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
     char buf[PATH_MAX + 1];
     const char *dev_name;
     unsigned int maj, min;
-    int n, base;
+    int n;
 
     if (fstat(fd, &sbuf))
         return NULL;
@@ -2956,11 +2956,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
         return NULL;
     };
 
-    base = drmGetMinorBase(type);
-    if (base < 0)
-        return NULL;
-
-    n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= sizeof(buf))
         return NULL;
 
@@ -3854,7 +3850,7 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
     char             node[PATH_MAX + 1];
     const char      *dev_name;
     int              node_type, subsystem_type;
-    int              maj, min, n, ret, base;
+    int              maj, min, n, ret;
 
     if (fd == -1 || device == NULL)
         return -EINVAL;
@@ -3886,11 +3882,7 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
         return -EINVAL;
     };
 
-    base = drmGetMinorBase(node_type);
-    if (base < 0)
-        return -EINVAL;
-
-    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= PATH_MAX)
       return -errno;
     if (stat(node, &sbuf))
@@ -4110,7 +4102,7 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
     char             node[PATH_MAX + 1];
     const char      *dev_name;
     int              node_type;
-    int              maj, min, n, base;
+    int              maj, min, n;
 
     if (fstat(fd, &sbuf))
         return NULL;
@@ -4139,11 +4131,7 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
         return NULL;
     };
 
-    base = drmGetMinorBase(node_type);
-    if (base < 0)
-        return NULL;
-
-    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+    n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
     if (n == -1 || n >= PATH_MAX)
       return NULL;
 
Quoted 7 lines
Quoted 7 lines
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel