Commit f3d25584 authored by Shashank Sharma's avatar Shashank Sharma Committed by Shashank Sharma
Browse files

xf86: allow DDX driver for GPU/PCI hot-plug



The current X server infrastructure sets modesetting driver as default driver
to handle PCI-hotplug of a GPU device. This prevents the respective DDX driver
(like AMDGPU DDX driver) to take control of the card.

This patch:
- fine-tunes the PCI-hotplug infrastructure to allow the resoective DDX driver
  to be loaded.
- scans and updates the PCI device list before adding the new GPU device
  in platform, so that the association of the platform device and PCI
  device is in place (dev->pdev).

Cc: Alex Deucher <alexandar.deucher@amd.com>
Signed-off-by: default avatarShashank Sharma <shashank.sharma@amd.com>
parent 7d2014e7
Pipeline #517655 passed with stages
in 2 minutes and 3 seconds
......@@ -272,6 +272,22 @@ xf86PlatformMatchDriver(XF86MatchedDrivers *md)
}
}
void xf86PlatformScanPciDev(void)
{
int i;
if (!xf86scanpci())
return;
xf86Msg(X_CONFIG, "Scanning the platform PCI devices\n");
for (i = 0; i < xf86_num_platform_devices; i++) {
char *busid = xf86_platform_odev_attributes(i)->busid;
if (strncmp(busid, "pci:", 4) == 0)
platform_find_pci_info(&xf86_platform_devices[i], busid);
}
}
int
xf86platformProbe(void)
{
......@@ -614,7 +630,7 @@ xf86platformAddGPUDevices(DriverPtr drvp)
}
int
xf86platformAddDevice(int index)
xf86platformAddDevice(char *driver_name, int index)
{
int i, old_screens, scr_index, scrnum;
DriverPtr drvp = NULL;
......@@ -625,7 +641,15 @@ xf86platformAddDevice(int index)
return -1;
/* force load the driver for now */
xf86LoadOneModule(hotplug_driver_name, NULL);
if (driver_name) {
if (xf86LoadOneModule(driver_name, NULL))
/* Driver load success */
hotplug_driver_name = driver_name;
}
/* Load modesetting driver if no driver supplied, or driver open failed */
if (hotplug_driver_name != driver_name)
xf86LoadOneModule(hotplug_driver_name, NULL);
for (i = 0; i < xf86NumDrivers; i++) {
if (!xf86DriverList[i])
......
......@@ -44,6 +44,7 @@ int xf86platformProbe(void);
int xf86platformProbeDev(DriverPtr drvp);
int xf86platformAddGPUDevices(DriverPtr drvp);
void xf86MergeOutputClassOptions(int entityIndex, void **options);
void xf86PlatformScanPciDev(void);
extern int xf86_num_platform_devices;
extern struct xf86_platform_device *xf86_platform_devices;
......@@ -56,7 +57,7 @@ extern Bool
xf86_get_platform_device_unowned(int index);
extern int
xf86platformAddDevice(int index);
xf86platformAddDevice(char *driver_name, int index);
extern void
xf86platformRemoveDevice(int index);
......
......@@ -125,7 +125,7 @@ xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs)
xf86_remove_platform_device(index);
return;
}
ret = xf86platformAddDevice(index);
ret = xf86platformAddDevice(attribs->driver, index);
if (ret == -1)
xf86_remove_platform_device(index);
}
......@@ -181,7 +181,10 @@ void NewGPUDeviceRequest(struct OdevAttributes *attribs)
if (xf86_get_platform_device_unowned(xf86_num_platform_devices - 1) == TRUE)
return;
ret = xf86platformAddDevice(xf86_num_platform_devices-1);
/* Scan and update PCI devices before adding new platform device */
xf86PlatformScanPciDev();
ret = xf86platformAddDevice(attribs->driver, xf86_num_platform_devices-1);
if (ret == -1)
xf86_remove_platform_device(xf86_num_platform_devices-1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment