Commit Graph

36 Commits

Author SHA1 Message Date
Chris Wilson e0c93a3e53 intel: If a non-root user starts X, don't release master
SET_MASTER and DROP_MASTER are only available to the root user. If we
are started as an ordinary user, and we are master by virtue of being
the first user of the device, never release our fd or master.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-04-09 18:55:18 +01:00
Chris Wilson 7cf0676ff8 intel: Do not close server fds
If we are given an fd by the Xserver, then it is not our responsibility
to close it during CloseScreen.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Hans de Goede <hdegoede@redhat.com>
2014-03-20 08:52:12 +00:00
Chris Wilson 9f4c121974 intel: Refactor finding device path if unknown
Since we already lookup the device path if we do not know it after
opening the fd, we can remove the special case along the legacy PCI
probe path.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-20 08:48:40 +00:00
Hans de Goede 6446bf96f0 intel: Don't close the fd on probe failure if it is server managed
I hit this corner case when testing a single X server spanning both intel
gfx + an usb display link adapter driven by xf86-video-modesetting.

In this scenario the intel driver gets its platformProbe method called first,
and if it then closes the server managed fd, the xf86-video-modesetting gets
EBADFD errors.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-03-18 15:55:54 +00:00
Chris Wilson 4a6e09c6cd uxa: Add support for server managed fds (via intel_device)
Based on the patch by Hans de Goede, this removes the handling of
drmOpen() and DRM_MASTER from within uxa and instead uses the common
routines. This reduces the duplicate code from within uxa, and enables
new features such as server managed fds.

Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-18 15:52:19 +00:00
Chris Wilson 923b158e5c intel: Fallback to drmGetDeviceNameFromFd()
If we are not supplied the path, call the libdrm function to search for
the canonical name for our device.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-13 08:14:48 +00:00
Chris Wilson dd1ff32302 intel: Protect against a NULL platform device with server fd
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-11 10:06:24 +00:00
Chris Wilson d10a5abcbd intel: Supply a fallback guess for the device path
If for some reason we have an fd, but no device path, use the likely
default path (derived from and validated against the major/minor of the
open device fd).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-10 22:19:25 +00:00
Hans de Goede 28cab948f5 intel: Add support for server managed fds
In the post-modern world, the platform device nodes are handed to a
non-privileged Xserver by systemd/logind. We can then query the core for
our assigned fd rather than try to open the device for ourselves (which
would fail when trying to obtain DRM_MASTER status). A consequence is
that we then do not directly control DRM_MASTER status and must act as a
delegate of systemd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-03-10 22:19:25 +00:00
Hans de Goede a01548ccf1 intel: export fd_set_cloexec / fd_set_nonblock
Allow fd_set_cloexec / fd_set_nonblock to be used outside of intel_device.c.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-02-15 02:32:25 +00:00
Hans de Goede 5601f8cc33 intel: Fix fd_set_nonblock
O_NONBLOCK is a status flag not a descriptor flag, so F_GETFL / F_SETFL should
be used to modify it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-02-15 00:01:30 +00:00
Chris Wilson 35ea7b2dd5 intel: Silence a compiler warning (-Wshadow)
intel_device.c: In function 'intel_entity_get_devid':
intel_device.c:82:32: warning: declaration of 'index' shadows a global declaration [-Wshadow]

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-01-17 12:55:33 +00:00
Chris Wilson 76b14a90c1 sna: Quieten a couple of valgrind warnings about unknown ioctls
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-28 20:55:41 +00:00
Chris Wilson 7284e7f48b intel: Filter out the control bit from the device minor
When computing the render node for the device, filter out the potential
control node.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-05 23:00:49 +01:00
Chris Wilson a0476ee6d0 intel: Allow opening the device only through platform information
Only fail to open the device based on the PCI address, if and only if we
do not have sufficient platform information to find the correct system
device.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-03 16:15:22 +01:00
Chris Wilson a47f8683fe intel: Handle fallback probing without match_data
One extreme fallback path through the xf86PlatformProbe results in a
call without any match data. As we have a device by this point, we can
simply do a reverse match.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-03 16:15:22 +01:00
Chris Wilson 6c157a925f intel: Remove dependence upon having PciInfo
After some probing mechanisms, we may end up with a valid device without
knowing its PCI address a priori. Having a valid device, we can just
query it for the correct device id, and can safely abort any path that
requires PCI information that we don't have. (Those paths are not valid
under such hosting anyway - if it may be required, we could reconstruct
the address.)

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-03 16:13:38 +01:00
Chris Wilson 58b26055f4 intel: Querying device attributes must be non-NULL
Check first for a NULL platform device before querying the attributes or
else suffer a segfault during PCI probing.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-03 14:09:26 +01:00
Chris Wilson b7d5292e01 intel: Fix fallout from accident push of ODEV_ATTRIB_FD
This is WIP for passing along a hosted fd. It wasn't meant to be pushed
along with the bug fix this morning.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-03 13:38:06 +01:00
Chris Wilson 3b3a5ca603 intel: Query platform fd
Under a compositor, we wish to use the pre-authorized fd passed to us by
the host, stashed away in the platform device.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-02 18:29:38 +01:00
Chris Wilson 7978592048 intel: Pass the platform device along to the open routines
This allows us to pass along more metadata along with the platform
device in future. Currently we pass the device path, but in a hosted
environment we should be passing along the authorized fd from the host.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-02 18:24:47 +01:00
Chris Wilson dcf9b5ae18 intel: Compile fixes for base install of SLED11.sp3
Highlights of that distribution include xorg-xserver-1.6.5, kernel
3.0.76 and gcc-4.3.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-18 12:49:41 +01:00
Chris Wilson 0c697aee9b Revert "sna: Add XMir support"
This reverts commit 42d94356f6.

