Too many callers relied on the refcnt being handled correctly. Use a simple
wrapper to handle that case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
There's no point in turning on outputs connected to GPU screens during initial
configuration. Not only does this cause them to just display black, it also
confuses clients when these screens are attached to a master screen and RandR
reports that the outputs are already on.
Also, don't print the warning about no outputs being found on GPU screens,
since that's expected.
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Dave Airlie <airlied@gmail.com>
I didn't think we needed this before, but after doing some more
work with reverse optimus it seems like it should be called.
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
scrn->display is a property of the main screen really, and we don't
want to have the GPU screens use it for anything when picking modes
or a front buffer size.
This fixes a bug where when you plugged a display link device, it
would try and allocate a screen the same size as the current running
one (3360x1050 in this case), which was too big for the device. Avoid
doing this and just pick sizes based on whats plugged into this device.
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
When we disconnect an output/offload slave set the changed bits,
so a later TellChanged can do something.
Then when we remove a GPU slave device, sent change notification
to the protocol screen.
This allows hot unplugged USB devices to disappear in clients.
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
commit 6703a7c7cf
Author: Keith Packard <keithp@keithp.com>
Date: Tue Jan 8 20:24:32 2013 -0800
hw/xfree86: Require only one working CRTC to start the server.
changed the logic to try to set the mode on all connected outputs rather
than abort upon the first failure. The return error code was then
tweaked such that it reported success if it set a mode on any crtc.
However, this confuses the headless case where we never enable any crtcs
and also, importantly, never fail to set a crtc.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59190
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Also-written-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Fixes build on non-udev systems, since XSERVER_PLATFORM_BUS is only
defined in configure.ac if $CONFIG_UDEV_KMS is true.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
So when we VT switch back and attempt to flush the input devices,
we don't succeed because evdev won't return part of an event,
since we were only asking for 4 bytes, we'd only get -EINVAL back.
This could later cause events to be flushed that we shouldn't have
gotten.
This is a fix for CVE-2013-1940.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Revert 70739e817b and mostly revert
c31eac647a.
Further investigation shows the encountered race condition is between
lightdm and plymouth-splash, as implemented in the Ubuntu distribution
within the limitations of upstart's job coordination logic, and can (and
should) be fixed within those limiations. Not in xserver itself.
This leaves some of the diagnostic improvements from the recent patch
series, in case others run into a similar situation.
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This path is technically executed through config/udev, but having two
messages in the form "config/udev: Adding drm device" makes it appear as if
the udev filters are wrong and it's trying to add the same device twice. In
fact, it's only one device, only added once, but a duplicate log message.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
We don't want to hotplug output devices while we are VT switched,
as we get races between multiple X servers on the device open, and
drm device master status. This just queues device opens until we return
from VT switch.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This replaces some previous uses of direct xf86Screens[0] accesses.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@gmail.com>
This is just a simple interface to avoid accessing x86Screens[0]
directly.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@gmail.com>
This removes a large number of redundant declaration warnings.
Signed-off-by: Jeremy White <jwhite@codeweavers.com>
Reviewed-by: Robert Morell <rmorell@nvidia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
If other processes have had drm open previously, xserver may attempt to
open the device too early and fail, with xserver error exit "Cannot
run in framebuffer mode" or Xorg.0.log messages about "setversion 1.4
failed".
In this situation, we're receiving back -EACCES from libdrm. To address
this we need to re-set ourselves as the drm master, and keep trying to
set the interface until it works (or until we give up).
See https://bugs.launchpad.net/ubuntu/+source/libdrm/+bug/982889
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
And if we've had to delay booting due to not being able to set the
interface, fess up.
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
Section "Monitor"
Identifier "a21inch"
Option "PreferredMode" "1600x1200"
Option "ZoomModes" "1600x1200 1280x1024 1280x1024 640x480"
EndSection
The option's effect is to search for and mark once each named mode in
the output modes list. So the specification order is free and the zoom
modes sequence follows the order of the output modes list. All marked
modes are available via the Ctrl+Alt+Keypad-{Plus,Minus} key
combination.
See also http://bugs.freedesktop.org/show_bug.cgi?id=17954.
This option has its use for combined monitor and television setups.
It allows for easy switching between 60 Hz and 50 Hz modes even when a
monitor refuses to display the input signal.
(Includes a few minor changes suggested by Aaron for v2)
Signed-off-by: Servaas Vandenberghe <vdb@picaros.org>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Otherwise, displays driven by GPU screens remain on all the time.
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
So in the cold plug server shutdown case, we reap the resources
before we call CloseScreen handlers, so the config->randr_provider
is a dangling pointer when the xf86CrtcCloseScreen handler is called,
however in the hot screen unplug case, we can't rely on automatically
reaped resources, so we need to clean up the provider in the xf86CrtcCloseScreen
case.
This patch provides a cleanup callback from the randr provider removal
into the DDX so it can cleanup properly, this then gets called by the automatic
code for cold plug, or if hot unplug it gets called explicitly.
Fixes a number of random server crashes on shutdown
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58174
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=891140
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
The previous fix for the previous fix, didn't fully work,
If we don't set compat_output we end up doing derferences
of arrays with -1, leading to valgrind warnings.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Due to another bug, the modesetting/udl driver would fail to init properly
on hotplug, when it did the code didn't clean up properly, and on removing
the device the server could crash.
Found in F18 testing.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
xf86Cursor.c:19:18: warning: redundant redeclaration of 'inputInfo'
[-Wredundant-decls]
In file included from xf86Cursor.c:18:0:
../../../include/inputstr.h:614:57: note: previous declaration of
'inputInfo' was here
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Unused as of 5d309af2ed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
This is necessary when the input handler deletes itself from the
list. Bug found by Maarten Lankhorst, this patch uses the list macros
instead of open-coding the fix.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
man xorg.conf states that the 'Device' identifier is required in the
'Screen' section, yet current xserver defaults properly and boots up
fine without it.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=20742
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Instead of defaulting to -intel for Oaktrail, Medfield, and CDV chips,
default to -fbdev. For Poulsbo (only), attempt to use -psb if it's
installed, and fallback to fbdev otherwise. All other Intel chips
should use -intel.
This fixed an issue where -intel would load on these chips and cause a
boot failure. Newer -intel drivers avoid the boot hang, but it's still
the wrong driver to load, so why take chances.
The patch was originally created by Stefan Dirsch for OpenSUSE. We have
included it in our stable release (Ubuntu "quantal" 12.10) since
December.
ref: https://bugzilla.novell.com/show_bug.cgi?id=772279
ref: https://bugs.launchpad.net/ubuntu/+bug/1069031
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=60514
Signed-off-by: Bryce Harrington <bryce@canonical.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
If we're about to abort, we're already in the signal handler and cannot call
down to the default device cleanup routines (which reset, free, alloc, and
do a bunch of other things).
Add a new DEVICE_ABORT mode to signal a driver's DeviceProc that it must
reset the hardware if needed but do nothing else. An actual HW reset is only
required for some drivers dealing with the HW directly.
This is largely backwards-compatible, hence the input ABI minor bump only.
Drivers we care about either return BadValue on a mode that's not
DEVICE_{INIT|ON|OFF|CLOSE} or print an error and return BadValue. Exception
here is vmmouse, which currently ignores it and would not reset anything.
This should be fixed if the reset is required.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
If acpid sends a string in a format that we can't parse, bail out instead of
potentially dereferencing a NULL-pointer.
X.Org Bug 73227 <http://bugs.freedesktop.org/show_bug.cgi?id=73227>
Signed-off-by: Ted Felix <ted@tedfelix.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Call find_header first, returning on failure before calling malloc.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Found by parfait 1.1 memory analyser:
Memory leak of pointer 'pAdapt' allocated with malloc((88 * num_adaptors))
at line 162 of hw/xfree86/common/xf86xvmc.c in function 'xf86XvMCScreenInit'.
'pAdapt' allocated at line 158 with malloc((88 * num_adaptors)).
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Also avoids leaving invalid pointers in structures if realloc had to
move them elsewhere to make them larger.
Found by parfait 1.1 code analyzer:
Memory leak of pointer 'newCallbacks' allocated with realloc(((char*)offman->FreeBoxesUpdateCallback), (8 * (offman->NumCallbacks + 1)))
at line 328 of hw/xfree86/common/xf86fbman.c in function 'localRegisterFreeBoxCallback'.
'newCallbacks' allocated at line 320 with realloc(((char*)offman->FreeBoxesUpdateCallback), (8 * (offman->NumCallbacks + 1))).
newCallbacks leaks when newCallbacks != NULL at line 327.
Memory leak of pointer 'newPrivates' allocated with realloc(((char*)offman->devPrivates), (8 * (offman->NumCallbacks + 1)))
at line 328 of hw/xfree86/common/xf86fbman.c in function 'localRegisterFreeBoxCallback'.
'newPrivates' allocated at line 324 with realloc(((char*)offman->devPrivates), (8 * (offman->NumCallbacks + 1))).
newPrivates leaks when newCallbacks == NULL at line 327.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reported by parfait 1.1 code analyzer:
Error: Null pointer dereference (CWE 476)
Read from null pointer 'p'
at line 746 of hw/xfree86/common/xf86Option.c in function 'xf86TokenToOptName'.
Function 'xf86TokenToOptinfo' may return constant 'NULL' at line 721, called at line 745.
Null pointer introduced at line 721 in function 'xf86TokenToOptinfo'.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Our in-house parfait 1.1 code analysis tool complained that every exit
path from xf86ValidateModes() in hw/xfree86/common/xf86Mode.c leaks the
storeClockRanges allocation made at line 1501 with XNFalloc.
Investigating, it seems that this code to copy the clock range list to
the clockRanges list in the screen pointer is just plain insane, and
according to git, has been since we first imported it from XFree86.
We start at line 1495 by walking the linked list from scrp->clockRanges
until we find the end. But that was just a diversion, since we've found
the end and immediately forgotten it, and thus at 1499 we know that
storeClockRanges is NULL, but that's not a problem since we're going to
immediately overwrite that value as the first thing in the loop.
So we move on through this loop at 1499, which takes us through the
linked list from the clockRanges variable, and for every entry in
that list allocates a new structure and copies cp to it. If we've
not filled in the screen's clockRanges pointer yet, we set it to
the first storeClockRanges we copied from cp. Otherwise, as best
I can tell, we just drop it into memory and let it leak away, as
parfait warned.
And then we hit the loop action, which if we haven't hit the end of
the cp list, advances cp to the next item in the list, and then just
for the fun of it, also sets storeClockRanges to the ->next pointer it
has just copied from cp as well, even though it's going to overwrite
it as the very first instruction in the loop body.
v2: rewritten using nt_list_* macros from Xorg's list.h header
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
The changes to miPointerSetPosition interface from int->double breaks
the SIS driver build, so time to bump this.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
DGA only handles master devices but it does intercept slave device events as
well (since the event handlers are per event type, not per device).
The DGA code must thus call into UpdateDeviceState to reset the button/key
state on the slave device before it discards the remainder of the event.
Test case:
- Passive GrabModeSync on VCP
- Press button
- Enable DGA after ButtonPress
- AllowEvents(SyncPointer)
- Release button
The button release is handled by DGAProcessPointerEvent but the device state
is never updated, so the slave ends up with the button permanently down.
And since the master's button state is the union of the slave states, the
master has the button permanently down.
X.Org Bug 59100 <http://bugs.freedesktop.org/show_bug.cgi?id=59100>
Reported-by: Steven Elliott <selliott4@austin.rr.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reported-by: Steven Elliott <selliott4@austin.rr.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>