All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Add sysfs file for VBIOS
@ 2017-08-23 18:12 Kent Russell
       [not found] ` <1503511940-645-1-git-send-email-kent.russell-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Kent Russell @ 2017-08-23 18:12 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: 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)

Signed-off-by: Kent Russell <kent.russell@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index a1f9424..f40be71 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c
index d69aa2e..69500a8 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.h b/drivers/gpu/drm/amd/amdgpu/atom.h
index ddd8045..a391709 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.h
+++ b/drivers/gpu/drm/amd/amdgpu/atom.h
@@ -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;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2017-08-25 20:14 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23 18:12 [PATCH] drm/amdgpu: Add sysfs file for VBIOS Kent Russell
     [not found] ` <1503511940-645-1-git-send-email-kent.russell-5C7GfCeVMHo@public.gmane.org>
2017-08-24  1:21   ` Michel Dänzer
2017-08-24  6:21   ` Christian König
     [not found]     ` <1e64a642-411e-ea58-1639-390e4c3cd75d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-08-24  9:58       ` Russell, Kent
     [not found]         ` <BN6PR1201MB01801A32C06AE0DA6634F440859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-08-24 12:55           ` Alex Deucher
     [not found]             ` <CADnq5_PD3s8HHPtr49ZJ3DXPVXgP5xyvFZj_YTzsGCi=cnOUKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-24 13:06               ` Russell, Kent
     [not found]                 ` <BN6PR1201MB018010027CA78E203F629BA7859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-08-24 15:35                   ` Kuehling, Felix
     [not found]                     ` <DM5PR1201MB023503F29269CEC80DC7DAD8929A0-grEf7a3NxMBd8L2jMOIKKmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-08-24 15:39                       ` Alex Deucher
     [not found]                         ` <CADnq5_Piyp7mtHi+4GZ0pUw1kMNT68ZVyA6jp1TR4VhbCjWAOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-24 16:37                           ` Russell, Kent
     [not found]                             ` <BN6PR1201MB01804846B5629D28766FDFA0859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-08-24 18:10                               ` Christian König
     [not found]                                 ` <fa2dddb4-5ceb-87f3-6305-fb5f6e6e5c2d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-08-24 21:30                                   ` Russell, Kent
     [not found]                                     ` <BN6PR1201MB0180502DC4720A3C33D642DB859A0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-08-25 12:36                                       ` Tom St Denis
     [not found]                                         ` <4cec0dad-502e-68f2-68c9-b5d0103d7093-5C7GfCeVMHo@public.gmane.org>
2017-08-25 12:40                                           ` Russell, Kent
     [not found]                                             ` <BN6PR1201MB01803DD5EBD0049397F4E9F0859B0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-08-25 12:56                                               ` Christian König
     [not found]                                                 ` <0a3d4d07-e3cd-6216-466b-30bc60c8a26a-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-08-25 12:57                                                   ` Tom St Denis
     [not found]                                                     ` <22c4b9e2-67e2-bd0a-1147-6e896843783e-5C7GfCeVMHo@public.gmane.org>
2017-08-25 12:59                                                       ` Russell, Kent
     [not found]                                                         ` <BN6PR1201MB01806ACF078801D91460C110859B0-6iU6OBHu2P/H0AMcJMwsYmrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-08-25 13:05                                                           ` Tom St Denis
     [not found]                                                             ` <ebeb7962-c55c-9ba3-6969-6f7cf9934a5b-5C7GfCeVMHo@public.gmane.org>
2017-08-25 13:32                                                               ` Tom St Denis
2017-08-25 13:34                                                               ` Tom St Denis
     [not found]                                                                 ` <cc70864c-1106-1668-d80f-49cfbb6a6325-5C7GfCeVMHo@public.gmane.org>
2017-08-25 13:36                                                                   ` Russell, Kent
2017-08-25 14:36                                                           ` Alex Deucher
2017-08-25 15:56                                                           ` Deucher, Alexander
     [not found]                                                             ` <BN6PR12MB16526CDFB29BC696816F2326F79B0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-25 15:58                                                               ` Russell, Kent
2017-08-25 19:33                                                               ` Felix Kuehling
     [not found]                                                                 ` <88a3901d-d05b-15c2-919a-03a5c90961ac-5C7GfCeVMHo@public.gmane.org>
2017-08-25 19:36                                                                   ` Tom St Denis
2017-08-25 19:40                                                                   ` Deucher, Alexander
     [not found]                                                                     ` <BN6PR12MB165282855F85ABA5587C99BDF79B0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-25 19:59                                                                       ` Felix Kuehling
     [not found]                                                                         ` <863e1868-5a14-0748-cffe-81ff88c144ec-5C7GfCeVMHo@public.gmane.org>
2017-08-25 20:06                                                                           ` Deucher, Alexander
     [not found]                                                                             ` <BN6PR12MB1652B766212C3249B22FC286F79B0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-08-25 20:14                                                                               ` Deucher, Alexander

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.