Ordered-by: The Management.
2013-09-07 08:42:26 +01:00
Chris Wilson 42d94356f6 sna: Add XMir support
With lots of updates by Christopher James Halse Rogers as he updated the
XMir API - but now supposedly frozen!

"<RAOF> ickle: I think the xmir api should be pretty much stable now,
barring people coming up with more awesome ways of doing things."

Signed-off-by: Christopher James Halse Rogers <raof@ubuntu.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-04 15:18:29 +01:00
Chris Wilson dbf5751b5b sna: Open the device non-blocking
This is essential to prevent deadlocks when running with ZaphodHeads.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-08-31 10:35:36 +01:00
Chris Wilson 8b0d69e76c intel: Add experimental rendernode support
Render nodes allow clients full access to off-screen rendering and GPU
offload, without assuming any master responsiblities (for device and
display management). As they have a more limited interface, they can be
used in a more permissive manner.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-08-23 19:27:23 +01:00
Chris Wilson b6b5c3f009 intel: Disable incompatible features whilst hosted
Start adding the infrastructure to disable direct hardware access if X
is being run under a system compositor (aka "hosted").

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-08-09 11:46:24 +01:00
Chris Wilson 282507af8e intel: Move the validation of the KMS device into the open routine
Currently we leak the fd should we open the device node and decide that
is not a GEM/KMS kernel driver. The simplest way to perform the cleanup
upon failure is to move the checking for GEM/KMS into the device open
routine.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-07-02 09:38:07 +01:00
Chris Wilson 5005bd2d52 intel: Fix failure code for reporting !drmCheckModesetingSupported
The new function returns the fd, not a Bool, so the error code must now
be -1.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-30 15:02:19 +01:00
Jonathan Gray f8738d7b4c intel: replace direct ioctl use with drm{Set, Drop}Master
Use drmSetMaster/drmDropMaster instead of calling the ioctls
directly.  Fixes compilation on OpenBSD where these ioctls
aren't defined.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
2013-06-30 11:32:24 +01:00
Chris Wilson 40301e6d03 sna: Store the path used to open the device and pass to DRI
Avoid having to search the device tree once again in order to simply
recover the path we used to open the device.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-30 11:32:24 +01:00
Chris Wilson 48b5ac11a0 intel: Use fcntl to try and set CLOEXEC if the open(O_CLOEXEC) fails
As suggested by Arkadiusz Miskiewicz.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-27 21:42:13 +01:00
Chris Wilson 9b3e5c2114 intel: #ifdef O_CLOEXEC for compilation on squeeze
If the system doesn't support O_CLOEXEC, then we simply can't use it.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-27 21:09:38 +01:00
Chris Wilson 98feba417c sna: Drop master when closing the screen
As we reacquire master when initialisation the next gen of the server,
to keep the reference counting consistent we need to release our master
reference on CloseScreen.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-25 18:36:59 +01:00
Chris Wilson febfd38823 intel: Use the correct errno value for reporting the drmSetVersion failure
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-25 18:05:28 +01:00
Chris Wilson 7ec0378b64 sna: Only open the /dev/dri/cardX device once
Merge the device open in the main driver with the probing so that we can
open the path explicitly passed in by the PlatformProbe and keep that fd
around for the main driver and so avoid a later search.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-06-23 07:33:56 +01:00