Skip to contentSkip to conversation

drm/amdgpu: Add sysfs file for VBIOS

PATCH Superseded Kent Russell 7 participants 29 messages Aug 23, 2017 – Aug 25, 2017 22 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Add sysfs file for VBIOS

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
 drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +23 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
 	return r;
 }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+						 struct device_attribute *attr,
+						 char *buf)
+{
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = ddev->dev_private;
+	struct atom_context *ctx = adev->mode_info.atom_context;
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version);
+}
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+		   NULL);
+
 /**
  * amdgpu_atombios_fini - free the driver info and callbacks for atombios
  *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
 	adev->mode_info.atom_context = NULL;
 	kfree(adev->mode_info.atom_card_info);
 	adev->mode_info.atom_card_info = NULL;
+	device_remove_file(adev->dev, &dev_attr_vbios_version);
 }
 
 /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
 {
 	struct card_info *atom_card_info =
 	    kzalloc(sizeof(struct card_info), GFP_KERNEL);
+	int ret;
 
 	if (!atom_card_info)
 		return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
 		amdgpu_atombios_scratch_regs_init(adev);
 		amdgpu_atombios_allocate_fb_scratch(adev);
 	}
+
+	ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+	if (ret) {
+		DRM_ERROR("Failed to create device file for VBIOS version\n");
+		return ret;
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
 		idx = 0x80;
 
 	str = CSTR(idx);
-	if (*str != '\0')
+	if (*str != '\0') {
 		pr_info("ATOM BIOS: %s\n", str);
+		strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+	}
+
 
 	return ctx;
 }
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
index ddd8045..a391709 100644
@@ -140,6 +140,7 @@ struct atom_context {
 	int io_mode;
 	uint32_t *scratch;
 	int scratch_size_bytes;
+	char vbios_version[20];
 };
 
 extern int amdgpu_atom_debug;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1503511940-645-1-git-send-email-kent.russell-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 8 lines · Kent Russell

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Most if not all instances of "VBIOS" in the commit log should probably be replaced by "VBIOS version" for clarity.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw
In reply to a message not in the archive

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 6 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 85 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
  drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +23 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
  	return r;
  }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+						 struct device_attribute *attr,
+						 char *buf)
+{
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = ddev->dev_private;
+	struct atom_context *ctx = adev->mode_info.atom_context;
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version);
+}
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+		   NULL);
+
  /**
   * amdgpu_atombios_fini - free the driver info and callbacks for atombios
   *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
  	adev->mode_info.atom_context = NULL;
  	kfree(adev->mode_info.atom_card_info);
  	adev->mode_info.atom_card_info = NULL;
+	device_remove_file(adev->dev, &dev_attr_vbios_version);
  }
 
  /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  {
  	struct card_info *atom_card_info =
  	    kzalloc(sizeof(struct card_info), GFP_KERNEL);
+	int ret;
 
  	if (!atom_card_info)
  		return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  		amdgpu_atombios_scratch_regs_init(adev);
  		amdgpu_atombios_allocate_fb_scratch(adev);
  	}
+
+	ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+	if (ret) {
+		DRM_ERROR("Failed to create device file for VBIOS version\n");
+		return ret;
+	}
+
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
  		idx = 0x80;
 
  	str = CSTR(idx);
-	if (*str != '\0')
+	if (*str != '\0') {
  		pr_info("ATOM BIOS: %s\n", str);
+		strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+	}
+
 
  	return ctx;
  }
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
index ddd8045..a391709 100644

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
@@ -140,6 +140,7 @@ struct atom_context {
  	int io_mode;
  	uint32_t *scratch;
  	int scratch_size_bytes;
+	char vbios_version[20];
  };
 
  extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1e64a642-411e-ea58-1639-390e4c3cd75d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#5 lore raw

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 6 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 87 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
  drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
  	return r;
  }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+						 struct device_attribute *attr,
+						 char *buf)
+{
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = ddev->dev_private;
+	struct atom_context *ctx = adev->mode_info.atom_context;
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+		   NULL);
+
  /**
   * amdgpu_atombios_fini - free the driver info and callbacks for atombios
   *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
  	adev->mode_info.atom_context = NULL;
  	kfree(adev->mode_info.atom_card_info);
  	adev->mode_info.atom_card_info = NULL;
+	device_remove_file(adev->dev, &dev_attr_vbios_version);
  }
 
  /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  {
  	struct card_info *atom_card_info =
  	    kzalloc(sizeof(struct card_info), GFP_KERNEL);
+	int ret;
 
  	if (!atom_card_info)
  		return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  		amdgpu_atombios_scratch_regs_init(adev);
  		amdgpu_atombios_allocate_fb_scratch(adev);
  	}
+
+	ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+	if (ret) {
+		DRM_ERROR("Failed to create device file for VBIOS version\n");
+		return ret;
+	}
+
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
  		idx = 0x80;
 
  	str = CSTR(idx);
-	if (*str != '\0')
+	if (*str != '\0') {
  		pr_info("ATOM BIOS: %s\n", str);
+		strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+	}
+
 
  	return ctx;
  }
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
index ddd8045..a391709 100644

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
@@ -140,6 +140,7 @@ struct atom_context {
  	int io_mode;
  	uint32_t *scratch;
  	int scratch_size_bytes;
+	char vbios_version[20];
  };
 
  extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR1201MB01801A32C06AE0DA6634F440859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#7 lore raw
Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 113 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 6 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 93 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
  drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
      return r;
  }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf)
+{
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
  /**
   * amdgpu_atombios_fini - free the driver info and callbacks for atombios
   *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
      adev->mode_info.atom_context = NULL;
      kfree(adev->mode_info.atom_card_info);
      adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
  }
 
  /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  {
      struct card_info *atom_card_info =
          kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
      if (!atom_card_info)
              return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
              amdgpu_atombios_scratch_regs_init(adev);
              amdgpu_atombios_allocate_fb_scratch(adev);
      }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
      return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
              idx = 0x80;
 
      str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
              pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
      return ctx;
  }
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
index ddd8045..a391709 100644
@@ -140,6 +140,7 @@ struct atom_context {
      int io_mode;
      uint32_t *scratch;
      int scratch_size_bytes;
+     char vbios_version[20];
  };
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
  extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_PD3s8HHPtr49ZJ3DXPVXgP5xyvFZj_YTzsGCi=cnOUKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#9 lore raw

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 112 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 6 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 92 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
  drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +21 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
      return r;
  }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
  /**
   * amdgpu_atombios_fini - free the driver info and callbacks for atombios
   *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
      adev->mode_info.atom_context = NULL;
      kfree(adev->mode_info.atom_card_info);
      adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
  }
 
  /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  {
      struct card_info *atom_card_info =
          kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
      if (!atom_card_info)
              return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
              amdgpu_atombios_scratch_regs_init(adev);
              amdgpu_atombios_allocate_fb_scratch(adev);
      }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
      return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
              idx = 0x80;
 
      str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
              pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
      return ctx;
  }
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
index ddd8045..a391709 100644
@@ -140,6 +140,7 @@ struct atom_context {
      int io_mode;
      uint32_t *scratch;
      int scratch_size_bytes;
+     char vbios_version[20];
  };
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
  extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR1201MB018010027CA78E203F629BA7859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#11 lore raw

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Regards,
Felix
________________________________________
From: amd-gfx <[email protected]> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 112 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 6 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 92 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
  drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +21 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
      return r;
  }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
  /**
   * amdgpu_atombios_fini - free the driver info and callbacks for atombios
   *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
      adev->mode_info.atom_context = NULL;
      kfree(adev->mode_info.atom_card_info);
      adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
  }
 
  /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  {
      struct card_info *atom_card_info =
          kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
      if (!atom_card_info)
              return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
              amdgpu_atombios_scratch_regs_init(adev);
              amdgpu_atombios_allocate_fb_scratch(adev);
      }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
      return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
              idx = 0x80;
 
      str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
              pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
      return ctx;
  }
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
index ddd8045..a391709 100644
@@ -140,6 +140,7 @@ struct atom_context {
      int io_mode;
      uint32_t *scratch;
      int scratch_size_bytes;
+     char vbios_version[20];
  };
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
  extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): DM5PR1201MB023503F29269CEC80DC7DAD8929A0-grEf7a3NxMBd8L2jMOIKKmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#13 lore raw
Quoted 4 lines · Felix

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.

Alex

Quoted 147 lines

Regards,
Felix
________________________________________
From: amd-gfx <[email protected]> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 112 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 6 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 92 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
  drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +21 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
      return r;
  }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
  /**
   * amdgpu_atombios_fini - free the driver info and callbacks for atombios
   *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
      adev->mode_info.atom_context = NULL;
      kfree(adev->mode_info.atom_card_info);
      adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
  }
 
  /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  {
      struct card_info *atom_card_info =
          kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
      if (!atom_card_info)
              return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
              amdgpu_atombios_scratch_regs_init(adev);
              amdgpu_atombios_allocate_fb_scratch(adev);
      }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
      return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
              idx = 0x80;
 
      str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
              pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
      return ctx;
  }
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
index ddd8045..a391709 100644
@@ -140,6 +140,7 @@ struct atom_context {
      int io_mode;
      uint32_t *scratch;
      int scratch_size_bytes;
+     char vbios_version[20];
  };
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
  extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_Piyp7mtHi+4GZ0pUw1kMNT68ZVyA6jp1TR4VhbCjWAOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#15 lore raw

We already access the GPU Power usage via debugfs, which is why I didn't think it was a huge deal to switch it over, since we already need root access for the SMI due to that.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 11:39 AM
To: Kuehling, Felix
Cc: Russell, Kent; Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 4 lines · Felix

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.

Alex

Quoted 149 lines

Regards,
Felix
________________________________________
From: amd-gfx <[email protected]> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 113 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 7 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 92 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
  drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +21 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
      return r;
  }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
  /**
   * amdgpu_atombios_fini - free the driver info and callbacks for atombios
   *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
      adev->mode_info.atom_context = NULL;
      kfree(adev->mode_info.atom_card_info);
      adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
  }
 
  /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
  {
      struct card_info *atom_card_info =
          kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
      if (!atom_card_info)
              return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
              amdgpu_atombios_scratch_regs_init(adev);
              amdgpu_atombios_allocate_fb_scratch(adev);
      }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
      return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
              idx = 0x80;
 
      str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
              pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
      return ctx;
  }
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
index ddd8045..a391709 100644
@@ -140,6 +140,7 @@ struct atom_context {
      int io_mode;
      uint32_t *scratch;
      int scratch_size_bytes;
+     char vbios_version[20];
  };
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
  extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR1201MB01804846B5629D28766FDFA0859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#17 lore raw

Actually the main difference is not root vs. user, but rather unstable vs stable interface.

If you want a stable interface for an userspace tool you should use sysfs, if you don't care about that you should use debugfs.

Christian.

Am 24.08.2017 um 18:37 schrieb Russell, Kent:

Quoted 165 lines

We already access the GPU Power usage via debugfs, which is why I didn't think it was a huge deal to switch it over, since we already need root access for the SMI due to that.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 11:39 AM
To: Kuehling, Felix
Cc: Russell, Kent; Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 4 lines · Felix

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.

Alex

Quoted 145 lines

Regards,
Felix
________________________________________
From: amd-gfx <[email protected]> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 117 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 7 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 85 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
   drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
   3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +21 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
       return r;
   }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
   /**
    * amdgpu_atombios_fini - free the driver info and callbacks for atombios
    *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
       adev->mode_info.atom_context = NULL;
       kfree(adev->mode_info.atom_card_info);
       adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
   }
 
   /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
   {
       struct card_info *atom_card_info =
           kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
       if (!atom_card_info)
               return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
               amdgpu_atombios_scratch_regs_init(adev);
               amdgpu_atombios_allocate_fb_scratch(adev);
       }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
       return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
               idx = 0x80;
 
       str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
               pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
       return ctx;
   }
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
index ddd8045..a391709 100644

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
@@ -140,6 +140,7 @@ struct atom_context {
       int io_mode;
       uint32_t *scratch;
       int scratch_size_bytes;
+     char vbios_version[20];
   };
 
   extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): fa2dddb4-5ceb-87f3-6305-fb5f6e6e5c2d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#19 lore raw

The plan is for the vbios version to be available through the ROCM-SMI utility. We have the GPU power usage listed in the debugfs currently. If they are both to be used for a userspace utility, should we be moving both of those to sysfs instead?

Kent

KENT RUSSELL
Software Engineer | Vertical Workstation/Compute
1 Commerce Valley Drive East
Markham, ON L3T 7X6
Canada
O +(1) 289-695-2122 | Ext x72122

________________________________
From: Christian König <[email protected]>
Sent: Thursday, August 24, 2017 2:10:35 PM
To: Russell, Kent; Alex Deucher; Kuehling, Felix
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Actually the main difference is not root vs. user, but rather unstable vs stable interface.

If you want a stable interface for an userspace tool you should use sysfs, if you don't care about that you should use debugfs.

Christian.

Am 24.08.2017 um 18:37 schrieb Russell, Kent:

Quoted 165 lines

We already access the GPU Power usage via debugfs, which is why I didn't think it was a huge deal to switch it over, since we already need root access for the SMI due to that.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 11:39 AM
To: Kuehling, Felix
Cc: Russell, Kent; Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 4 lines · Felix

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.

Alex

Quoted 145 lines

Regards,
Felix
________________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 117 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 7 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 85 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
   drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
   3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +21 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
       return r;
   }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
   /**
    * amdgpu_atombios_fini - free the driver info and callbacks for atombios
    *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
       adev->mode_info.atom_context = NULL;
       kfree(adev->mode_info.atom_card_info);
       adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
   }
 
   /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
   {
       struct card_info *atom_card_info =
           kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
       if (!atom_card_info)
               return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
               amdgpu_atombios_scratch_regs_init(adev);
               amdgpu_atombios_allocate_fb_scratch(adev);
       }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
       return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
               idx = 0x80;
 
       str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
               pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
       return ctx;
   }
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
index ddd8045..a391709 100644

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
@@ -140,6 +140,7 @@ struct atom_context {
       int io_mode;
       uint32_t *scratch;
       int scratch_size_bytes;
+     char vbios_version[20];
   };
 
   extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR1201MB0180502DC4720A3C33D642DB859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#21 lore raw

Hi Kent,

Loosely following this thread. Was there a decision on whether to leave this in debugfs or sysfs?

I'd like to throw the version string in umr's config output (umr -c) :-)

Cheers,
Tom

Quoted 204 lines · Kent

The plan is for the vbios version to be available through the ROCM-SMI utility. We have the GPU power usage listed in the debugfs currently. If they are both to be used for a userspace utility, should we be moving both of those to sysfs instead?

Kent

KENT RUSSELL
Software Engineer | Vertical Workstation/Compute
1 Commerce Valley Drive East
Markham, ON L3T 7X6
Canada
O +(1) 289-695-2122 | Ext x72122

------------------------------------------------------------------------
*From:* Christian König <[email protected]>
*Sent:* Thursday, August 24, 2017 2:10:35 PM
*To:* Russell, Kent; Alex Deucher; Kuehling, Felix
*Cc:* [email protected]
*Subject:* Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS Actually the main difference is not root vs. user, but rather unstable vs stable interface.

If you want a stable interface for an userspace tool you should use sysfs, if you don't care about that you should use debugfs.

Christian.

Am 24.08.2017 um 18:37 schrieb Russell, Kent:

Quoted 165 lines

We already access the GPU Power usage via debugfs, which is why I didn't think it was a huge deal to switch it over, since we already need root access for the SMI due to that.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 11:39 AM
To: Kuehling, Felix
Cc: Russell, Kent; Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 4 lines · Felix

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.

Alex

Quoted 145 lines

Regards,
Felix
________________________________________
From: amd-gfx <[email protected]> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 117 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 7 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format (3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 85 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
   drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
   3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +21 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
       return r;
   }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
   /**
    * amdgpu_atombios_fini - free the driver info and callbacks for atombios
    *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
       adev->mode_info.atom_context = NULL;
       kfree(adev->mode_info.atom_card_info);
       adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
   }
 
   /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
   {
       struct card_info *atom_card_info =
           kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
       if (!atom_card_info)
               return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
               amdgpu_atombios_scratch_regs_init(adev);
               amdgpu_atombios_allocate_fb_scratch(adev);
       }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
       return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
               idx = 0x80;
 
       str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
               pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
       return ctx;
   }
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
index ddd8045..a391709 100644

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
@@ -140,6 +140,7 @@ struct atom_context {
       int io_mode;
       uint32_t *scratch;
       int scratch_size_bytes;
+     char vbios_version[20];
   };
 
   extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 4cec0dad-502e-68f2-68c9-b5d0103d7093-5C7GfCeVMHo@public.gmane.org

#23 lore raw

The decision to move the VBIOS version to sysfs has been decided. I didn't get any confirmation regarding moving the GPU power usage, or the actual VBIOS dump, as the dump seems to make more sense in debugfs. I'd like to move power usage to sysfs as the SMI tool needs root privileges just to read the value, which makes people cranky. I just want to make sure that it's alright to do so from the powers-that-be.

Kent

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Tom St Denis
Sent: Friday, August 25, 2017 8:37 AM
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Hi Kent,

Loosely following this thread. Was there a decision on whether to leave this in debugfs or sysfs?

I'd like to throw the version string in umr's config output (umr -c) :-)

Cheers,
Tom

Quoted 210 lines · Kent

The plan is for the vbios version to be available through the ROCM-SMI utility. We have the GPU power usage listed in the debugfs currently. If they are both to be used for a userspace utility, should we be moving both of those to sysfs instead?

Kent

KENT RUSSELL
Software Engineer | Vertical Workstation/Compute
1 Commerce Valley Drive East
Markham, ON L3T 7X6
Canada
O +(1) 289-695-2122 | Ext x72122

----------------------------------------------------------------------
--
*From:* Christian König <[email protected]>
*Sent:* Thursday, August 24, 2017 2:10:35 PM
*To:* Russell, Kent; Alex Deucher; Kuehling, Felix
*Cc:* [email protected]
*Subject:* Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS Actually the main difference is not root vs. user, but rather unstable vs stable interface.

If you want a stable interface for an userspace tool you should use sysfs, if you don't care about that you should use debugfs.

Christian.

Am 24.08.2017 um 18:37 schrieb Russell, Kent:

Quoted 167 lines

We already access the GPU Power usage via debugfs, which is why I didn't think it was a huge deal to switch it over, since we already need root access for the SMI due to that.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 11:39 AM
To: Kuehling, Felix
Cc: Russell, Kent; Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 4 lines · Felix

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.

Alex

Quoted 147 lines

Regards,
Felix
________________________________________
From: amd-gfx <[email protected]> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 119 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 8 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format
(3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 86 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
   drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
   3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
       return r;
   }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); 
+ }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
   /**
    * amdgpu_atombios_fini - free the driver info and callbacks for atombios
    *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
       adev->mode_info.atom_context = NULL;
       kfree(adev->mode_info.atom_card_info);
       adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
   }
 
   /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
   {
       struct card_info *atom_card_info =
           kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
       if (!atom_card_info)
               return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
               amdgpu_atombios_scratch_regs_init(adev);
               amdgpu_atombios_allocate_fb_scratch(adev);
       }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
       return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
               idx = 0x80;
 
       str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
               pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
       return ctx;
   }
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
index ddd8045..a391709 100644

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
@@ -140,6 +140,7 @@ struct atom_context {
       int io_mode;
       uint32_t *scratch;
       int scratch_size_bytes;
+     char vbios_version[20];
   };
 
   extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR1201MB01803DD5EBD0049397F4E9F0859B0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#25 lore raw

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

Regards,
Christian.

Am 25.08.2017 um 14:40 schrieb Russell, Kent:

Quoted 233 lines

The decision to move the VBIOS version to sysfs has been decided. I didn't get any confirmation regarding moving the GPU power usage, or the actual VBIOS dump, as the dump seems to make more sense in debugfs. I'd like to move power usage to sysfs as the SMI tool needs root privileges just to read the value, which makes people cranky. I just want to make sure that it's alright to do so from the powers-that-be.

Kent

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Tom St Denis
Sent: Friday, August 25, 2017 8:37 AM
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Hi Kent,

Loosely following this thread. Was there a decision on whether to leave this in debugfs or sysfs?

I'd like to throw the version string in umr's config output (umr -c) :-)

Cheers,
Tom

Quoted 208 lines · Kent

The plan is for the vbios version to be available through the ROCM-SMI utility. We have the GPU power usage listed in the debugfs currently. If they are both to be used for a userspace utility, should we be moving both of those to sysfs instead?

Kent

KENT RUSSELL
Software Engineer | Vertical Workstation/Compute
1 Commerce Valley Drive East
Markham, ON L3T 7X6
Canada
O +(1) 289-695-2122 | Ext x72122

----------------------------------------------------------------------
--
*From:* Christian König <[email protected]>
*Sent:* Thursday, August 24, 2017 2:10:35 PM
*To:* Russell, Kent; Alex Deucher; Kuehling, Felix
*Cc:* [email protected]
*Subject:* Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS Actually the main difference is not root vs. user, but rather unstable vs stable interface.

If you want a stable interface for an userspace tool you should use sysfs, if you don't care about that you should use debugfs.

Christian.

Am 24.08.2017 um 18:37 schrieb Russell, Kent:

Quoted 166 lines

We already access the GPU Power usage via debugfs, which is why I didn't think it was a huge deal to switch it over, since we already need root access for the SMI due to that.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 11:39 AM
To: Kuehling, Felix
Cc: Russell, Kent; Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 4 lines · Felix

Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?

I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.

Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.

Alex

Quoted 146 lines

Regards,
Felix
________________________________________
From: amd-gfx <[email protected]> on behalf of Russell, Kent <[email protected]>
Sent: Thursday, August 24, 2017 9:06:22 AM
To: Alex Deucher
Cc: Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I can definitely add that as well.

Kent

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Thursday, August 24, 2017 8:56 AM
To: Russell, Kent
Cc: Christian König; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Kent

No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!

While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.

Alex

Quoted 118 lines

Kent

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, August 24, 2017 2:22 AM
To: Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Am 23.08.2017 um 20:12 schrieb Kent Russell:

Quoted 8 lines

This won't change after initialization, so we can add the information when we parse the atombios information. This ensures that we can find out the VBIOS, even when the dmesg buffer fills up, and makes it easier to associate which VBIOS is for which GPU on mGPU configurations. Set the size to 20 characters in case of some weird VBIOS suffix that exceeds the expected 17 character format
(3-8-3\0)

Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.

Christian.

Quoted 86 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++
    drivers/gpu/drm/amd/amdgpu/atom.c          |  5 ++++-
    drivers/gpu/drm/amd/amdgpu/atom.h          |  1 +
    3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 -0
index a1f9424..f40be71 100644
@@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
        return r;
    }
 
+static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf) {
+     struct drm_device *ddev = dev_get_drvdata(dev);
+     struct amdgpu_device *adev = ddev->dev_private;
+     struct atom_context *ctx = adev->mode_info.atom_context;
+
+     return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version);
+ }
+
+static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
+                NULL);
+
    /**
     * amdgpu_atombios_fini - free the driver info and callbacks for atombios
     *
@@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
        adev->mode_info.atom_context = NULL;
        kfree(adev->mode_info.atom_card_info);
        adev->mode_info.atom_card_info = NULL;
+     device_remove_file(adev->dev, &dev_attr_vbios_version);
    }
 
    /**
@@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
    {
        struct card_info *atom_card_info =
            kzalloc(sizeof(struct card_info), GFP_KERNEL);
+     int ret;
 
        if (!atom_card_info)
                return -ENOMEM;
@@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
                amdgpu_atombios_scratch_regs_init(adev);
                amdgpu_atombios_allocate_fb_scratch(adev);
        }
+
+     ret = device_create_file(adev->dev, &dev_attr_vbios_version);
+     if (ret) {
+             DRM_ERROR("Failed to create device file for VBIOS version\n");
+             return ret;
+     }
+
        return 0;
    }
 
drivers/gpu/drm/amd/amdgpu/atom.c +4 -1
index d69aa2e..69500a8 100644
@@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
                idx = 0x80;
 
        str = CSTR(idx);
-     if (*str != '\0')
+     if (*str != '\0') {
                pr_info("ATOM BIOS: %s\n", str);
+             strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));
+     }
+
 
        return ctx;
    }
drivers/gpu/drm/amd/amdgpu/atom.h +0 -0
index ddd8045..a391709 100644

drivers/gpu/drm/amd/amdgpu/atom.h struct atom_context { · line 146

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/atom.h +1 -0
@@ -140,6 +140,7 @@ struct atom_context {
        int io_mode;
        uint32_t *scratch;
        int scratch_size_bytes;
+     char vbios_version[20];
    };
 
    extern int amdgpu_atom_debug;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 8 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 0a3d4d07-e3cd-6216-466b-30bc60c8a26a-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#27 lore raw
Quoted 7 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 22c4b9e2-67e2-bd0a-1147-6e896843783e-5C7GfCeVMHo@public.gmane.org

#29 lore raw

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR1201MB01806ACF078801D91460C110859B0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#31 lore raw
Quoted 1 line · Kent

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

I thought the sensors were added to the DRM ioctl but apparently not.

Seems like that might be a bit easier place to put them than creating sysfs entries for every single sensor (it also means as new sensors are added you have to circle around back to add yet more sysfs entries).

Tom

Quoted 20 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

Quoted 6 lines

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): ebeb7962-c55c-9ba3-6969-6f7cf9934a5b-5C7GfCeVMHo@public.gmane.org

#33 lore raw
Quoted 4 lines · Tom St Denis
Quoted 1 line · Kent

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

I thought the sensors were added to the DRM ioctl but apparently not.

No it was, under AMDGPU_INFO you request info->query == AMDGPU_INFO_SENSOR and then specify which sensor you want in info->sensor_info.type (see amdgpu_kms.c).

So you can already read this from a normal user process who has an open DRM file handle.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#34 lore raw
In reply to a message not in the archive
Quoted 4 lines · Tom St Denis
Quoted 1 line · Kent

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

I thought the sensors were added to the DRM ioctl but apparently not.

Nope, it was actually (see amdgpu_kms.c). Under an AMDGPU_INFO command you ask for AMDGPU_INFO_SENSOR and then fill out sensor_info.type.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): cc70864c-1106-1668-d80f-49cfbb6a6325-5C7GfCeVMHo@public.gmane.org

#36 lore raw

Right. And according to Christian, it doesn't fit the format anyways, so power usage can stay. I'm working on the patch to move the vbios version to sysfs from debugfs. Should be up shortly. Maybe I can just make a new sysfs file for Average GPU usage by itself. Another task for another day. But I won't be moving the sensors over. Just vbios version for now, maybe average GPU power usage later.

Kent

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Tom St Denis
Sent: Friday, August 25, 2017 9:34 AM
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 6 lines · Tom St Denis
Quoted 3 lines · Kent

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

I thought the sensors were added to the DRM ioctl but apparently not.

Nope, it was actually (see amdgpu_kms.c). Under an AMDGPU_INFO command you ask for AMDGPU_INFO_SENSOR and then fill out sensor_info.type.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#37 lore raw
In reply to a message not in the archive
Quoted 2 lines · Kent

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

We can add a sysfs file for power info, but I'd like the keep the debugfs one as well since we regularly change the format as we add features and such. Depending on what info you want to get, you may already have what you need via the sysfs pp files.

Alex

Quoted 21 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Quoted 7 lines

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#38 lore raw
In reply to a message not in the archive
Quoted 10 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Russell, Kent
Sent: Friday, August 25, 2017 9:00 AM
To: StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

For power and voltage, I believe there are standard hwmon interfaces. It would probably be best to expose it via those. For clocks/pcie, I think you can already determine them via the existing pp sysfs interfaces.

Alex

Quoted 23 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Quoted 7 lines

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB16526CDFB29BC696816F2326F79B0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#40 lore raw

That sounds good. There's already the sclk/mclk/pcieclk in the device sysfs tree, it was just power that we had to obtain in the debugfs. Thanks, I'll work on that now. And I'll add voltage because I am sure someone will ask for it soon enough. hwmon makes perfect sense though, I'll add it in there.

Kent

-----Original Message-----
From: Deucher, Alexander
Sent: Friday, August 25, 2017 11:56 AM
To: Russell, Kent; StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 10 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Russell, Kent
Sent: Friday, August 25, 2017 9:00 AM
To: StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

For power and voltage, I believe there are standard hwmon interfaces. It would probably be best to expose it via those. For clocks/pcie, I think you can already determine them via the existing pp sysfs interfaces.

Alex

Quoted 23 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Quoted 7 lines

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#41 lore raw
In reply to a message not in the archive

I think the power measurement is a bit of a hack right now. It requires pinging the SMU twice to start and stop the measurement, and waiting for some time (but not too long) in between. I think if we want to expose this via hwmon, we'll need to have some kind of timer that polls it in regular intervals in the background and updates a value that can be queried through HWMon without delay.

Regards,
Felix

Quoted 42 lines · Alexander
Quoted 10 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Russell, Kent
Sent: Friday, August 25, 2017 9:00 AM
To: StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

There is GPU Power usage reported through amdgpu_pm_info, which also has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

For power and voltage, I believe there are standard hwmon interfaces. It would probably be best to expose it via those. For clocks/pcie, I think you can already determine them via the existing pp sysfs interfaces.

Alex

Quoted 21 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Quoted 7 lines

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 88a3901d-d05b-15c2-919a-03a5c90961ac-5C7GfCeVMHo@public.gmane.org

#43 lore raw
Quoted 6 lines · Felix Kuehling

I think the power measurement is a bit of a hack right now. It requires pinging the SMU twice to start and stop the measurement, and waiting for some time (but not too long) in between. I think if we want to expose this via hwmon, we'll need to have some kind of timer that polls it in regular intervals in the background and updates a value that can be queried through HWMon without delay.

We had this debate about 8 months ago :-)

I don't know if adding an ever present kthread just for this though is a super use of resources.

In umr when I read it I read the sensors in a separate thread from the main UI so that it doesn't mess with things.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#44 lore raw
In reply to a message not in the archive
Quoted 7 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Felix Kuehling
Sent: Friday, August 25, 2017 3:34 PM
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 6 lines

I think the power measurement is a bit of a hack right now. It requires pinging the SMU twice to start and stop the measurement, and waiting for some time (but not too long) in between. I think if we want to expose this via hwmon, we'll need to have some kind of timer that polls it in regular intervals in the background and updates a value that can be queried through HWMon without delay.

I don't know that hwmon has any requirements with respect to delay. I think a slight delay in reading it back through hwmon is preferable to a background thread polling it. Regular polling may also have negative impacts on performance or stability, depending on how it was validated.

Alex

Quoted 57 lines

Regards,
Felix

Quoted 2 lines · Alexander
Quoted 2 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On

Behalf

Quoted 6 lines
Quoted 6 lines

Of Russell, Kent
Sent: Friday, August 25, 2017 9:00 AM
To: StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

There is GPU Power usage reported through amdgpu_pm_info, which

also

Quoted 3 lines
Quoted 2 lines

has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

For power and voltage, I believe there are standard hwmon interfaces. It

would probably be best to expose it via those. For clocks/pcie, I think you can already determine them via the existing pp sysfs interfaces.

Quoted 31 lines

Alex

Quoted 21 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Quoted 7 lines

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB165282855F85ABA5587C99BDF79B0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#46 lore raw
Quoted 7 lines · Alexander
Quoted 7 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Felix Kuehling
Sent: Friday, August 25, 2017 3:34 PM
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 7 lines
Quoted 6 lines

I think the power measurement is a bit of a hack right now. It requires pinging the SMU twice to start and stop the measurement, and waiting for some time (but not too long) in between. I think if we want to expose this via hwmon, we'll need to have some kind of timer that polls it in regular intervals in the background and updates a value that can be queried through HWMon without delay.

I don't know that hwmon has any requirements with respect to delay. I think a slight delay in reading it back through hwmon is preferable to a background thread polling it. Regular polling may also have negative impacts on performance or stability, depending on how it was validated.

If an application is reading hwmon data from 4 GPUs and each query for power usage from each GPU takes one second, that would seriously limit the update frequency of the application.

Maybe the first read could block long enough to get useful data. But subsequent reads could probably avoid blocking if we keep track of the time stamp of the last query. If it was very recently, we can return the last value. If it was long enough ago, we can get an updated value from the SMU. If the last query was too long ago, we start over and block for a second.

Regards,
Felix

Quoted 60 lines

Alex

Quoted 58 lines

Regards,
Felix

Quoted 2 lines · Alexander
Quoted 2 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On

Behalf

Quoted 6 lines
Quoted 6 lines

Of Russell, Kent
Sent: Friday, August 25, 2017 9:00 AM
To: StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

There is GPU Power usage reported through amdgpu_pm_info, which

also

Quoted 3 lines
Quoted 2 lines

has some other information as well. I'd like that in sysfs, but I am unsure if we are allowed to due to the other information reported there.

For power and voltage, I believe there are standard hwmon interfaces. It

would probably be best to expose it via those. For clocks/pcie, I think you can already determine them via the existing pp sysfs interfaces.

Quoted 30 lines

Alex

Quoted 21 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 9 lines · Christian König

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply into this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Quoted 7 lines

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 863e1868-5a14-0748-cffe-81ff88c144ec-5C7GfCeVMHo@public.gmane.org

#48 lore raw
Quoted 31 lines

-----Original Message-----
From: Kuehling, Felix
Sent: Friday, August 25, 2017 3:59 PM
To: Deucher, Alexander; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Alexander
Quoted 2 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On

Behalf

Quoted 7 lines
Quoted 7 lines

Of Felix Kuehling
Sent: Friday, August 25, 2017 3:34 PM
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I think the power measurement is a bit of a hack right now. It requires pinging the SMU twice to start and stop the measurement, and waiting

for

Quoted 5 lines
Quoted 4 lines

some time (but not too long) in between. I think if we want to expose this via hwmon, we'll need to have some kind of timer that polls it in regular intervals in the background and updates a value that can be queried through HWMon without delay.

I don't know that hwmon has any requirements with respect to delay. I

think a slight delay in reading it back through hwmon is preferable to a background thread polling it. Regular polling may also have negative impacts on performance or stability, depending on how it was validated.

If an application is reading hwmon data from 4 GPUs and each query for power usage from each GPU takes one second, that would seriously limit the update frequency of the application.

Quoted 6 lines

Maybe the first read could block long enough to get useful data. But subsequent reads could probably avoid blocking if we keep track of the time stamp of the last query. If it was very recently, we can return the last value. If it was long enough ago, we can get an updated value from the SMU. If the last query was too long ago, we start over and block for a second.

Could we just set the sampling period down? If the application is polling for instantaneous power we'd probably want a short smu sampling period anyway. Otherwise, the application shouldn’t be polling so frequently in the first place.

Alex

Quoted 38 lines

Regards,
Felix

Quoted 18 lines

Alex

Quoted 16 lines

Regards,
Felix

Quoted 2 lines · Alexander
Quoted 2 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On

Behalf

Quoted 6 lines
Quoted 6 lines

Of Russell, Kent
Sent: Friday, August 25, 2017 9:00 AM
To: StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

There is GPU Power usage reported through amdgpu_pm_info, which

also

Quoted 1 line
Quoted 1 line

has some other information as well. I'd like that in sysfs, but I am

unsure if

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

we are allowed to due to the other information reported there.

For power and voltage, I believe there are standard hwmon interfaces.

It

Quoted 12 lines
Quoted 12 lines

would probably be best to expose it via those. For clocks/pcie, I think you can already determine them via the existing pp sysfs interfaces.

Quoted 10 lines

Alex

Quoted 8 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 29 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Christian König
Quoted 5 lines

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply

into

Quoted 22 lines
Quoted 22 lines
Quoted 14 lines
Quoted 7 lines
Quoted 4 lines

this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or the pm_info or something else?

Quoted 7 lines

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1652B766212C3249B22FC286F79B0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#50 lore raw
Quoted 46 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Deucher, Alexander
Sent: Friday, August 25, 2017 4:07 PM
To: Kuehling, Felix; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 17 lines

-----Original Message-----
From: Kuehling, Felix
Sent: Friday, August 25, 2017 3:59 PM
To: Deucher, Alexander; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 2 lines · Alexander
Quoted 2 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On

Behalf

Quoted 7 lines
Quoted 7 lines

Of Felix Kuehling
Sent: Friday, August 25, 2017 3:34 PM
To: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

I think the power measurement is a bit of a hack right now. It requires pinging the SMU twice to start and stop the measurement, and waiting

Quoted 8 lines

for

Quoted 5 lines
Quoted 4 lines

some time (but not too long) in between. I think if we want to expose this via hwmon, we'll need to have some kind of timer that polls it in regular intervals in the background and updates a value that can be queried through HWMon without delay.

I don't know that hwmon has any requirements with respect to delay. I

think a slight delay in reading it back through hwmon is preferable to a background thread polling it. Regular polling may also have negative

impacts

Quoted 6 lines

on performance or stability, depending on how it was validated.

If an application is reading hwmon data from 4 GPUs and each query for power usage from each GPU takes one second, that would seriously limit the update frequency of the application.

Quoted 6 lines

Maybe the first read could block long enough to get useful data. But subsequent reads could probably avoid blocking if we keep track of the time stamp of the last query. If it was very recently, we can return the last value. If it was long enough ago, we can get an updated value from the SMU. If the last query was too long ago, we start over and block for a second.

Quoted 4 lines

Could we just set the sampling period down? If the application is polling for instantaneous power we'd probably want a short smu sampling period anyway. Otherwise, the application shouldn’t be polling so frequently in the first place.

Another alternative would be to expose the SMU interface directly. So getting the power would be something like:

echo 1 > power
#wait
echo 0 > power
cat power

or:
echo 2 > power # seconds to sample
cat power #returns -EBUSY until the sampling period is done

Alex

Quoted 74 lines

Alex

Quoted 20 lines

Regards,
Felix

Quoted 16 lines

Alex

Quoted 14 lines

Regards,
Felix

Quoted 2 lines · Alexander
Quoted 2 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On

Behalf

Quoted 6 lines
Quoted 6 lines

Of Russell, Kent
Sent: Friday, August 25, 2017 9:00 AM
To: StDenis, Tom; Christian König; [email protected]
Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

There is GPU Power usage reported through amdgpu_pm_info,

which

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

also

Quoted 1 line
Quoted 1 line

has some other information as well. I'd like that in sysfs, but I am

unsure if

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

we are allowed to due to the other information reported there.

For power and voltage, I believe there are standard hwmon interfaces.

It

Quoted 1 line
Quoted 1 line

would probably be best to expose it via those. For clocks/pcie, I think

you

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

can already determine them via the existing pp sysfs interfaces.

Quoted 10 lines

Alex

Quoted 8 lines

Kent

-----Original Message-----
From: StDenis, Tom
Sent: Friday, August 25, 2017 8:58 AM
To: Christian König; Russell, Kent; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS

Quoted 12 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Christian König
Quoted 5 lines

Hi Kent,

agree on the VBIOS dump file, that clearly belongs to debugsf.

The power usage stuff I can't say much about cause I'm not deeply

into

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

this, but keep in mind the restriction for sysfs:
1. It's a stable interface. So it must be very well designed.
2. Only one value per file. I think the power stuff doesn't fulfill that requirement at the moment.

What "power" stuff are we talking about? The sensors interface or

the

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

pm_info or something else?

Keep in mind umr uses the sensors debugfs file in --top mode.

Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx