[Mesa-users] mesa 12.0.2 amdgpu

Albert Freeman albertwdfreeman at gmail.com
Thu Oct 13 07:59:23 UTC 2016


This patch is better

On 13 October 2016 at 06:38, Albert Freeman <albertwdfreeman at gmail.com> wrote:
> 1. libdrm does support amdgpu, in fact its required for mesa radeonsi
> drivers (with or without amdgpu)
> 2. Try the attached diff
>
> On 11 October 2016 at 09:32, Minkyu Lee <minkyu725 at gmail.com> wrote:
>> Hi,
>>
>> I built mesa-12.0.2 with “—wtih-gallium-drivers=radeonsi” in order to make
>> amdgpu work in mesa. The mesa is built successfully.  However, it seems that
>> drm_get_pci_id_for_fd() in
>> mesa/src/loader/loader.c:loader_get_pci_id_for_fd() cannot find pci_id.
>>
>> Therefore, I have two problems:
>> 1. Does libdrm supports amdgpu? Or does amdgpu can only be ran with
>> libudev, syses, or devq ?
>> (I listed these because loader_get_pci_id_for_fd provides these three
>> environments in addition to libdrm)
>>
>> 2. If libdrm supports amdgpu, what kind of code should be added in
>> drm_get_pci_id_for_fd()?
>>
>> Thanks
>>
>> _______________________________________________
>> mesa-users mailing list
>> mesa-users at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-users
>>
-------------- next part --------------
diff --git a/mesa/src/loader/loader.c b/mesa2/src/loader/loader.c
index 3e60e4c..4a89ba4 100644
--- a/mesa/src/loader/loader.c
+++ b/mesa2/src/loader/loader.c
@@ -515,6 +515,8 @@ sysfs_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
 #include <i915_drm.h>
 /* for radeon */
 #include <radeon_drm.h>
+/* for amdgpu */
+#include <amdgpu_drm.h>
 
 static int
 drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
@@ -564,6 +566,26 @@ drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
 	 *chip_id = -1;
       }
    }
+   else if (strcmp(version->name, "amdgpu") == 0) {
+      struct drm_amdgpu_info info;
+      struct drm_amdgpu_info_device info_device;
+      int ret;
+
+      *vendor_id = 0x1002;
+
+      memset(&info, 0, sizeof(info));
+      memset(&info_device, 0, sizeof(info_device));
+      info.query = AMDGPU_INFO_DEV_INFO;
+      info.return_pointer = (uint64_t) &info_device;
+      info.return_size = sizeof(struct drm_amdgpu_info_device);
+      ret = drmCommandWrite(fd, DRM_AMDGPU_INFO, &info, sizeof(info));
+      if (ret) {
+         log_(_LOADER_WARNING, "MESA-LOADER: failed to get info for amdgpu\n");
+         *chip_id = -1;
+      } else {
+         *chip_id = info_device.device_id;
+      }
+   }
    else if (strcmp(version->name, "nouveau") == 0) {
       *vendor_id = 0x10de;
       /* not used */


More information about the mesa-users mailing list