Re: [Mesa-dev] [PATCH] loader: Make drmGetVersion logic conditional on non-pci devices

2014-01-30 Thread Stéphane Marchesin
On Thu, Jan 30, 2014 at 12:07 AM, Eric Anholt e...@anholt.net wrote:

 Stéphane Marchesin marc...@chromium.org writes:

  On systems without libudev, the loader_get_pci_id_for_fd() call will
  return 0, which will trigger the drmGetVersion logic. Sadly, this
  logic assumes that the kernel driver name matches the dri driver name,
  which is not the case on recent intel GPUs (for example i965 dri
  driver and i915 kernel module).
 
  This patch changes this logic by making it conditional on a list of
  known non-pci drivers (freedreno and tegra). This fixes dri on machines
  without libudev.

 So, why are Linux people building without libudev?  Is it just that we
 forgot to make libudev-devel required in configure.ac?


I talked with krh on irc, he seemed opposed to it. But yes, that would be
fine by me. That said, it doesn't answer the question of other OSes. What
should we do there?

Stéphane
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] loader: Make drmGetVersion logic conditional on non-pci devices

2014-01-30 Thread Stéphane Marchesin
On Thu, Jan 30, 2014 at 12:20 AM, Stéphane Marchesin 
stephane.marche...@gmail.com wrote:




 On Thu, Jan 30, 2014 at 12:07 AM, Eric Anholt e...@anholt.net wrote:

 Stéphane Marchesin marc...@chromium.org writes:

  On systems without libudev, the loader_get_pci_id_for_fd() call will
  return 0, which will trigger the drmGetVersion logic. Sadly, this
  logic assumes that the kernel driver name matches the dri driver name,
  which is not the case on recent intel GPUs (for example i965 dri
  driver and i915 kernel module).
 
  This patch changes this logic by making it conditional on a list of
  known non-pci drivers (freedreno and tegra). This fixes dri on machines
  without libudev.

 So, why are Linux people building without libudev?  Is it just that we
 forgot to make libudev-devel required in configure.ac?


 I talked with krh on irc, he seemed opposed to it. But yes, that would be
 fine by me. That said, it doesn't answer the question of other OSes. What
 should we do there?


Oh and of course, there's the recent udev-systemd integration. At least for
Chrome OS I know of no plans to use systemd.

Stéphane
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] loader: Make drmGetVersion logic conditional on non-pci devices

2014-01-30 Thread Lauri Kasanen
On Wed, 29 Jan 2014 17:33:23 -0800
Stéphane Marchesin marc...@chromium.org wrote:

 On systems without libudev, the loader_get_pci_id_for_fd() call will
 return 0, which will trigger the drmGetVersion logic. Sadly, this
 logic assumes that the kernel driver name matches the dri driver name,
 which is not the case on recent intel GPUs (for example i965 dri
 driver and i915 kernel module).
 
 This patch changes this logic by making it conditional on a list of
 known non-pci drivers (freedreno and tegra). This fixes dri on machines
 without libudev.
 ---

Reviewed-by: Lauri Kasanen c...@gmx.com

This should also fix r600 (which got mapped to radeon_dri.so).

As for why I don't have libudev - nothing needed it so far, and now
that udev is in systemd, it will not be coming to my systems.

- Lauri
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] loader: Make drmGetVersion logic conditional on non-pci devices

2014-01-30 Thread Kristian Høgsberg
On Thu, Jan 30, 2014 at 12:20 AM, Stéphane Marchesin
stephane.marche...@gmail.com wrote:



 On Thu, Jan 30, 2014 at 12:07 AM, Eric Anholt e...@anholt.net wrote:

 Stéphane Marchesin marc...@chromium.org writes:

  On systems without libudev, the loader_get_pci_id_for_fd() call will
  return 0, which will trigger the drmGetVersion logic. Sadly, this
  logic assumes that the kernel driver name matches the dri driver name,
  which is not the case on recent intel GPUs (for example i965 dri
  driver and i915 kernel module).
 
  This patch changes this logic by making it conditional on a list of
  known non-pci drivers (freedreno and tegra). This fixes dri on machines
  without libudev.

 So, why are Linux people building without libudev?  Is it just that we
 forgot to make libudev-devel required in configure.ac?


 I talked with krh on irc, he seemed opposed to it. But yes, that would be
 fine by me. That said, it doesn't answer the question of other OSes. What
 should we do there?

