summaryrefslogtreecommitdiffstats
path: root/src/loader/loader.c
Commit message (Collapse)AuthorAgeFilesLines
* loader: cleanup copyright sectionEmil Velikov2016-10-181-40/+2
| | | | | | | | | | | With previous patches nearly all the original code (as seen in the various loaders) is gone. Update the copyright/license section to reflect that. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* loader: remove loader_get_driver_for_fd() driver_typeEmil Velikov2016-10-181-7/+1
| | | | | | | | | | | | | | Reminiscent from the pre-loader days, were we had multiple instances of the loader logic in separate places and one could build a "GALLIUM_ONLY" version. Since that is no longer the case and the loaders (glx/egl/gbm) do not (and should not) require to know any classic/gallium specific we can drop the argument and the related code. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* loader: remove final sysfs codepath in loader_get_device_name_for_fd()Emil Velikov2016-10-181-46/+1
| | | | | | | | | | | | | | Effectively everyone with actual hardware and/or requesting the "device_name" requires a working libdrm. Thus they could/should already be using the (now only) codepath. Apart from the code simplification, we can slim down our configure.ac even further. But that will be done in separate patch(es). Cc: Gary Wong <gtw@gnu.org> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* loader: remove libudev_get_device_name_for_fd and related codeEmil Velikov2016-10-181-126/+0
| | | | | | | | With this all the libudev related code is now gone. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* loader: reimplement loader_get_user_preferred_fd via libdrmEmil Velikov2016-10-181-141/+106
| | | | | | | | | | | | | | | | Currently not everyone has libudev and with follow-up patches we'll completely remove the divergent codepaths. Use the libdrm drm device API to construct the required ID_PATH_TAG-like string, to preserve the current functionality for libudev users and allow others to benefit from it as well. v2: Drop ranty comments, pick the correct device v3: \n -> \0 in PCI_ID_PATH_TAG_LENGTH comment (Axel). v4: Use snprintf (Nicolai) Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr>
* loader: annotate __driConfigOptionsLoader as staticEmil Velikov2016-10-181-1/+1
| | | | | | Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* loader: separate USE_DRICONF code into separate functionEmil Velikov2016-10-181-12/+18
| | | | | | | | Improves readability and allows us to do further cleanups a lot easier. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* loader: slim down loader_get_pci_id_for_fd implementation(s)Emil Velikov2016-10-181-156/+16
| | | | | | | | | | | | | | | | Currently mesa has three code paths in the loader - libudev, manual sysfs and drm ioctl one. Considering the issues we had with libudev - strip those down in favour of the libdrm drm device API. The latter can be implemented in any way depending on the platform and can be reused by others. v2: Use correct message on drmGetDevice failure. (Nicolai) Cc: Jonathan Gray <jsg@jsg.id.au> Cc: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr>
* loader: fix sysfs uevent file parsingFrank Binns2016-09-011-2/+4
| | | | | | | | | | When trying to get a device name for an fd using sysfs, it would always fail as it was expecting key/value pairs to be delimited by '\0', which is not the case. Signed-off-by: Frank Binns <frank.binns@imgtec.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* mesa: Use AC_HEADER_MAJOR to include correct header for major().Matt Turner2016-07-261-2/+5
| | | | | | Gentoo has been smoke testing an upcoming change to glibc. Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=580392
* loader: add a libdrm case for loader_get_device_name_for_fdJonathan Gray2016-04-211-1/+25
| | | | | | | | | Use dev_node_from_fd() with HAVE_LIBDRM to provide an implmentation of loader_get_device_name_for_fd() for non-linux systems that use libdrm but don't have udev or sysfs. Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* loader: use HAVE_LIBDRM instead of ! __NOT_HAVE_DRM_HEmil Velikov2015-07-221-4/+4
| | | | | | | | Double negatives in English language are normally avoided, plus the former seems cleaner and more consistent. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* loader: don't leak udev_enumerateGuillaume Desmottes2015-07-111-0/+4
| | | | | | Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90073 Signed-off-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: Look for any version of currently linked libudev.soChris Wilson2015-07-081-18/+28
| | | | | | | | | | | | | | | | | | | | | | Since there was an ABI break and linking twice against libudev.so.0 and libudev.so.1 causes the application to quickly crash, we first check if the application is currently linked against libudev before dlopening a local handle. However for backwards/forwards compatability, we need to inspect the application for current linkage against all known versions first. Not doing so causes a crash when both libraries are present and so mesa chooses libudev.so.1 but the application was linked against libudev.so.0. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Emil Velikov: I'm ever so slightly conserned that RTLD_NOLOAD is not part of the POSIX standard, thus it's missing on some platforms (*BSD seems ok, while Solaris, MacOS are not). Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Cc: mesa-stable@lists.freedesktop.org
* loader: move loader_open_device out of HAVE_LIBUDEV blockJulien Isorce2015-06-241-18/+18
| | | | | | | | | | | | | | | | | | Fixes the following build issue, when building without libudev. CCLD libGL.la ./.libs/libglx.a(dri2_glx.o): In function `dri2CreateScreen': src/glx/dri2_glx.c:1186: undefined reference to `loader_open_device' collect2: ld returned 1 exit status CCLD libEGL.la Undefined symbols for architecture x86_64: "_loader_open_device", referenced from: _dri2_initialize_x11_dri2 in libegl_dri2.a(platform_x11.o) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91077 Signed-off-by: Julien Isorce <j.isorce@samsung.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: Rename drm_open_device() to loader_open_device() and share itDerek Foreman2015-06-231-3/+3
| | | | | | | | | This is already our common idiom for opening files with CLOEXEC and it's a little ugly, so let's share this one implementation. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: include <sys/stat.h> for non-sysfs buildsEmil Velikov2015-03-161-1/+1
| | | | | | | | | | | Required by fstat(), otherwise we'll error out due to implicit function declaration. Cc: "10.4 10.5" <mesa-stable@lists.freedesktop.org> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89530 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reported-by: Vadim Rutkovsky <vrutkovs@redhat.com> Tested-by: Vadim Rutkovsky <vrutkovs@redhat.com>
* loader: not having a pci-id should not be a warnRob Clark2015-02-211-3/+6
| | | | | | | | | | If there is no pci-id, which is valid for vc4 and freedreno, just emit an info msg. Keep malformed but existing pci-id's as a warning. Mostly just to clean up a warning that confuses users for the non-pci devices. Signed-off-by: Rob Clark <robclark@freedesktop.org>
* loader: Check dlsym() did not fail in libudev_get_device_name_for_fd()Juha-Pekka Heikkila2014-09-231-0/+3
| | | | | Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
* loader: fds can be 0Dave Airlie2014-09-061-1/+1
| | | | | | | | Possible resource leak reported by coverity. Reported-by: Coverity scanner. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
* loader: Use drirc device_id parameter in complement to DRI_PRIMEAxel Davy2014-07-011-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | DRI_PRIME is not very handy, because you have to launch the executable with it set, which is not always easy to do. By using drirc, the user specifies the target executable and the device to use. After that the program will be launched everytime on the target device. For example if .drirc contains: <driconf> <device driver="loader"> <application name="Glmark2" executable="glmark2"> <option name="device_id" value="pci-0000_01_00_0" /> </application> </device> </driconf> Then glmark2 will use if possible the render-node of ID_PATH_TAG pci-0000_01_00_0. v2: Fix compilation issue v3: Add "-lm" and rebase. Signed-off-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
* loader: add gpu selection code via DRI_PRIME.Axel Davy2014-07-011-0/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v2: Fix the leak of device_name v3: Rebased It enables to use the DRI_PRIME env var to specify which gpu to use. Two syntax are supported: If DRI_PRIME is 1 it means: take any other gpu than the default one. If DRI_PRIME is the ID_PATH_TAG of a device: choose this device if possible. The ID_PATH_TAG is a tag filled by udev. You can check it with 'udevadm info' on the device node. For example it can be "pci-0000_01_00_0". Render-nodes need to be enabled to choose another gpu, and they need to have the ID_PATH_TAG advertised. It is possible for not very recent udev that the tag is not advertised for render-nodes, then ones need to add a file containing: SUBSYSTEM=="drm", IMPORT{builtin}="path_id" in /etc/udev/rules.d/ Signed-off-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
* loader: add optional /sys filesystem method for PCI identification.Gary Wong2014-05-291-0/+112
| | | | | | | | | | | | Introduce a simple PCI identification method of looking up the answer the /sys filesystem (available on Linux). Attempted after libudev, but before DRM. Disabled by default (available only when the --enable-sysfs configure option is specified). Signed-off-by: Gary Wong <gtw@gnu.org> Acked-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: allow attempting more than one method of PCI identification.Gary Wong2014-05-291-18/+46
| | | | | | | | | | | loader_get_pci_id_for_fd() and loader_get_device_name_for_fd() now attempt all available strategies to identify the hardware, instead of conditionally compiling in a single test. The existing libudev and DRM approaches have been retained, attempting first libudev (if available) and then DRM (if necessary). Signed-off-by: Gary Wong <gtw@gnu.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: don't limit the non-udev path to only androidJonathan Gray2014-04-051-1/+1
| | | | | | | | | | | | | Platforms that lack libudev (OpenBSD and possibly others) need this change in order to load the correct dri driver. Under linux we unconditionally require libudev, thus this code will never get build. v2: Add commit message (Emil Velikov) Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Cc: "10.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: use 0 instead of FALSE which isn't definedJonathan Gray2014-04-051-2/+2
| | | | | | Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Cc: "10.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: add special logic to distinguish nouveau from nouveau_vieuxIlia Mirkin2014-03-191-1/+4
| | | | | | | | | | | There are a lot of different pci ids supported by nouveau, and more are added all the time. The relevant distinguisher between drivers is the chipset id. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Cc: "10.1" <mesa-stable@lists.freedesktop.org>
* dri: Add a useful error message if someone's packages missed libudev deps.Eric Anholt2014-02-011-0/+5
| | | | Reviewed-by: Matt Turner <mattst88@gmail.com>
* dri: Also support the loader with libudev.so.0.Eric Anholt2014-02-011-0/+10
| | | | | | | | | As far as I know, this should be safe. If not, we have to decide whether to have variable lookup of the functions, or just drop support for .so.0 (which is a year and a half old it looks like) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74127 Reviewed-by: Matt Turner <mattst88@gmail.com>
* loader: do not print the pci id during normal operationEmil Velikov2014-01-291-1/+1
| | | | | | | | | | | | Spamming the pci id is not beneficial. Make sure it's printed only when needed. v2: Change severity to _LOADER_DEBUG, rather than removing the message. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* loader: print WARNING and FATAL messages using the default loggerEmil Velikov2014-01-291-1/+1
| | | | | | | | Lower values are used for more severe cases. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* loader: include dlfcn.h when building with HAVE_LIBUDEVEmil Velikov2014-01-281-0/+2
| | | | | | | | | | | | | The code depending on the definitions is already wrapped in the same conditional so go ahead and wrap the include. Otherwise we'll brake compilation on platforms that are missing the header. Add assert.h in there as well, as it is introduced and used in the same fashon. Cc: Eric Anholt <eric@anholt.net> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74122 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
* loader: Add missing \n on message printingEmil Velikov2014-01-271-12/+11
| | | | | | | | Cover both loader and glx/dri_glx Drop \n from the default loader logger Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* loader: Use dlsym to get our udev symbols instead of explicit linking.Eric Anholt2014-01-271-0/+42
| | | | | | | | | | | | | | | | Steam links against libudev.so.0, while we're linking against libudev.so.1. The result is that the symbol names (which are the same in the two libraries) end up conflicting, and some of the usage of .so.1 calls the .so.0 bits, which have different internal structures, and segfaults happen. By using a dlopen() with RTLD_LOCAL, we can explicitly look for the symbols we want, while they get the symbols they want. Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Tested-by: Alexandre Demers <alexandre.f.demers@gmail.com> Tested-by: Mike Lothian <mike@fireburn.co.uk>
* logger: Remove unused variable.José Fonseca2014-01-201-1/+0
| | | | | | Silences gcc "unused variable ‘buf’" warning. Trivial.
* logger: s/\<log\>/log_/José Fonseca2014-01-201-13/+13
| | | | | | | | | Currently the MSVC build is broken because of conflicting definitions of 'log' function. I didn't investigate thoroughly, but I suspect the it is conflicting standard math.h's log. log_ is admittedly not a great name, but it is better than a broken build. A better one can be used in a follow-on build.
* loader: ifdef libdrm specific code and includeEmil Velikov2014-01-191-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Mesa provides the flexibility of building without the need to have libdrm present on the system. The situation has regressed with the recent commit commit 8c2e7fd8460750543367053b1be9368cc38e1d6a Author: Emil Velikov <emil.l.velikov@gmail.com> Date: Fri Jan 10 23:36:16 2014 +0000 loader: introduce the loader util lib By isolating libdrm code by #ifndef __NOT_HAVE_DRM_H we can have libdrm-less builds on across all build systems. This patch converts Android's _EGL_NO_DRM to __NOT_HAVE_DRM_H to provide consistency with the other cases within mesa, allows compilation of libloader on libdrm-less scons and conditionally links against libdrm if present under automake. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73776 BUgzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73777 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* loader: fallback to drmGetVersion() for non-pci devicesRob Clark2014-01-181-2/+14
| | | | | | | | | | | | Use the kernel driver name are returned by drmGetVersion() for non-pci(platform) devices. Signed-off-by: Rob Clark <robclark@freedesktop.org> v2 (Emil): Rebased and weaked commit message. Reviewed-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* loader: introduce the loader util libEmil Velikov2014-01-181-0/+304
All the various window system integration layers duplicate roughly the same code for figuring out device and driver name, pci-id's, etc. Which is sad. So extract it out into a loader util lib. v2 (Emil) * Separate the introduction of libloader from the code de-duplication. * Strip out non-pci devices support. * Add scons + Android build system support. * Add VISIBILITY_CFLAGS to avoid exporting the loader funcs. v3 (Emil) * PIPE_OS_ANDROID is undefined at this scope, use ANDROID * Make sure we define _EGL_NO_DRM when building only swrast Signed-off-by: Rob Clark <robclark@freedesktop.org> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>