stevenrwalter

Untitled

Mar 23rd, 2017
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.35 KB | None | 0 0
  1. From 98898827a0da14a5bd73ec8875b6c078f76d7c21 Mon Sep 17 00:00:00 2001
  2. From: Steven Walter <stevenrwalter@gmail.com>
  3. Date: Thu, 9 Mar 2017 09:23:01 -0500
  4. Subject: [PATCH] get_primary_gpu_path: handle the lack of any boot_vga device
  5.  
  6. ---
  7.  src/backends/native/meta-launcher.c | 15 ++++++++++++++-
  8.  1 file changed, 14 insertions(+), 1 deletion(-)
  9.  
  10. diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c
  11. index ea28e5a..116b1c3 100644
  12. --- a/src/backends/native/meta-launcher.c
  13. +++ b/src/backends/native/meta-launcher.c
  14. @@ -321,6 +321,8 @@ get_primary_gpu_path (const gchar *seat_name)
  15.          {
  16.            /* if the device has been explicitly assigned other seat
  17.             * than seat0, it is probably the right device to use */
  18. +          if (path)
  19. +            g_free(path);
  20.            path = g_strdup (g_udev_device_get_device_file (dev));
  21.            break;
  22.          }
  23. @@ -332,6 +334,8 @@ get_primary_gpu_path (const gchar *seat_name)
  24.        platform_device = g_udev_device_get_parent_with_subsystem (dev, "platform", NULL);
  25.        if (platform_device != NULL)
  26.          {
  27. +          if (path)
  28. +            g_free(path);
  29.            path = g_strdup (g_udev_device_get_device_file (dev));
  30.            break;
  31.          }
  32. @@ -339,12 +343,21 @@ get_primary_gpu_path (const gchar *seat_name)
  33.        pci_device = g_udev_device_get_parent_with_subsystem (dev, "pci", NULL);
  34.        if (pci_device != NULL)
  35.          {
  36. +          /* If we've gotten this far, this device is a good candidate for
  37. +           * being the primary GPU.  However, we won't stop looking unless we
  38. +           * find the boot_vga attribute.  We might not find any device with
  39. +           * the boot_vga attribute (for example, if that device has been
  40. +           * grabbed by vfio-pci) in which case this device is better than no
  41. +           * device. */
  42. +          if (path)
  43. +            g_free(path);
  44. +          path = g_strdup (g_udev_device_get_device_file (dev));
  45. +
  46.            /* get value of boot_vga attribute or 0 if the device has no boot_vga */
  47.            boot_vga = g_udev_device_get_sysfs_attr_as_int (pci_device, "boot_vga");
  48.            if (boot_vga == 1)
  49.              {
  50.                /* found the boot_vga device */
  51. -              path = g_strdup (g_udev_device_get_device_file (dev));
  52.                break;
  53.              }
  54.          }
  55. --
  56. 2.9.3
Advertisement
Add Comment
Please, Sign In to add comment