Skip to content

Commit

Permalink
Merge pull request #102 from aleasto/jammy
Browse files Browse the repository at this point in the history
jammy LP: #2060268
  • Loading branch information
ktpawlak authored Aug 1, 2024
2 parents bed81c6 + 54927f9 commit 66dc185
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
5 changes: 5 additions & 0 deletions share/hybrid/71-u-d-c-gpu-detection.rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Rule installed by ubuntu-drivers-common

# Remove SimpleDRM device when nvidia-drm loads.
# This normally happens automatically for DRM devices that also register
# a framebuffer device, but that's not the case yet for the nvidia driver.
ACTION=="add", SUBSYSTEM=="module", KERNEL=="nvidia_drm", TEST=="/sys/devices/platform/simple-framebuffer.0/drm/card0", RUN+="/bin/rm /dev/dri/card0"

# Create a file with the card details for gpu-manager
ACTION=="add", SUBSYSTEM=="drm", DEVPATH=="*/drm/card*", RUN+="/sbin/u-d-c-print-pci-ids"

Expand Down
45 changes: 30 additions & 15 deletions share/hybrid/gpu-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,8 @@ int main(int argc, char *argv[]) {
/* Device information (discrete) */
struct device discrete_device = { 0 };

/* Get nvidia driver version */
int major, minor, extra;

while (1) {
static struct option long_options[] =
Expand Down Expand Up @@ -2986,6 +2988,34 @@ int main(int argc, char *argv[]) {
pci_cleanup(pacc);
pacc = NULL;
}

/* Probe graphic drivers earlier since some graphic related application
* (e.g. gdm, mutter) rely on udev rules to apply extra configurations.
*/
if (has_nvidia && !nvidia_blacklisted && !is_module_loaded("nvidia"))
load_module("nvidia");

/* Make sure the udev rules are applied for graphic cards.
*
* Also make sure to do this before trying to open /dev/dri/card*
* because doing so too early may trigger a nvidia bug:
* https://forums.developer.nvidia.com/t/545-29-06-18-1-flip-event-timeout-error-on-startup-shutdown-and-sometimes-suspend-wayland-unusable/274788
*/
if (has_nvidia && !nvidia_blacklisted) {
for (i = 0; i < 500; i++, usleep(20000)) {
if (is_file(UDEV_NVIDIA_COMPLETED))
break;
/* Get nvidia driver version inside loop because sometime nvidia
* driver take longer time to load.
*/
if (get_nvidia_driver_version(&major, &minor, &extra) &&
major < 390) {
break;
}
}
fprintf(log_handle, "Takes %dms to wait for nvidia udev rules completed.\n", i * 20);
}

/* Add information about connected outputs */
add_connected_outputs_info(current_devices, cards_n);

Expand Down Expand Up @@ -3026,12 +3056,6 @@ int main(int argc, char *argv[]) {
fprintf(log_handle, "Has nvidia? %s\n", (has_nvidia ? "yes" : "no"));
fprintf(log_handle, "How many cards? %d\n", cards_n);

/* Probe graphic drivers earlier since some graphic related application
* (e.g. gdm, mutter) rely on udev rules to apply extra configurations.
*/
if (has_nvidia && !nvidia_blacklisted && !is_module_loaded("nvidia"))
load_module("nvidia");

/* See if the system has changed */
has_changed = has_system_changed(old_devices,
current_devices,
Expand All @@ -3042,15 +3066,6 @@ int main(int argc, char *argv[]) {
if (has_changed)
fprintf(log_handle, "System configuration has changed\n");

/* Make sure the udev rules are applied for graphic cards. */
if (has_nvidia && !nvidia_blacklisted) {
for (i = 0; i < 500; i++, usleep(20000)) {
if (is_file(UDEV_NVIDIA_COMPLETED))
break;
}
fprintf(log_handle, "Takes %dms to wait for nvidia udev rules completed.\n", i * 20);
}

if (cards_n == 1) {
fprintf(log_handle, "Single card detected\n");

Expand Down

0 comments on commit 66dc185

Please sign in to comment.