The first attached patch will result in drmParsePciDeviceInfo always
reporting revision 0 on kernels without the second attached patch. Will
that be an issue for the amdgpu-pro stack?
Please follow up directly to the patch e-mails with any comments on the
patches.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
--- Begin Message ---
From: Emil Velikov <emil.veli...@collabora.com>
Currently the revision isn't available via sysfs/libudev thus if one
wants to know the value they need to read through the config file.
This in itself wakes/powers up the device, causing unwanted delay
since it can be quite costly.
Expose the revision as a separate file, just like we do for the device,
vendor, their subsystem version and class.
Cc: Jammy Zhou <jammy.z...@amd.com>
Cc: Michel Dänzer <michel.daen...@amd.com>
Cc: Bjorn Helgaas <bhelg...@google.com>
Cc: linux-...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
Gents, I'm not subscribed to the mailing list so please keep me in the
CC chain.
Thanks
Emil
---
drivers/pci/pci-sysfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index bcd10c7..0666287 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -50,6 +50,7 @@ pci_config_attr(vendor, "0x%04x\n");
pci_config_attr(device, "0x%04x\n");
pci_config_attr(subsystem_vendor, "0x%04x\n");
pci_config_attr(subsystem_device, "0x%04x\n");
+pci_config_attr(revision, "0x%02x\n");
pci_config_attr(class, "0x%06x\n");
pci_config_attr(irq, "%u\n");
@@ -568,6 +569,7 @@ static struct attribute *pci_dev_attrs[] = {
&dev_attr_device.attr,
&dev_attr_subsystem_vendor.attr,
&dev_attr_subsystem_device.attr,
+ &dev_attr_revision.attr,
&dev_attr_class.attr,
&dev_attr_irq.attr,
&dev_attr_local_cpus.attr,
--
2.9.3
_______________________________________________
dri-devel mailing list
dri-de...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
--- End Message ---
--- Begin Message ---
From: Emil Velikov <emil.veli...@collabora.com>
Parsing config sysfs file wakes up the device. The latter of which may
be slow and isn't required to begin with.
Reading through config is/was required since the revision is not
available by other means, although with a kernel patch in the way we can
'cheat' temporarily.
That should be fine, since no open-source project has ever used the
value.
Cc: Michel Dänzer <michel.daen...@amd.com>
Cc: Mauro Santos <registo.maill...@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98502
Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
Mauro can you apply this against libdrm and rebuild it. You do _not_
need to rebuild mesa afterwords.
Thanks
---
xf86drm.c | 50 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/xf86drm.c b/xf86drm.c
index 52add5e..5a5100c 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2950,25 +2950,45 @@ static int drmParsePciDeviceInfo(const char *d_name,
drmPciDeviceInfoPtr device)
{
#ifdef __linux__
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+ static const char *attrs[] = {
+ "revision", /* XXX: make sure it's always first, see note below */
+ "vendor",
+ "device",
+ "subsystem_vendor",
+ "subsystem_device",
+ };
char path[PATH_MAX + 1];
- unsigned char config[64];
- int fd, ret;
+ unsigned int data[ARRAY_SIZE(attrs)];
+ FILE *fp;
+ int ret;
- snprintf(path, PATH_MAX, "/sys/class/drm/%s/device/config", d_name);
- fd = open(path, O_RDONLY);
- if (fd < 0)
- return -errno;
+ for (unsigned i = 0; i < ARRAY_SIZE(attrs); i++) {
+ snprintf(path, PATH_MAX, "/sys/class/drm/%s/device/%s",
+ d_name, attrs[i]);
+ fp = fopen(path, "r");
+ if (!fp) {
+ /* Note: First we check the revision, since older kernels
+ * may not have it. Default to zero in such cases. */
+ if (i == 0) {
+ data[i] = 0;
+ continue;
+ }
+ return -errno;
+ }
- ret = read(fd, config, sizeof(config));
- close(fd);
- if (ret < 0)
- return -errno;
+ ret = fscanf(fp, "%x", &data[i]);
+ fclose(fp);
+ if (ret != 1)
+ return -errno;
+
+ }
- device->vendor_id = config[0] | (config[1] << 8);
- device->device_id = config[2] | (config[3] << 8);
- device->revision_id = config[8];
- device->subvendor_id = config[44] | (config[45] << 8);
- device->subdevice_id = config[46] | (config[47] << 8);
+ device->revision_id = data[0] & 0xff;
+ device->vendor_id = data[1] & 0xffff;
+ device->device_id = data[2] & 0xffff;
+ device->subvendor_id = data[3] & 0xffff;
+ device->subdevice_id = data[4] & 0xffff;
return 0;
#else
--
2.10.0
_______________________________________________
dri-devel mailing list
dri-de...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
--- End Message ---
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx