xfree86: recognize primary BUS_PCI device in xf86IsPrimaryPlatform()

The new platform bus code and the old PCI bus code overlap. Platform bus
can handle any type of device, including PCI devices, whereas the PCI code
can only handle PCI devices. Some drivers only support the old style
PCI-probe methods, but the primary device detection code is server based,
not driver based; so we might end up with a primary device which only has
a PCI bus-capable driver, but was detected as primary by the platform
code, or the other way around.

(The above paragraph was shamelessly stolen from Hans de Goede, and
customized.)

The latter case applies to QEMU's virtio-gpu-pci device: it is detected as
a BUS_PCI primary device, but we actually probe it first (with the
modesetting driver) through xf86platformProbeDev(). The
xf86IsPrimaryPlatform() function doesn't recognize the device as primary
(it bails out as soon as it sees BUS_PCI); instead, we add the device as a
secondary graphics card under "autoAddGPU". In turn, the success of this
automatic probing-as-GPU prevents xf86CallDriverProbe() from proceeding to
the PCI probing.

The result is that the server exits with no primary devices detected.

Commit cf66471353 ("xfree86: use udev to provide device enumeration for
kms devices (v10)") added "cross-bus" matching to xf86IsPrimaryPci(). Port
that now to xf86IsPrimaryPlatform(), so that we can probe virtio-gpu-pci
as a primary card in platform bus code.

Cc: Adam Jackson <ajax@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Keith Packard <keithp@keithp.com>
Cc: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Tested-By: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Laszlo Ersek 2016-09-07 15:08:06 +02:00 committed by Adam Jackson
parent 44968da376
commit ca8d88e503

View File

@ -114,7 +114,15 @@ xf86_find_platform_device_by_devnum(int major, int minor)
static Bool
xf86IsPrimaryPlatform(struct xf86_platform_device *plat)
{
return ((primaryBus.type == BUS_PLATFORM) && (plat == primaryBus.id.plat));
if (primaryBus.type == BUS_PLATFORM)
return plat == primaryBus.id.plat;
#ifdef XSERVER_LIBPCIACCESS
if (primaryBus.type == BUS_PCI)
if (plat->pdev)
if (MATCH_PCI_DEVICES(primaryBus.id.pci, plat->pdev))
return TRUE;
#endif
return FALSE;
}
static void