I think I made a snarky remark, but I'm not opposed.  I introduced the
libudev dependeny in the first place and I'd be happy to just make
udev a hard requirement. On the other hand, we could keep glx+dri2
working without udev as it has in the past, and only require it for
new window systems (egl, glx+dri3) that have always required it.  I'm
fine either way.

Kristian

 Stéphane


 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] loader: Make drmGetVersion logic conditional on non-pci devices

2014-01-29 Thread Stéphane Marchesin
On systems without libudev, the loader_get_pci_id_for_fd() call will
return 0, which will trigger the drmGetVersion logic. Sadly, this
logic assumes that the kernel driver name matches the dri driver name,
which is not the case on recent intel GPUs (for example i965 dri
driver and i915 kernel module).

This patch changes this logic by making it conditional on a list of
known non-pci drivers (freedreno and tegra). This fixes dri on machines
without libudev.
---
 src/loader/loader.c | 52 ++--
 1 file changed, 34 insertions(+), 18 deletions(-)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index ee4c1e0..71c1252 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -301,34 +301,50 @@ out:
return device_name;
 }
 
-char *
-loader_get_driver_for_fd(int fd, unsigned driver_types)
+static char*
+loader_get_nonpci_name_for_fd(int fd)
 {
-   int vendor_id, chip_id, i, j;
+#ifndef __NOT_HAVE_DRM_H
char *driver = NULL;
+   int i = 0;
+   char* known_nonpci_drivers[] = { msm, kgsl, tegra, NULL };
 
-   if (!driver_types)
-  driver_types = _LOADER_GALLIUM | _LOADER_DRI;
-
-   if (!loader_get_pci_id_for_fd(fd, vendor_id, chip_id)) {
+   /* fallback to drmGetVersion(): */
+   drmVersionPtr version = drmGetVersion(fd);
 
-#ifndef __NOT_HAVE_DRM_H
-  /* fallback to drmGetVersion(): */
-  drmVersionPtr version = drmGetVersion(fd);
+   if (!version) {
+  log_(_LOADER_WARNING, failed to get driver name for fd %d\n, fd);
+  return NULL;
+   }
 
-  if (!version) {
- log_(_LOADER_WARNING, failed to get driver name for fd %d\n, fd);
- return NULL;
+   while (known_nonpci_drivers[i]) {
+  if (!strcmp(version-name, known_nonpci_drivers[i])) {
+ driver = strndup(version-name, version-name_len);
+ log_(_LOADER_INFO, using driver %s for %d\n, driver, fd);
+ break;
   }
+  i++;
+   }
 
-  driver = strndup(version-name, version-name_len);
-  log_(_LOADER_INFO, using driver %s for %d\n, driver, fd);
+   drmFreeVersion(version);
 
-  drmFreeVersion(version);
+   return driver;
+#else
+   return NULL;
 #endif
+}
 
-  return driver;
-   }
+char *
+loader_get_driver_for_fd(int fd, unsigned driver_types)
+{
+   int vendor_id, chip_id, i, j;
+   char *driver = NULL;
+
+   if (!driver_types)
+  driver_types = _LOADER_GALLIUM | _LOADER_DRI;
+
+   if (!loader_get_pci_id_for_fd(fd, vendor_id, chip_id))
+  return loader_get_nonpci_name_for_fd(fd);
 
for (i = 0; driver_map[i].driver; i++) {
   if (vendor_id != driver_map[i].vendor_id)
-- 
1.8.5.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev