[PATCH xserver 3/4] dri2: refine dri2_probe_driver_name
Emil Velikov
emil.l.velikov at gmail.com
Tue Jan 10 13:48:44 UTC 2017
On 10 January 2017 at 10:51, Qiang Yu <Qiang.Yu at amd.com> wrote:
> Get PCI information from info->fd with drmGetDevice instead of
> assuming the info->fd is the first entity of scrn which is not
> true for multi entities scrn.
>
IIRC you want to bump the libdrm version in configure to one that
provides the API.
> Signed-off-by: Qiang Yu <Qiang.Yu at amd.com>
> ---
> hw/xfree86/dri2/dri2.c | 35 ++++++++++++++++++-----------------
> 1 file changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 2165603..adc59a6 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -1440,21 +1440,16 @@ get_prime_id(void)
> static char *
> dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
> {
> - ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
> - EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
> - struct pci_device *pdev = NULL;
> int i, j;
> -
> - if (pEnt)
> - pdev = xf86GetPciInfoForEntity(pEnt->index);
> + char *driver = NULL;
> + drmDevicePtr dev;
>
> /* For non-PCI devices, just assume that the 3D driver is named
> * the same as the kernel driver. This is currently true for vc4
> * and msm (freedreno).
> */
> - if (!pdev) {
> + if (drmGetDevice(info->fd, &dev)) {
This does not align with the comment above. Bail out in the [very]
unlikely case that the function fails.
Then honour _drmDevice::bustype for the respective PCI vs other case(s).
> drmVersionPtr version = drmGetVersion(info->fd);
> - char *kernel_driver;
>
> if (!version) {
> xf86DrvMsg(pScreen->myNum, X_ERROR,
> @@ -1463,29 +1458,35 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
> return NULL;
> }
>
> - kernel_driver = strndup(version->name, version->name_len);
> + driver = strndup(version->name, version->name_len);
> drmFreeVersion(version);
> - return kernel_driver;
> + return driver;
> }
>
> for (i = 0; driver_map[i].driver; i++) {
> - if (pdev->vendor_id != driver_map[i].vendor_id)
> + if (dev->deviceinfo.pci->vendor_id != driver_map[i].vendor_id)
... or in other words.
This will cause a _lot_ of grief as we merge Thierry's work to support
!PCI devices.
Thanks
Emil
More information about the xorg-devel
mailing list