beignet-1.3.2-reduce-notfound-output2.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Description: Reduce error spew on unsupported or hybrid hardware
  2. Explicitly check if the device is i915 before calling random ioctl()s
  3. to avoid triggering pointless user-visible error messages if it is not.
  4. Origin: upstream b70d65ba25a32a965cc122bf944ba14a1aa0a095
  5. Author: Mark Thompson
  6. --- a/src/intel/intel_driver.c
  7. +++ b/src/intel/intel_driver.c
  8. @@ -312,6 +312,26 @@ return ret;
  9. }
  10. #endif
  11. +static int
  12. +intel_driver_check_device(int dev_fd)
  13. +{
  14. + // Ensure that this is actually an i915 DRM device.
  15. + drmVersion *version;
  16. + int ret;
  17. + version = drmGetVersion(dev_fd);
  18. + if (!version) {
  19. + fprintf(stderr, "drmGetVersion(%d) failed: %s\n", dev_fd, strerror(errno));
  20. + close(dev_fd);
  21. + return 0;
  22. + }
  23. + ret = !strcmp(version->name, "i915");
  24. + drmFreeVersion(version);
  25. + // Don't print an error here if this device is using a different driver,
  26. + // because we might be iterating over multiple devices looking for a
  27. + // compatible one.
  28. + return ret;
  29. +}
  30. +
  31. LOCAL int
  32. intel_driver_init_master(intel_driver_t *driver, const char* dev_name)
  33. {
  34. @@ -326,6 +346,11 @@ if (dev_fd == -1) {
  35. return 0;
  36. }
  37. +if (!intel_driver_check_device(dev_fd)) {
  38. + close(dev_fd);
  39. + return 0;
  40. +}
  41. +
  42. // Check that we're authenticated
  43. memset(&client, 0, sizeof(drm_client_t));
  44. ret = ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client);
  45. @@ -356,6 +381,11 @@ dev_fd = open(dev_name, O_RDWR);
  46. if (dev_fd == -1)
  47. return 0;
  48. +if (!intel_driver_check_device(dev_fd)) {
  49. + close(dev_fd);
  50. + return 0;
  51. +}
  52. +
  53. ret = intel_driver_init(driver, dev_fd);
  54. driver->need_close = 1;